summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorroot <root@krebs>2011-05-10 12:32:20 +0200
committerroot <root@krebs>2011-05-10 12:34:51 +0200
commitb9b5122481ed6fbf6899549e9936a76493e407e4 (patch)
tree2271c2d7fc9eb83d9ae58af23d3ad0d90ae2c9fd /modules
parent82135f42e4c13318bdaddb832877b7376883e67c (diff)
arping_users scanner added
arping_users.py: arping_users script scans the shack network for hosts online and, loads a set of mac-addresses and names from a file and checks which hosts the script "knows". Known hosts will be written to stdout mac_names.lst: list of macs associated with names
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/people/src/arping_users.py49
-rw-r--r--modules/people/src/mac_names.lst1
2 files changed, 50 insertions, 0 deletions
diff --git a/modules/people/src/arping_users.py b/modules/people/src/arping_users.py
new file mode 100755
index 00000000..1f936eba
--- /dev/null
+++ b/modules/people/src/arping_users.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+from arping import arpingy
+import subprocess,re,logging
+from multiprocessing import Pool
+
+logging.basicConfig(level=logging.ERROR)
+DEV='eth0'
+MAC_NAMES='mac_names.lst'
+data = []
+ret = {}
+names = load_names(FNAME)
+
+def get_own_addr():
+ data = subprocess.Popen(['/sbin/ifconfig',DEV],
+ stdout=subprocess.PIPE).communicate()[0].replace('\n','')
+ return re.sub(r'.*HWaddr ([0-9A-Fa-f:]*).*inet addr:([0-9.]*).*' ,
+ r'\1 \2',data).split()
+
+def load_names(MAC_NAMES):
+ names = {}
+ f = open(MAC_NAMES)
+ for l in f:
+ print l
+ mac,name = l.split()
+ names[mac] = name
+ f.close()
+ return names
+
+def arping_helper(dic):
+ return arpingy(**dic)
+
+for first in range(3):
+ for second in range(255):
+ data.append({'iprange':'10.42.'+str(first)+'.'+str(second),'iface':DEV})
+
+try:
+ p = Pool(20)
+ ret = filter(lambda x:x , p.map(arping_helper, data))
+ myip,mymac = get_own_addr()
+ ret.append([mymac,myip])
+ p.terminate()
+except:
+ print 'you fail'
+
+
+
+for p in ret:
+ if p[1] in names:
+ print name + " is online"
diff --git a/modules/people/src/mac_names.lst b/modules/people/src/mac_names.lst
new file mode 100644
index 00000000..dcd3c2b0
--- /dev/null
+++ b/modules/people/src/mac_names.lst
@@ -0,0 +1 @@
+00:40:63:c8:b5:a0 krebs