We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab3058f commit 15971d8Copy full SHA for 15971d8
1 file changed
subnetScanner.py
@@ -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