def main(opt): resp = srp1(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=opt.dst)) if resp: print(oui_lookup(resp[ARP].hwsrc) or "unknown") print(resp.summary())
def callback(pkt): #print(pkt.summary()) arp = pkt[ARP] if arp.op is 1: print("\x1b[32mRequest\x1b[39m %s[%s] %s >> %s" % (arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.psrc, arp.pdst)) elif arp.op is 2: print("\x1b[34mReply\x1b[39m %s[%s] %s -> %s[%s] %s" % (arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.psrc, arp.hwdst, oui_lookup(arp.hwdst) or "unknown", arp.pdst)) else: print(pkt)
def callback(pkt): #print(pkt.summary()) arp = pkt[ARP] if arp.op is 1: print("\x1b[32mRequest\x1b[39m %s[%s] %s >> %s" % ( arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.psrc, arp.pdst) ) elif arp.op is 2: print("\x1b[34mReply\x1b[39m %s[%s] %s -> %s[%s] %s" % ( arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.psrc, arp.hwdst, oui_lookup(arp.hwdst) or "unknown", arp.pdst) ) else: print(pkt)
def scanner(opts): for ip in IPNetwork(opts.network): ip = "%s" % ip try: resp = srp1( Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=opts.timeout, verbose=False ) if resp: oui = oui_lookup(resp[ARP].hwsrc) or "unknown" print("%s %s[%s]" % (ip, resp[ARP].hwsrc, oui)) except: print(ip) break print("Complete")
def callback(pkt): global colors arp = pkt[ARP] ether = pkt[Ether] def print_header(): header_str = { "hwtype": "0x%x" % (arp.hwtype,), "ptype": "0x%x" % (arp.ptype,), "hwlen": "%d" % (arp.hwlen,), "plen": "%d" % (arp.plen,), } default = { "hwtype": 0x1, "ptype": 0x800, "hwlen": 6, # MAC Addr len "plen": 4 # IPv4 Addr len } for k, v in default.items(): if getattr(arp, k) != v: header_str[k] = colors["red"] + header_str[k] + colors["reset"] print("| hw:%s p:%s hwl:%s pl:%s" % ( header_str["hwtype"], header_str["ptype"], header_str["hwlen"], header_str["plen"] )) print("") print(".%s" % ("-" * 50)) print("| Ether") print("| %s[%s] -> %s[%s]" % ( ether.src, oui_lookup(ether.src) or "unknown", ether.dst, oui_lookup(ether.dst) or "unknown" )) if arp.op is 1: print("| %s %s >> %s ?" % ( colors["green"] + "Request" + colors["reset"], arp.psrc, arp.pdst, )) print("| %s[%s] -> %s[%s]" % ( arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.hwdst, oui_lookup(arp.hwdst) or "unknown" )) print_header() elif arp.op is 2: print("| %s %s -> %s" % ( colors["blue"] + "Reply" + colors["reset"], arp.psrc, arp.pdst )) print("| %s[%s] -> %s[%s]" % ( arp.hwsrc, oui_lookup(arp.hwsrc) or "unknown", arp.hwdst, oui_lookup(arp.hwdst) or "unknown" )) print_header() else: print("| %s %s -> %s" % ( colors["cyan"] + ("%d" % (arp.op,)) + colors["reset"], arp.psrc, arp.pdst )) print_header() print(pkt.summary()) print("`%s" % ("-" * 50))