diff options
Diffstat (limited to 'census')
-rw-r--r-- | census/Makefile | 5 | ||||
-rw-r--r-- | census/README.md | 23 | ||||
-rw-r--r-- | census/TODO.md | 3 | ||||
-rw-r--r-- | census/VERSION | 1 | ||||
-rwxr-xr-x | census/arping.py | 34 | ||||
-rwxr-xr-x | census/arping_users.py | 92 | ||||
-rw-r--r-- | census/mac_names.lst | 14 | ||||
-rwxr-xr-x | census/sched-arping | 8 | ||||
-rw-r--r-- | census/title.lst | 11 |
9 files changed, 0 insertions, 191 deletions
diff --git a/census/Makefile b/census/Makefile deleted file mode 100644 index 9993bf2a..00000000 --- a/census/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -.phony: all - -all: arping.py arping_users.py -install: - ./sched-arping diff --git a/census/README.md b/census/README.md deleted file mode 100644 index 2842368d..00000000 --- a/census/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Census (formerly known as ARPING Users) -========== - -This is a simplified python script which checks the available subnet for computers online and returns a list of users which are online based on their mac-address - -The initial idea was to find known users in the given network, now it finds and stores everyone in the given network and might try to resolve these addresses into names. This is why the name `census` is coined for the project. - -Return Data ----------- -after trying to reach all hosts in the selected subnets the script spits out th e following data: -<pre> - { "timestamp" : 12345678, "data" : { "ip1" : ["mac1","mac2","macn"] } -</pre> - -Census is meant to be put into a cronjob or some kind of wrapper scripts as it is currently really really (2-3 minutes) slow. - -SNMPWALK Command -=============== - -For historic reasons, this is the snmpwalk command to pull the currently registered mac-addresses on the firewall: -<pre> -snmpwalk -c shammunity 10.42.0.1 1.3.6.1.2.1.3.1.1.2 -</pre> diff --git a/census/TODO.md b/census/TODO.md deleted file mode 100644 index daacfd58..00000000 --- a/census/TODO.md +++ /dev/null @@ -1,3 +0,0 @@ -BUGS -===== - diff --git a/census/VERSION b/census/VERSION deleted file mode 100644 index 6c50e659..00000000 --- a/census/VERSION +++ /dev/null @@ -1 +0,0 @@ -+++++++[>+++++++>+++++++<<-]>.>---.<-. diff --git a/census/arping.py b/census/arping.py deleted file mode 100755 index ed257441..00000000 --- a/census/arping.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/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]) diff --git a/census/arping_users.py b/census/arping_users.py deleted file mode 100755 index eb47f308..00000000 --- a/census/arping_users.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python -import subprocess,re,logging,sys -import json -from arping import arpingy -from multiprocessing import Pool -logging.basicConfig(level=logging.WARNING) -log = logging.getLogger("main") -DEV='eth1' -MAC_NAMES='mac_names.lst' -data = [] -my_addr = False -my_names = {} -ret = {} -quiet=False - -names = {} -if len(sys.argv) > 1 and sys.argv[1] == 'q': - quiet=True -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_file): - f = open(mac_file) - for l in f: - mac,name = l.split(' ',1) - names[mac] = name.replace('\n','') - f.close() - return names - -def print_config(): - log.info("My Addr : %s" %str(my_addr)) - log.info("MAC Names file: %s " %MAC_NAMES) - log.debug("Loaded names : ") - for mac,name in my_names.iteritems(): - log.debug("%s => %s" %(mac,name)) - -def init(): - my_addr = get_own_addr() - my_names = load_names(MAC_NAMES) - -def arping_helper(dic): - log.debug("trying arpingy(%s)" %dic) - return arpingy(**dic) - -def main(): - init() - print_config() - - for first in range(1,4): - for second in range(256): - data.append({'iprange':'10.42.'+str(first)+'.'+str(second),'iface':DEV}) - try: - log.info("creating new Pool") - p = Pool(35) - ret = filter(lambda x:x , p.map(arping_helper, data)) - log.info("killing it") - p.terminate() - - except Exception as e: - print 'you fail '+str(e) - sys.exit(1) - myip,mymac = get_own_addr() - ret.append([mymac,myip]) - - print_json(ret) - #print_names(ret) - -def print_names(ret): - for p in ret: - if not quiet: - print p[0] + " => " + p[1] - if p[1] in names: - print names[p[1]]+ " is online" - -def print_json(ret): - from time import time - output = {} - output["timestamp"] = time() - for i in ret: - mac = i[0] - ip = i[1] - if i[0] not in output: - output[mac] = [] - output[mac].append(ip) - print json.dumps(output) - -if __name__ == "__main__": - log.debug("starting arping_users") - main() diff --git a/census/mac_names.lst b/census/mac_names.lst deleted file mode 100644 index 5f123dbe..00000000 --- a/census/mac_names.lst +++ /dev/null @@ -1,14 +0,0 @@ -00:40:63:c8:b5:a0 urkrebs -00:23:54:29:1d:3e hadez -00:26:c7:bd:a7:1a Martin -04:1e:64:05:39:28 Stephan -5c:59:48:22:2d:d2 Phil -00:21:00:fb:5c:b6 Kah-Hah -00:1e:64:27:3b:72 Felix -40:30:04:4f:de:73 Armin -00:26:c6:82:51:38 samuirai -3c:8b:fe:5c:4e:da Moh-Moh -00:26:bb:69:98:cc Jan -78:dd:08:d5:34:28 Patrick -78:ca:39:6e:ed:16 Tillman -00:22:43:25:61:79 Te vau diff --git a/census/sched-arping b/census/sched-arping deleted file mode 100755 index 14f8af3c..00000000 --- a/census/sched-arping +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -TMP=`mktemp` -crontab -l >$TMP - -echo "23 * * * * $PWD/arping_users.py > $PWD/../db/arping" | -../util/bin/magic create "arping" $TMP -crontab $TMP diff --git a/census/title.lst b/census/title.lst deleted file mode 100644 index dade858f..00000000 --- a/census/title.lst +++ /dev/null @@ -1,11 +0,0 @@ -KM kh -KM lassulus -KM makefu -KM miefda -KM momo -KM pfleidi -KM rtjure -KM tv -CN cmile -CN infin -CP * |