summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Richter <Felix.Richter@syntax-fehler.de>2011-05-22 02:17:33 +0200
committerFelix Richter <Felix.Richter@syntax-fehler.de>2011-05-22 02:17:33 +0200
commitfaf725402cd589173b16152c42e5e48965e3999e (patch)
tree134babeef7fe1c8f1445fef2804e459d7ffab25d
parent4f3b31fd611de21d75b0a465b438577632f47ee0 (diff)
parent951d398e20fdb778289e7dff2350594503dc300f (diff)
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r--Makefile9
-rwxr-xr-xinfest/etc12
-rw-r--r--modules/Monitoring/Makefile7
-rw-r--r--modules/Monitoring/conf/hostgroups_nagios2.cfg31
-rw-r--r--modules/Monitoring/conf/krebs_hosts.cfg67
-rw-r--r--modules/Monitoring/conf/krebsnet.cfg14
-rw-r--r--modules/Monitoring/conf/localhost.cfg60
-rw-r--r--modules/Monitoring/conf/shack_infrastructure.cfg138
-rw-r--r--modules/Monitoring/conf/tinc_hosts.cfg45
-rw-r--r--modules/Monitoring/conf/tincnet.cfg31
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/favicon.icobin0 -> 822 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2bin0 -> 1047 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/krebs.pngbin0 -> 323 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/shack.gd2bin0 -> 1047 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/shack.pngbin0 -> 316 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2bin0 -> 1305 bytes
-rw-r--r--modules/Monitoring/htdocs/images/logos/krebs/tinc.pngbin0 -> 361 bytes
-rwxr-xr-xmodules/bigeye/bigeyed68
-rw-r--r--modules/people/Makefile6
-rw-r--r--modules/people/README.md11
-rw-r--r--modules/people/TODO.md3
-rwxr-xr-xmodules/people/arping.py (renamed from modules/people/src/arping.py)2
-rwxr-xr-xmodules/people/arping_users.py (renamed from modules/people/src/arping_users.py)25
-rwxr-xr-xmodules/people/bin/run.sh5
-rw-r--r--modules/people/conf/example.json22
-rw-r--r--modules/people/mac_names.lst (renamed from modules/people/src/mac_names.lst)0
-rwxr-xr-xmodules/people/src/main.py33
-rwxr-xr-xmodules/people/src/snmp_users.py122
-rw-r--r--root/.vimrc31
29 files changed, 542 insertions, 200 deletions
diff --git a/Makefile b/Makefile
index 09b68293..d31a7c9d 100644
--- a/Makefile
+++ b/Makefile
@@ -7,4 +7,13 @@ all: select-target
infest:
infest/etc
infest/root
+
+install-debian:
+ [ `which git` ] || apt-get install git-core
+ [ `which tmux` ] || apt-get install tmux
+ [ `which screen` ] && apt-get remote screen
+ [ `which vim` ] || apt-get install vim
+
+noise:
make -C modules/noise infest
+
diff --git a/infest/etc b/infest/etc
index 0ddf4150..78ce8d06 100755
--- a/infest/etc
+++ b/infest/etc
@@ -32,3 +32,15 @@ echo 'krebs:x:0:' >>$f
for i in etc/*; do
cat $i > /$i
done
+
+# TMPFS for tmp and log
+
+if [ ! "`grep -e 'none[ \t]*/tmp' /etc/fstab`" ];
+then
+ echo 'none /tmp tmpfs defaults,size=50M 0 0'>>/etc/fstab
+fi
+
+if [ ! "`grep -e 'none[ \t]*/var/log' /etc/fstab`" ];
+then
+ echo 'none /var/log tmpfs defaults,size=50M 0 0'>>/etc/fstab
+fi
diff --git a/modules/Monitoring/Makefile b/modules/Monitoring/Makefile
new file mode 100644
index 00000000..2d837b43
--- /dev/null
+++ b/modules/Monitoring/Makefile
@@ -0,0 +1,7 @@
+.phony: debian
+debian:
+ [ `which nagios3` ] || apt-get install nagios3
+ cp -r conf/* /etc/nagios3/conf.d/
+ cp -R htdocs/* /usr/share/nagios3/htdocs/
+ cp -r plugins /usr/lib/nagios
+ /etc/init.d/nagios3 reload
diff --git a/modules/Monitoring/conf/hostgroups_nagios2.cfg b/modules/Monitoring/conf/hostgroups_nagios2.cfg
new file mode 100644
index 00000000..63acbf50
--- /dev/null
+++ b/modules/Monitoring/conf/hostgroups_nagios2.cfg
@@ -0,0 +1,31 @@
+# Some generic hostgroup definitions
+
+# A simple wildcard hostgroup
+define hostgroup {
+ hostgroup_name all
+ alias All Servers
+ members *
+ }
+
+# A list of your Debian GNU/Linux servers
+define hostgroup {
+ hostgroup_name debian-servers
+ alias Debian GNU/Linux Servers
+ members localhost
+ }
+
+# A list of your web servers
+define hostgroup {
+ hostgroup_name http-servers
+ alias HTTP servers
+ members localhost
+ }
+
+# A list of your ssh-accessible servers
+define hostgroup {
+ hostgroup_name ssh-servers
+ alias SSH servers
+ members localhost
+ }
+
+
diff --git a/modules/Monitoring/conf/krebs_hosts.cfg b/modules/Monitoring/conf/krebs_hosts.cfg
new file mode 100644
index 00000000..6857cd45
--- /dev/null
+++ b/modules/Monitoring/conf/krebs_hosts.cfg
@@ -0,0 +1,67 @@
+
+#
+# Ur-Krebs
+#
+define host{
+ use generic-host
+ host_name krebs.shack
+ alias krebs
+ _tinc_address 10.7.7.156
+ address 10.42.23.5
+ parents shack-router
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# UTART
+#
+define host{
+ use generic-host
+ host_name utart
+ alias UTART
+ _tinc_address 10.7.7.66
+ address 10.42.23.23
+ parents shack-router
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# ytart
+#
+define host{
+ use generic-host
+ host_name ytart
+ alias ytart
+ _tinc_address 10.7.7.201
+ parents shack-router
+ address 10.42.1.227
+ hostgroups krebs-machines,tinc-nodes,ssh-servers
+ }
+#
+# uPM
+#
+define host{
+ use generic-host
+ host_name upm
+ alias uPM Virtual Machine
+ _tinc_address 10.7.7.99
+ address upm.shack
+ parents shack-vplatform
+ hostgroups krebs-machines,ssh-servers,shack-rz
+ #,tinc-nodes
+ }
+
+# TODO add upm and genericore as tinc-nodes
+# TODO check MONGODB on uPM
+
+
+
+#TODO verkrebse genericore/get password
+define host{
+ use generic-host
+ host_name genericore
+ alias genericore Virtual Machine
+ #_tinc_address 10.7.7.XX
+ address genericore.shack
+ parents shack-vplatform
+ hostgroups ssh-servers,shack-rz
+ #,tinc-nodes,krebs-machines
+ }
diff --git a/modules/Monitoring/conf/krebsnet.cfg b/modules/Monitoring/conf/krebsnet.cfg
new file mode 100644
index 00000000..211ed76a
--- /dev/null
+++ b/modules/Monitoring/conf/krebsnet.cfg
@@ -0,0 +1,14 @@
+## extended infos for krebsnet
+define hostgroup {
+ hostgroup_name krebs-machines
+ alias Krebs Machines
+ }
+define hostextinfo{
+ hostgroup_name krebs-machines
+ notes Deployed Krebse
+# notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1
+ icon_image krebs/krebs.png
+ icon_image_alt Krebs
+ vrml_image krebs.png
+ statusmap_image krebs/krebs.gd2
+ }
diff --git a/modules/Monitoring/conf/localhost.cfg b/modules/Monitoring/conf/localhost.cfg
new file mode 100644
index 00000000..3b098195
--- /dev/null
+++ b/modules/Monitoring/conf/localhost.cfg
@@ -0,0 +1,60 @@
+# A simple configuration file for monitoring the local host
+# This can serve as an example for configuring other servers;
+# Custom services specific to this host are added here, but services
+# defined in nagios2-common_services.cfg may also apply.
+#
+
+define host{
+ use generic-host ; Name of host template to use
+ host_name localhost
+ alias localhost
+ address 127.0.0.1
+ hostgroups krebs-machines
+ }
+
+# Define a service to check the disk space of the root partition
+# on the local machine. Warning if < 20% free, critical if
+# < 10% free space on partition.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Disk Space
+ check_command check_all_disks!20%!10%
+ }
+
+
+
+# Define a service to check the number of currently logged in
+# users on the local machine. Warning if > 20 users, critical
+# if > 50 users.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Current Users
+ check_command check_users!20!50
+ }
+
+
+# Define a service to check the number of currently running procs
+# on the local machine. Warning if > 250 processes, critical if
+# > 400 processes.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Total Processes
+ check_command check_procs!250!400
+ }
+
+
+
+# Define a service to check the load on the local machine.
+
+define service{
+ use generic-service ; Name of service template to use
+ host_name localhost
+ service_description Current Load
+ check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0
+ }
diff --git a/modules/Monitoring/conf/shack_infrastructure.cfg b/modules/Monitoring/conf/shack_infrastructure.cfg
new file mode 100644
index 00000000..2b75a241
--- /dev/null
+++ b/modules/Monitoring/conf/shack_infrastructure.cfg
@@ -0,0 +1,138 @@
+#
+
+define hostgroup {
+ hostgroup_name shack-rz
+ alias Shack RZ Infrastructure
+ }
+define hostextinfo{
+ hostgroup_name shack-rz
+ notes Shack RZ Infrastructure
+# notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1
+ icon_image krebs/shack.png
+ icon_image_alt shack-RZ
+ vrml_image shack.png
+ statusmap_image krebs/shack.gd2
+ }
+#
+# Shack Virtual Machine Hoster Platform
+#
+define host{
+ use generic-host
+ host_name shack-vplatform
+ alias Shack Virtualization Server
+ address node0.shack
+ parents shack-router
+ hostgroups shack-rz,ssh-servers
+ }
+define host{
+ use generic-host
+ host_name shack-router
+ alias Shack Cisco Router
+ address 10.42.0.3
+ hostgroups shack-rz,ssh-servers
+ }
+
+define host{
+ use generic-host
+ host_name shack-plattenschwein
+ parents shack-router
+ alias Shack Plattenschwein
+ address plattenschwein.shack
+ hostgroups shack-rz,ssh-servers
+ }
+
+
+#
+# Shack DNS Server
+#
+
+define host{
+ use generic-host
+ host_name shack-dns
+ parents shack-vplatform
+ alias Shack DNS Virtual Host
+ address dns.shack
+ hostgroups shack-rz
+ }
+define service {
+ host_name shack-dns
+ service_description DNS Service
+ use generic-service
+ check_command check_dns_shack
+ }
+define command {
+ command_name check_dns_shack
+ command_line /usr/lib/nagios/plugins/check_dns -H shack.shack -s '$HOSTADDRESS$'
+ }
+
+define host{
+ use generic-host
+ host_name shack-pxe
+ parents shack-vplatform
+ alias Shack PXEBoot Vhost
+ address pxeboot.shack
+ hostgroups shack-rz
+ }
+define host{
+ use generic-host
+ host_name shack-printsrv
+ parents shack-vplatform
+ alias Shack Print Server
+ address printer.shack
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-aptproxy
+ parents shack-vplatform
+ alias Shack Apt-proxy
+ address aptproxy.shack
+ hostgroups shack-rz
+ }
+
+define host{
+ use generic-host
+ host_name shack-shack
+ parents shack-vplatform
+ alias Shack Data Exchange
+ address shack.shack
+ hostgroups shack-rz,ssh-servers
+ }
+
+#
+# shack ldap server
+#
+define host{
+ use generic-host
+ host_name shack-ldap
+ parents shack-vplatform
+ alias Shack LDAP Server
+ address ldap.shack
+ hostgroups shack-rz
+ }
+define service {
+ host_name shack-ldap
+ service_description LDAP Service
+ use generic-service
+ check_command check_ldap!shammunity
+ }
+
+#
+# Shack gateway
+#
+define host{
+ use generic-host
+ host_name shack-gw
+ parents shack-router
+ alias Watchguard Shack Gateway
+ address 10.42.0.1
+ hostgroups shack-rz,ssh-servers
+ }
+define service {
+ host_name shack-gw
+ service_description DNS Service
+ use generic-service
+ check_command check_dns
+ }
+
diff --git a/modules/Monitoring/conf/tinc_hosts.cfg b/modules/Monitoring/conf/tinc_hosts.cfg
new file mode 100644
index 00000000..4b1ad9ab
--- /dev/null
+++ b/modules/Monitoring/conf/tinc_hosts.cfg
@@ -0,0 +1,45 @@
+#connection will not work if no internet is available (e.g. no shack-gateway)
+
+#
+# Miefda Supernode
+#
+define host{
+ use generic-host
+ host_name supernode
+ alias Supernode External
+ _TINC_ADDRESS 10.7.7.1
+ address miefda.org
+ parents shack-gw
+ hostgroups tinc-nodes,ssh-servers,http-servers
+ }
+
+define service {
+ host_name supernode
+ service_description IRC
+ use generic-service
+ check_command check_ircd
+ }
+#
+# Sharepoint (dhbw-stuttgart)
+#
+define host{
+ use generic-host
+ host_name sharepoint
+ alias PA Sharepoint
+ address 141.31.8.11
+ _TINC_ADDRESS 10.7.7.5
+ parents shack-gw
+ hostgroups tinc-nodes,ssh-servers
+ }
+#
+# Leechi
+#
+define host{
+ use generic-host
+ host_name leechi
+ alias no_omo
+ address leechi.kicks-ass.org
+ _TINC_ADDRESS 10.7.7.111
+ parents shack-gw
+ hostgroups tinc-nodes,ssh-servers,http-servers
+ }
diff --git a/modules/Monitoring/conf/tincnet.cfg b/modules/Monitoring/conf/tincnet.cfg
new file mode 100644
index 00000000..f0b35b4e
--- /dev/null
+++ b/modules/Monitoring/conf/tincnet.cfg
@@ -0,0 +1,31 @@
+define hostgroup {
+ hostgroup_name tinc-nodes
+ alias Tinc Nodes
+ }
+
+define hostextinfo{
+ hostgroup_name tinc-nodes
+ notes Tinc Nodes
+ icon_image krebs/tinc.png
+ icon_image_alt tinc
+ vrml_image tinc.png
+ statusmap_image krebs/tinc.gd2
+ }
+
+define command {
+ command_name check_internal_tinc_up
+ command_line $USER1$/check_ping -H $_HOSTTINC_ADDRESS$ -w $ARG1$ -c $ARG2$
+ }
+define command {
+ command_name check_ircd
+ command_line $USER1$/check_ircd $_HOSTTINC_ADDRESS$
+ }
+
+define service {
+ hostgroup_name tinc-nodes
+ service_description tinc internal
+ check_command check_internal_tinc_up!100.0,20%!500.0,60%
+ use generic-service
+ notification_interval 0
+}
+
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico b/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico
new file mode 100644
index 00000000..fa18384c
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/favicon.ico
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2
new file mode 100644
index 00000000..1113f03e
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/krebs.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/krebs.png b/modules/Monitoring/htdocs/images/logos/krebs/krebs.png
new file mode 100644
index 00000000..3d8a8ab8
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/krebs.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2
new file mode 100644
index 00000000..8b0d98e5
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/shack.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/shack.png b/modules/Monitoring/htdocs/images/logos/krebs/shack.png
new file mode 100644
index 00000000..53f1275b
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/shack.png
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2 b/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2
new file mode 100644
index 00000000..36572d4a
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/tinc.gd2
Binary files differ
diff --git a/modules/Monitoring/htdocs/images/logos/krebs/tinc.png b/modules/Monitoring/htdocs/images/logos/krebs/tinc.png
new file mode 100644
index 00000000..daa1fdeb
--- /dev/null
+++ b/modules/Monitoring/htdocs/images/logos/krebs/tinc.png
Binary files differ
diff --git a/modules/bigeye/bigeyed b/modules/bigeye/bigeyed
new file mode 100755
index 00000000..c246c872
--- /dev/null
+++ b/modules/bigeye/bigeyed
@@ -0,0 +1,68 @@
+#! /bin/sh
+#
+# usage: bigeyed
+#
+
+set -euf
+
+mkdir -vp /tmp/bigeye
+cd /tmp/bigeye
+
+cleanup() {
+ test -n "$spid" && kill -9 $spid && spid=
+}
+
+#python -m http.server 3 & server=$!
+python -m SimpleHTTPServer 3 & spid=$?
+trap cleanup EXIT HUP INT QUIT TERM
+
+base64 -d>favicon.ico<<EOF
+AAABAAEAICAQAAEABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAVQAAAKoAAABVVQAAVVVVAP9VVQCqqgAAqqqqAP+qqgD//6oAVf//AKr//wD///8A
+AAAAAAAAAAAAAAAAnHzMd3REQAAAAABERERHm8nMx3REQAAAAAAAAERERHmXx3dEAAAAAAAAAAAA
+R0REzMREQAAAAzNLu0BAAAR0RMxEQAAAMzMURES7REAARHfEQAADMzNERERERLtEAAR3RAAAMzBE
+R3dwRABEtEAER0AAMzgER3d3e0REAEtEAEQAAzGwRHMzAAAHREADtEAEAAMbBEcwAAAAAHdEADtE
+AAAxS0RzAAEAAAALdEAztEADNERHMAAQAAAAALdDA7tAE0S0swAAABEAAAAHdDS7RBNLRLMAAAEA
+ERAQC3M0N4QzS0tzABAQAAAAAQB0AEeHNEtLcBARABAAEAAAdDBHhBRLR3ABF1VVEREAAXRESIRE
+S0dwF3FQUVUREAF0REiEd3d3wQVZQVVBQUEIh3iZhIfMzMwFlRRVVBQUC3x4iYQHd8fMAJFRQUFB
+QAt6R0uEB8d0vIAJFBQUFAC3x0S7hAd4dEzIAVVBQUALd6REukcAd3hEzMgVFBQAt3dES6RAcAe4
+hEd8yIiIjLd4SEtEAGcHe8xEd3fMjHd3hEzEQABmcES4hERHd3fHdETLRAAMJmYERIiIRERERESZ
+tEAAzBEWYARMnIiIiIiIm0QADMchEXYAREnJycnMy0RADMybARISYABEREREtEREAMzJexAhIWEA
+AERERERAAAzMebsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
+EOF
+
+hostname="`hostname`"
+blink() {
+ date="`date --rfc-3339=s`"
+ echo $date
+ # nobody will ever need more than 3 frames to initialize!
+ frame=4
+ device="/dev/`cd /sys/class/video4linux && ls | head -n 1`"
+ mplayer -frames $frame -quiet \
+ -vo jpeg \
+ -tv driver=v4l2:device=$device \
+ tv:// #1>/dev/null 2>/dev/null
+ mv 0000000$frame.jpg index.jpg
+ cat>00000001.html<<EOF
+ <!doctyle html>
+ <META HTTP-EQUIV="REFRESH" CONTENT="2">
+ <style type="text/css">
+ body {
+ background-color: black;
+ color: white;
+ font-family: monospace;
+ }
+ </style>
+ <title>$hostname's bigeye</title>
+ <p>$date</p>
+ <p><img src="index.jpg" alt="ZOMBIECANCER" /></p>
+EOF
+ mv 00000001.html index.html
+}
+
+while blink; do
+ sleep 1
+done
+
diff --git a/modules/people/Makefile b/modules/people/Makefile
new file mode 100644
index 00000000..2c6c1c03
--- /dev/null
+++ b/modules/people/Makefile
@@ -0,0 +1,6 @@
+.phony: all
+
+all: arping.py arping_users.py
+ echo "call python ./arping_users.py v"
+install:
+ apt-get install python-scapy
diff --git a/modules/people/README.md b/modules/people/README.md
index d28100d3..e45d39c1 100644
--- a/modules/people/README.md
+++ b/modules/people/README.md
@@ -1,12 +1,11 @@
-SNMP Users
+ARPING Users
==========
-asks an snmp-router for its arp-list and tries to verify this list via
-ARPING. The snmping is done via snmp-net and command line parsing,
-the arping uses 'scapy'.
+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
-This script needs superuser rights and otherwise will just skip the
-verification
+
+arping_users.py:
+ call `python arping_users.py v` for verbose output -> print all discovered hosts
SNMPWALK Command
===============
diff --git a/modules/people/TODO.md b/modules/people/TODO.md
index dfefa9a0..daacfd58 100644
--- a/modules/people/TODO.md
+++ b/modules/people/TODO.md
@@ -1,4 +1,3 @@
BUGS
=====
-- an exception is thrown but handled wrong when snmp servers and arping is
- unreachable
+
diff --git a/modules/people/src/arping.py b/modules/people/arping.py
index 6c040969..1b51ab1b 100755
--- a/modules/people/src/arping.py
+++ b/modules/people/arping.py
@@ -2,6 +2,8 @@
import logging
log = logging.getLogger('arpingy')
+logging.disable(logging.WARNING)
+
import os,sys
try:
if (os.geteuid() != 0):
diff --git a/modules/people/src/arping_users.py b/modules/people/arping_users.py
index 1f936eba..c576e4f3 100755
--- a/modules/people/src/arping_users.py
+++ b/modules/people/arping_users.py
@@ -1,15 +1,16 @@
#!/usr/bin/python
+import subprocess,re,logging,sys
+
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)
+verb = False
+if len(sys.argv) > 1 and sys.argv[1] == 'v':
+ verb = True
def get_own_addr():
data = subprocess.Popen(['/sbin/ifconfig',DEV],
stdout=subprocess.PIPE).communicate()[0].replace('\n','')
@@ -20,30 +21,34 @@ def load_names(MAC_NAMES):
names = {}
f = open(MAC_NAMES)
for l in f:
- print l
mac,name = l.split()
- names[mac] = name
+ names[mac] = name.replace('\n','')
f.close()
return names
def arping_helper(dic):
return arpingy(**dic)
-for first in range(3):
+for first in range(4):
for second in range(255):
data.append({'iprange':'10.42.'+str(first)+'.'+str(second),'iface':DEV})
+names = load_names(MAC_NAMES)
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'
+except Exception as e:
+ print 'you fail '+str(e)
for p in ret:
+ if verb:
+ print p[0] + " => " + p[1]
if p[1] in names:
- print name + " is online"
+ print names[p[1]]+ " is online"
+
+
diff --git a/modules/people/bin/run.sh b/modules/people/bin/run.sh
deleted file mode 100755
index 6da3d059..00000000
--- a/modules/people/bin/run.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-echo basedir $0
-BINDIR="`dirname $0`/../src"
-
-python2 "$BINDIR/main.py" $@
diff --git a/modules/people/conf/example.json b/modules/people/conf/example.json
deleted file mode 100644
index f34c20f0..00000000
--- a/modules/people/conf/example.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "snmp_users": {
- "amqp": {
- "connection": {
- "login": "guest",
- "password": "guest",
- "host": "localhost"
- },
- "out": {
- "exchange": "snmp_src"
- }
- },
- "snmp": {
- "server": "127.0.0.1",
- "community": "community"
- },
- "arping": {
- "active": true,
- "dev": "eth0"
- }
- }
-}
diff --git a/modules/people/src/mac_names.lst b/modules/people/mac_names.lst
index dcd3c2b0..dcd3c2b0 100644
--- a/modules/people/src/mac_names.lst
+++ b/modules/people/mac_names.lst
diff --git a/modules/people/src/main.py b/modules/people/src/main.py
deleted file mode 100755
index c70bffd4..00000000
--- a/modules/people/src/main.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python2
-import sys,json,time
-from snmp_users import snmp_users
-import logging
-import genericore as gen
-MODULE_NAME='snmp_users'
-log = logging.getLogger(MODULE_NAME)
-PROTO_VERSION = 1
-DESCRIPTION = 'performes statistical analysis against mails from stream'
-
-
-# set up instances of needed modules
-conf = gen.Configurator(PROTO_VERSION,DESCRIPTION)
-amqp = gen.auto_amqp(MODULE_NAME)
-s = snmp_users(MODULE_NAME) # the magic mail parsing class
-
-conf.configure([amqp,s]) #set up parser and eval parsed stuff
-
-# start network connections
-amqp.create_connection()
-
-log.info('Starting up snmp_users')
-print ' Sending Messages in Intervals. To exit press CTRL+C'
-try:
- while True:
- log.info("collecting data from network")
- ret = s.collect()
- data = { 'type' : 'snmp', 'subtype' : 0, 'data' : ret}
- log.debug("writing data to queue : %s" % data)
- amqp.publish(json.dumps(data))
- time.sleep(s.repeat)
-except Exception as e:
- print "something happened :( " + str(e)
diff --git a/modules/people/src/snmp_users.py b/modules/people/src/snmp_users.py
deleted file mode 100755
index 871ed9dd..00000000
--- a/modules/people/src/snmp_users.py
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/python2
-
-import logging, subprocess,re
-from multiprocessing import Pool
-from genericore import Configurable
-from arping import arpingy
-log = logging.getLogger('snmp_users')
-
-DEFAULT_CONFIG= {
- "snmp" : {
- "server" : "127.0.0.1",
- "community" : "community",
- "tree" : "1.3.6.1.2.1.3.1.1.2"
- },
- "arping" : {
- "active" : True,
- "dev" : "eth0"
- }
-}
-
-def arping_helper(dic):
- return arpingy(**dic)
-
-class snmp_users(Configurable):
- mac_list = {}
-
- def __init__(self,MODULE_NAME,config=None):
- self.NAME=MODULE_NAME
- newConf = { MODULE_NAME : DEFAULT_CONFIG }
- Configurable.__init__(self,newConf)
- self.load_conf(config)
-
- def call_external(self):
- """returns an array of lines produced by snmpwalk """
- conf = self.config[self.NAME]['snmp']
-
- out = subprocess.Popen(
- ['snmpwalk',
- '-v2c',
- '-c',conf['community'],
- conf['server'],
- conf['tree']],
- stdout=subprocess.PIPE).communicate()[0]
- return out.split('\n')
-
- def parse_output(self,output):
- """ parses output lines produced by snmpwalk """
- data = []
- for i in output:
- if i == '':
- continue
- data.append(re.sub(r'.*\.(\d+\.\d+\.\d+\.\d+) = Hex-STRING: ([ 0-9A-F]*) ', r'\1 : \2',i).split(' : '))
- data = [ [ip,':'.join(mac.split()).lower()] for ip,mac in data] #sanitize
-
- return data
-
- def update_results(self,new):
- """ Verifies ip and mac via ARP Scan
- in addition it adds the correct ip to the mac_list """
- macl = self.mac_list = {}
- for ip,mac in new: # fill the mac_list
- if not macl.get(mac,None):
- macl[mac] = []
- macl[mac].append(ip)
- return True
-
- def verify(self,snmp_data):
- """ verifies retrieved data where data is an array of arrays where
- [0] is the ip and [1] is the mac (space-delimited)"""
- arp_data = self.arping_parallel(snmp_data)
- self.update_results(arp_data)
-
- def get_own_addr(self):
- data = subprocess.Popen(['/sbin/ifconfig',self.config[self.NAME]['arping']['dev']],
- stdout=subprocess.PIPE).communicate()[0].r