Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nets #948

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Nets #948

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions networkscanner/README.md
Original file line number Diff line number Diff line change
@@ -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)
48 changes: 48 additions & 0 deletions networkscanner/network_scanner.py
Original file line number Diff line number Diff line change
@@ -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)
Empty file added networkscanner/new_file.txt
Empty file.
1 change: 1 addition & 0 deletions networkscanner/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scapy