user3427653
user3427653

Reputation: 21

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.

Upvotes: 0

Views: 2712

Answers (2)

Tanu
Tanu

Reputation: 1563

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.

Upvotes: 0

gbin
gbin

Reputation: 3000

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

Upvotes: 1

Related Questions