Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kenobivangogh authored Nov 7, 2021
0 parents commit 854ad94
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Net_Scanner0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import scapy.all as scapy
from scapy.layers.l2 import ARP, Ether

# 1) arp request
# 2) broadcast
# 3) response

arp_request_packet = ARP(pdst="10.0.2.1/24")
# scapy.ls(ARP())
broadcast_packet = Ether(dst="ff:ff:ff:ff:ff:ff")
# scapy.ls(Ether())
combined_packet = broadcast_packet/arp_request_packet # 2 packet in 1, combine two packets
# result = scapy.srp(combined_packet, timeout=1)
# print(result)

(answered_list, unanswered_list) = scapy.srp(combined_packet, timeout=1)
# print(list(answered_list))
answered_list.summary()
30 changes: 30 additions & 0 deletions Network_Scanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import scapy.all as scapy
from scapy.layers.l2 import ARP, Ether
import optparse

# 1) arp request
# 2) broadcast
# 3) response

def get_user_input():
parse_object = optparse.OptionParser()
parse_object.add_option("-i", "--ipaddress", dest="ip_address", help="Enter IP Address")

(user_input, arguments) = parse_object.parse_args()

if not user_input.ip_address:
print("Enter IP Address")

return user_input

def scan_network(ip):
arp_request_packet = ARP(pdst=ip)
# scapy.ls(ARP())
broadcast_packet = Ether(dst="ff:ff:ff:ff:ff:ff")
# scapy.ls(Ether())
combined_packet = broadcast_packet/arp_request_packet # 2 packet in 1, combine two packets
(answered_list, unanswered_list) = scapy.srp(combined_packet, timeout=1)
answered_list.summary()

user_ip_address = get_user_input()
scan_network(user_ip_address.ip_address)

0 comments on commit 854ad94

Please sign in to comment.