diff options
author | tv <tv@also> | 2011-05-29 15:47:21 +0200 |
---|---|---|
committer | tv <tv@also> | 2011-05-29 15:47:21 +0200 |
commit | 12c77cdbfa4ec48d935af3ae7cf1118e38bec6e1 (patch) | |
tree | 2fdf8b557d2a2a1edaba2be569c2110c3822559f /people/arping.py | |
parent | edaa1d7f7a0ed33c019fce185b8aff7563498b6e (diff) |
lowered filesystem hierarchy--everything are modules
Diffstat (limited to 'people/arping.py')
-rwxr-xr-x | people/arping.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/people/arping.py b/people/arping.py new file mode 100755 index 00000000..1b51ab1b --- /dev/null +++ b/people/arping.py @@ -0,0 +1,37 @@ +#!/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'): + log.debug("pinging "+ str(iprange)) + """Arping function takes IP Address or Network, returns nested mac/ip list""" + try: + conf.verb=0 + ans,unans=arping(iprange,iface=iface,timeout=1,retry=3) + + 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: + log.error("Cannot load arping functions!" + str(e)) + def arpingy(iprange='',iface=''): + raise Exception ('arping not available') + + +if __name__ =='__main__': + logging.basicConfig(level=logging.DEBUG) + arpingy(sys.argv[1],sys.argv[2]) |