Skip to content

Commit 15971d8

Browse files
committed
Create subnetScanner using netifaces, netaddr and pprint
1 parent ab3058f commit 15971d8

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

subnetScanner.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
3+
from scapy.all import *
4+
import netaddr
5+
import netifaces
6+
import pprint
7+
8+
iface = 'enp0s3'
9+
addrs = netifaces.ifaddresses(iface)
10+
11+
infos = addrs[netifaces.AF_INET][0]
12+
addr = infos['addr']
13+
netmask = infos['netmask']
14+
#https://pythonhosted.org/netaddr/tutorial_01.html
15+
cidr = netaddr.IPNetwork('%s/%s' %(addr,netmask))
16+
17+
for ip in cidr:
18+
arpRequest = Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=str(ip), hwdst="ff:ff:ff:ff:ff:ff")
19+
arpResponse = srp1(arpRequest, timeout=1, verbose=0)
20+
if arpResponse:
21+
print "IP: " +arpResponse.psrc + "MAC: " + arpResponse.hwsrc
22+

0 commit comments

Comments
 (0)