Skip to content

Commit abccef5

Browse files
authored
First commit ✓
0 parents  commit abccef5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

main.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import scapy.all as scapy
2+
import argparse
3+
4+
def get_arguments():
5+
parser = argparse.ArgumentParser()
6+
parser.add_argument("-i", "--ip", dest="target", help="Target IP / IP Range")
7+
options = parser.parse_args()
8+
if not options.target:
9+
parser.error("[!] Please add an interface to proceed (like : 192.168.1.1/24), --help for more informations.")
10+
return options
11+
12+
def scan(ip):
13+
arp_request = scapy.ARP(pdst = ip)
14+
broadcast = scapy.Ether(dst = "ff:ff:ff:ff:ff:ff")
15+
packet = broadcast/arp_request
16+
ask_list = scapy.srp(packet, timeout = 1, verbose = False)[0]
17+
18+
packet_list = []
19+
for i in ask_list:
20+
packet_dict = {"ip" : i[1].psrc, "mac" : i[1].hwsrc}
21+
packet_list.append(packet_dict)
22+
return(packet_list)
23+
24+
def print_res(res):
25+
print(""" __ _ ___ _____ _ _ __ ___ _ __ __ ___ __ __ _ __ _ ___ ___
26+
| \| | __|_ _| | | |/__\| _ \ |/ / /' _/ / _// \| \| | \| | __| _ \
27+
| | ' | _| | | | 'V' | \/ | v / < `._`.| \_| /\ | | ' | | ' | _|| v /
28+
|_|\__|___| |_| !_/ \_!\__/|_|_\_|\_\ |___/ \__/_||_|_|\__|_|\__|___|_|_\ """)
29+
print("=========================================")
30+
print("IP\t\t\tMAC Address\n=========================================")
31+
for n in res:
32+
print(n["ip"] + "\t\t" + n["mac"])
33+
34+
options = get_arguments()
35+
scan_result = scan(options.target)
36+
print_res(scan_result)

0 commit comments

Comments
 (0)