简体   繁体   中英

get mac address of the client machine from python

Hi I am trying to capture the mac address of the client machine from python or java.I tried from java but no luck.its printing only for server mac address.I need client mac address.I tried some methods in python.

from uuid import getnode as get_mac
mac = get_mac()

The above code print uuid number of the machine.But I think it works only for server machine.I need to capture for client machine.Any help will be appreciated.

After a pip install netifaces :

import netifaces
print(netifaces.ifaddresses('wlan0')[netifaces.AF_LINK]['addr'])

Should print the mac address of your interface: ac:bc:32:ba:bd:cb

More info here

You can use system interfaces address file

def getmacaddress(interface):
    macaddress = open('/sys/class/net/'+interface+'/address').readline()
    return macaddress[0:17]

call this using MACADDRESS = getmacaddress("wlan0") This will return your system macaddress.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM