?
Solved

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

Posted on 2016-08-26
2
Medium Priority
?
140 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
2 Comments
 
LVL 84

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 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