嗨,我试图重新构建一个脚本。在 python 3 中,我使用了 _winreg 并且脚本正在运行,但是我在 python 2 中需要它,现在我得到了这个错误:
File "discoverNetworks.py", line 14, in printNets
guid = _winreg.EnumKey(key, i)
WindowsError: [Error 259] No more data is available
但当然在那个文件夹中有很多文件。
这是代码:
import _winreg
def val2addr(val):
addr = ''
for ch in val:
addr += '%02x '% ord(ch)
addr = addr.strip(' ').replace(' ', ':')[0:17]
return addr
def printNets():
net = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList\\Signatures\\Unmanaged"
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,net)
print '\n[*] Networks You have Joined.'
for i in range(100):
try:
guid = _winreg.EnumKey(key, i)
netKey = _winreg.OpenKey(key, str(guid))
(n, addr, t) = _winreg.EnumValue(netKey, 5)
(n, name, t) = EnumValue(netKey, 4)
macAddr = val2addr(addr)
netName = str(name)
print '[+] ' + netName + ' ' + macAddr
_winreg.CloseKey(guid)
except WindowsError:
break
def main():
printNets()
if __name__ == "__main__":
main()
谢谢!