diff options
author | root <root@krebs> | 2011-05-09 21:02:54 +0200 |
---|---|---|
committer | root <root@krebs> | 2011-05-09 21:02:54 +0200 |
commit | 9e22c8b62b449af8391e28477d9d8ff4b50e86d8 (patch) | |
tree | 1e181e39f3794252dbf653c4737c7447fe745a27 /modules/people/src/arping.py | |
parent | 8aad7ae37a2ac51dbeb07da7bb18810ca15af865 (diff) | |
parent | 483a46be9a90ef46b3f478d62f108d675159cdc6 (diff) |
Merge remote branch 'snmp_users/master'
Diffstat (limited to 'modules/people/src/arping.py')
-rw-r--r-- | modules/people/src/arping.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/modules/people/src/arping.py b/modules/people/src/arping.py new file mode 100644 index 00000000..11fb81a9 --- /dev/null +++ b/modules/people/src/arping.py @@ -0,0 +1,30 @@ +#!/usr/bin/python2 + +import logging +log = logging.getLogger('arpingy') +import os +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) + + 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') |