嗨,我试图理解这段代码。我知道它会在注册表中获取网关名称和 mac 地址,但是当我尝试运行此代码时,它没有显示任何内容。有人可以给我有关具有基本示例的 winreg 的链接。谢谢你
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():
net = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged"
key = OpenKey(HKEY_LOCAL_MACHINE, net)
print ("[*] 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()