Solved

I cannot read information from Windows Registry using python on windows 8.1

Posted on 2016-08-26
2
109 Views
Last Modified: 2016-08-27
This script returns the MAC addresses and network names of all the WiFi networks you have joined. But when I run on my pychram python 2.7.12 it gives me the following out put:

C:\Python27\python.exe C:/Users/Bdd/PycharmProjects/untitled6/pp.py
Process finished with exit code 0

from _winreg import *

def val2addr(val):

    addr = ''

    for ch in val:

        addr += '%02x '% ord(ch)

    addr = addr.strip(' ').replace(' ', ':')[0:17]

    return addr

def printNets():

    print '[+] '

    net = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"+\
          "\NetworkList\Signatures\Unmanaged"
    key = OpenKey(HKEY_LOCAL_MACHINE, net)

    print '\n[*] Networks You have Joined.'

    for i in range(100):
        try:
            guid = EnumKey(key, i)

            netKey = OpenKey(key, str(guid))

            (n, addr, t) = EnumValue(netKey, 5)

            (n, name, t) = EnumValue(netKey, 4)


            macAddr = val2addr(addr)

            netName = str(name)

            print '[+] ' + netName + ' ' + macAddr

            CloseKey(netKey)
        except:

            break

def main():

    printNets()

if __name__ == "__main__":

    main()

Open in new window

0
Comment
Question by:zrdad mont
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 81

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 41772925
32 bit python on x64 system you need to specify you want x64 version of registry and not syswow64 section

key = OpenKey(HKEY_LOCAL_MACHINE, net, 0, KEY_READ | KEY_WOW64_64KEY)

Open in new window


You may need administrative permissions (run as administrator) test via command prompt
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList

Open in new window

0
 

Author Closing Comment

by:zrdad mont
ID: 41773029
Thanks, solution worked perfectly fine
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question