-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_mac.py
More file actions
32 lines (28 loc) · 838 Bytes
/
get_mac.py
File metadata and controls
32 lines (28 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from winreg import *
def Nets():
net="\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList\\Signatures\\Unmanaged"
print(net)
key=OpenKey(HKEY_LOCAL_MACHINE,net)
print('network 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 val2addr(val):
addr=" "
for ch in val:
addr+= ( " %02x " % ord(ch))
addr=addr.strip(" ").replace(" ",":")[0:17]
return addr
def main():
print (Nets())
if __name__=='__main__':
main()