diff options
author | euer <root@euer.krebsco.de> | 2012-12-20 03:26:08 +0100 |
---|---|---|
committer | euer <root@euer.krebsco.de> | 2012-12-20 03:26:21 +0100 |
commit | 325ab16e706b21abd172d3006729b51d323c93b9 (patch) | |
tree | 12777bdad6a0ee4d9b1447baf96a349e0f086280 /god/census/arping.py | |
parent | 38dbb8ee3867060fddd427d1bb4e57ee0300c8bb (diff) |
//{filebitch,census} -> //god
Diffstat (limited to 'god/census/arping.py')
-rwxr-xr-x | god/census/arping.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/god/census/arping.py b/god/census/arping.py new file mode 100755 index 00000000..ed257441 --- /dev/null +++ b/god/census/arping.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import logging +log = logging.getLogger('arpingy') +logging.disable(logging.WARNING) + +import os,sys +try: + if (os.geteuid() != 0): + raise Exception('no root permissions') + from scapy.all import * #might throws "no such module" + + def arpingy(iprange="10.42.1.0/24",iface='eth0'): + """Arping function takes IP Address or Network, returns nested mac/ip list""" + try: + conf.verb=0 + ans,unans=arping(iprange,iface=iface,timeout=3,retry=1) + + collection = [] + for snd, rcv in ans: + result = rcv.sprintf(r"%ARP.psrc% %Ether.src%").split() + log.debug(result) + return result # take just the first arp reply + except Exception as e: + print ("something went wrong while arpinging " + str(e)) + return [] + +except Exception as e: + raise Exception("Cannot load arping functions!" + str(e)) + + +if __name__ =='__main__': + logging.basicConfig(level=logging.DEBUG) + arpingy(sys.argv[1],sys.argv[2]) |