-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 854ad94
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |