35
loading...
This website collects cookies to deliver better user experience
import sh
from subprocess import Popen, PIPE
import re
def getMac(ip):
pid = Popen(["arp", "-n", ip], stdout=PIPE)
s = pid.communicate()[0]
a=re.search(r"(([a-f\d]{1,2}\:){5}[a-f\d]{1,2})", str(s))
if a ==None:
b=('this')
return b
else:
mac = a.groups()[0]
return mac
for num in range(1,256):
ip = "192.168.1."+str(num)
try:
sh.ping(ip, "-c 1",_out="/dev/null")
mac=getMac(ip)
print ("PING ",ip , "OK ",mac)
except sh.ErrorReturnCode_1:
#print ("PING ", ip, "FAILED")
pass
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
import sh
from subprocess import Popen, PIPE
import re
def getMac(ip):
pid = Popen(["arp", "-n", ip], stdout=PIPE)
s = pid.communicate()[0]
a=re.search(r"(([a-f\d]{1,2}:){5}[a-f\d]{1,2})", str(s))
if a ==None:
b=('this')
return b
else:
mac = a.groups()[0]
return mac
for num in range(1,256):
ip = "192.168.1."+str(num)
try:
sh.ping(ip, "-c 1",_out="/dev/null")
mac=getMac(ip)
print ("PING ",ip , "OK ",mac)
except sh.ErrorReturnCode_1:
#print ("PING ", ip, "FAILED")
pass
Enter fullscreen mode
Exit fullscreen mode