diff --git a/networkscanner/README.md b/networkscanner/README.md new file mode 100644 index 000000000..22e7a50ba --- /dev/null +++ b/networkscanner/README.md @@ -0,0 +1,18 @@ +# network-scanner +# usage +pip install -r requirements.txt +clone the repository with git clone https://github.com/fixit-py/network-scanner.git + +change into the directory with cd MAC-CHANGER2.0 + +give the file permission to run as an executable with chmod +x network_scanner.py + +run python network_scanner.py -r or --range "full ip range with CIDR notation" while using python2 + +run python3 network_scanner.py -r or --range "full ip range with CIDR notation" while using python3 + +replace the "full ip range with CIDR notation" with the name of your ip range +# ABOUT +This python program scans your local network for all devices connected to the network compatible with both python 2 and python 3 specify the interface name using the -r or --range from the bash terminal or cmd. this script works on both linux, MAC and windows as long as all the required external libaries are downloaded and imported +# module +scapy , optparse(argparse) diff --git a/networkscanner/network_scanner.py b/networkscanner/network_scanner.py new file mode 100644 index 000000000..03b5b81b9 --- /dev/null +++ b/networkscanner/network_scanner.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import scapy.all as scapy +import optparse + +print('############################################################################################################################################') +print('') +print(' ######## ## ## ## ## ######## ') +print(' ## ## ## ## ## ## ') +print(' ## ## ## ## ## ## ') +print(' ######## ## #### ## ## ') +print(' ## ## ## ## ## ## ') +print(' ## ## ## ## ## ## ') +print(' ## ## ## ## ## ## ') +print('') +print('############################################################################################################################################') +print('') +def get_arguments(): + parser = optparse.OptionParser() + parser.add_option('-r', "--range", dest="target", help="Target IP / IP range") + (options, argument) = parser.parse_args() + if not options.target: + parser.error("please enter an ip range") + return options + +def scan(ip): + arp_request = scapy.ARP(pdst=ip) # we create a object that represent an ARP packet and set the pdst to ip + print(arp_request.summary()) # prints the summary of what the script does + # scapy.ls(scapy.ARP()) # it the shows the list of variables we can set for a class + broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") # creates an ethernet object and set the destination mac as the broadcast mac + arp_request_broadcast = broadcast/arp_request # we combine both packets into 1 + # arp_request_broadcast.show() # shows more info on each packet + # to send packets and recieve packets split into two parts the answered and unanswered and make it less verbose + answered_list = scapy.srp(arp_request_broadcast,timeout=1,verbose=False)[0] + client_list=[] + # print(answered_list.summary()) prints the summary of the sent packets + for element in answered_list: # iterates through the answered list + client_dict = {"ip": element[1].psrc, "MAC": element[1].hwsrc} + client_list.append (client_dict) + print(element[1].psrc + "\t\t" + element[1].hwsrc) # to print the source ip address and source MAC address of the packet + return client_list + +def print_result(result_list): + print ("IP\t\t\tMAC ADDRESS\n -------------------------------------------------") + for client in result_list: + print(client["ip"] + "\t\t" + client["MAC"]) +options = get_arguments() +scan_result = scan(options.target) +print_result(scan_result) diff --git a/networkscanner/new_file.txt b/networkscanner/new_file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/networkscanner/requirements.txt b/networkscanner/requirements.txt new file mode 100644 index 000000000..30564abd0 --- /dev/null +++ b/networkscanner/requirements.txt @@ -0,0 +1 @@ +scapy