Skip to content

Commit e0d71de

Browse files
committed
network scanner in python
1 parent ce7e971 commit e0d71de

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

Network_scanner/Linux.png

52.9 KB
Loading

Network_scanner/network_scanner.py

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

Network_scanner/readme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this tool will show all the IP's on the same network and their respective MAC adresses

Network_scanner/windows.png

13.8 KB
Loading

0 commit comments

Comments
 (0)