Skip to content

Commit 123ce27

Browse files
Merge pull request avinashkranjan#212 from pritamp17/network_scan
Network scannner (issue # 196)
2 parents c4221fe + 1812f7f commit 123ce27

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

Network_scanner/Linux.png

52.9 KB
Loading

Network_scanner/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This tool will show all the IP's on the same network and their respective MAC adresses
2+
3+
### Modules used
4+
1. scapy
5+
2. optparse

Network_scanner/network_scanner.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
try:
2+
import scapy.all as scapy
3+
import optparse
4+
except ImportError:
5+
print("[+] packages not installed ")
6+
print("try-> pip install scapy")
7+
print("pip install optparse-pretty")
8+
9+
10+
def get_arguments(): # function to pass input in console
11+
parser = optparse.OptionParser()
12+
parser.add_option("-t", "--target", dest="target",
13+
help="Target IP / IP range.")
14+
options, arguments = parser.parse_args()
15+
return options
16+
17+
18+
def scan(ip):
19+
arp_request = scapy.ARP(pdst=ip) # destinationn ip
20+
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
21+
arp_request_broadcast = broadcast/arp_request
22+
# print(arp_request_broadcast.summary())
23+
# arp_request_broadcast.show()
24+
answered_list = scapy.srp(arp_request_broadcast,
25+
timeout=1, verbose=False)[0]
26+
# print(answered_list.summary())
27+
# print(unanswered.summary())
28+
29+
clients_list = []
30+
for element in answered_list:
31+
clients_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc}
32+
clients_list.append(clients_dict)
33+
# print(element[1].psrc +"\t\t"+element[1].hwsrc)
34+
35+
return(clients_list)
36+
37+
38+
def print_result(result_list):
39+
print("IP\t\t\tMAC ADDRESS\n..........................................................................")
40+
for client in result_list:
41+
print(client["ip"]+"\t\t"+client["mac"])
42+
43+
44+
options = get_arguments()
45+
scan_result = scan(options.target)
46+
print_result(scan_result)

Network_scanner/windows.png

13.8 KB
Loading

0 commit comments

Comments
 (0)