diff options
190 files changed, 6289 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0d20b648 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..ed0cb4ed --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "submodules/github/visionmedia/query"] + path = submodules/github/visionmedia/query + url = https://github.com/visionmedia/query +[submodule "submodules/github/tmpvar/jsdom"] + path = submodules/github/tmpvar/jsdom + url = https://github.com/tmpvar/jsdom +[submodule "submodules/github/mikeal/request"] + path = submodules/github/mikeal/request + url = https://github.com/mikeal/request.git +[submodule "submodules/github/NV/cssom"] + path = submodules/github/NV/cssom + url = https://github.com/NV/CSSOM +[submodule "submodules/github/tautologistics/node-htmlparser"] + path = submodules/github/tautologistics/node-htmlparser + url = https://github.com/tautologistics/node-htmlparser diff --git a/Kübelwagen/Makefile b/Kübelwagen/Makefile new file mode 100644 index 00000000..e180d047 --- /dev/null +++ b/Kübelwagen/Makefile @@ -0,0 +1,14 @@ + +CC := gcc -std=c99 +CFLAGS := -D_XOPEN_SOURCE=500 +LIBS := $(shell pkg-config --cflags --libs jack) + +.PHONY: all clean + +all: a.out + +clean: + rm -f a.out + +a.out: index.c + $(CC) $(CFLAGS) -o $@ $^ $(LIBS) diff --git a/Kübelwagen/alarm.sh b/Kübelwagen/alarm.sh new file mode 100644 index 00000000..601a18db --- /dev/null +++ b/Kübelwagen/alarm.sh @@ -0,0 +1,5 @@ +#! /bin/sh +echo 'You are made of stupid!' >&2 +exit 23 + +sleep 5h 19m && while :; do echo $(echo "($(od -tu -An -N 2 /dev/urandom)%1000)+500"|bc) $(echo "($(od -tu -An -N 2 /dev/urandom)%500)+100"|bc) ; done | ./a.out 1 diff --git a/Kübelwagen/index.c b/Kübelwagen/index.c new file mode 100644 index 00000000..9a15c7c3 --- /dev/null +++ b/Kübelwagen/index.c @@ -0,0 +1,206 @@ +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> +#include <math.h> + +#include <jack/jack.h> + +const double PI = 3.14; + +/*Our output port*/ +jack_port_t *output_port; + +typedef jack_default_audio_sample_t sample_t; + +/*The current sample rate*/ +jack_nframes_t sr; + +/*samples in cycle*/ +jack_nframes_t samincy; +/*the current offset*/ +long offset=0; + +/*frequency of our sound*/ +int tone = 262; +int length = 1000000; + +char const *name = "<undefined>"; + +int process (jack_nframes_t nframes, void *arg){ + /*grab our output buffer*/ + sample_t *out = (sample_t *) jack_port_get_buffer + (output_port, nframes); + + int _tone = tone > 0 ? tone : 1; + + /*For each required sample*/ + for(jack_nframes_t i=0;i < nframes;i++){ + /*Copy the sample at the current position in the cycle to the buffer*/ + + jack_nframes_t samincy = sr / _tone; + sample_t scale = 2 * PI / samincy; + out[i] = sin(offset * scale); + + /*and increment the offset, wrapping to 0 if needed*/ + /*(Dumb increment fixed thanks to Jussi Sainio)*/ + offset++; + if(offset >= samincy) + offset = 0; + } + + return 0; +} + +int srate (jack_nframes_t nframes, void *arg){ + printf ("the sample rate is now %lu/sec\n", nframes); + sr=nframes; + return 0; +} + +void error (const char *desc){ + fprintf (stderr, "JACK error: %s\n", desc); +} + +void jack_shutdown (void *arg){ + exit (1); +} + +void usage(void) { + fprintf (stderr, "usage: %s [Hz [ms]]\n", name); +} + +int main (int argc, char *argv[]){ + jack_client_t *client; + const char **ports; + + name = argv[0]; + + if (argc < 2) { + usage(); + return 1; + } + if (argc >= 2) { + tone = atoi(argv[1]); + if (tone == 0) { + usage(); + return 1; + } + fprintf(stderr, "tone: %dHz\n", tone); + if (argc >= 3) { + length = atoi(argv[2]) * 1000; + if (length == 0) { + usage(); + return 1; + } + fprintf(stderr, "length: %dms\n", length/1000); + } + } + + /* tell the JACK server to call error() whenever it + experiences an error. Notice that this callback is + global to this process, not specific to each client. + + This is set here so that it can catch errors in the + connection process + */ + jack_set_error_function (error); + + /* try to become a client of the JACK server */ + + if ((client = jack_client_open(argv[0], JackNullOption, NULL)) == 0) { + fprintf (stderr, "jack server not running?\n"); + return 1; + } + + /* tell the JACK server to call `process()' whenever + there is work to be done. + */ + + jack_set_process_callback (client, process, 0); + + /* tell the JACK server to call `srate()' whenever + the sample rate of the system changes. + */ + + + jack_set_sample_rate_callback (client, srate, 0); + + /* tell the JACK server to call `jack_shutdown()' if + it ever shuts down, either entirely, or if it + just decides to stop calling us. + */ + + jack_on_shutdown (client, jack_shutdown, 0); + + /* display the current sample rate. once the client is activated + (see below), you should rely on your own sample rate + callback (see above) for this value. + */ + printf ("engine sample rate: %lu\n", jack_get_sample_rate (client)); + + + sr=jack_get_sample_rate (client); + + /* create two ports */ + + + output_port = jack_port_register (client, "output", + JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); + + /* tell the JACK server that we are ready to roll */ + + if (jack_activate (client)) { + fprintf (stderr, "cannot activate client"); + return 1; + } + + /* connect the ports*/ + if ((ports = jack_get_ports (client, NULL, NULL, + JackPortIsPhysical|JackPortIsInput)) == NULL) { + fprintf(stderr, "Cannot find any physical playback ports\n"); + exit(1); + } + + int i=0; + while(ports[i]!=NULL){ + if (jack_connect (client, jack_port_name (output_port), ports[i])) { + fprintf (stderr, "cannot connect output ports\n"); + } + i++; + } + + free (ports); + + //while (1) { //scanf("%i %i", &tone, &length) == 2) { + char buf[BUFSIZ]; + while (fgets(buf, BUFSIZ, stdin) == buf) { + //if (strstr(buf, "Hz\n")) { + // sscanf(buf, "%i", &tone); + // fprintf(stderr, "%dHz\n", tone); + //} + //if (strstr(buf, "us\n")) { + // sscanf(buf, "%i", &length); + // fprintf(stderr, "%dus\n", length); + //} + + int length = 0; + int c; + int pos = 0, n; + while ((c = sscanf(buf + pos, "%i%i%n", &tone, &length, &n)) == 2) { + + if (length > 0) { + usleep(length * 1000); + } + + pos += n; + + fprintf(stderr, "%dHz %dms\n", tone, length); + } + } + ///* 3 seconds of bleep is plenty*/ + ///usleep(length); + jack_client_close(client); + + exit(0); +} diff --git a/Kübelwagen/sin.js b/Kübelwagen/sin.js new file mode 100644 index 00000000..0f472715 --- /dev/null +++ b/Kübelwagen/sin.js @@ -0,0 +1,37 @@ + + + +var x = 3000; + +var t = 0; +var i = 0; +var j = 0.00001; +var t0 = new Date(); +(function rec () { + + var t1 = new Date(); + console.error('dt = ' + (t1 - t0)); + t0 = t1; + + if (x === 3000) { + x = 1000; + } else { + x = 3000; + }; + + console.log('2000 50 0 50 2000 50 0 50 ' + x + ' 100 0 0'); + return setTimeout(rec, 1000); + + i += 0.01; + console.log((2000 + Math.sin(i) * 1000 | 0) + ' 0'); + return setTimeout(rec, 1); + + var f = Math.abs(1000 + 500 * Math.tan( t )); + var scale = 1; + + console.log(((f * scale)|0) + ' 0'); + + t++; + setTimeout(rec, 100); + //process.nextTick(rec); +})(); diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..188e6ca2 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +DIST = debian + +.PHONY: infest all +all: select-target + +infest: + make -C infest + +install-core: + core/$(DIST) + +noise: + make -C noise infest +streams: + make -C streams +monitoring: + make -C Monitoring debian +zoneminder: + make -C zoneminder fix it so hard diff --git a/Monitoring/Makefile b/Monitoring/Makefile new file mode 100644 index 00000000..794f9262 --- /dev/null +++ b/Monitoring/Makefile @@ -0,0 +1,23 @@ +NAGDIR = /etc/nagios3/ +NAGLIBDIR = /usr/lib/nagios +HTDOCS = /usr/share/nagios3/htdocs + +.phony: debian +debian: + git pull origin master + [ `which python` ] || apt-get install python python-simplejson + [ `which nagios3` ] || apt-get install nagios3 + rm $(NAGDIR)/conf.d/* || true + cp -r conf/* $(NAGDIR)/conf.d/ + htpasswd -bc htpasswd.users nagiosadmin krebs + htpasswd -b htpasswd.users shack shackit + sed -i 's/\(authorized_for_all_hosts=nagiosadmin\)$$/\1,shack/' $(NAGDIR)/cgi.cfg + sed -i 's/\(check_external_commands=\)0$$/\11/' $(NAGDIR)/nagios.cfg + sed -i 's/\(authorized_for_all_services=nagiosadmin\)$$/\1,shack/' $(NAGDIR)/cgi.cfg + cp -R htdocs/* $(HTDOCS) + cp -r plugins $(NAGLIBDIR) + /etc/init.d/nagios3 reload + chown nagios:www-data /var/lib/nagios3 || true + chown nagios:www-data /var/lib/nagios3/rw || true + chmod g+x /var/lib/nagios3 || true + chmod ugo=rwx /var/lib/nagios3/rw/nagios.cmd || true diff --git a/Monitoring/TODO b/Monitoring/TODO new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Monitoring/TODO diff --git a/Monitoring/conf/extinfo.cfg b/Monitoring/conf/extinfo.cfg new file mode 100644 index 00000000..e4300b72 --- /dev/null +++ b/Monitoring/conf/extinfo.cfg @@ -0,0 +1,9 @@ +define hostextinfo{ + hostgroup_name debian-servers + notes Debian GNU/Linux servers +# notes_url http://webserver.localhost.localdomain/hostinfo.pl?host=netware1 + icon_image base/debian.png + icon_image_alt Debian GNU/Linux + vrml_image debian.png + statusmap_image base/debian.gd2 + } diff --git a/Monitoring/conf/hostgroups_generic.cfg b/Monitoring/conf/hostgroups_generic.cfg new file mode 100644 index 00000000..4e3625c5 --- /dev/null +++ b/Monitoring/conf/hostgroups_generic.cfg @@ -0,0 +1,28 @@ +# 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/Monitoring/conf/krebs_hosts.cfg b/Monitoring/conf/krebs_hosts.cfg new file mode 100644 index 00000000..a929fa19 --- /dev/null +++ b/Monitoring/conf/krebs_hosts.cfg @@ -0,0 +1,78 @@ + +# +# 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-coreswitch + 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-coreswitch + hostgroups krebs-machines,tinc-nodes,ssh-servers + } +# +# ytart +# will use tinc ip as long as no static ip is supplied +# +define host{ + use generic-host + host_name ytart + alias ytart + _tinc_address 10.7.7.201 + parents shack-wlan-ap5 + address 10.7.7.201 + 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-node1 + 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-node1 + hostgroups ssh-servers,shack-rz + #,tinc-nodes,krebs-machines + } + +define host{ + use generic-host + host_name shepherd + alias Shepherd Krebs + _tinc_address 10.7.7.29 + address 10.42.23.42 + parents shack-coreswitch + hostgroups krebs-machines,tinc-nodes,ssh-servers + } diff --git a/Monitoring/conf/krebsnet.cfg b/Monitoring/conf/krebsnet.cfg new file mode 100644 index 00000000..ae5b898e --- /dev/null +++ b/Monitoring/conf/krebsnet.cfg @@ -0,0 +1,20 @@ +## 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 + } +#define host{ +# use generic-host +# register 0 +# name tinc-only-host +# check_command check_internal_tinc_up!100.0,20%!500.0,60% +# } diff --git a/Monitoring/conf/localhost.cfg b/Monitoring/conf/localhost.cfg new file mode 100644 index 00000000..3b098195 --- /dev/null +++ b/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/Monitoring/conf/other_hosts.cfg b/Monitoring/conf/other_hosts.cfg new file mode 100644 index 00000000..bbdc676a --- /dev/null +++ b/Monitoring/conf/other_hosts.cfg @@ -0,0 +1,22 @@ +define host{ + use generic-host + host_name google.de + alias Google Website + address google.de + parents shack-gw + hostgroups http-servers + } + +define host{ + use generic-host + host_name google-dns + parents shack-gw + alias Google DNS Service (always reachable) + address 8.8.8.8 + } +define service { + host_name google-dns + service_description DNS Service + use generic-service + check_command check_dns + } diff --git a/Monitoring/conf/services.cfg b/Monitoring/conf/services.cfg new file mode 100644 index 00000000..e3a61eb0 --- /dev/null +++ b/Monitoring/conf/services.cfg @@ -0,0 +1,26 @@ +# check that web services are running +define service { + hostgroup_name http-servers + service_description HTTP + check_command check_http + use generic-service + notification_interval 0 ; set > 0 if you want to be renotified +} + +# check that ssh services are running +define service { + hostgroup_name ssh-servers + service_description SSH + check_command check_ssh + use generic-service + notification_interval 0 ; set > 0 if you want to be renotified +} + +# check that ping-only hosts are up +define service { +# hostgroup_name ping-servers + service_description PING + check_command check_ping!100.0,20%!500.0,60% + use generic-service + notification_interval 0 ; set > 0 if you want to be renotified +} diff --git a/Monitoring/conf/shack_contacts.cfg b/Monitoring/conf/shack_contacts.cfg new file mode 100644 index 00000000..832a215e --- /dev/null +++ b/Monitoring/conf/shack_contacts.cfg @@ -0,0 +1,22 @@ +define contact{ + contact_name makefu + alias makefu + service_notification_period 24x7 + host_notification_period 24x7 + service_notification_options w,u,c,r + host_notification_options d,u,r + service_notification_commands notify-service-by-email + host_notification_commands notify-host-by-email + email shack_nagios_notification@syntax-fehler.de + } +define contactgroup{ + contactgroup_name krebsminers + alias Krebsminers + members makefu + } + +define contactgroup{ + contactgroup_name admins + alias admins + } + diff --git a/Monitoring/conf/shack_guests.cfg b/Monitoring/conf/shack_guests.cfg new file mode 100644 index 00000000..5832725a --- /dev/null +++ b/Monitoring/conf/shack_guests.cfg @@ -0,0 +1,105 @@ +# +# Bitcoin mines +# +define host{ + use generic-host + host_name gauda0 + parents shack-serverswitch + alias Gauda0 Bitcoin Mining Rig 0 + address 10.42.0.99 + hostgroups bitcoin-miner + } +define host{ + use generic-host + host_name gauda1 + parents shack-serverswitch2 + alias Gauda1 Bitcoin Mining Rig 1 + address 10.42.0.98 + hostgroups bitcoin-miner + } +define host{ + use generic-host + host_name gauda2 + parents shack-serverswitch2 + alias Gauda2 Bitcoin Mining Rig 2 + address 10.42.0.97 + hostgroups bitcoin-miner + } + +#Chinaman +define host{ + use generic-host + host_name chinaman + parents shack-router + alias Chinaman Bitcoin Mining Rig + #address 10.42.0.96 + #_TINC_ADDRESS 10.7.7.6 + address 10.7.7.6 + _SPEED_URL http://leechi.kicks-ass.org/tmp/live/chinaman_bitcoinslc_live + _TEMPER_URL http://leechi.kicks-ass.org/tmp/live/chinaman_ati_temper + hostgroups bitcoin-miner,tinc-nodes,ssh-servers + contact_groups krebsminers + } +define command { + command_name check_speed + command_line $USER1$/check_speed $_HOSTSPEED_URL$ $ARG1$ + } +define service { + host_name chinaman + service_description Temperature Checker + use generic-service + check_command check_temper!85 85 65 45 + contact_groups krebsminers + } +define command { + command_name check_temper + command_line $USER1$/check_temper $_HOSTTEMPER_URL$ $ARG1$ + } +define service { + host_name chinaman + service_description Mining Speed checker + use generic-service + check_command check_speed!600 + contact_groups krebsminers + } +#define service { +# host_name chinaman +# service_description BTCGUILD hash rate checker +# use generic-service +# check_command check_btcguild_miner!4bf1543d2eca8648277bdc66c326eea9!txgen_chinaman!450 +# contact_groups krebsminers +# } + + +#define command { +# command_name check_btcguild_miner +# command_line $USER1$/check_btcguild_miner $ARG1$ $ARG2$ $ARG3$ +# } + +define host{ + use generic-host + host_name Sascha privater Server + parents shack-serverswitch + alias Sascha Server + address 10.42.23.100 + #hostgroups bitcoin-miner + } + +define host{ + use generic-host + host_name Telefonzelle + parents shack-coreswitch + alias Telefonzelle + address 10.42.23.101 + #hostgroups bitcoin-miner + } + +define host{ + use generic-host + host_name shack-pnp + alias Shack Bestueckungsautomat + address 10.42.100.5 + parents shack-coreswitch + #hostgroups shack-rz + } + diff --git a/Monitoring/conf/shack_infrastructure.cfg b/Monitoring/conf/shack_infrastructure.cfg new file mode 100644 index 00000000..f404f3e4 --- /dev/null +++ b/Monitoring/conf/shack_infrastructure.cfg @@ -0,0 +1,241 @@ +# + +# +# Shack Virtual Machine Hoster Platform +# + +# +# Virtualization and storage +# +define host{ + use generic-host + host_name shack-node0 + alias Shack Virtualization Server 0 + address 10.42.0.10 + parents shack-serverswitch + hostgroups shack-rz,ssh-servers + } +define host{ + use generic-host + host_name shack-node1 + alias Shack Virtualization Server 1 + address 10.42.0.10 + parents shack-serverswitch + hostgroups shack-rz,ssh-servers + } +define host{ + use generic-host + host_name shack-plattenschwein + parents shack-serverswitch + alias Shack Plattenschwein + address 10.42.0.12 + hostgroups shack-rz,ssh-servers + } +# +# Network Infrastructure +# + +# +## Shack gateway (no gateway-no internet) +# +define host{ + use generic-host + host_name shack-gw + parents shack-coreswitch + alias Watchguard Shack Gateway + address 10.42.0.1 + hostgroups shack-rz,ssh-servers + } +#deprecated +#define host{ +# use generic-host +# host_name shack-modem +# parents shack-gw +# alias Shack Telecom VDSL Router +# address 192.168.2.1 +# hostgroups shack-rz +# } +define host{ + use generic-host + host_name shack-externswitch + parents shack-gw + alias Shack External Switch (2.OG) + address 10.0.10.2 + hostgroups shack-rz + } +# +# Serverswitch 2 +# +define host{ + use generic-host + host_name shack-serverswitch2 + parents shack-serverswitch + alias Shack switch Rack 2 (cisco 3524) + address 10.42.0.5 + hostgroups shack-rz + } + +define service { + host_name shack-serverswitch2 + service_description Telnet + use generic-service + check_command check_telnet + } + +define service { + host_name shack-serverswitch2 + service_description Admin HTTP Terminal + use generic-service + check_command check_http + } + + +define service { + host_name shack-gw + service_description DNS Service + use generic-service + check_command check_dns + } +define host{ + use generic-host + host_name shack-coreswitch + alias Shack Cisco Router Coreswitch + address 10.42.0.3 + hostgroups shack-rz,ssh-servers + } +define host{ + use generic-host + host_name shack-serverswitch + parents shack-coreswitch + alias Shack Cisco Router Serverswitch + address 10.42.0.4 + hostgroups shack-rz + } + +define host{ + use generic-host + host_name shack-wlan-ap2 + parents shack-coreswitch + alias Shack Wlan Access Point 2 + address 10.42.0.6 + hostgroups wlan-ap + } +define host{ + use generic-host + host_name shack-wlan-ap3 + parents shack-coreswitch + alias Shack Wlan Access Point 3 + address 10.42.0.7 + hostgroups wlan-ap + } +define host{ + use generic-host + host_name shack-wlan-ap4 + parents shack-coreswitch + alias Shack Wlan Access Point 4 + address 10.42.0.8 + hostgroups wlan-ap + } +define host{ + use generic-host + host_name shack-wlan-ap5 + parents shack-coreswitch + alias Shack Wlan Access Point 5 + address 10.42.0.9 + hostgroups wlan-ap + } +# +# Voip Infrastructure +# +define host{ + use generic-host + host_name shack-voip + alias Shack Cisco VOIP Gateway + address 10.42.0.2 + parents shack-coreswitch + hostgroups shack-rz,http-servers + } + +define service{ + host_name shack-voip + service_description SIP Service + use generic-service + check_command check_sip + } + +# +# Shack DNS Server +# + +define host{ + use generic-host + host_name shack-dns + parents shack-node0 + alias Shack DNS Virtual Host + address 10.42.0.100 + hostgroups shack-rz + } +define service { + host_name shack-dns + service_description DNS Service + use generic-service + check_command check_dns_shack + } + +define host{ + use generic-host + host_name shack-pxe + parents shack-node0 + alias Shack PXEBoot Vhost + address pxeboot.shack + hostgroups shack-rz + } + +define host{ + use generic-host + host_name shack-printsrv + parents shack-node1 + alias Shack Print Server + address printer.shack + hostgroups shack-rz + } + +define host{ + use generic-host + host_name shack-aptproxy + parents shack-node0 + alias Shack Apt-proxy + address aptproxy.shack + hostgroups shack-rz + } + +define host{ + use generic-host + host_name shack-shack + parents shack-node1 + 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-node0 + 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 + } + +# +# Random stuff (not necessary located in RZ) +# diff --git a/Monitoring/conf/shacknet.cfg b/Monitoring/conf/shacknet.cfg new file mode 100644 index 00000000..802e5e3a --- /dev/null +++ b/Monitoring/conf/shacknet.cfg @@ -0,0 +1,47 @@ +define hostgroup { + hostgroup_name shack-rz + alias Shack RZ Infrastructure + } +define hostgroup { + hostgroup_name bitcoin-miner + alias Bitcoin miner in Shack-RZ + } +define hostextinfo{ + hostgroup_name bitcoin-miner + notes Bitcoin miner in Shack-RZ + icon_image krebs/bitcoin_miner.png + icon_image_alt bitcoin_miner + vrml_image bitcoin_miner.png + statusmap_image krebs/bitcoin_miner.gd2 + } + +define hostgroup { + hostgroup_name wlan-ap + alias Shack Wlan Access Points + } +define hostextinfo{ + hostgroup_name wlan-ap + notes Access Points for Shack + icon_image krebs/wireless_access_point.png + icon_image_alt wireless_access_point + vrml_image wireless_access_point.png + statusmap_image krebs/wireless_access_point.gd2 + } +define hostextinfo{ + hostgroup_name shack-rz + notes Shack RZ Infrastructure + icon_image krebs/shack.png + icon_image_alt shack-RZ + vrml_image shack.png + statusmap_image krebs/shack.gd2 + } + +define command { + command_name check_sip + command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 5060 + } + +define command { + command_name check_dns_shack + command_line $USER1$/check_dns -H shack.shack -s '$HOSTADDRESS$' + } diff --git a/Monitoring/conf/templates.cfg b/Monitoring/conf/templates.cfg new file mode 100644 index 00000000..41807e1c --- /dev/null +++ b/Monitoring/conf/templates.cfg @@ -0,0 +1,45 @@ +# generic service template definition +define service{ + name generic-service ; The 'name' of this service template + active_checks_enabled 1 ; Active service checks are enabled + passive_checks_enabled 1 ; Passive service checks are enabled/accepted + parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) + obsess_over_service 1 ; We should obsess over this service (if necessary) + check_freshness 0 ; Default is to NOT check service 'freshness' + notifications_enabled 1 ; Service notifications are enabled + event_handler_enabled 1 ; Service event handler is enabled + flap_detection_enabled 1 ; Flap detection is enabled + failure_prediction_enabled 1 ; Failure prediction is enabled + process_perf_data 1 ; Process performance data + retain_status_information 1 ; Retain status information across program restarts + retain_nonstatus_information 1 ; Retain non-status information across program restarts + notification_interval 0 ; Only send notifications on status change by default. + is_volatile 0 + check_period 24x7 + normal_check_interval 5 + retry_check_interval 1 + max_check_attempts 4 + notification_period 24x7 + notification_options w,u,c,r + contact_groups admins + register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! + } +# Generic host definition template - This is NOT a real host, just a template! + +define host{ + name generic-host ; The name of this host template + notifications_enabled 1 ; Host notifications are enabled + event_handler_enabled 1 ; Host event handler is enabled + flap_detection_enabled 1 ; Flap detection is enabled + failure_prediction_enabled 1 ; Failure prediction is enabled + process_perf_data 1 ; Process performance data + retain_status_information 1 ; Retain status information across program restarts + retain_nonstatus_information 1 ; Retain non-status information across program restarts + check_command check-host-alive + max_check_attempts 10 + notification_interval 0 + notification_period 24x7 + notification_options d,u,r + contact_groups admins + register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! + } diff --git a/Monitoring/conf/timeperiods.cfg b/Monitoring/conf/timeperiods.cfg new file mode 100644 index 00000000..55ecf9df --- /dev/null +++ b/Monitoring/conf/timeperiods.cfg @@ -0,0 +1,50 @@ +############################################################################### +# timeperiods.cfg +############################################################################### + +# This defines a timeperiod where all times are valid for checks, +# notifications, etc. The classic "24x7" support nightmare. :-) + +define timeperiod{ + timeperiod_name 24x7 + alias 24 Hours A Day, 7 Days A Week + sunday 00:00-24:00 + monday 00:00-24:00 + tuesday 00:00-24:00 + wednesday 00:00-24:00 + thursday 00:00-24:00 + friday 00:00-24:00 + saturday 00:00-24:00 + } + +# Here is a slightly friendlier period during work hours +define timeperiod{ + timeperiod_name workhours + alias Standard Work Hours + monday 09:00-17:00 + tuesday 09:00-17:00 + wednesday 09:00-17:00 + thursday 09:00-17:00 + friday 09:00-17:00 + } + +# The complement of workhours +define timeperiod{ + timeperiod_name nonworkhours + alias Non-Work Hours + sunday 00:00-24:00 + monday 00:00-09:00,17:00-24:00 + tuesday 00:00-09:00,17:00-24:00 + wednesday 00:00-09:00,17:00-24:00 + thursday 00:00-09:00,17:00-24:00 + friday 00:00-09:00,17:00-24:00 + saturday 00:00-24:00 + } + +# This one is a favorite: never :) +define timeperiod{ + timeperiod_name never + alias Never + } + +# end of file diff --git a/Monitoring/conf/tinc_hosts.cfg b/Monitoring/conf/tinc_hosts.cfg new file mode 100644 index 00000000..717c75a8 --- /dev/null +++ b/Monitoring/conf/tinc_hosts.cfg @@ -0,0 +1,33 @@ +#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 + } diff --git a/Monitoring/conf/tincnet.cfg b/Monitoring/conf/tincnet.cfg new file mode 100644 index 00000000..f0b35b4e --- /dev/null +++ b/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/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.gd2 b/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.gd2 Binary files differnew file mode 100644 index 00000000..5e585c62 --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.gd2 diff --git a/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.png b/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.png Binary files differnew file mode 100644 index 00000000..87200fe4 --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/bitcoin_miner.png diff --git a/Monitoring/htdocs/images/logos/krebs/favicon.ico b/Monitoring/htdocs/images/logos/krebs/favicon.ico Binary files differnew file mode 100644 index 00000000..fa18384c --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/favicon.ico diff --git a/Monitoring/htdocs/images/logos/krebs/krebs.gd2 b/Monitoring/htdocs/images/logos/krebs/krebs.gd2 Binary files differnew file mode 100644 index 00000000..1113f03e --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/krebs.gd2 diff --git a/Monitoring/htdocs/images/logos/krebs/krebs.png b/Monitoring/htdocs/images/logos/krebs/krebs.png Binary files differnew file mode 100644 index 00000000..3d8a8ab8 --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/krebs.png diff --git a/Monitoring/htdocs/images/logos/krebs/shack.gd2 b/Monitoring/htdocs/images/logos/krebs/shack.gd2 Binary files differnew file mode 100644 index 00000000..8b0d98e5 --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/shack.gd2 diff --git a/Monitoring/htdocs/images/logos/krebs/shack.png b/Monitoring/htdocs/images/logos/krebs/shack.png Binary files differnew file mode 100644 index 00000000..53f1275b --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/shack.png diff --git a/Monitoring/htdocs/images/logos/krebs/tinc.gd2 b/Monitoring/htdocs/images/logos/krebs/tinc.gd2 Binary files differnew file mode 100644 index 00000000..36572d4a --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/tinc.gd2 diff --git a/Monitoring/htdocs/images/logos/krebs/tinc.png b/Monitoring/htdocs/images/logos/krebs/tinc.png Binary files differnew file mode 100644 index 00000000..daa1fdeb --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/tinc.png diff --git a/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2 b/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2 Binary files differnew file mode 100644 index 00000000..6e740ec4 --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/wireless_access_point.gd2 diff --git a/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png b/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png Binary files differnew file mode 100644 index 00000000..9febe45e --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/wireless_access_point.png diff --git a/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png b/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png Binary files differnew file mode 100644 index 00000000..fe9788af --- /dev/null +++ b/Monitoring/htdocs/images/logos/krebs/wireless_access_point_64.png diff --git a/Monitoring/plugins/check_btcguild_miner b/Monitoring/plugins/check_btcguild_miner new file mode 100755 index 00000000..2e6a8de3 --- /dev/null +++ b/Monitoring/plugins/check_btcguild_miner @@ -0,0 +1,36 @@ +#!/usr/bin/python + +import sys +from urllib2 import urlopen +try: + import json + getattr(json,"load") +except: #deal with it + import simplejson as json + +if len(sys.argv) != 4 : + print "** Usage: %s APIKEY WORKER_NAME LOW_WORKER_SPEED" % sys.argv[0] + print "** aka YOU ARE MADE OF STUPID" + exit (3) + +API_KEY=sys.argv[1] +WORKER_NAME=sys.argv[2] +LOW_WORKER_SPEED=float(sys.argv[3]) +url="http://www.btcguild.com/api.php?api_key=%s" % API_KEY +try: + fh = urlopen(url) + result = json.load(fh) +except Exception,e: + print "?? cannot parse json or connect to server: %s"% str(e) + exit (1) + +for k,v in result["workers"].iteritems(): + if v["worker_name"] == WORKER_NAME: + curr = v["hash_rate"] + if curr < LOW_WORKER_SPEED: + print "!! %f is below expected %f" % (curr,LOW_WORKER_SPEED) + exit (2) + else: + print "++ everything fine, current speed is %f" % curr + exit(0) + diff --git a/Monitoring/plugins/check_sip b/Monitoring/plugins/check_sip new file mode 100755 index 00000000..24374727 --- /dev/null +++ b/Monitoring/plugins/check_sip @@ -0,0 +1,252 @@ +#!/usr/bin/perl -w +# +# check_sip plugin for nagios +# $Revision: 1.2 $ +# +# Nagios plugin to check SIP servers +# +# By Sam Bashton, Bashton Ltd +# bashton.com/content/nagiosplugins +# Michael Hirschbichler, Institute of Broadband Communications, +# Vienna University of Technology +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +use strict; +use lib "/usr/lib/nagios/plugins"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); +use vars qw($PROGNAME); +use IO::Socket::INET; +#use Sys::Hostname; +use Time::HiRes qw(gettimeofday); +use Net::Domain qw (hostname hostfqdn hostdomain); + +$PROGNAME = "check_sip"; +my $VERSION = "1.2"; + +$ENV{'BASH_ENV'}=''; +$ENV{'ENV'}=''; +$ENV{'PATH'}=''; +$ENV{'LC_ALL'}='C'; + +my ($opt_V,$opt_h,$opt_u,$opt_p,$opt_H, $opt_w, $opt_s, $opt_f); +$opt_V = $opt_h = $opt_u = $opt_p = $opt_H = $opt_w = $opt_s = $opt_f = ''; + +my $state = 'UNKNOWN'; + +use Getopt::Long; +Getopt::Long::Configure('bundling'); +GetOptions( + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "s" => \$opt_s, + "f=s" => \$opt_f, "fromuri=s" => \$opt_f, + "u=s" => \$opt_u, "uri=s" => \$opt_u, + "p=s" => \$opt_p, "port=s" => \$opt_p, + "H=s" => \$opt_H, "host=s" => \$opt_H, + "w=s" => \$opt_w, "warn=s" => \$opt_w +); + +# -h displays help +if ($opt_h) { printHelp(); exit $ERRORS{'OK'}; } + +# -V display version number +if ($opt_V) { + print_revision($PROGNAME, $VERSION); + exit $ERRORS{'OK'}; +}; + +# Check the sip URI is OK +unless ($opt_u) { printHelp(); exit $ERRORS{'UNKNOWN'} } + +# Port is 5060 unless otherwise specified +unless ($opt_p) { $opt_p = 5060 } + +# Determine the host from the sip URI if it wasn't specified with -H +unless ($opt_H) { $opt_H = hostFromURI($opt_u) } + +# Check the host is valid +unless (utils::is_hostname($opt_H)) +{ + print "$opt_H is not a valid hostname\n"; + printHelp(); + exit $ERRORS{"UNKNOWN"}; +} + +unless ($opt_w) { $opt_w = 5 } # Warn if response takes longer than 5 seconds + +### Main code ############################################################### + +# Timeout if we don't recieve a response within a suitable timeframe.. +$SIG{'ALRM'} = sub { + print ("SIP timeout: No response from SIP server after $TIMEOUT seconds\n"); + exit $ERRORS{"CRITICAL"}; +}; +alarm($TIMEOUT); + +my $localhost = hostfqdn(); +$opt_f = getFromURI($opt_f,$localhost,$opt_p); +my $user=getUserPart($opt_f); +my $socket = uconnect($opt_H, $opt_p); +my @localinfo = unpack_sockaddr_in($socket->sockname); +my $req = buildReq($localinfo[0], $opt_u, $opt_f,$user,$localhost); +my (undef, $starttime) = gettimeofday; +$socket->send($req); +my $response; +$socket->recv($response, 1024) or $state = 'CRITICAL'; + +#get rid of the 100 Trying - provisional response ... +if (getResponseCode($response) eq "100"){ + $socket->recv($response, 1024) or $state = 'CRITICAL'; +} + +my (undef, $finishtime) = gettimeofday; +my $rtime = ($finishtime - $starttime) / 1000000; # Time taken in seconds +if(checkResponse($response,$rtime,$opt_s)) +{ + if ($rtime > $opt_w) { $state = 'WARNING' } + else { $state = 'OK' } +} +else { $state = 'CRITICAL' } + +exit $ERRORS{$state}; + +### Subroutines ############################################################## + + +sub uconnect +{ + my ($host, $port) = @_; + my $socket = new IO::Socket::INET->new(PeerPort=>$port, Proto=>'udp', PeerAddr=>$host); + unless ($socket) { print "Unable to connect to $host\n"; exit $ERRORS{'UNKNOWN'} } + return $socket; +} + +sub getFromURI{ + my ($from, $localhost,$localport) = @_; + if (!("$from" eq "")){ + return "$from:$localport"; + }else + { + return "sip:checksip\@$localhost:$localport"; + } +} + +sub getUserPart{ + my ($uri) = @_; + my @uris=split(/\@/,$uri); + my $user=$uris[0]; + return $user; +} + +sub hostFromURI +{ + my ($uri) = @_; + $uri =~ s/sip:[^\@]+@//; + return $uri; +} + +sub getResponseCode +{ + my ($message) = @_; + my @messageparts=split(/\ /,$message); + return $messageparts[1]; +} + +sub buildReq +{ + my ($localport, $dsturi, $fromuri,$user,$localhost) = @_; + + my $req; + my $tag = genTag(); + my $idtag = genTag(); + $req.= "OPTIONS $dsturi SIP/2.0\r\n"; + $req.= "Via: SIP/2.0/UDP $localhost:$localport;branch=z9hG4bKhjhs8ass877\r\n"; + $req.= "Max-Forwards: 70\r\n"; + $req.= "To: $dsturi\r\n"; + $req.= "From: $fromuri;tag=$tag\r\n"; + $req.= "Call-ID: $idtag\@$localhost\r\n"; + $req.= "CSeq: 1 OPTIONS\r\n"; + $req.= "Contact: <$user\@$localhost:$localport>\r\n"; + $req.= "Accept: application/sdp\r\n"; + $req.= "Content-Length: 0\r\n\r\n"; + return $req; +} + +sub genTag +{ + my $tag; + my @chars = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p', + 'q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8', + '9'); + + for (my $i = 0; $i < 6; $i++) + { + $tag .= $chars[rand(scalar @chars)]; + } + return $tag; +} + +sub printHelp +{ + print "This plugin tests the sip service on the specified host.\n\n"; + print "Usage: $PROGNAME -u sip:uri\@example.com [-H host -p PORT -f sip:fromuri\@example.com -w WARNTIME -s]\n"; + print " $PROGNAME [-h | --help]\n"; + print " $PROGNAME [-V | --version]\n\n"; + print "Options:\n"; + print " -u sip:uri\@example.com\n"; + print " Full SIP uri, eg sip:uri\@example.com\n"; + print " -h, --help\n"; + print " Print this help\n"; + print " -V, --version\n"; + print " Print version information\n"; + print " -H host\n"; + print " Host name or IP Address to connect to\n"; + print " -p port\n"; + print " Port to connect to\n"; + print " -f sip:fromuri\@example.com\n"; + print " Full SIP uri, will be used for the \"From:\"-Header\n"; + print " -s\n"; + print " Changes default behavior: all SIP-responses will result in an \"OK\"\n\n"; + + +} + +sub checkResponse +{ + my ($response, $rtime, $sp_behavior) = @_; + my @header=split(/\r/,$response); + my $tstring=$header[0]; + my $rcode=getResponseCode($response); + if (!$sp_behavior){ + #in this case, we want to see if the SIP-server is respoding positively to our request + # Some SUT respond with 100 Trying - assume everything is OK if we get this + if ($response =~ /^SIP.+[12]00/){ + print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; + return 1; + } + elsif ($response =~ /^SIP.+404 Not Found/) { + print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; + return 0 } + else { print "Unknown error: $tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; return 0; } + }else{ + #in this case, we accept every response from the server, as long it is SIP + if ($response =~ /^SIP./){ + print "$tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; + return 1; + } + else { print "Unknown error: $tstring, $rtime seconds response time|rtt=".$rtime."s;0.5s;1s;0:10; code=".$rcode."\n"; return 0; } + } +} diff --git a/Monitoring/plugins/check_speed b/Monitoring/plugins/check_speed new file mode 100755 index 00000000..14a5b612 --- /dev/null +++ b/Monitoring/plugins/check_speed @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +#TODO check_speed is nearly the same as check_speeder, consolidate both scripts, probably by giving HIGH:LOW as params +import sys +import urllib + +if len(sys.argv) < 2 or '-h' in sys.argv: + print ("?? usage: %s URL [low-mhashes] ..." % sys.argv[0]) + print ("?? Server reply should look like this: '2011-07-11T09:00 400.0'") + exit(3) + +URL=sys.argv[1] +thresholds=[ float(i) for i in sys.argv[2:]] + +ecode=0 +try: + ret = urllib.urlopen(URL).read().split() + date = ret[0] + speeds = [float(i) for i in ret[1:]] + print ("** %s : %s Mhashes" % (date,' '.join([str(i) for i in speeds]))) + if len(speeds) != len(thresholds): + raise Exception("!! Number of speeds != number of given thresholds") + for i,speed in enumerate(speeds): + if speed < thresholds[i]: + print ("!! %.2f Mhash < %.2f Mhash ! (field %d)" %(speed,thresholds[i],i)) + ecode=2 +except Exception,e: + print("!! Something aweful happened: "+str(e)) + exit (1) +#TODO return WARNING if date is too old +if not ecode: + print ("** Everything is fine!") + +exit(ecode) diff --git a/Monitoring/plugins/check_temper b/Monitoring/plugins/check_temper new file mode 100755 index 00000000..95191026 --- /dev/null +++ b/Monitoring/plugins/check_temper @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import sys +import urllib + +if len(sys.argv) < 2 or '-h' in sys.argv: + print ("?? usage: %s URL [high-val field 1] [high field 2] ..." % sys.argv[0]) + print ("?? Server reply should look like this: '2011-07-11T09:00 50.0 40.0'") + exit(3) + +URL=sys.argv[1] +thresholds=[ float(i) for i in sys.argv[2:]] + +ecode=0 +try: + ret = urllib.urlopen(URL).read().split() + date = ret[0] + temps = [float(i) for i in ret[1:]] + print ("** %s : %s" % (date,' '.join([str(i)+"°C" for i in temps]))) + if len(temps) != len(thresholds): + raise Exception("Number of temps != number of given thresholds") + for i,temp in enumerate(temps): + if temp > thresholds[i]: + print ("!! %.2f°°C > %.2f°C (field %d)!" %(temp,thresholds[i],i)) + ecode=2 +except Exception,e: + print("!! Something awful happened: "+str(e)) + exit (1) +if not ecode: + print ("** Everything is fine!") +exit(ecode) diff --git a/bigeye/bigeyed b/bigeye/bigeyed new file mode 100755 index 00000000..5aa36210 --- /dev/null +++ b/bigeye/bigeyed @@ -0,0 +1,70 @@ +#! /bin/sh +# +# usage: bigeyed +# + +set -euf + +mkdir -vp /tmp/bigeye +cd /tmp/bigeye + +cleanup() { + test -n "$spid" && kill -9 $spid && spid= +} + +port=`touch /dev/bigeye 2>/dev/null && rm /dev/bigeye && echo 3 || echo 3333` + +#python -m http.server $port & server=$! +python -m SimpleHTTPServer $port & 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/btc/btcguild/index.js b/btc/btcguild/index.js new file mode 100644 index 00000000..1f33db06 --- /dev/null +++ b/btc/btcguild/index.js @@ -0,0 +1,20 @@ +api_key = process.env.api_key; + +var options = { + host: 'www.btcguild.com', + port: 80, + path: '/api.php?api_key=' + api_key +}; + +http = require('http'); +http.get(options, function(res) { + var data = ''; + res.on('data', function (chunk) { + data += chunk; + }); + res.on('end', function () { + console.log(JSON.parse(data)); + }); +}).on('error', function(e) { + console.error('Error: ' + e.message); +}); diff --git a/btc/mining/CONFIGURE b/btc/mining/CONFIGURE new file mode 100644 index 00000000..299cbd53 --- /dev/null +++ b/btc/mining/CONFIGURE @@ -0,0 +1,8 @@ +How to Configure +=============== + +1. change the mining-url in ~/startup.sh +2. in KDE - 'AMDOverdriveCtrl - configure profile +3. in KDE-Autostart - activate the startup script +2. sudo /etc/init.d/gdm restart + diff --git a/btc/mining/Makefile b/btc/mining/Makefile new file mode 100644 index 00000000..8701920f --- /dev/null +++ b/btc/mining/Makefile @@ -0,0 +1,20 @@ +.PHONY: all format install configure +select-target: + @echo "You are made of stupid!" + echo "look here" + @cat Makefile +format: + cat README +fix-linucCoin: configure + apt-get install --yes lm-sensors tmux + echo '#!/bin/bash' > /usr/bin/ati_license + echo '#!/bin/sh' > /etc/init.d/live-boot + echo 'wall "going down"' >> /etc/init.d/live-boot + chmod 755 /etc/init.d/live-boot + echo 'sudo tar xvf /opt/AMD-APP-SDK-v2.4-lnx64/icd-registration.tgz -C /' >> /usr/bin/ati_license + cp -r user /home +configure: + yes '' | sensors-detect + @cat CONFIGURE +archlinux: + bin/archlinux-cruise-control diff --git a/btc/mining/README b/btc/mining/README new file mode 100644 index 00000000..ad8c3468 --- /dev/null +++ b/btc/mining/README @@ -0,0 +1,9 @@ +What to do: +format the usb-stick: +Device Boot Start End Blocks Id System +/dev/sda1 * 1 254 976345 c W95 FAT32 (LBA) +/dev/sda2 255 1017 2932972 83 Linux + +1. install coinlinux live system on sda1. +2. mkfs.ext3 /dev/sda2 -L live-rw +3. install grub on /dev/sda diff --git a/btc/mining/TODO b/btc/mining/TODO new file mode 100644 index 00000000..bafaa72a --- /dev/null +++ b/btc/mining/TODO @@ -0,0 +1,2 @@ +- fix the sed script in "make archlinux" to replace only the first occurrence +- test the amdoverdrive stuff from the home dir (user) diff --git a/btc/mining/bin/archlinux-cruise-control b/btc/mining/bin/archlinux-cruise-control new file mode 100755 index 00000000..de5a0fa4 --- /dev/null +++ b/btc/mining/bin/archlinux-cruise-control @@ -0,0 +1,70 @@ +#!/bin/bash +set -euf +export EDITOR=vim +echo "!! ARCHLINUX Cruise Control Mining installer !!" +echo "** adding main network profile" +cp /etc/network.d/examples/ethernet-dhcp /etc/network.d/main +echo 'POST_UP="sed -i \"1i nameserver 8.8.8.8\" /etc/resolv.conf"' >> /etc/network.d/main +echo "** adding worker account" +grep -q worker /etc/passwd || adduser worker +gpasswd -a worker wheel +gpasswd -a worker tty +gpasswd -a worker audio +gpasswd -a worker video +gpasswd -a worker network +gpasswd -a worker power + +echo "** adding archlinuxfr to pacman.conf" +grep -q archlinuxfr /etc/pacman.conf || echo "[archlinuxfr]" >> /etc/pacman.conf && echo "Server = http://repo.archlinux.fr/x86_64" >> /etc/pacman.conf +echo "** installing all the required parts" +pacman --needed --noconfirm -Syu rsync git openssh yajl sudo tmux lm_sensors vim yaourt kernel26-headers beep +echo "** doing some tweaks" +rm /usr/bin/python -f +ln -s /usr/bin/python2 /usr/bin/python +echo "syntax on" > /home/worker/.vimrc +echo "syntax on" > /root/.vimrc +echo "** installing tinc" +[ "`yaourt -Q tinc`" ] || yaourt -S --noconfirm tinc +sed -i -e 's/.*\%wheel.*/%wheel ALL=(ALL) NOPASSWD: ALL/1' /etc/sudoers +echo "** Installing ATI drivers" +[ "`yaourt -Q catalyst-utils`" ] || yaourt -S --noconfirm catalyst-utils +[ "`yaourt -Q catalyst-hook`" ] || yaourt -S --noconfirm catalyst-hook +[ "`yaourt -Q amdstream`" ] || yaourt -S --noconfirm amdstream +echo "** installing X" +pacman --needed -S --noconfirm xorg-server xorg-apps xorg-appres xorg-xinit xautolock xlockmore xorg-fonts xorg-xhost xorg-xauth xterm rxvt-unicode fluxbox slim +echo "** editing slim configuration" +sed -i 's/.*default_user.*/default_user worker/' /etc/slim.conf +sed -i 's/.*auto_login.*/auto_login yes/' /etc/slim.conf +echo "** Installing mining tools and overclocking stuff" +[ "`yaourt -Q phoenix-miner-svn`" ] || yaourt -S --noconfirm phoenix-miner-svn +echo "!! warning, you might need to adjust the version number of AMDOverdriveCTRL !!" +[ "`yaourt -Q amdoverdrivectrl`" ] || yaourt -S amdoverdrivectrl +echo "** copying bin folder" +cp -r $(readlink -f `dirname $0`)/ /home/worker +echo "** creating new .Xauthority for worker" +sudo -u worker /home/worker/bin/newkey.sh +mkdir -p /home/worker/.fluxbox +cp /krebs/mining/user/startup.sh /home/worker/startup.sh +chmod a+x /home/worker/startup.sh +cp /krebs/mining/user/startup.sh /home/worker/.fluxbox/startup +chmod a+x /home/worker/.fluxbox/startup +cp /krebs/mining/user/mining.ovdr /home/worker/ +chown -R worker:users /home/worker +echo "configuring X" +echo "!! ACTION REQUIRED, write down the first number of your ATI Graphics Adapter." +echo "!! i will open /etc/X11/xorg.conf for you, change the BusID of every Device to the numbers you see here" +echo "!! press enter to continue" +lspci|grep VGA +read +aticonfig --initial=dual-head +vim /etc/X11/xorg.conf +echo "** creating xinitrc and start x" +echo 'setxkbmap -option terminate:ctrl_alt_bksp' > /home/worker/.xinitrc +echo 'xautolock -corners +-+- -locker "xlock -mode blank"&' >> /home/worker/.xinitrc +echo '/home/worker/startup.sh &' >> /home/worker/.xinitrc +echo 'xterm &' >> /home/worker/.xinitrc +echo 'exec fluxbox' >> /home/worker/.xinitrc +echo '!! start x with `xinit `' +echo 'add "x:5:respawn:/usr/bin/slim >/dev/null 2>&1" to /etc/inittab to start slim" + + diff --git a/btc/mining/bin/ati_temper b/btc/mining/bin/ati_temper new file mode 100755 index 00000000..283a6024 --- /dev/null +++ b/btc/mining/bin/ati_temper @@ -0,0 +1,5 @@ +#displays: CARD1TEMP CARD2TEMP CPUTEMP OUTSIDE +echo -n "`DISPLAY=:0 aticonfig --adapter=1 --od-gettemperature | grep Temperature | sed -n 's/.*Temperature - \([0-9.]*\) C/\1/;p'` " +echo -n "`DISPLAY=:0 aticonfig --adapter=2 --od-gettemperature | grep Temperature | sed -n 's/.*Temperature - \([0-9.]*\) C/\1/;p'` " +echo -n "`sensors | grep temp1 | sed -e 's/temp1: *+\([0-9.]*\).*/\1/'` " +echo "`temper`" diff --git a/btc/mining/bin/cleanup_tmp b/btc/mining/bin/cleanup_tmp new file mode 100755 index 00000000..e1395b19 --- /dev/null +++ b/btc/mining/bin/cleanup_tmp @@ -0,0 +1,4 @@ +#! /bin/sh +ls -lAtr /tmp/ | sed -rn ' + /\.so$/{$!{s/.* ([A-Za-z0-9]+\.so)$/rm -v \/tmp\/\1/p}} +' | sudo sh diff --git a/btc/mining/bin/ensure-router b/btc/mining/bin/ensure-router new file mode 100755 index 00000000..ec78f610 --- /dev/null +++ b/btc/mining/bin/ensure-router @@ -0,0 +1,27 @@ +#! /bin/sh + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +if=eth2 + +if ! ifconfig $if | grep -q 'inet addr'; then + beep -l 50 -f 2500; ifconfig $if 0.0.0.0 down || : + beep -l 50 -f 2500; ifconfig $if 23.0.0.1/8 up || : + beep -l 50 -f 2500; /etc/init.d/dnsmasq restart + beep -l 50 -f 2500; iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE + beep -l 50 -f 2500; iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE + if ifconfig $if | grep -q 'inet addr'; then + beep -l 50 -f 2500 -n -l 100 -f 3000 + else + beep -l 50 -f 2500 -n -l 100 -f 1000 + fi +else + case "${1-}" in + (--quiet) : ;; + (*) beep -l 50 -f 2500 -n -l 100 -f 2500 ;; + esac +fi diff --git a/btc/mining/bin/ensure-wlan0 b/btc/mining/bin/ensure-wlan0 new file mode 100755 index 00000000..fa92c4f5 --- /dev/null +++ b/btc/mining/bin/ensure-wlan0 @@ -0,0 +1,41 @@ +#! /bin/sh + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo -E "$0" "$@" + exit 23 # go to hell +fi + +has_internet() { + curl -sS google.com >/dev/null +} + +if test "${force-false}" = true || ! has_internet; then + + ## get rid of the fuckers + for fucker in NetworkManager nm-applet; do + pkill -9 $fucker + (IFS=:; for dir in $PATH; do rm -vf $dir/$fucker; done) + done + + beep -l 50 -f 2000; pkill wpa + beep -l 50 -f 2000; rm -vf /var/run/wpa_supplicant/* + beep -l 50 -f 2000; wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf & + while ! wpa_cli status | grep -q wpa_state=COMPLETED; do + beep -l 50 -f 2000 -D 50 -n -l 50 -f 2000 + sleep 1 + done + beep -l 50 -f 2000; dhcpcd -x wlan0 + beep -l 50 -f 2000; dhcpcd wlan0 + #echo nameserver 8.8.8.8 >/etc/resolv.conf + if has_internet; then + beep -l 50 -f 2000 -n -l 100 -f 3000 + else + beep -l 50 -f 2000 -n -l 100 -f 1000 + fi +else + case "${1-}" in + (--quiet) : ;; + (*) beep -l 50 -f 2000 -n -l 100 -f 2000 ;; + esac +fi diff --git a/btc/mining/poll_btcguild b/btc/mining/poll_btcguild new file mode 100644 index 00000000..92a02657 --- /dev/null +++ b/btc/mining/poll_btcguild @@ -0,0 +1,2 @@ +API_KEY= +curl http://www.btcguild.com/api.php\?api_key\=${API_KEY} | python -mjson.tool diff --git a/btc/mining/user/.config/autostart/startup.desktop b/btc/mining/user/.config/autostart/startup.desktop new file mode 100644 index 00000000..67c35ef8 --- /dev/null +++ b/btc/mining/user/.config/autostart/startup.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=LXDE Autostart +Exec=/home/user/startup.sh +Terminal=true +Type=Application +Categories=Configuration diff --git a/btc/mining/user/mining.ovdr b/btc/mining/user/mining.ovdr new file mode 100644 index 00000000..d6cf6fec --- /dev/null +++ b/btc/mining/user/mining.ovdr @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<OVERDRIVE_PROFILE> + <PERFORMANCE_LEVEL level="2" gpu="90000" mem="30000" voltage="1040"/> + <PERFORMANCE_LEVEL level="1" gpu="55000" mem="30000" voltage="1000"/> + <PERFORMANCE_LEVEL level="0" gpu="15700" mem="30000" voltage="950"/> + <FAN_SETTING percentage="AUTO"/> + <FAN_CTRL enabled="yes"/> + <FAN_CTRL_CURVE type="0"/> + <FAN_CTRL_POINT nr="0" temperature="2000" percentage="0"/> + <FAN_CTRL_POINT nr="1" temperature="3400" percentage="9300"/> + <FAN_CTRL_POINT nr="2" temperature="4800" percentage="10000"/> + <FAN_CTRL_POINT nr="3" temperature="7000" percentage="10100"/> + <FAN_CTRL_POINT nr="4" temperature="10000" percentage="10100"/> + <MONITOR_SAMPLE_TIME interval="10"/> + <COLOR_PROFILE enabled="no" longitude="-13.000000" latitude="52.000000" color_temp_day="0" color_temp_night="0" transition="30"/> +</OVERDRIVE_PROFILE> diff --git a/btc/mining/user/startup.sh b/btc/mining/user/startup.sh new file mode 100755 index 00000000..6274a892 --- /dev/null +++ b/btc/mining/user/startup.sh @@ -0,0 +1,13 @@ +sudo pkill tmux +sleep 5 +source ~/.profile +export DISPLAY=:0 +export URL="${URL-http://txgen_chinaman:lolwut@uk.btcguild.com:8332}" +#export URL="http://txgen:qJrXefWX@bitcoinpool.com:8334" +tmux start-server +tmux new-session -d -s mining -n mining +tmux new-window -t mining:1 'cd ~;AMDOverdriveCtrl -i 0 mining.ovdr' +tmux new-window -t mining:2 'cd ~;AMDOverdriveCtrl -i 3 mining.ovdr' +sleep 5 +tmux new-window -t mining:3 "cd /usr/src/phoenix-miner/; while sleep 1; do sudo ./phoenix.py -u $URL -k phatk DEVICE=0 VECTORS BFI_INT WORKSIZE=256 AGGRESSION=12 FASTLOOPS=false;done" +tmux new-window -t mining:4 "cd /usr/src/phoenix-miner/; while sleep 1; do sudo ./phoenix.py -u $URL -k phatk DEVICE=1 VECTORS BFI_INT WORKSIZE=256 AGGRESSION=12 FASTLOOPS=false;done" diff --git a/btc/mtgox/mtgox.getDepth b/btc/mtgox/mtgox.getDepth new file mode 100755 index 00000000..9a607979 --- /dev/null +++ b/btc/mtgox/mtgox.getDepth @@ -0,0 +1,3 @@ +#! /bin/sh +# get mtgox market depth +$ curl -ksS https://mtgox.com/code/data/getDepth.php diff --git a/btc/mtgox/mtgox.getTrades b/btc/mtgox/mtgox.getTrades new file mode 100755 index 00000000..73e5a68d --- /dev/null +++ b/btc/mtgox/mtgox.getTrades @@ -0,0 +1,3 @@ +#! /bin/sh +# get mtgox last trades +$ curl -ksS https://mtgox.com/code/data/getTrades.phl diff --git a/btc/mtgox/mtgox.ticker b/btc/mtgox/mtgox.ticker new file mode 100755 index 00000000..b24dfb35 --- /dev/null +++ b/btc/mtgox/mtgox.ticker @@ -0,0 +1,4 @@ +#! /bin/sh +# get mtgox ticker data +set -euf +curl -ksS https://mtgox.com/code/data/ticker.php diff --git a/cholerab/live.sh b/cholerab/live.sh new file mode 100755 index 00000000..62a2c3cf --- /dev/null +++ b/cholerab/live.sh @@ -0,0 +1,88 @@ +#! /bin/sh +set -euf +stty cbreak -echo + +go() { + state=$1 + wr 7 + wr "[1;70H " >&2 + wr "[1;70Hstate=$state" >&2 + wr 8 + $1 +} + +rd() { + dd bs=1 count=1 2>/dev/null +} + +bufrd() { + buf="`rd`" + bufinfowr +} + +bufrda() { + buf="$buf`rd`" + bufinfowr +} + +bufinfowr() { + wr 7 + wr "[2;70H " >&2 + wr "[3;70H " >&2 + case "$buf" in + () wr '[2;70H[35m^[[m' >&2;; + (*) wr "[2;70H$buf" >&2;; + esac + wr "[3;70H`wr "$buf" | xxd -p`" >&2 + wr 8 +} + +wr() { + echo -n "$1" +} + +C0="`echo C0 | xxd -r -p`"; DF="`echo DF | xxd -r -p`" +E0="`echo E0 | xxd -r -p`"; EF="`echo EF | xxd -r -p`" +F0="`echo F0 | xxd -r -p`"; F7="`echo F7 | xxd -r -p`" +S() { + bufrd + case "$buf" in + () go ESC;; + () wr '[D [D'; go S;; + ([$C0-$DF]) go U1;; + ([$E0-$EF]) go U2;; + ([$F0-$F7]) go U3;; + (*) wr "$buf"; go S;; + esac +} + +U1() { buf="$buf`rd`"; wr "$buf"; go S; } +U2() { buf="$buf`rd`"; go U1; } +U3() { buf="$buf`rd`"; go U2; } + + +ESC() { + bufrda + case "$buf" in + ('[') go ESC_OSQRB;; + (*) + wr '[35m^[[m' + go S + ;; + esac +} + +ESC_OSQRB() { + bufrda + case "$buf" in + ('[A'|'[B'|'[C'|'[D') wr "$buf"; go S;; + (*) + wr '[35m^[[m[' + go S + ;; + esac +} + + +wr 'c' +go S diff --git a/cholerab/max_dirty_hack.sh b/cholerab/max_dirty_hack.sh new file mode 100755 index 00000000..7183a760 --- /dev/null +++ b/cholerab/max_dirty_hack.sh @@ -0,0 +1,102 @@ +#!/bin/sh +stty -echo cbreak -ofdel +x_max=90 +y_max=10 +x_cur=1 +y_cur=1 +y= +t=1 +outputfile=/tmp/cholerab_out +inputfile=/tmp/cholerab_in +echo -n "c" + +while [ $t -lt $(( y_max+2 )) ];do + echo -e "[$t;$(( x_max+1 ))Hx" + t=$(( t+1 )) +done +t=1 +while [ $t -lt $(( x_max+2 )) ];do + echo -e "[$(( y_max+1 ));${t}Hx" + t=$(( t+1 )) +done + +echo -n "[$y_cur;${x_cur}H" +#Main Loop +while x="`dd bs=1 count=1 2>/dev/null`"; do + y="$y$x" + case "$y" in + (*"[A") + if [[ $y_cur -le 1 ]];then + y_cur=$y_max + echo -n "[$y_cur;${x_cur}H" + else + echo -n "[A" + y_cur=$(( y_cur-1 )) + fi + y= + ;; + (*"[B") + if [[ $y_cur -ge $y_max ]];then + y_cur=1 + echo -n "[$y_cur;${x_cur}H" + else + echo -n "[B" + y_cur=$(( y_cur+1 )) + fi + y= + ;; + (*"[C") + if [[ $x_cur -ge $x_max ]];then + x_cur=1 + echo -n "[$y_cur;${x_cur}H" + else + echo -n "[C" + x_cur=$(( x_cur+1 )) + fi + y= + ;; + (*"[D") + if [[ $x_cur -le 1 ]];then + x_cur=$x_max + echo -n "[$y_cur;${x_cur}H" + else + echo -n "[D" + x_cur=$(( x_cur-1 )) + fi + y= + ;; + (*"") + if [[ $x_cur -le 1 ]];then + x_cur=$x_max + echo -n "[$y_cur;${x_cur}H" + else + echo -n "[D [D" + x_cur=$(( x_cur-1 )) + fi + y= + ;; + (|\[) + : + ;; + (*) + if [[ $x_cur -ge $x_max ]];then + x_cur=1 + echo -n "[$y_cur;${x_cur}H" + else + echo -n "$x" + echo "<0 $x $x_cur $y_cur>" >> $outputfile + x_cur=$(( x_cur+1 )) + fi + y= + ;; + esac + while [[ -s $inputfile ]]; do + cat $inputfile | head -n 1 | sed 's,[<>],,g' | { read MODE CHAR XN YN ; echo -n "7[$YN;${XN}H$CHAR8"; } + sed -i -e "1d" $inputfile + done + + state=`echo -n "$x" | od -An -tx | tr -d "[$IFS]"` + echo -n "7[1;$(( x_max+2 ))H$state8" + echo -n "7[2;$(( x_max+2 ))H 8" + echo -n "7[2;$(( x_max+2 ))H$x_cur:$y_cur8" +done diff --git a/cobra/README b/cobra/README new file mode 100644 index 00000000..145ecd14 --- /dev/null +++ b/cobra/README @@ -0,0 +1,33 @@ + +# usage +cobra [target...] + +# description +cobra tries to satisfies all specified targets and all of it dependencies. + +# targets +targets can be a lot of different things, e.g. directories + +## dirctory targets +try to do the right thing when the cobra search path contains a directory +that contains an index.{js,sh,py,etc.} file. + +## cobra search path +like your sh's PATH + +## example: cobra as some kind of make +$ echo $COBRA_PATH +. +$ ls . +foo/ bar/ baz/ +$ cat foo/cobra.json +{ "deps": "bar", "baz" } +$ cat bar/cobra.json +No such file or directory +$ cat baz/cobra.json +No such file or directory +$ cobra foo +[cobra bar] +[cobra baz] +[cobra foo] +$ exit diff --git a/cobra/hello/index.sh b/cobra/hello/index.sh new file mode 100644 index 00000000..df2dea7c --- /dev/null +++ b/cobra/hello/index.sh @@ -0,0 +1 @@ +echo 'Hello, world!' diff --git a/cobra/index.sh b/cobra/index.sh new file mode 100755 index 00000000..1118a823 --- /dev/null +++ b/cobra/index.sh @@ -0,0 +1,16 @@ +#! /bin/sh +set -euf +trap "echo 'You are made of stupid!' >&2; exit 23" EXIT + +COBRA_PATH="${COBRA_PATH-$PWD}" + +## main +for target; do + for path in $COBRA_PATH; do + if test -d "$path/$target"; then + if index="$path/$target/index.sh" && test -f "$index"; then + exec /bin/sh "$index" + fi + fi + done +done diff --git a/db/User-Agent.txt b/db/User-Agent.txt new file mode 100644 index 00000000..3ed1f91f --- /dev/null +++ b/db/User-Agent.txt @@ -0,0 +1,19 @@ +Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50215; .NET CLR 3.0.0450 +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Trident/4.0; SV1; SpamBlockerUtility 4.7.5) +Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp) +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6.4; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0. +Mozilla/5.0 (Linux; U; Android 1.5; fr-fr, HTC Hero Build/CUPCAKE) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3/5/9 +Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 +Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB0.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.3 +Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) +Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 (.NET CLR 3.5.30729) +Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2) +Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.50 +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR +Opera/9.80 (Macintosh; PPC Mac OS X; U; en) Presto/2.2.15 Version/10.10 +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR +Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727) +Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 (.NET CLR 3.5.30729) diff --git a/doc/AAA b/doc/AAA new file mode 100644 index 00000000..cbb139d7 --- /dev/null +++ b/doc/AAA @@ -0,0 +1,53 @@ +auto application architect + +p2p + +web services + +streaming + +protokolle - file formate + +sprachen (c) + +verschiedene module generieren (in verschiedene sprachen) + +kann komplette projekte planen + +aus TODOs sachen generieren (auto-CEO) + +auto-salesmen + wer braucht was gebaut wurden? + auto-verkaufsgespraeche mit voice + +auto-innovation + +Wie soll getestet werden (unit-test,sichttest) + +wie soll dokumentiert werden (doxygen,grep) + +entwicklungs-prozesse: + v-modell + extreme-programming + ... + +projektarten: + worum soll es gehen? + alles bis auf die implementierung soll automatisiert werden + +entscheidung automatiseren: + die maschine hat es so gewollt + +Auto-Corp + +auf welchen konferenzen soll es verkauft werden, veranstaltungen,etc + +Betriebssystem auswaehlen + +wie soll es skalieren? + web scale + Auto-mengengeruest + +Auto-specifierer + + diff --git a/doc/Error.txt b/doc/Error.txt new file mode 100644 index 00000000..b49ee9ff --- /dev/null +++ b/doc/Error.txt @@ -0,0 +1,4 @@ +# Error 1: You are made of stupid! + +This gets issued whenever the probability of General Failure riding the +user's thinking process approaches 1. diff --git a/doc/cholerab b/doc/cholerab new file mode 100644 index 00000000..2500ba6b --- /dev/null +++ b/doc/cholerab @@ -0,0 +1 @@ +see krebscode/cholerab diff --git a/doc/cookbook/LASAGNE b/doc/cookbook/LASAGNE new file mode 100644 index 00000000..fee77c42 --- /dev/null +++ b/doc/cookbook/LASAGNE @@ -0,0 +1,113 @@ + +RANDOM_RAGOUT: +In einem Topf ${OEL} erhitzen, das ${HAUPTESSBARE} darin rundherum anbraten und +die gehackten ${GEMUESE} und die ${KREUTER} dazugeben. ${WURZEL}scheiben und +${GEMUESE}mark dazu rühren und mitbraten. Mit den ${GEMUESE} aufgießen, +${GEWUERZ1} und ${GEWUERZ2}. ${ALKOHOLHALTIGESGETRAENK} nach Belieben beifügen. +Das Ragout mindestens eine halbe Stunde lang bei geöffnetem Topf einkochen +lassen. + +RANDOM_SAUCE: +${FETT} in einem kleinen Topf schmelzen und das ${VERDICKUNGSMITTEL1} mit dem +Schneebesen dazuarbeiten. Die ${FLUESSIGKEIT} nun dazugießen und die Sauce +glatt rühren. Die Sauce sollte fast eine {halbe-ganze} Stunde lang auf kleiner +Flamme köcheln, damit sie den ${VERDICKUNGSMITTEL1}geschmack verliert. Mit +${GEWUERZ1}, ${GEWUERZ2} und ${FRUCHT}saft sowie etwas ${GEWUERZ3} abschmecken. + +RANDOM_LASAGNE: +In einer ge${FETT}eten, feuerfesten Form etwas ${RANDOM_RAGOUT1} verteilen, +eine Schicht ${TEIGWAREN1} darauf legen, die ${TEIGWAREN1} wieder mit Ragout +und dann mit einer ${RANDOM_SAUCE}nnschicht bedecken. Anschließend wieder eine +Schicht ${TEIGWAREN1}, Ragout und ${RANDOM_SAUCE}. So Schicht für Schicht die +Form füllen. Die letzte Schicht sollte die ${RANDOM_SAUCE} bilden. Dick mit +geriebenen ${REIBBAREM} bestreuen, ${FETT}flöckchen darauf setzen. Die Lasagne +bei {150-230}°C im Ofen überbacken, bis die Kruste goldbraun ist. + + + + +# Protokoll: Skycock's Hochzeits-Bananen-Gulasch-Lasagne +Fleisch koennte kleiner geschnitten geweswen sein, haette aber vielleicht +auch den Bananengeschmack angekommen. +Alles hat voll den Bananengeschmack angenommen, vermutlich wegen dem vielen +Butterschmalz. +Was ist eigentlich mit dem Salat passiert? +Man kann ueberall Salat reinmachen und es passiert nichts. + -- z.B in Schokoladensauce (TODO) +Nudeln und Zwiebeln werden Eins -- verbinden sich einfach mit dem Fett, wie +alles andere auch. +Kaese war superlecker. + +h0uz3: Du isst ein Stueck Fleisch und danach hast du den vollen +Bananengeschmack. Sehr lecker. Voll cool. Witzig. + +Fazit: +pfleidi: alles ist besser mit geschmolzenem Kaese. +makefu: ich bin fasziniert von der Wirkung und dem Geschmack des Fettes. +tv: alles stinkt nach Butterschmalz. + +Gesamt: "Wenn Computer kochen koennen, dann kann ich das auch!" +Vertrauen in Computer wieder hergestellt. +Kochen ist keine Magie sonder Logik und/oder Zufall. + +When in doubt, then cook more. + +Thanks to the Sky-Cock-Team. + +# Sat Jun 4 00:30:33 CEST 2011: Weinbloat2 +Wappentrunk Rotwein - Lieblich +Verschnitt von Weinen aus verschiedenen Laendern der EG +tv: Wasser, dann sauer... +makefu: Gluehwein (MOD Gewuerz) ohne warm +pfleidi: Story vom Gluehpferd + +garnicht mal so gut + +hat nur 10%--schmeckt aber nach viel mehr +schon komisch... + +schmeckt minderwertig + +unnatuerlich dunkel + +falsch dunkel + +Schluerfen = Supersauer + +pfleidi: den wuerde ich zum KOchen nehmen +tv: den haben wir gerade zum Kochen genommen + +makefu: Der riecht irgendwie nicht richtig--wie aus der EU + +pfleidi: da ist komplett Europa drin + +kh: garnichtmal so schlecht fyuer ein Tetrapack-Wein + +makefu: vielleicht ist das von Skycock zusammengestellt... + +tv: Riecht nach Erdbeeren... + +Eher sauer als lieblich.. + + +All the pelz + +Je mehr man ext, desto saurer wird + +Grosse Schluecke = fuu + +Der Wein wurde von Sauron, dem Skycock gebraut... + +## Fnordkorea + +Einfach nur Sauer--hat sein Geschmack verloren +Club-Mate has no effekt + +Mehr atmen != besser + +tv: Pi +pfleidi: last+0.5 = 3 +makefu: 3.6 +kh: 5.23 + +Eignet sich zum Fliegen toeten diff --git a/doc/cookbook/reducer.sh b/doc/cookbook/reducer.sh new file mode 100755 index 00000000..fa3d4e3d --- /dev/null +++ b/doc/cookbook/reducer.sh @@ -0,0 +1,7 @@ +#! /bin/sh +# TODO tolower +tr '[:upper:]' '[:lower:]' | +sed -r ' + s/\<dosen?//g + s/mark//g +' diff --git a/evan/Makefile b/evan/Makefile new file mode 100644 index 00000000..f87e8505 --- /dev/null +++ b/evan/Makefile @@ -0,0 +1,9 @@ +.PHONY: infect +INSTALL_DIR = /root/bin +infect: + mkdir -p ${INSTALL_DIR} + cp evan ${INSTALL_DIR} + cp satz-liste ${INSTALL_DIR} + cp evan-startup /etc/init.d/evan + update-rc.d evan start + diff --git a/evan/evan b/evan/evan new file mode 100755 index 00000000..608ac6b8 --- /dev/null +++ b/evan/evan @@ -0,0 +1,27 @@ +#!/bin/bash +SATZ_LISTE=/krebs/evan/satz-liste +p="${noise_pitch-10}" +v="${noise_lang-de}" +k="${noise_capital-0}" +a="${noise_amplitude-600}" +g="${noise_gap-1}" +RND_DELAY=3600 +#set -x +function helpme () +{ + cat << EOF + $0 [-d] + -d -- daemonize + -h -- this help file +EOF + exit 0 +} + +[ "${1:-}" = "-h" ] && helpme + +while true +do + espeak -v $v -p $p -k $k -a $a -g $g "`shuf \"$SATZ_LISTE\" | tail -1`" + [ ! "${1:-}" = "-d" ] && exit 0 # break if not daemonized + sleep $((${RANDOM}%${RND_DELAY})) +done diff --git a/evan/evan-startup b/evan/evan-startup new file mode 100755 index 00000000..8a7f8daa --- /dev/null +++ b/evan/evan-startup @@ -0,0 +1,74 @@ +#! /bin/sh +# +### BEGIN INIT INFO +# Provides: evan +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network +# Should-Start: $syslog $named +# Should-Stop: $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start evan daemons +# Description: + +### END INIT INFO +# +# Based on Lubomir Bulej's Redhat init script. + +DAEMON="/root/bin/evan" +PIDFILE="/var/lock/evan" +NAME="evan" +DESC="evan daemons" +TCONF="/etc/evan" + +test -f $DAEMON || exit 0 + +[ -r /etc/default/evan ] && . /etc/default/evan + + +start() { + [ -e $PIDFILE ] && echo "$PIDFILE already exists" && return + $DAEMON $EXTRA -d "$@" & + echo $(($$+1)) > $PIDFILE #TODO fix this ugly hack! +} +stop() { + [ ! -e $PIDFILE ] && echo "$PIDFILE does not exist" && return + kill `cat $PIDFILE` + #killall evan + rm $PIDFILE +} + +reload() { + echo "do nothing" + # do nothing +} + +restart() { + stop "$@" + start "$@" +} + +case "$1" in + start) + echo -n "Starting $DESC:" + start + ;; + stop) + echo -n "Stopping $DESC:" + stop + ;; + reload|force-reload) + echo -n "Reloading $DESC configuration:" + reload + ;; + restart) + echo -n "Restarting $DESC:" + restart + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}" + exit 1 + ;; +esac +echo "done" +exit 0 diff --git a/evan/satz-liste b/evan/satz-liste new file mode 100644 index 00000000..7586ea3b --- /dev/null +++ b/evan/satz-liste @@ -0,0 +1,10 @@ +wenn ich meinen erzeugten abfall vor dem nach hause gehen beseitige steigt mein soziales ansehen +bringe eine pflanze mit +ein sauberer scheck ist ein guter scheck +auch du weißt wie man den geschirrspüler einräumt +wer die toilette putzt kommt in den himmel +der große bruder sieht es gerne wenn die genossen die vereinsräume in stand halten +henry der staubsauger saugt für dich +muelltrennung bringt gutes karma +saubere mitglieder sind glückliche mitglieder +fnord diff --git a/infest/Makefile b/infest/Makefile new file mode 100644 index 00000000..ec5836a3 --- /dev/null +++ b/infest/Makefile @@ -0,0 +1,18 @@ + +ifndef patch_file +patch_file := /etc/Verkrebsung.patch +endif + +ifndef patch_flags +patch_flags := +endif + +.PHONY: infest dry-run +infest: $(patch_file) + unset POSIXLY_CORRECT; patch $(patch_flags) -fNp0 < $< + +$(patch_file): bin/make-patch + $< >$@ + +dry-run: + make patch_file=/tmp/krebs-infest-dry-run.patch patch_flags=--dry-run diff --git a/infest/bin/make-patch b/infest/bin/make-patch new file mode 100755 index 00000000..1051c1aa --- /dev/null +++ b/infest/bin/make-patch @@ -0,0 +1,59 @@ +#! /bin/sh + +t="`mktemp`" +p="`mktemp`" +trap "test -e $t && rm $t; test -e $p && rm $p" EXIT INT + +f=/etc/passwd +cat $f >$t +#sed -ri 's^(root:[^:]+):0:0:(.*)$\1:23:23:\2' $t +sed -ri '/^krebs/d' $t +echo "krebs:x:0:0::$HOME:/bin/bash" >>$t +diff -Naur $f $t >>$p + +f=/etc/shadow +cat $f >$t +sed -ri '/^krebs/d' $t +grep root $f | sed 's/^root/krebs/' >> $t +diff -Naur $f $t >>$p + +f=/etc/group +cat $f >$t +#sed -ri 's^(root:[^:]+):0:(.*)$\1:23:\2' $t +sed -ri '/^krebs/d' $t +echo 'krebs:x:0:' >>$t +diff -Naur $f $t >>$p + +f=/etc/fstab +cat $f >$t +if ! grep -q 'none[ \t]*/tmp' $t; then + echo 'none /tmp tmpfs defaults,size=50M 0 0' >>$t +fi +if ! grep -q 'none[ \t]*/var/log' $t; then + echo 'none /var/log tmpfs defaults,size=50M 0 0' >>$t +fi +diff -Naur $f $t >>$p + +readlink=`readlink -f $0` +dirname=`dirname $readlink` +echo [32m$dirname/../skel[m >&2 +ls -l $dirname/../skel +if cd $dirname/../skel; then + if cd etc; then + find . -mindepth 1 -maxdepth 1 -exec diff -Naur /etc/\{\} \{\} \; >>$p + cd .. + sed -i ' + s:^+++ \./:+++ /etc/: + ' $p + fi + if cd home; then + find . -type f -exec diff -Naur $HOME/\{\} \{\} \; >>$p + cd .. + sed -i ' + s:^+++ \./:+++ '$HOME'/: + ' $p + fi + cd .. +fi + +cat $p diff --git a/infest/bootstrap.sh b/infest/bootstrap.sh new file mode 100644 index 00000000..c434a4fe --- /dev/null +++ b/infest/bootstrap.sh @@ -0,0 +1,23 @@ +#!/bin/sh +set -x +[ "`id -u`" -eq "0" ] || { echo "you need to be root!"; exit 1;} || exit 1 + +[ -e '/usr/bin/git' ] || \ +apt-get install -y git-core || \ +yum install git || \ +opkg install git || \ +pacman -Sy git || \ +{ echo "please install git!"; exit 1;} || exit 1 + +[ -e '/krebs' ] || git clone git://github.com/krebscode/painload.git /krebs \ +|| { echo "cloning failed :(" ; exit 1; } || exit 1 + +cd /krebs || { echo "cannot change into /krebs folder:(" ; exit 1; } || exit 1 + +#read -n1 -p "infest now? [yN]" + +#[[ $REPLY = [yY] ]] && make infest +#echo $REPLY +echo "do 'make infest' in /krebs" +echo "have a nice day" + diff --git a/infest/core/angstrom b/infest/core/angstrom new file mode 100755 index 00000000..dafb840f --- /dev/null +++ b/infest/core/angstrom @@ -0,0 +1,4 @@ +#!/bin/sh + +opkg install vim vim-syntax +opkg install git diff --git a/infest/core/debian b/infest/core/debian new file mode 100755 index 00000000..fedd1ede --- /dev/null +++ b/infest/core/debian @@ -0,0 +1,6 @@ +#!/bin/sh +set -x +[ `which git` ] || apt-get install --yes git-core +[ `which tmux` ] || apt-get install --yes tmux +[ `which screen` ] && apt-get remote --yes screen +[ `which vim` ] || apt-get install --yes vim diff --git a/infest/host-patch/beagleboard/Makefile b/infest/host-patch/beagleboard/Makefile new file mode 100644 index 00000000..55952104 --- /dev/null +++ b/infest/host-patch/beagleboard/Makefile @@ -0,0 +1,9 @@ +.PHONY: all +all: select-target + +patchfile: + diff /krebs/etc/profile /etc/profile > profile.patch || true + +patch: + cd /;\ + patch -p0 < /krebs/host-patch/beagleboard/profile.patch diff --git a/infest/host-patch/beagleboard/profile.patch b/infest/host-patch/beagleboard/profile.patch new file mode 100644 index 00000000..d96173d7 --- /dev/null +++ b/infest/host-patch/beagleboard/profile.patch @@ -0,0 +1,42 @@ +--- /krebs/etc/profile Tue May 24 19:31:39 2011 ++++ /etc/profile Tue May 24 20:15:17 2011 +@@ -11,26 +11,13 @@ + alias la='ls -lA' + alias lAtr='ls -lAtr' + alias ll='ls -l' +-alias ls='ls -h --color=auto --group-directories-first' ++alias ls='ls -h --color=auto' + alias vi='vim' + alias vim='vim -p' + alias view='vim -R' + + set -o notify + +-if test -n "${BASH_VERSION-}" ; then +- shopt -s checkhash +- shopt -s histappend histreedit histverify +- shopt -s no_empty_cmd_completion +- complete -d cd +- +- function comp_sch() { +- local cword="${COMP_WORDS[$COMP_CWORD]}" +- COMPREPLY=( $(sch -l "$cword.*" ) ) +- } +- complete -F comp_sch sch +-fi +- + export HISTSIZE='65536' + export HISTFILESIZE="$HISTSIZE" + export HISTCONTROL='ignoredups' +@@ -43,10 +30,7 @@ + PS1='\[\033[${PS1_COLOR}m\]$(PS1)\[\033[32m\]\w\[\033[39m\]${PSx-} ' # green \w + PS1='\[\033[32m\]\w\[\033[m\] ' # green \w + +-if test -n "${SSH_CLIENT-}" ; then +- PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname +- #TERM=xterm-256color xtermcontrol --bg \#292d29 --fg \#d0d0d0 +-fi ++PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname + + export PATH="/krebs/bin:$PATH" + diff --git a/infest/skel/etc/motd.tail b/infest/skel/etc/motd.tail new file mode 100644 index 00000000..0e685c01 --- /dev/null +++ b/infest/skel/etc/motd.tail @@ -0,0 +1,10 @@ +KREBS PAINLOAD (MORE COBRA) +[31;1m x x x x + xx xx xx xx xx xx + xx xx xx xx xx xx + xxx x x xxx + x xxxxxxxxxxxx x + xxxxxxxxxxxxxxxx + x xxxxxxxxxxxx x + x x x x x x + x x x x x x[m diff --git a/infest/skel/etc/profile b/infest/skel/etc/profile new file mode 100755 index 00000000..2812c86c --- /dev/null +++ b/infest/skel/etc/profile @@ -0,0 +1,58 @@ +#! /bin/sh + +export EDITOR=vi + +set -u +alias bc='bc -q' +alias df='df -h' +alias du='du -h' +alias grep='grep --color=auto' +alias ps?="ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep" +alias la='ls -lA' +alias lAtr='ls -lAtr' +alias ll='ls -l' +alias ls='ls -h --color=auto --group-directories-first' +alias vi='vim' +alias vim='vim -p' +alias view='vim -R' + +set -o notify + +if test -n "${BASH_VERSION-}" ; then + shopt -s checkhash + shopt -s histappend histreedit histverify + shopt -s no_empty_cmd_completion + complete -d cd + + function comp_sch() { + local cword="${COMP_WORDS[$COMP_CWORD]}" + COMPREPLY=( $(sch -l "$cword.*" ) ) + } + complete -F comp_sch sch +fi + +export HISTSIZE='65536' +export HISTFILESIZE="$HISTSIZE" +export HISTCONTROL='ignoredups' + +case "${TERM-dumb}" in + linux) PS1_COLOR=34 ;; + rxvt-unicode) PS1_COLOR=30 ;; + *) PS1_COLOR=39 ;; +esac +PS1='\[\033[${PS1_COLOR}m\]$(PS1)\[\033[32m\]\w\[\033[39m\]${PSx-} ' # green \w +PS1='\[\033[32m\]\w\[\033[m\] ' # green \w + +#if test -n "${SSH_CLIENT-}" ; then + PS1='\[\033[35m\]\h'" $PS1" # prefix with magenta hostname + #TERM=xterm-256color xtermcontrol --bg \#292d29 --fg \#d0d0d0 +#fi + +export PATH="/krebs/bin:$PATH" + +echo '--' >&2 +test -e ~/TODO && cat ~/TODO >&2 + +set +u + +cd /krebs diff --git a/infest/skel/etc/rc.local b/infest/skel/etc/rc.local new file mode 100755 index 00000000..f224f9e4 --- /dev/null +++ b/infest/skel/etc/rc.local @@ -0,0 +1,10 @@ +#! /bin/sh -e + +morse() { + /krebs/morse/morse.sh "$@" +} + +morse -l 42 -f 4000 `hostname` +morse -l 42 -f 2000 BEREIT + +exit 0 diff --git a/infest/skel/home/.ssh/authorized_keys b/infest/skel/home/.ssh/authorized_keys new file mode 100644 index 00000000..8bd54293 --- /dev/null +++ b/infest/skel/home/.ssh/authorized_keys @@ -0,0 +1,7 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCl3RTOHd5DLiVeUbUr/GSiKoRWknXQnbkIf+uNiFO+XxiqZVojPlumQUVhasY8UzDzj9tSDruUKXpjut50FhIO5UFAgsBeMJyoZbgY/+R+QKU00Q19+IiUtxeFol/9dCO+F4o937MC0OpAC10LbOXN/9SYIXueYk3pJxIycXwUqhYmyEqtDdVh9Rx32LBVqlBoXRHpNGPLiswV2qNe0b5p919IGcslzf1XoUzfE3a3yjk/XbWh/59xnl4V7Oe7+iQheFxOT6rFA30WYwEygs5As//ZYtxvnn0gA02gOnXJsNjOW9irlxOUeP7IOU6Ye3WRKFRR0+7PS+w8IJLag2xb makefu@servarch +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3SFNYGRiH0oz44G51MWx+o4cC3Fj+ez5DKO5jjtEFZ0ik8XQ5CrVj7a87WbwABA/XRdIt+3WHoInsRmuDfgcIMYgWC567v2GdOxXg2danEIAhhsOY7KiCBLCfZz7lrFO7F6eJH1RCkwrXY+59hkA+i3LNtLmZazJIb2AGwFF8Xf+b/eWmLhqjCYON+OpvqftbCm9CwhLYOUcVoR94gFAzlMYSCHR7RuBBdLV6zrkmEwFEsKghBI7fcdhwfQxuV5UGVCD58KkTQTgK/Mf2tmAg/muBM+P8s2O6wVbtixmIiiDxfc99C3QD1MYVNHqWgV1Rz9JKfmyuVvFqn7TRuuT1 tv@also +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtDhAxjiCH0SmTGNDqmlKPug9qTf+IFOVjdXfk01lAV2KMVW00CgNo2d5kl5+6pM99K7zZO7Uo7pmSFLSCAg8J6cMRI3v5OxFsnQfcJ9TeGLZt/ua7F8YsyIIr5wtqKtFbujqve31q9xJMypEpiX4np3nLiHfYwcWu7AFAUY8UHcCNl4JXm6hsmPe+9f6Mg2jICOdkfMMn0LtW+iq1KZpw1Nka2YUSiE2YuUtV+V+YaVMzdcjknkVkZNqcVk6tbJ1ZyZKM+bFEnE4VkHJYDABZfELpcgBAszfWrVG0QpEFjVCUq5atpIVHJcWWDx072r0zgdTPcBuzsHHC5PRfVBLEw== makefu@arch +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp83zynhIueJJsWlSEykVSBrrgBFKq38+vT8bRfa+csqyjZBl2SQFuCPo+Qbh49mwchpZRshBa9jQEIGqmXxv/PYdfBFQuOFgyUq9ZcTZUXqeynicg/SyOYFW86iiqYralIAkuGPfQ4howLPVyjTZtWeEeeEttom6p6LMY5Aumjz2em0FG0n9rRFY2fBzrdYAgk9C0N6ojCs/Gzknk9SGntA96MDqHJ1HXWFMfmwOLCnxtE5TY30MqSmkrJb7Fsejwjoqoe9Y/mCaR0LpG2cStC1+37GbHJNH0caCMaQCX8qdfgMVbWTVeFWtV6aWOaRgwLrPDYn4cHWQJqTfhtPrNQ== death@Uriel +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvZvfMwszjeUcmrs5Tpd4XJDVNDNUu3Qn3ZxgJzwuoys5LXxPcMikTO++dyrXl2kyexxgSMk6SZtuh34Xg0f9JDb5pN+DJwoeYv96lqTZ5QY4dn+1F0CoP+cK692GH14Kh1wBQyiL50Wj/iWR5/QHpRzrOLsepcZim1nL9FjsW6S2l+uDnUwC4x1EhsRezqJESJlqEsiS+kbhtiPybs7KcY0U4SkpYjfNjlpFE9eLrvSouoyQOUcIVjplcGIma/SVOVYWng4wQA0d5TkCAWAU0OZb0377KynDa7F8K/wN0hRGLGZGFbs3kNDJHqR1lt+sals8M6JO7qk1VVJJj1OsUw== pfleidi@pfleidimobile +ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQB2G4SpJ/UYxmTidUl8ytT6bdNGTdYvv2nmhQyaFBroNit3xdDOVxKvaMEGDuR6ncRugw5BBvrv6iPMTCFluHJxjuh6lk3JrrsJ8CT22ZOGsA593hRoXZOCrs5SxcFkw9EBiCuaHHlWiS9+Dffr6/zpkhH3djTz05uGnDrvtKuV/Zmu5XHAurNn+X3C5S/zk/y0n8o62iSQHVKeNBGO2WYhVce9d65Ucek5dOvXZYVKSe1LeAOKyeHWv+VWP8QlObmfVrQ5l1Pou6WV6Wpo85KBa/mmBJIygC9rrG+gx/1LX7JxStbCu/WoUlUwkSaP2qxWaET9KaSO8+2Wrg5i34ax== samuel@localhost +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTciEeSjcXQ++lfI262rGVVwRM8AJJxrxs+6tl51VGuIGJbIkm0ErO4T338FeXabsmK2T26ZD8CB3FGzm1fKiEaXqZPQzE1hib6n5mdbk1C3HjqXrGFCHui29Nayh+SEHfGwIBFhLGTfaJl9D1cllYjZ23TNQKRMZJO0o3XzrtSgBgS8FPG50+OY4J3MA+9WYkefTDCHOi22pWnTthYLSry35EizUuRxS2T0htKTMls/Tie0M15dN6mgr5104jO0c8IrBroAm9eLBoJl6DNbobLNqflMkiTaoQE6YCaxb1s12dSj9no2XSv/hEtQri9yZR82h+V1Qoypx3Kg6J+ZXf miefda@miefda901 diff --git a/infest/skel/home/.vimrc b/infest/skel/home/.vimrc new file mode 100644 index 00000000..22bbf99d --- /dev/null +++ b/infest/skel/home/.vimrc @@ -0,0 +1,31 @@ +" do the right thing all the time +" +" Colors and stuff +syntax on +set background=dark + + + + +" searching +set hlsearch +set showmatch +set ignorecase +set incsearch +set wildignore=*.o,*.obj,*.bak,*.pyc + +" tabbing +set tabstop=2 +set et +set sw=2 +set smarttab +set autoindent + +" vim magic +filetype plugin indent on + + +" fuck you, help command +inoremap <F1> <ESC> +nnoremap <F1> <ESC> +vnoremap <F1> <ESC> diff --git a/morse/COPYING b/morse/COPYING new file mode 100644 index 00000000..d28e4178 --- /dev/null +++ b/morse/COPYING @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 23, December 1984 + + Copyright (C) 2011 tv@shackspace + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/morse/README b/morse/README new file mode 100644 index 00000000..67951c00 --- /dev/null +++ b/morse/README @@ -0,0 +1,32 @@ +MORSE(1) MORSE(1) + +NAME + morse.sh - morse code generator + +SYNOPSIS + morse [-l N] [-f N] [-c|-x] [text...] + +DESCRIPTION + Generate visible or audible from text or stdin. + +OPTIONS + -l N use N milliseconds as length of dit. Default: 60 ms + + -f N beep at N Hz. Default: 2000 Hz + + -c compile only. Morse will output morse-executable morse code. + + -x execute only. Interpret text as morse code, i.e. do not try + to convert text or stdin. + +BUGS + None.^_^ + +REPORTING BUGS + Please use Github's issue tracking system. + +AUTHOR + This program was written by tv@shackspace and is distributed under the + Do What The Fuck You Want To Public License. + + April 2011 MORSE(1) diff --git a/morse/morse.sh b/morse/morse.sh new file mode 100755 index 00000000..c84538ca --- /dev/null +++ b/morse/morse.sh @@ -0,0 +1,160 @@ +#! /bin/sh +set -euf + +freq=2000 +dit=60 +mode=compile+execute + +## plain stupid options "parser" +while test $# -gt 0; do + case "$1" in + (-l) dit=$2; shift 2;; + (-f) freq=$2; shift 2;; + (-c) mode=compile; shift 1;; + (-x) mode=execute; shift 1;; + (*) break 2;; + esac +done + +# Ein Dah ist dreimal so lang wie ein Dit. +dah=`echo "$dit * 3" | bc` + +## Convert a character to the corresponting morse code. +## Note: any unknown characters are left unaltered. +char2morse() { +tr [a-z] [A-Z] | +sed ' + # Die Pause zwischen Wörtern beträgt sieben Dits. (1/2) + s:[[:space:]]\+::g + + # Zwischen Buchstaben in einem Wort wird eine Pause von Dah eingeschoben. + s:[^ ]:& :g + + # Die Pause zwischen Wörtern beträgt sieben Dits. (2/2) + s: : :g +' | +sed ' + # Lateinische Buchstaben + # Die Pause zwischen zwei gesendeten Symbolen ist ein Dit lang. + s:A:· −:g + s:B:− · · ·:g + s:C:− · − ·:g + s:D:− · ·:g + s:E:·:g + s:F:· · − ·:g + s:G:− − ·:g + s:H:· · · ·:g + s:I:· ·:g + s:J:· − − −:g + s:K:− · −:g + s:L:· − · ·:g + s:M:− −:g + s:N:− ·:g + s:O:− − −:g + s:P:· − − ·:g + s:Q:− − · −:g + s:R:· − ·:g + s:S:· · ·:g + s:T:−:g + s:U:· · −:g + s:V:· · · −:g + s:W:· − −:g + s:X:− · · −:g + s:Y:− · − −:g + s:Z:− − · ·:g +' | +sed ' + # Ziffern + # Die Pause zwischen zwei gesendeten Symbolen ist ein Dit lang. + s:0:− − − − −:g + s:1:· − − − −:g + s:2:· · − − −:g + s:3:· · · − −:g + s:4:· · · · −:g + s:5:· · · · ·:g + s:6:− · · · ·:g + s:7:− − · · ·:g + s:8:− − − · ·:g + s:9:− − − − ·:g +' | +sed ' + # TODO Sonder- und Satzzeichen + #s:À, Ã…:· − − · − + #s:Ä:· − · − + #s:È:· − · · − + #s:É:· · − · · + #s:Ö:− − − · + #s:Ãœ:· · − − + #s:ß:· · · − − · · + #s:CH:− − − − + #s:Ñ:− − · − − + #s:. (AAA) · − · − · − + #s:, (MIM) − − · · − − + #s:: − − − · · · + #s:; − · − · − · + #s:? (IMI) · · − − · · + #s:- − · · · · − + #s:_ · · − − · − + #s:( − · − − · + #s:) − · − − · − + #s:'\'' · − − − − · + #s:= − · · · − + #s:+ · − · − · + #s:/ − · · − · + #s:@ (AC) · − − · − · +' | +sed ' + # TODO Signale + # KA + # (Spruchanfang) − · − · − + # BT + # (Pause) − · · · − + # AR + # (Spruchende) · − · − · + # VE + # (verstanden) · · · − · + # SK + # (Verkehrsende) · · · − · − + # SOS + # (internationaler + # (See-)Notruf) · · · − − − · · · + # HH + # (Fehler; Irrung; + # Wiederholung + # ab letztem + # vollständigen Wort) · · · · · · · · +' +} + +## Convert morse code to beep(1) arguments. +morse2beeparg() { +sed " + s: : -n -f 1 -l $dit:g + s:·: -n -f $freq -l $dit:g + s:−: -n -f $freq -l $dah:g +" | + sed ' + 1s:^:beep -f 1 -l 1: +' +} + +compile() { + char2morse +} + +execute() { + `morse2beeparg` +} + +## main - process either [any non-option] arguments or stdin. +if test $# -gt 0; then + echo "$*" +else + cat +fi | +case "$mode" in + (compile) compile;; + (execute) execute;; + (compile+execute) compile | execute;; + (*) echo bad mode: $mode >&2; exit 23;; +esac diff --git a/node/Makefile b/node/Makefile new file mode 100644 index 00000000..20e15c70 --- /dev/null +++ b/node/Makefile @@ -0,0 +1,24 @@ + + +.PHONY: all build install + +all: + @echo "You are made of stupid!"; exit 23 + +build: node node/build/default/node + cd node && ./configure && make + +install: build + cd node && make install + +node: node-git + ln -vsnf $< $@ + +node-git: + git clone https://github.com/joyent/node node-git + +node-%: /usr/bin/curl + curl http://nodejs.org/dist/$@.tar.gz | tar zx + +/usr/bin/curl: + apt-get install --yes curl diff --git a/noise/Makefile b/noise/Makefile new file mode 100644 index 00000000..932c5940 --- /dev/null +++ b/noise/Makefile @@ -0,0 +1,16 @@ + +.PHONY: all +all: select-target + +.PHONY: infest +infest: + apt-get install --yes expect beep alsa-utils ucspi-tcp espeak + f=/usr/bin/beep; chown krebs:krebs $$f && chmod 4755 $$f + getent passwd noise || useradd noise + ln -vsnf /krebs/noise/init.d/noise /etc/init.d/noise + ## tv: TODO update-rc.d is DEBIAN ONLY, fix this + update-rc.d -f noise defaults + amixer sset 'Master' 100 unmute || true + amixer sset 'PCM' 100 unmute || true + amixer sset 'PC Speaker' 100 unmute || \ + amixer sset 'Beep' 100 unmute || true diff --git a/noise/TODO b/noise/TODO new file mode 100644 index 00000000..a20f74e9 --- /dev/null +++ b/noise/TODO @@ -0,0 +1,60 @@ +#### file:noise/TODO + +- /channels +- /hist N -- zum anzeigen von N letzten Nachrichten + - Log? Es werden maximal chat_histsize Zeilen gespeichert. +- Anbindung ans MoinMoin +- IRC <-> 23.shack - Brücke +- when nick changes say "You're now known as XXX" to yourself +- twitter: push new tweets as they arrive to all connected clients with + the variable tweet_me set to ON + +- Author, Maintainer etc. direkt in die Module in der erweiterten Hilfe, also + in /help MODULENAME -> man sollte sich auf ein einheitliches Dokmentierungs- + Format einigen. + - All modules should contain: + - Author(s) w/ e-mail, Copyright, License + - Maintainer(s) w/ e-mail + - Module-Version + - last tested System-Version + - we need to export the system version +- GIT commits tweeten (shack und root) +- /kick [CHANNEL] # from channel / telnet +- /ban # :-) +- /op +- USER-A: /ping USER-B + - USER-B: /pong + - write time to USER-{A,B} +- style-sheets for everything MOAR!!1 +- libraries +- HTTP-interface +- /whois, /whoami, /whowas +- join,part&co. should support multiple channels +- /TODO,/bug,/issue or something should be added as tracking-system +- /part should say something like "X has left." +- /join should say something like "X has joined." + # it's obvious that the channels is meant... + - or else say: "X has joined channel Y." when we can join more than one + channel +- /part should unset chat_channel (somehow) else keeping /part'ing will + broadcast to chat_channel that X has quit... +- split /twitter into /tweet and X, to make it clear when tweets are fired +- POP3 mail off googlemail and show them to curious telnetters +- /set x 23 -> blah $x + +- /rewrite -- e.g. /rewrite "!%s" "/play %s" oder sowasi +- Zugriff per ssh +- module to standard unix-commands (name like /system) + - unix-commands should simply link to system +- /save TOKEN, /load TOKEN +- /op # NUR VIA SSH! (s.o.) +- MODULE-TEST-SUITE [blackbox] +- sub-modules like /chat-join which may be abbreviated as /join when + $default_command is set to /chat, YAY + - unclutter /help: + - /help -> show all (main) modules + - /help MODULE -> show help of MODULE and show all sub-modules + - /help MODULE SUB-MODULE -> show help of SUB-MODULE and show all sub^2... +- watchdog + +#### end of file. diff --git a/noise/cron/bin/zeit b/noise/cron/bin/zeit new file mode 100755 index 00000000..168a7b7b --- /dev/null +++ b/noise/cron/bin/zeit @@ -0,0 +1,18 @@ +#! /bin/sh + +beep -l 1000 -f 4000 +sleep 1 +/krebs/morse/morse.sh -l 100 -f 700 `date +%k` +sleep 1 +expect >/dev/null <<EOF +spawn nc localhost telnet +expect READY. +send "/zeit\r" +expect READY. +# pitch set to 10 +expect READY. +# Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono +expect READY. +# pitch changed from 10 to 100 +expect READY. +EOF diff --git a/noise/init.d/noise b/noise/init.d/noise new file mode 100755 index 00000000..075e47d7 --- /dev/null +++ b/noise/init.d/noise @@ -0,0 +1,48 @@ +#!/bin/sh -e +### BEGIN INIT INFO +# Provides: noise +# Required-Start: $remote_fs $syslog dbus +# Required-Stop: $remote_fs $syslog dbus +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +# Short-Description: Start the noise "Telnet" server +# Description: System mode startup script for +# the noise "Telnet" server. +### END INIT INFO + +DAEMON=/krebs/noise/noise-server + +test -x $DAEMON || exit 1 + +noise_pid() { + ps aux | grep tcpserver | grep noise-as-user | awk '{print$2}' +} + +noise_start() { + "$DAEMON" & +} + +noise_stop() { + kill "`noise_pid`" +} + +case "$1" in + start|stop) + noise_${1} + ;; + restart|reload|force-reload) + noise_stop + noise_start + ;; + #force-stop) ;; + status) + kill -s 0 "`noise_pid`" + exit $? + ;; + *) + echo "Usage: /etc/init.d/noise {start|stop|force-stop|restart|reload|force-reload|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/noise/modules/cat b/noise/modules/cat new file mode 100755 index 00000000..e090acba --- /dev/null +++ b/noise/modules/cat @@ -0,0 +1,14 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + while read line ; do + case "$line" in + (/quit) + break 2 + ;; + (*) + echo "[$line]" + esac + done +esac diff --git a/noise/modules/chat b/noise/modules/chat new file mode 100755 index 00000000..e5badc36 --- /dev/null +++ b/noise/modules/chat @@ -0,0 +1,33 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (/nick) + echo set nick to $2 + echo /set chat_nick $2 >$NOISE_linefeed;; + (/names) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + channel="$chat_channel" + echo "[34mUsers in channel [4m$channel[m" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "[33m$chat_nick[m" + fi + unset chat_nick + unset chat_channel + unset default_command + done ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel [33m$nick:[m $*" > $NOISE_linefeed + + + #echo /wall [33m@@[m $* >$NOISE_linefeed +esac diff --git a/noise/modules/date b/noise/modules/date new file mode 100755 index 00000000..8cd1b0c1 --- /dev/null +++ b/noise/modules/date @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + date --rfc-3339=s +esac diff --git a/noise/modules/echo b/noise/modules/echo new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/noise/modules/echo @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/noise/modules/ein_mal_eins b/noise/modules/ein_mal_eins new file mode 100755 index 00000000..fb385b31 --- /dev/null +++ b/noise/modules/ein_mal_eins @@ -0,0 +1,37 @@ +#! /bin/bash + +R() { + echo "`od -t d -N 1 /dev/urandom | sed -rn '1s/^[0-9]+ +//p'` % $@" | bc +} + + + + +case "$1" in + (--help) echo Stellt eine einfache Aufgabe ;; + (*) + a="`R 69`" + b="`R 69`" + op="`echo "\ +Was ist, A hoch B +Was ist, A plus B +Was ist, A minus B +Was ist, A mal B +Was ist, sinus von 0 +Was ist, Pi halbe mal 2 +Was ist, 2 hoch 8 +Was ist, 2 hoch 16 +Was ist, 2 hoch 32 +Was ist, 42 geteilt durch Pi mal 100 +Was ist, l n von 1 +Was ist, 42 +Was ist, 23 +Starte den Server neu +Löte ein Kabel an einen Kompjuter +Was ist, A geteilt durch B"`" + o="$(R `echo "$op" | wc -l` + 1)" + + aufgabe=`echo "$op" | sed -n "$o{s/A/$a/;s/B/$b/;p}"` + + echo "/espeak -v Löse die Aufgabe: $aufgabe?" >$NOISE_linefeed +esac diff --git a/noise/modules/espeak b/noise/modules/espeak new file mode 100755 index 00000000..815d9d99 --- /dev/null +++ b/noise/modules/espeak @@ -0,0 +1,34 @@ +#! /bin/sh + +print_var() { + echo "[35;4m$1[;35m = [32m$2[m" +} + +speak() { + p="${noise_pitch-100}" + v="${noise_lang-de}" + k="${noise_capital-0}" + a="${noise_amplitude-600}" + g="${noise_gap-1}" + if test "$debug" = true; then + print_var pitch $p + print_var lang $v + print_var capital $k + print_var amplitude $a + print_var gap $g + fi + if test "$verbose" = true; then + echo "espeak: $@" + fi + #echo "[31mespeak -p \"$pitch\" -v \"$lang\" \"$*\"[m" >&2 + (espeak --stdout -a $a -k $k -p $p -v $v -g $g | aplay)<<EOF +$* +EOF +} + +case "$1" in + (--help) echo say something with espeak ;; + (-d|--debug) shift; debug=true speak "$@";; + (-v|--verbose) shift; verbose=true speak "$@";; + (*) speak "$@";; +esac diff --git a/noise/modules/help b/noise/modules/help new file mode 100755 index 00000000..bc4c2931 --- /dev/null +++ b/noise/modules/help @@ -0,0 +1,24 @@ +#! /bin/sh +case "$1" in + (-*) : ;; # ignore all options + ('') { for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory"/* ; do + echo `basename "$module"` `$module --help` + done 2>/dev/null + done + ## print all documented built-in commands + sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" + } | sort | uniq | sed -rn ' + $s/$/[m/ + s:^([a-z]+) (.+):[35mtype [32m/\1[35m to \2:p' ;; + (*) + ## call + for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory/$1" ; do + if test -e $module ; then + shift + exec $module --help --verbose "$@" 2>&1 + fi + done + done +esac diff --git a/noise/modules/join b/noise/modules/join new file mode 100755 index 00000000..68afcb66 --- /dev/null +++ b/noise/modules/join @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo set default_command to chat and join channel ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel "${1-#23}" "$nick" joined the channel >$NOISE_linefeed + echo /set default_command chat >$NOISE_linefeed + echo /set chat_channel "${1-#23}" >$NOISE_linefeed + echo "[32m joined channel ${1-#23}[m" + echo /part to go back to espeak ;; + + +esac diff --git a/noise/modules/lang b/noise/modules/lang new file mode 100755 index 00000000..07b6802e --- /dev/null +++ b/noise/modules/lang @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "set language or list available languages" ;; + (list) + espeak --voices | sed -n '1!p' | awk '{\ + printf"[32m/lang %s [0;35mset [4mlang[0;35m to %s[m\n",$2,$4 + }' ;; + ('') + echo /set lang >$NOISE_linefeed ;; + (*) + if test -z "$2" ; then + echo /set lang "$1" + else + echo /set lang "$1" + shift + echo "$*" + echo /set lang "${noise_lang-de}" + fi >$NOISE_linefeed +esac + diff --git a/noise/modules/mpc b/noise/modules/mpc new file mode 100755 index 00000000..0ab72058 --- /dev/null +++ b/noise/modules/mpc @@ -0,0 +1,14 @@ +#! /bin/sh + +case "$1" in + (--help) + case "$2" in + (--verbose) mpc --help ;; + (*) echo access mpd + esac ;; + (*) + ##echo test-module called with following arguments: "$@" + ## send command for re-evaluation: + ##echo /espeak test >$NOISE_linefeed + MPD_HOST=mpd.shack mpc $@ +esac diff --git a/noise/modules/names b/noise/modules/names new file mode 100755 index 00000000..f5922064 --- /dev/null +++ b/noise/modules/names @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + if test "$default_command" != chat ; then exit ; fi + nick="${chat_nick-$NOISE_pid}" + channel="${1-$chat_channel}" + echo "[34mUsers in channel [4m$channel[m" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "[33m$chat_nick[m" + fi + unset chat_nick + unset chat_channel + unset default_command + done +esac diff --git a/noise/modules/nick b/noise/modules/nick new file mode 100755 index 00000000..5ed1e9d9 --- /dev/null +++ b/noise/modules/nick @@ -0,0 +1,10 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel $chat_channel $nick is now known as $1 > $NOISE_linefeed + echo /set chat_nick $1 >$NOISE_linefeed;; +esac diff --git a/noise/modules/part b/noise/modules/part new file mode 100755 index 00000000..d35ac501 --- /dev/null +++ b/noise/modules/part @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo leave chat mode ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel $nick has quit [4m${*-no reason}[m" > $NOISE_linefeed + + echo /set default_command espeak >$NOISE_linefeed + echo "[32mdisabled chat mode (set back to espeak)[m" ;; + + +esac diff --git a/noise/modules/ping b/noise/modules/ping new file mode 100755 index 00000000..acf2529f --- /dev/null +++ b/noise/modules/ping @@ -0,0 +1,24 @@ +#! /bin/sh +cd /tmp/noise +case "$1" in + (--help) : ;; + ('') + . $NOISE_pid/environment + ping_timestamp=${ping_timestamp-0} + ping_challenger=${ping_challenger-0} + if test $ping_challenger != 0 ; then + echo There is already a ping challange running + else + timestamp=`date +%s%N` + for client in * ; do + echo /ping $NOISE_pid $timestamp >$client/linefeed & + done + fi + ;; + (*) + echo "/set -q ping_timestamp $2" >$NOISE_pid/linefeed + if test $NOISE_pid != $1 ; then + echo "/set -q ping_challenger $1" >$NOISE_pid/linefeed + echo "PING?" + fi +esac diff --git a/noise/modules/play b/noise/modules/play new file mode 100755 index 00000000..749b450a --- /dev/null +++ b/noise/modules/play @@ -0,0 +1,36 @@ +#! /bin/sh +case "$1" in + (--help) + echo "play an audio file" ;; + (*) + exec 2>&1 + ffs='wav mp3 ogg asf flac' + + if test -z "$*" ; then + ls $HOME/noise/samples | sed -r ' + s:\.('"`echo "$ffs" | tr \ \|`"')$: [30m\1[m: + s:^:/play : + s:.*:[32m&[m: + ' + else + for i in $ffs ; do + f=$HOME/noise/samples/$1.$i + test -f "$f" && + case "$i" in + wav) aplay "$f" & ;; + *) mplayer "$f" & ;; + esac && break + done || cat<<EOF +[33m\ +Keine Audiodatei mit dem Namen + + [4m$1[;33m.EXT + +gefunden... am besten gleich uploaden: + + scp NAME shack@shack.shack:noise/samples/ + +folgende Dateiendungen werden erkannt: $ffs[m +EOF + fi +esac diff --git a/noise/modules/pong b/noise/modules/pong new file mode 100755 index 00000000..eb2df46d --- /dev/null +++ b/noise/modules/pong @@ -0,0 +1,26 @@ +#! /bin/sh +cd /tmp/noise +case "$1" in + (--help) : ;; + ('') + . $NOISE_pid/environment + ping_timestamp=${ping_timestamp-0} + ping_challenger=${ping_challenger-0} + if test $ping_challenger = 0 ; then + echo There is no ping challange running + else + timestamp=`date +%s%N` + echo /pong $NOISE_pid $timestamp >$ping_challenger/linefeed + ## reset ping TODO /unset + echo /set -q ping_timestamp 0 >$NOISE_pid/linefeed + echo /set -q ping_challenger 0 >$NOISE_pid/linefeed + fi + ;; + (*) + . $1/environment + # XXX is attendee the right counterpart to 'challenger'? + attendee_nick=$chat_nick + . $NOISE_pid/environment + time=`echo "scale=3; ($2 - $ping_timestamp)/10^9" | bc` + echo "PONG! $attendee_nick ${time}s" +esac diff --git a/noise/modules/query b/noise/modules/query new file mode 100755 index 00000000..ceeff8a5 --- /dev/null +++ b/noise/modules/query @@ -0,0 +1,23 @@ +#! /bin/sh + +case "$1" in + (--help) echo send a message to a specific user ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + target="$1" + shift + for client in * ; do + . $client/environment + if test "$target" = "${chat_nick-$client}" ; then + echo "/echo <-- $nick: $*" > $client/linefeed + echo "--> $target: $*" + exit + fi + unset chat_channel + + done + + echo "$nick not found" +esac diff --git a/noise/modules/send_to_channel b/noise/modules/send_to_channel new file mode 100755 index 00000000..4a0470af --- /dev/null +++ b/noise/modules/send_to_channel @@ -0,0 +1,17 @@ +#! /bin/sh + +case "$1" in + (--help) : ;; + (*) + cd /tmp/noise + channel="$1" + shift + for client in * ; do + . $client/environment + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "/echo $*" > $client/linefeed + fi + unset chat_channel + + done +esac diff --git a/noise/modules/sendmail b/noise/modules/sendmail new file mode 100755 index 00000000..182d96e3 --- /dev/null +++ b/noise/modules/sendmail @@ -0,0 +1,55 @@ +#!/usr/bin/python +import os,sys,smtplib,string +''' + Mail Plugin for the noise telnet suite + See: http://docs.python.org/library/smtplib.html + Author: Felix +''' + +# help +if len(sys.argv) == 2: + if sys.argv[1] == "--help": + print "send an e-mail ( \"TO(s)\" \"SUBJECT\" [string instead of EOF])" + sys.exit(0) + +# sanity +if len(sys.argv) <= 2: + print "wrong number of parameters, see help" + sys.exit(1) + +# write variables +# check of EOF +if len(sys.argv) == 4 : + EOFstring="%s\n"% sys.argv[3] +else: + EOFstring="EOF\n" + +fromaddr=u"Karl Koch<shockspasm@googlemail.com>" +toaddrs=sys.argv[1] +subject=sys.argv[2] + + +#write header: +msg = u"From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs,subject) +print "Write your text now, finish with %s" % EOFstring +sys.stdout.flush() # flushing is important to make sure the line is written + +while 1: + try: + line = sys.stdin.readline() + if line == EOFstring: + break + msg = msg + line + except EOFError: + break + +msg = msg + "[!] Written with NOISE telnet" + +print "Thank you for your message! Delivering it now..." +sys.stdout.flush() +server = smtplib.SMTP('localhost') +#server.set_debuglevel(1) +server.sendmail(fromaddr,toaddrs.split(','),msg) +server.quit() +print "mail send successfully" +sys.exit(0) diff --git a/noise/modules/shackstatus b/noise/modules/shackstatus new file mode 100755 index 00000000..a5058f0a --- /dev/null +++ b/noise/modules/shackstatus @@ -0,0 +1,104 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report status of all shack services." + ;; + (*) + test "$(dig +short localhost @10.42.0.10 )" = "127.0.0.1" && + STAT_DNS_I="läuft" || STAT_DNS_I="antwortet nicht" + test "$(dig +short shackspace.de @10.42.0.10 )" = "141.31.176.214" && + STAT_DNS_E="läuft" || STAT_DNS_E="antwortet nicht" + test "$(dig +short shackspace.de @141.31.176.214 )" = "141.31.176.214" && + STAT_DNS_X="läuft"|| STAT_DNS_X="antwortet nicht" + + STAT_LINE=$(ping -c 5 -i 0.2 -q 141.31.176.214 | + awk '/packet loss/ { print 100-$6}' ) + + cat <<-EOF >$NOISE_linefeed + /set pitch 10 + /espeak -v Hallo - Ich bin Krebs. + /espeak -v Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y` + /zeit + /espeak -v tcheck der systeme: + /espeak -v Energie versorgung -- aktiv + /espeak -v shackhost -- läuft + /espeak -v telnet -- läuft + /espeak -v interner - D N S -- interne - do-mejn -- $STAT_DNS_I + /espeak -v interner - D N S -- externe - do-mejn -- $STAT_DNS_E + /espeak -v externer - D N S - $STAT_DNS_X + /espeak -v Leitungsqualität - $STAT_LINE prozent. + /temp + /espeak -v krebs kompjuting bereit + EOF + ;; + esac 2>&1 +} + +wochentag() { + case $(date +%a) in + (Mon) echo Montag ;; + (Tue) echo Dienstag ;; + (Wed) echo Mittwoch ;; + (Thu) echo Donnerstag ;; + (Fri) echo Freitag ;; + (Sat) echo Samstag ;; + (Sun) echo Sonntag ;; + esac +} + +tag() { + case $(date +%d) in + (1) echo erste ;; + (2) echo zweite ;; + (3) echo dritte ;; + (4) echo vierte ;; + (5) echo fünfte ;; + (6) echo sechste ;; + (7) echo siebte ;; + (8) echo achte ;; + (9) echo neunte ;; + (10) echo zehnte ;; + (11) echo elfte ;; + (12) echo zwölfte ;; + (13) echo dreizehnte ;; + (14) echo vierzehnte ;; + (15) echo fünfzehnte ;; + (16) echo sechzehnte ;; + (17) echo siebzehnte ;; + (18) echo achtzehnte ;; + (19) echo neunzehnte ;; + (20) echo zwanzigste ;; + (21) echo einundzwanzigste ;; + (22) echo zweiundzwanzigste ;; + (23) echo dreiundzwanzigste ;; + (24) echo vierundzwanzigste ;; + (25) echo füfundzwanzigste ;; + (26) echo sechsundzwanzigste ;; + (27) echo siebenundzwanzigste ;; + (28) echo achtundzwanzigste ;; + (29) echo neunundzwanzigste ;; + (30) echo dreissigste ;; + (31) echo einunddreissigste ;; + esac +} + +monat() { + case $(date +%b) in + (Jan) echo Januar ;; + (Feb) echo Februar ;; + (Mar) echo März ;; + (Apr) echo April ;; + (May) echo Mai ;; + (Jun) echo Juni ;; + (Jul) echo Juli ;; + (Aug) echo August ;; + (Sep) echo September ;; + (Oct) echo Oktober ;; + (Nov) echo November ;; + (Dec) echo Dezember ;; + esac +} + +main "$@" diff --git a/noise/modules/sleep b/noise/modules/sleep new file mode 100755 index 00000000..89712cac --- /dev/null +++ b/noise/modules/sleep @@ -0,0 +1,10 @@ +#! /bin/sh +case "$1" in + (--help) echo "pause for NUMBER seconds" ;; + (*) + if echo "$1" | grep -Eq '^([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)$' ; then + sleep "$1" + else + echo '[31;1mFAIL: $1 is not a number[m' + fi +esac diff --git a/noise/modules/stream b/noise/modules/stream new file mode 100755 index 00000000..1e6fd0c5 --- /dev/null +++ b/noise/modules/stream @@ -0,0 +1,64 @@ +#! /bin/sh +inputdir=$HOME/noise/streams +basename="`basename "$0"`" +case "$1" in + (--help) + if echo "$0 $*" | grep -q '[[:space:]]--verbose\>'; then + echo -e "\x1B[35mtype \x1B[32m/$basename off \x1B[35mto turn stream off\x1B[m" + for i in `ls $inputdir` ; do + filename="$inputdir/$i" + shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"` + title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"` + topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"` + stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"` + echo -e "\x1B[35mtype \x1B[32m/$basename $shortcut \x1B[35mfor $topic\x1B[m" + done + else + echo "play an audio stream" + fi + ;; + (*) + exec 2>&1 + ffs='xml' + + if test -z "$*" ; then + echo -e "\x1B[32m/stream off \x1B[33m- turn stream off\x1B[m" + for i in `ls $inputdir` ; do + filename="$inputdir/$i" + shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"` + title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"` + topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"` + stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"` + echo -e "\x1B[32m/stream $shortcut \x1B[33m- $title \x1B[35m$topic\x1B[m" + done + else if [ "$1" = "off" ]; then + [ ! -d /tmp/noise ] || ( echo "no directory /tmp/noise; aborting" ; exit 1 ) + [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` ) + [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 ) + else + for i in `ls $inputdir` ; do + filename="$inputdir/$i" + shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"` + stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"` + if [ "$shortcut" == "$1" ]; then + [ ! -d /tmp/noise ] || ( umask 077 ; mkdir /tmp/noise ) || ( echo "can't create /tmp/noise; aborting" ; exit 1 ) + [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` ) + [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 ) + mplayer -cache 2048 -quiet "$stream" & + ( umask 077 ; echo $! > /tmp/noise/stream.pid ) + break + fi + done || cat<<EOF +[33m\ +Keine Audiostreambeschreibung mit dem Namen + + [4m$1[;33m.EXT + +gefunden... am besten gleich anlegen: + + ssh shack@shack.shack:noise/streams/ + +folgende Dateiendungen werden erkannt: $ffs[m +EOF + fi fi +esac diff --git a/noise/modules/temp b/noise/modules/temp new file mode 100755 index 00000000..2f1dfcef --- /dev/null +++ b/noise/modules/temp @@ -0,0 +1,56 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report temperature in K, °C, °R, or °F." + ;; + (-C|--celsius) + espeak_inside `inside_temp 'x - 273.15'` Grad Zelsius + espeak_outside `outside_temp 'x - 273.15'` Grad Zelsius + ;; + (-F|--fahrenheit) + espeak_inside `inside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit + espeak_outside `outside_temp 'x * 9/5 - 459.67'` Grad Fahrenheit + ;; + (-R|--rankine) + espeak_inside `inside_temp 'x * 9/5'` Grad Renkin + espeak_outside `outside_temp 'x * 9/5'` Grad Renkin + ;; + (-K|--kelvin|*) + espeak_inside `inside_temp` Kelvin + espeak_outside `outside_temp` Kelvin + ;; + esac +} + +## temp [<formula with temperature as x>] +## Echo temperature in K. If formula is given then return that result instead. +inside_temp() { + echo "scale=2; x=`/krebs/temper/temper` + 273.15; ${1-x}" | bc +} + +outside_temp() { + echo "scale=2; x=`dig +short txt outside.elwood.temp.citecs.de | + sed 's/^"DEG \([0-9]\+\.[0-9]\+\)"$/\1/' + ` + 273.15; ${1-x}" | bc +} + +espeak_inside() { + echo Die Krebs-tempera-tur beträgt $@ | to_espeak +} + +espeak_outside() { + echo Die Außen-tempera-tur beträgt $@ | to_espeak +} + +to_espeak() { + sed ' + s/\(\.[0-9]\)0\+/\1/g + s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /; + s/^-/minus /; + s/\./ komma /; + ' | tee $NOISE_linefeed +} + +main "$@" diff --git a/noise/modules/test b/noise/modules/test new file mode 100755 index 00000000..2c0b8e0d --- /dev/null +++ b/noise/modules/test @@ -0,0 +1,13 @@ +#! /bin/sh + +case "$1" in + (--help) echo do some test-module related stuff ;; + (*) + + echo -n ">> " + read TEST + if [ $TEST == 'q' ]; then exit; fi + echo /wall [33m@@[m $TEST >$NOISE_linefeed + #sleep 1 + #sleep 1; echo /test >$NOISE_linefeed & +esac diff --git a/noise/modules/twitter b/noise/modules/twitter new file mode 100755 index 00000000..26982525 --- /dev/null +++ b/noise/modules/twitter @@ -0,0 +1,125 @@ +#!/usr/bin/python +#encode=utf8 + +#print "[31;4;5;1mTODO Bug Robert to implement Twitter-OAuth![m" +#exit(1) +import sys + +#sys.path.append("/usr/local/lib/") + +import twitter, os, pwd + +#os.getlogin = lambda: pwd.getpwuid(os.getuid())[0] + +sys.stderr = sys.stdout + +def shorten(text): + + text = text.replace("about ", "~") + text = text.replace("an", "1") + text = text.replace(" minutes", "m") + text = text.replace(" minute", "m") + text = text.replace(" hours", "h") + text = text.replace(" hour", "h") + text = text.replace(" seconds", "s") + text = text.replace(" second", "s") + text = text.replace(" days", "d") + text = text.replace(" day", "d") + text = text.replace(" weeks", "w") + text = text.replace(" week", "w") + text = text.replace(" years", "y") + text = text.replace(" year", "y") + text = text.replace(" ago", "") + text = text.replace("a", "1") + return text + + +def parse(text): + text = text.replace("\n","") + t = text.split(" ") + new = "" + for piece in t: + escape = "" + if piece.startswith("@"): + escape = "[33;4m" + if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": + escape = "[31;4m" + + elif piece.startswith("#"): + escape = "[35m" + elif piece.startswith("http://"): + escape = "[36;4m" + if escape: + new += escape + piece + "[m " + else: + new += piece + " " + + return new + +if len(sys.argv) > 1 and sys.argv[1] == "--help": + print "read or post to the shackspam twitter timeline" + if len(sys.argv) == 3 and sys.argv[2] == "--verbose": + print "call without parameters to read" + print "use /twitter [your tweet] to tweet something to the shackspam twitter timeline" + exit() + + + +api = twitter.Api("Z7f9npE5ixvZ0lMCHDZBOg", "8z0gyfOABar1HxKvqL6fYXLqRFUPLQ9OOzDFt7Q4F4", "139766258-94TGPvNsJ8tYVv68eZewfXOIyDvRCWdycNlUgHrs", "NRnDQZPCoLrDizFvakZkSWgoG4vgGuT3OOMChSfiI") + +#api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42") + +if len(sys.argv) > 1: + + + tweet = u"" + + for t in sys.argv[1:]: + tweet += t.decode("utf8") + u" " + tweet = tweet[:-1] + + print u"Length: [32;1m" + str(len(tweet)) + u"[m" + + if len(tweet) > 140: + print u"[31;6mYour Tweet must be shorter than 140 characters.[m\n" + exit() + + status = api.PostUpdate(tweet) + + + + +else: + """print "\t[31;4mshackspace tweets:[m" + for i in api.GetUserTimeline(): + i.text = parse(i.text) + print ("[32m" + i.user.screen_name + "[m [34m" + i.GetRelativeCreatedAt() + "[m " + i.text).encode("utf8").replace("\n"," ") + + print "\n\t[31;4mfriends tweets[m" + """ + a = api.GetFriendsTimeline() + a.reverse() + for i in a: + text = i.text + ilen = len(i.user.screen_name) + len(shorten(i.GetRelativeCreatedAt())) + 2 + if i.user.screen_name.lower() == "shackspace" or i.user.screen_name.lower() == "shackspam": + info = "[32;4m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" + else: + info = "[32m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" + text = info + " " + parse(text) + + t = text.split(" ") + tmp = "" + for n in t: + if ((len(tmp) + len(n)) >= 80): + print parse(tmp).encode("utf8") + tmp = " " * ilen + + tmp += " " + n + if len(tmp) > ilen: + print parse(tmp).encode("utf8") + + + + + diff --git a/noise/modules/vvs b/noise/modules/vvs new file mode 100755 index 00000000..fc23375f --- /dev/null +++ b/noise/modules/vvs @@ -0,0 +1,17 @@ +#! /bin/sh + +wrapper() { + exec 2>&1 + echo date: `date +%H:%M` + "$@" +} + +case "$1" in + (--help) echo query VVS ;; + (*) + case $# in + (2) wrapper vvs.de "$@" ;; + (0) wrapper vvs ;; + (*) echo "[31mSyntax: /vvs [ORIGIN DESTINATION][m" ; return ;; + esac +esac diff --git a/noise/modules/wall b/noise/modules/wall new file mode 100755 index 00000000..c73744ea --- /dev/null +++ b/noise/modules/wall @@ -0,0 +1,8 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (?*) + for linefeed in /tmp/noise/*/linefeed ; do + echo /echo "$*" >$linefeed + done +esac diff --git a/noise/modules/zeit b/noise/modules/zeit new file mode 100755 index 00000000..9fbc33e4 --- /dev/null +++ b/noise/modules/zeit @@ -0,0 +1,19 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "say current time" ;; + (*) + exec >>$NOISE_linefeed + k=`date +%k|sed 's/^[[:space:]]*1[[:space:]]*$/ein/'` + M=`date +%M|sed 's/0*//'` + echo /set pitch 10 + case "$lang" in + (de|'') echo "/espeak Es ist $k Uhr $M" ;; + (en|*-en) + test -z "$M" || M="and $M minutes" + echo "/espeak It is $k o clock $M" ;; + (*) echo "[31mError: unsupported [4mlang[0;31m = $lang[m" >&2 + esac + echo /set pitch ${noise_pitch-100} +esac 2>&1 diff --git a/noise/noise b/noise/noise new file mode 100755 index 00000000..bd6b17c8 --- /dev/null +++ b/noise/noise @@ -0,0 +1,182 @@ +#! /bin/sh + +noise_set() { # set a variable + case "$1" in + (-q|--quiet) echo=: ; shift ;; + (*) echo=echo ;; + esac + case $# in + (0) ## print all noise variables + env | sed -rn ' + s/^noise_([[:alnum:]_]+)=(.*)$/[35;4m\1[;35m = [32m\2[m/p + ' | sort + ;; + (1) ## print value the specified variable + eval "echo \"[35;4m$1[0;35m = [0;32m\$noise_$1[m\"" + ;; + (*) ## set the specified variable + if echo "$1" | grep -q '[^[:alnum:]_]' ; then + fail invalid variable name "[4m$1" + return 23 + fi + eval "old=\"\$noise_$1\"" + if test "x$old" = "x$2" ; then + eval "$echo \"[35;4m$1[0;35m is already [0;32m$2[m\"" + elif test -z "$old" ; then + eval "export noise_$1='$2' ; $echo \ +\"[35;4m$1[0;35m set to [0;32m$2[m\"" + else + eval "export noise_$1='$2' ; $echo \ +\"[35;4m$1[0;35m changed from $old to [0;32m$2[m\"" + fi + ## write variable to $env + if grep -q "^$1=" "$env" ; then + sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env + else + echo "$1='$2'" >>$env + fi + ;; + esac +} + +noise_unset() { # unset a variable + case "$1" in + (-q|--quiet) echo=: ; shift ;; + (*) echo=echo ;; + esac + case $# in + (1) ## + unset "noise_$1" + sed -ni "/^$1=/!p" $env + ;; + (*) + fail "broken commandline: $@" + ;; + esac +} + +noise_quit() { # exit + echo "[35mGood bye![m" + exit +} + +fail() { + echo "[31mFAIL: $*[m" + return 23 +} + +cleanup() { + kill $jobs + rm -f $linefeed $env + rmdir /tmp/noise/$$ 2>/dev/null + rmdir /tmp/noise 2>/dev/null +} + +exec 2>&1 +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +export HOME='/home/noise' +if test -d "$dirname/modules" ; then + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$HOME/noise/modules" +fi +mkdir -p /tmp/noise/$$ +linefeed="/tmp/noise/$$/linefeed" +env="/tmp/noise/$$/environment" +trap cleanup EXIT +mkfifo $linefeed +touch $env +## +## +## +readline() { + { read REPLY && echo "$REPLY" ; } | sed -rn " + s/[']//g + s/~%/\n/g + s/([^\\])([#<>])/\1\\\\\2/g + s:^/([a-z_]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t + s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t + s:.*:command='$noise_default_command'; args='&';:p;t + " +} +## +## +## +while echo -n "$noise_prompt" && eval "`readline`" ; do + ## modcall + for dir in `echo "$NOISE_PATH" | tr : \ ` ; do + module="$dir/$command" + if test -x "$module" ; then +#echo foo $module:$@: + #shift + eval 'NOISE="$0" NOISE_pid="$$" NOISE_linefeed="$linefeed" "$module"' "$args" + continue 2 + fi + done + ## funcall + if type noise_$command | grep -q function ; then + eval 'noise_$command' "$args" + continue + fi + ## + fail unknown command "[4m$command[m" +done <$linefeed & +jobs="${jobs+$jobs }`jobs -p`" +## +## +## +cat<<EOF +[35mWelcome to [1;4m23.shack[;35m version 0.9 beta 4 \ +commit ` + cd $dirname && + git log -n 1 | head -n 1 | cut -d\ -f 2 | dd count=23 bs=1 2>/dev/null +`... +[;33m +## Motto Of The Day\ +[m +[33;1mJoin the 23.shack-dev-team, we've got ` + sloccount $dirname/* | + sed -rn ' + s/.*\(SLOC\)[[:space:]]*=[[:space:]]*([0-9]+)$/\1/p + '` SLOC, ` + { + ls $dirname/modules/ + test -d ~noise/modules && ls ~noise/modules/ + } | sort | uniq | wc -l + ` mods, +`grep ^- $dirname/TODO | wc -l`+ TODOs and drive the irregular Hackathon @shackspace. +Follow [34;4mhttp://twitter.com/shackspam[;1;33m [5mFTW[;1;33m! +[;33m +## Hints\ +[m +Start your telnet session with [4mrlwrap[;m for MAXIMUM profit. +Get online-help with [32m/help[m. +[m +EOF +# TODO: MOTD-candidates: +#twitter: #shackspam +#mail: shockspasm@googlemail.com +#irc: freenode/#shackspace +#afk: @shackspace +## +## +## +exec >>$linefeed +## +## +## +echo '/set -q default_command espeak' +echo '/set -q prompt "[30mREADY.[m~%"' +## +## +## +while read REPLY; do + case $REPLY in + (/quit) echo /quit ; exit ;; + (*) tr \; \\n | grep . ;; + esac<<EOF +$REPLY +EOF +done +#### end of file. diff --git a/noise/noise-as-user b/noise/noise-as-user new file mode 100755 index 00000000..21e4102f --- /dev/null +++ b/noise/noise-as-user @@ -0,0 +1,4 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +exec su noise -c "env -i TCPREMOTEIP='$TCPREMOTEIP' '$dirname/noise'" diff --git a/noise/noise-server b/noise/noise-server new file mode 100755 index 00000000..0df803b1 --- /dev/null +++ b/noise/noise-server @@ -0,0 +1,4 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +exec tcpserver -c 423 -t 2 -D 0.0.0.0 23 "$dirname/noise-as-user" diff --git a/people/Makefile b/people/Makefile new file mode 100644 index 00000000..2c6c1c03 --- /dev/null +++ b/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/people/README.md b/people/README.md new file mode 100644 index 00000000..e45d39c1 --- /dev/null +++ b/people/README.md @@ -0,0 +1,13 @@ +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 + + +arping_users.py: + call `python arping_users.py v` for verbose output -> print all discovered hosts + +SNMPWALK Command +=============== + +snmpwalk -c shammunity 10.42.0.1 1.3.6.1.2.1.3.1.1.2 diff --git a/people/TODO.md b/people/TODO.md new file mode 100644 index 00000000..daacfd58 --- /dev/null +++ b/people/TODO.md @@ -0,0 +1,3 @@ +BUGS +===== + diff --git a/people/VERSION b/people/VERSION new file mode 100644 index 00000000..6c50e659 --- /dev/null +++ b/people/VERSION @@ -0,0 +1 @@ ++++++++[>+++++++>+++++++<<-]>.>---.<-. diff --git a/people/arping.py b/people/arping.py new file mode 100755 index 00000000..3245f1ee --- /dev/null +++ b/people/arping.py @@ -0,0 +1,35 @@ +#!/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: + 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/people/arping_users.py b/people/arping_users.py new file mode 100755 index 00000000..008fe337 --- /dev/null +++ b/people/arping_users.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +import subprocess,re,logging,sys + +from arping import arpingy +from multiprocessing import Pool +DEV='eth0' +MAC_NAMES='mac_names.lst' +data = [] +ret = {} +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','') + 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: + mac,name = l.split(' ',1) + names[mac] = name.replace('\n','') + f.close() + return names + +def arping_helper(dic): + return arpingy(**dic) + +for first in range(1,3): + 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 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 names[p[1]]+ " is online" diff --git a/people/mac_names.lst b/people/mac_names.lst new file mode 100644 index 00000000..ae58b539 --- /dev/null +++ b/people/mac_names.lst @@ -0,0 +1,7 @@ +00:40:63:c8:b5:a0 krebs +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 diff --git a/retiolum/Makefile b/retiolum/Makefile new file mode 100644 index 00000000..0d99ee70 --- /dev/null +++ b/retiolum/Makefile @@ -0,0 +1,15 @@ +.phony: update it all so install + +all: select-target + +it: so +so: it + +/etc/tinc/retiolum/hosts: + cd $(dir $@) && git clone https://github.com/krebscode/hosts + +update: /etc/tinc/retiolum/hosts + cd $< && git pull + +install: + scripts/tinc_setup/install.sh diff --git a/retiolum/README b/retiolum/README new file mode 100644 index 00000000..9b9725f2 --- /dev/null +++ b/retiolum/README @@ -0,0 +1,29 @@ +Retiolum Darknet Module for Krebs +======================== + +Enter the darknet with the help of tinc retiolum + +Getting Started +------------- +to get you started, check out scripts/tinc_setup/README + +1. the first step you will need to do is grab a binary copy of tinc via your +packet manager, build it yourself or place all your hope into the build +script of your distribution. +2. after doing that you might want to run the scripts/tinc_setup/install.sh +script to write all the configuration files and private/public keys. +This installation is somewhat interactive so be sure not to fuck shit up. + +Other cool stuff +--------------- +in bin/ there are some cool scripts which are partly needed and partly +totally unnecessary to work with retiolum. + +As all the scripts are not too horribly long, be sure to use +`cat bin/SCRIPTNAME` to get an understanding of what they do + +besides that in scripts/ there are 3 more scripts which perform pretty +sophisticated tasks like finding instances via multicast or writing graphs +of the current retiolum network. Try them if you dare :) + + diff --git a/retiolum/bin/fillxx b/retiolum/bin/fillxx new file mode 100755 index 00000000..5e558362 --- /dev/null +++ b/retiolum/bin/fillxx @@ -0,0 +1,6 @@ +#! /bin/sh +while echo $1 | grep -q xx; do + xx=`od -An -tx1 -N 1 /dev/urandom | tr -d \ ` + set -- `echo $1 | sed s/xx/$xx/` +done +echo $1 diff --git a/retiolum/bin/hosts b/retiolum/bin/hosts new file mode 100755 index 00000000..6939f52c --- /dev/null +++ b/retiolum/bin/hosts @@ -0,0 +1,11 @@ +#! /bin/sh +set -euf + +netname=${1-retiolum} + +cd /etc/tinc/$netname/hosts + +for i in `ls`; do + sed -rn 's|^ *Subnet *= *([^ /]*)(/[0-9]*)? *$|\1\t'$i' '$i'.'$netname'|p' $i +done | sort + diff --git a/retiolum/bin/install b/retiolum/bin/install new file mode 100755 index 00000000..9e4459fb --- /dev/null +++ b/retiolum/bin/install @@ -0,0 +1,18 @@ +#! /bin/sh +# +# +# +set -euf + +trap 'echo "${comment+$comment +}You are made of stupid!">&2; exit 23' EXIT + +if ! test -e /usr/sbin/tincd; then + if grep -iq ubuntu /etc/issue; then + sudo apt-get install --yes tinc + else + comment='Install tinc to continue.' exit + fi +fi + +trap - EXIT diff --git a/retiolum/bin/ipv6 b/retiolum/bin/ipv6 new file mode 100755 index 00000000..65a1eaa1 --- /dev/null +++ b/retiolum/bin/ipv6 @@ -0,0 +1,35 @@ +#! /bin/sh +# +# Manage IPv6 of the retiolum interface. +# +# usage: ipv6 {start,stop} +# +set -euf + +if test `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +file=/etc/tinc/retiolum/hosts/`hostname` +addr=`sed -rn 's|^Subnet *= *(42:[0-9A-Fa-f:]*/128)|\1|p' $file` +route=42::/16 + +start() { + stop + ip -6 addr add $addr dev retiolum + ip -6 route add $route dev retiolum +} + +stop() { + ip -6 addr del $addr dev retiolum 2>/dev/null || : + ip -6 route del $route dev retiolum 2>/dev/null || : +} + +## dispatch +case "$1" in + (start) start;; + (stop) stop;; + (*) echo "You're made of stupid" 2>/dev/null; exit 23;; +esac diff --git a/retiolum/bin/tinc b/retiolum/bin/tinc new file mode 100755 index 00000000..ffa1dbee --- /dev/null +++ b/retiolum/bin/tinc @@ -0,0 +1,18 @@ +#! /bin/sh +# +set -euf + +init() { + f=/tmp/retiolum.GraphDumpFile + if ! test -f $f; then + touch $f && + chown -v tincd: $f + fi + + modprobe -v tun +} + +if init; then + exec tincd --user=tincd --net=retiolum "$@" +fi + diff --git a/retiolum/bin/update_tinc_hosts b/retiolum/bin/update_tinc_hosts new file mode 100755 index 00000000..fe0785e3 --- /dev/null +++ b/retiolum/bin/update_tinc_hosts @@ -0,0 +1,48 @@ +#! /bin/sh +set -euf + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +DIRNAME=`dirname $0` +export PATH="`readlink -f $DIRNAME`:$PATH" + +hosts="${hosts-/etc/hosts}" + +bs='# BEGIN OF RETIOLUM' +es='# END OF RETIOLUM' + +case "${*-I am made of stupid}" in + (start|restart) + hosts | $0 replace magic + ;; + (stop) + $0 clear magic + ;; + ('print magic') + echo "$bs" + cat + echo "$es" + ;; + ('create magic') + $0 has magic || $0 print magic >> $hosts < /dev/null + ;; + ('destroy magic') + $0 has magic && sed -ie "/^$bs$/,/^$es$/d" $hosts + ;; + ('has magic') + grep -q "^$bs$" $hosts && grep -q "^$es$" $hosts + ;; + ('replace magic') + $0 destroy magic && $0 print magic >> $hosts + ;; + ('clear magic') + $0 replace magic < /dev/null + ;; + (*) + echo 'Error 1: You are made of stupid!' >&2 + exit 23 +esac diff --git a/retiolum/doc/device.c b/retiolum/doc/device.c new file mode 100644 index 00000000..7ffe51dd --- /dev/null +++ b/retiolum/doc/device.c @@ -0,0 +1,37 @@ +#include "system.h" +#include "conf.h" +#include "logger.h" +#include "net.h" +#include "route.h" +#include "utils.h" +#include "xalloc.h" + +int device_fd = -1; +char *device = NULL; +char *iface = NULL; + + +bool setup_device(void) { + device = xstrdup("null"); + iface = xstrdup("null"); + device_fd = -1; + + return true; +} + +void close_device(void) { + free(device); + free(iface); +} + +bool read_packet(vpn_packet_t *packet) { + + return true; +} + +bool write_packet(vpn_packet_t *packet) { + return true; +} + +void dump_device_stats(void) { +} diff --git a/retiolum/doc/install_dotcloud b/retiolum/doc/install_dotcloud new file mode 100644 index 00000000..ea976c55 --- /dev/null +++ b/retiolum/doc/install_dotcloud @@ -0,0 +1,85 @@ +The Dotcloud provided by duostack.com is a application development platform +for simple deployment of your stuff. + +It also provides an ssh-interface via: +<code> + dotcloud ssh project.module +</code> + +to be able to use it without the hassle of going through the api, you will +need to create an own dsa-key for ssh to use and deploy this public key on +the machine +<code> + ssh-keygen -t dsa -f dotcloud_project.dss + cat dotcloud_project.dss.pub (copy the contents to the dotclouds + ~/.ssh/authorized_keys2) +</code> +find your dotcloud host ip via +<code> + dotcloud info project.module +</code> + +You will gain a user shell with +<code> + ssh dotcloud@module.project -p 5960 +</code> +we will need to build some stuff in order to get a working copy of tinc. +Everything needs to be done in userspace. +<code> + mkdir build + cd build + curl http://www.openssl.org/source/openssl-1.0.0d.tar.gz | tar xz + cd openssl-1.0.0d + ./config --prefix=$HOME/usr -fPIC + make install + cp lib* $HOME/usr/lib + cd .. + + curl http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz | tar xz + cd lzo-2.04 + ./configure --prefix=$HOME/usr + + curl http://zlib.net/zlib-1.2.5.tar.gz | tar xz + cd zlib-1.2.5/ + ./configure --prefix=$HOME/usr + make install +</code> +before building we need to patch the tinc daemon to run without the need +for a tun device. + +tutorial is here: +https://hackerspace.be/TincVPN +<code> + + curl http://www.tinc-vpn.org/packages/tinc-1.0.14.tar.gz | tar xz + cd tinc-1.0.14 + #replace the device.c with the patched (empty) one from the webpage + ./configure --prefix=$HOME/usr --sysconfdir=$HOME/etc \ + --localstatedir=$HOME/var --with-openssl=`pwd`/../openssl-1.0.0d/ \ + --with-openssl-lib=`pwd`/../openssl-1.0.0d/ \ + --with-zlib-include=$HOME/usr/include --with-zlib-lib=$HOME/usr/lib + make + make install + mkdir ~/etc + mkdir -p ~/var/run + cd ~/painload/retiolum/scripts/tinc_setup + ./install cloudkrebs 10.7.7.221 +</code> + +be sure to fix the portnumber in the generated host file and add your own +address in hosts/cloudkrebs: +<code> + Address = my.public.address + Port = 1655 + + PUBKEY +</code> + +also write the right in tinc.conf: +<code> + Name = cloudkrebs + + Mode = switch + #device = ... + # no device :) +</code> diff --git a/retiolum/doc/install_no.de b/retiolum/doc/install_no.de new file mode 100644 index 00000000..69fecc61 --- /dev/null +++ b/retiolum/doc/install_no.de @@ -0,0 +1,16 @@ +ok, i tried to just do the same step i did in the other cloud service, but +it failed when trying to include tunnel headers.this is what to do: + +./configure +./configure --prefix=$HOME/usr --sysconfdir=$HOME/etc --disable-lzo --disable-zlib --localstatedir=$HOME/var +# add PATH_MAX to conf.c + +Add to your own path: +$PATH:/home/node/usr/sbin/:/home/node/painload/modules/retiolum/bin/ + +patch the install paths in modules/retiolum/scripts/tinc_setup/krebs + +update the write_channel script with the correct path + +mkdir -p ~/var/run + diff --git a/retiolum/scripts/README b/retiolum/scripts/README new file mode 100644 index 00000000..4dbb42af --- /dev/null +++ b/retiolum/scripts/README @@ -0,0 +1,16 @@ +This Folder contains all the cool scripts created for tinc_retiolum + +currently the following functions are deployed: + +adv_graphgen/ - makefu + this folder contains a script suite which parses the interesting + parameters from the syslog file by sending SIGUSR2 to the tinc process + +tinc_multicast/ - Miefda,Lassulus + A tinc multicast script suite which provides automagic-discovery in a + local network by utilizing multicast + +tinc_setup/ - makefu (i am so sorry...) + A number of scripts which build and configure tinc on a local machine. + Core is the install.sh script which actually writes the configuration + and creates users as well as private/public keys diff --git a/retiolum/scripts/adv_graphgen/README b/retiolum/scripts/adv_graphgen/README new file mode 100644 index 00000000..082e0f2b --- /dev/null +++ b/retiolum/scripts/adv_graphgen/README @@ -0,0 +1,28 @@ +The folder contains a number of scripts which provide a convenient way to +generate advanced graphs from the SIGUSR2 output of tinc. + +it currently contains the following files: + +sanitize.sh: + wrapper arond parse.py which filters the syslog file for all tinc + related lines and removes the status informations: + this means that + <code> + May 19 20:40:44 servarch dnsmasq[5382]: reading /etc/resolv.conf + May 19 20:41:38 servarch tinc.retiolum[4780]: Error looking up pa-sharepoint.informatik.ba-stuttgart.de port 655: Name or service not known + </code> + becomes + <code> + Error looking up pa-sharepoint.informatik.ba-stuttgart.de port 655: Name or service not known + </code> + and so on. + It also provides a wrapper around graphviz which automagically + generates graphs from the produced graph file + +parse.py: + reads from stdin the sanitized syslog file and prints a valid dot file + from the given output. + The parser module may also produce any other output (e.g. for dns + entries and so on) you will need to actually read and modify the source + in order to be able to do this. ~May the source be with you~ + diff --git a/retiolum/scripts/adv_graphgen/parse.py b/retiolum/scripts/adv_graphgen/parse.py new file mode 100755 index 00000000..9c2dd051 --- /dev/null +++ b/retiolum/scripts/adv_graphgen/parse.py @@ -0,0 +1,102 @@ +#!/usr/bin/python2 +# -*- coding: utf8 -*- + +import sys +""" TODO: Refactoring needed to pull the edges out of the node structures again, +it should be easier to handle both structures""" + +def write_digraph(nodes): + """ + writes the complete digraph in dot format + """ + print ('digraph retiolum {') + print (' node[shape=box,style=filled,fillcolor=grey]') + print (' overlap=false') + generate_stats(nodes) + nodes = delete_unused_nodes(nodes) + merge_edges(nodes) + for k,v in nodes.iteritems(): + write_node(k,v) + print ('}') +def generate_stats(nodes): + """ Generates some statistics of the network and nodes + """ + for k,v in nodes.iteritems(): + v['num_conns'] = len(v.get('to',[])) +def delete_unused_nodes(nodes): + new_nodes = {} + for k,v in nodes.iteritems(): + if v.get('to',[]): + new_nodes[k] = v + return new_nodes +def merge_edges(nodes): + """ merge back and forth edges into one + DESTRUCTS the current structure by deleting "connections" in the nodes + + """ + for k,v in nodes.iteritems(): + for con in v.get('to',[]): + for i,secon in enumerate(nodes[con['name']].get('to',[])): + if k == secon['name']: + del (nodes[con['name']]['to'][i]) + con['bidirectional'] = True + + +def write_node(k,v): + """ writes a single node and its edges + edges are weightet with the informations inside the nodes provided by + tinc + """ + node = " "+k+"[label=\"" + node += k+"\\l" + node += "external:"+v['external-ip']+":"+v['external-port']+"\\l" + if v.has_key('num_conns'): + node += "Num Connects:"+str(v['num_conns'])+"\\l" + for addr in v.get('internal-ip',['¯\\\\(°_o)/¯']): + node += "internal:"+addr+"\\l" + node +="\"" + if v['external-ip'] == "MYSELF": + node += ",fillcolor=steelblue1" + node += "]" + print node + + for con in v.get('to',[]): + edge = " "+k+ " -> " +con['name'] + "[weight="+str(float(con['weight'])) + if con.get('bidirectional',False): + edge += ",dir=both" + edge += "]" + print edge + +def parse_input(): + nodes={} + for line in sys.stdin: + line = line.replace('\n','') + if line == 'Nodes:': + nodes={} + for line in sys.stdin: + if line == 'End of nodes.\n': + break + l = line.replace('\n','').split() #TODO unhack me + nodes[l[0]]= { 'external-ip': l[2], 'external-port' : l[4] } + if line == 'Subnet list:': + for line in sys.stdin: + if line == 'End of subnet list.\n': + break + l = line.replace('\n','').split() + if not nodes[l[2]].get('internal-ip',False): + nodes[l[2]]['internal-ip'] = [] + nodes[l[2]]['internal-ip'].append(l[0].split('#')[0]) + if line == 'Edges:': + edges = {} + for line in sys.stdin: + if line == 'End of edges.\n': + break + l = line.replace('\n','').split() + + if not nodes[l[0]].has_key('to') : + nodes[l[0]]['to'] = [] + nodes[l[0]]['to'].append( + {'name':l[2],'addr':l[4],'port':l[6],'weight' : l[10] }) + return nodes +nodes = parse_input() +write_digraph(nodes) diff --git a/retiolum/scripts/adv_graphgen/sanitize.sh b/retiolum/scripts/adv_graphgen/sanitize.sh new file mode 100755 index 00000000..2febc54c --- /dev/null +++ b/retiolum/scripts/adv_graphgen/sanitize.sh @@ -0,0 +1,17 @@ +GRAPH_SETTER1=dot +GRAPH_SETTER2=circo +GRAPH_SETTER3=neato +GRAPH_SETTER3=sfdp +LOG_FILE=/var/log/everything.log +OPENER=/bin/true + +sudo pkill -USR2 tincd +sudo sed -n '/tinc.retiolum/{s/.*tinc.retiolum\[[0-9]*\]: //gp}' $LOG_FILE |\ + ./parse.py > retiolum.dot + +$GRAPH_SETTER1 -Tpng -o $1retiolum_1.png retiolum.dot +$GRAPH_SETTER2 -Tpng -o $1retiolum_2.png retiolum.dot +$GRAPH_SETTER3 -Tpng -o $1retiolum_3.png retiolum.dot +$GRAPH_SETTER4 -Tpng -o $1retiolum_4.png retiolum.dot +$OPENER retiolum_1.png &>/dev/null +#rm retiolum.dot diff --git a/retiolum/scripts/autostart/Makefile b/retiolum/scripts/autostart/Makefile new file mode 100644 index 00000000..aba6bd33 --- /dev/null +++ b/retiolum/scripts/autostart/Makefile @@ -0,0 +1,14 @@ +INIT_FOLDER=/etc/init.d +.phony: all +debian: + #TODO change the tinc file before writing + cp tinc /etc/init.d/tinc + chmod +x /etc/init.d + echo "retiolum" > /etc/tinc/nets.boot + update-rc.d tinc defaults +arch: + @cp tinc /etc/rc.d + @chmod +x /etc/rc.d/tinc + @echo "add tinc to DAEMONS in /etc/rc.conf" + + diff --git a/retiolum/scripts/autostart/tinc b/retiolum/scripts/autostart/tinc new file mode 100755 index 00000000..12e77d6a --- /dev/null +++ b/retiolum/scripts/autostart/tinc @@ -0,0 +1,94 @@ +#! /bin/sh +# +### BEGIN INIT INFO +# Provides: tinc +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network +# Should-Start: $syslog $named +# Should-Stop: $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start tinc daemons +# Description: Create a file $NETSFILE (/etc/tinc/nets.boot), +# and put all the names of the networks in there. +# These names must be valid directory names under +# $TCONF (/etc/tinc). Lines starting with a # will be +# ignored in this file. +### END INIT INFO +# +# Based on Lubomir Bulej's Redhat init script. + +DAEMON="/usr/sbin/tincd" +NAME="tinc" +DESC="tinc daemons" +TCONF="/etc/tinc" +NETSFILE="$TCONF/nets.boot" +NETS="" + +modprobe tun + +test -f $DAEMON || exit 0 + +[ -r /etc/default/tinc ] && . /etc/default/tinc + +# foreach_net "what-to-say" action [arguments...] +foreach_net() { + if [ ! -f $NETSFILE ] ; then + echo "Please create $NETSFILE." + exit 0 + fi + echo -n "$1" + shift + egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do + echo -n " $net" + "$@" $net $args + done + echo "." +} + +start() { + $DAEMON $EXTRA -n "$@" +} +stop() { + $DAEMON -n $1 -k +} +reload() { + $DAEMON -n $1 -kHUP +} +restart() { + stop "$@" + sleep 0.5 + i=0; + while [ -f /var/run/tinc.$1.pid ] ; do + if [ $i = '10' ] ; then + break + else + echo -n "." + sleep 0.5 + i=$(($i+1)) + fi + done + start "$@" +} + +case "$1" in + start) + foreach_net "Starting $DESC:" start + ;; + stop) + foreach_net "Stopping $DESC:" stop + ;; + reload|force-reload) + foreach_net "Reloading $DESC configuration:" reload + ;; + restart) + foreach_net "Restarting $DESC:" restart + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 + diff --git a/retiolum/scripts/tinc_multicast/retiolum b/retiolum/scripts/tinc_multicast/retiolum new file mode 100755 index 00000000..1d6b775f --- /dev/null +++ b/retiolum/scripts/tinc_multicast/retiolum @@ -0,0 +1,34 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +TINCNAME='retiolum' +case "$1" in + start) + stat_busy "Starting retiolum Daemon" + success=0 + /home/death/git/retiolum/.scripts/tinc_multicast/retiolum.py -n retiolum -T & + sleep 2 + if [ $success -eq 0 ]; then + add_daemon retiolum + stat_done + else + stat_fail + fi + ;; + stop) + stat_busy "Stopping retiolum Daemon" + kill `cat /var/lock/retiolum.retiolum` + rm_daemon retiolum + stat_done + ;; + restart) + $0 stop + sleep 4 + $0 start + ;; + *) + echo "usage $0 {start¦stop¦restart}" +esac +exit 0 diff --git a/retiolum/scripts/tinc_multicast/retiolum.py b/retiolum/scripts/tinc_multicast/retiolum.py new file mode 100755 index 00000000..8cf57471 --- /dev/null +++ b/retiolum/scripts/tinc_multicast/retiolum.py @@ -0,0 +1,349 @@ +#!/usr/bin/python2 +import sys, os, time, signal, socket, subprocess, thread, random, Queue, binascii, logging, hashlib, urllib2 #these should all be in the stdlib +from optparse import OptionParser + +def pub_encrypt(hostname_t, text): #encrypt data with public key + logging.debug("encrypt: " + text) + if hostname_t.find("`") != -1: return(-1) + try: + enc_text = subprocess.os.popen("echo '" + text + "' | openssl rsautl -pubin -inkey /etc/tinc/" + netname + "/hosts/.pubkeys/" + hostname_t + " -encrypt | base64 -w0") + return(enc_text.read()) + except: + return(-1) + +def priv_decrypt(enc_data): #decrypt data with private key + if enc_data.find("`") != -1: return(-1) + dec_text = subprocess.os.popen("echo '" + enc_data + "' | base64 -d | openssl rsautl -inkey /etc/tinc/" + netname + "/rsa_key.priv -decrypt") + return(dec_text.read()) + +def address2hostfile(hostname, address): #adds address to hostsfile or restores it if address is empty + hostfile = "/etc/tinc/" + netname + "/hosts/" + hostname + addr_file = open(hostfile, "r") + addr_cache = addr_file.readlines() + addr_file.close() + if address != "": + addr_cache.insert(0, "Address = " + address + "\n") + addr_file = open(hostfile, "w") + addr_file.writelines(addr_cache) + addr_file.close + logging.info("sending SIGHUP to tinc deamon!") + tincd_ALRM = subprocess.call(["tincd -n " + netname + " --kill=HUP" ],shell=True) + else: + recover = subprocess.os.popen("tar xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/ " + hostname) + +def findhostinlist(hostslist, hostname, ip): #finds host + ip in list + for line in xrange(len(hostslist)): + if hostname == hostslist[line][0] and ip == hostslist[line][1]: + return line + return -1 #nothing found + +def getHostname(netname): + tconf = open("/etc/tinc/" + netname + "/tinc.conf", "r") + feld = tconf.readlines() + tconf.close() + for x in feld: + if x.startswith("Name"): + return str(x.partition("=")[2].lstrip().rstrip("\n")) + + print("hostname not found!") + return -1 #nothing found + +def get_hostfiles(url_files, url_md5sum): + try: + get_hosts_tar = urllib2.urlopen(url_files) + get_hosts_md5 = urllib2.urlopen(url_md5sum) + hosts_tar = get_hosts_tar.read() + hosts_md5 = get_hosts_md5.read() + + if str(hosts_md5) == str(hashlib.md5(hosts_tar).hexdigest() + " hosts.tar.gz\n"): + hosts = open("/etc/tinc/" + netname + "/hosts/hosts.tar.gz", "w") + hosts.write(hosts_tar) + hosts.close() + else: + logging.error("hosts.tar.gz md5sum check failed!") + except: + logging.error("hosts file download failed!") + + +####Thread functions + + +def sendthread(sendfifo, ghostmode): #send to multicast, sends keep alive packets + while True: + try: + #{socket init start + ANY = "0.0.0.0" + SENDPORT = 23542 + MCAST_ADDR = "224.168.2.9" + MCAST_PORT = 1600 + + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) #initalize socket with udp + sock.bind((ANY,SENDPORT)) #now bound to Interface and Port + sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255) #activate multicast + #}socket init end + + if ghostmode == 0: + + i = 9 + + while True: + i += 1 + if not sendfifo.empty(): + sock.sendto(sendfifo.get(), (MCAST_ADDR,MCAST_PORT) ) + logging.info("send: sending sendfifo") + else: + time.sleep(1) + if i == 10: + sock.sendto("#Stage1#" + netname + "#" + hostname + "#", (MCAST_ADDR,MCAST_PORT) ) + logging.debug("send: sending keep alive") + i = 0 + else: + while True: + if not sendfifo.empty(): + sock.sendto(sendfifo.get(), (MCAST_ADDR,MCAST_PORT) ) + logging.info("send: sending sendfifo") + else: + time.sleep(1) + + except: + logging.error("send: socket init failed") + time.sleep(10) + + + +def recvthread(timeoutfifo, authfifo): #recieves input from multicast, send them to timeout or auth + while True: + try: + ANY = "0.0.0.0" + MCAST_ADDR = "224.168.2.9" + MCAST_PORT = 1600 + + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) #create a UDP socket + sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) #allow multiple sockets to use the same PORT number + sock.bind((ANY,MCAST_PORT)) #Bind to the port that we know will receive multicast data + sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255) #tell the kernel that we are a multicast socket + + + status = sock.setsockopt(socket.IPPROTO_IP, + socket.IP_ADD_MEMBERSHIP, #Tell the kernel that we want to add ourselves to a multicast group + socket.inet_aton(MCAST_ADDR) + socket.inet_aton(ANY)); #The address for the multicast group is the third param + + while True: + while True: + + try: + data, addr = sock.recvfrom(1024) + ip, port = addr + break + except socket.error, e: + pass + + logging.debug("recv: got data") + dataval = data.split("#") + if dataval[0] == "": + if dataval[2] == netname: + if dataval[1] == "Stage1": + if dataval[3] != hostname: + timeoutfifo.put(["tst", dataval[3], ip]) + logging.info("recv: got Stage1: writing data to timeout") + logging.debug("recv: ;tst;" + dataval[3] + ";" + ip) + if dataval[1] == "Stage2": + if dataval[3] == hostname: + authfifo.put([dataval[1], dataval[3], ip, dataval[4]]) + logging.info("recv: got Stage2: writing data to auth") + logging.debug("recv: ;" + dataval[1] + ";" + dataval[3] + ";" + ip + ";" + dataval[4]) + if dataval[1] == "Stage3": + if dataval[3] != hostname: + authfifo.put([dataval[1], dataval[3], ip, dataval[4]]) + logging.info("recv: got Stage3: writing data to auth") + logging.debug("recv: ;" + dataval[1] + ";" + dataval[3] + ";" + ip + ";" + dataval[4]) + except: + logging.error("recv: socket init failed") + time.sleep(10) + +def timeoutthread(timeoutfifo, authfifo): #checks if the hostname is already in the list, deletes timeouted nodes +# hostslist = [] #hostname, ip, timestamp + + while True: + if not timeoutfifo.empty(): + curhost = timeoutfifo.get() + if curhost[0] == "add": + with hostslock: + hostslist.append([curhost[1], curhost[2], time.time()]) + address2hostfile(curhost[1], curhost[2]) + logging.info("adding host to hostslist") + elif curhost[0] == "tst": + with hostslock: + line = findhostinlist(hostslist, curhost[1], curhost[2]) + if line != -1: + hostslist[line][2] = time.time() + logging.debug("timeout: refreshing timestamp of " + hostslist[line][0]) + else: + authfifo.put(["Stage1", curhost[1], curhost[2]]) + logging.info("timeout: writing to auth") + + else: + i = 0 + with hostslock: + while i < len(hostslist): + if time.time() - hostslist[i][2] > 60: + address2hostfile(hostslist[i][0], "") + hostslist.remove(hostslist[i]) + logging.info("timeout: deleting dead host") + else: + i += 1 + time.sleep(2) + +def auththread(authfifo, sendfifo, timeoutfifo): #manages authentication with clients (bruteforce sensitve, should be fixed) + authlist = [] #hostname, ip, Challenge, timestamp + + + while True: + try: + if not authfifo.empty(): + logging.debug("auth: authfifo is not empty") + curauth = authfifo.get() + if curauth[0] == "Stage1": + line = findhostinlist(authlist, curauth[1], curauth[2]) + if line == -1: + challengenum = random.randint(0,65536) + encrypted_message = pub_encrypt(curauth[1], "#" + hostname + "#" + str(challengenum) + "#") + authlist.append([curauth[1], curauth[2], challengenum, time.time()]) + else: + encrypted_message = pub_encrypt(authlist[line][0], "#" + hostname + "#" + str(authlist[line][2]) + "#") + if encrypted_message == -1: + logging.info("auth: RSA Encryption Error") + else: + sendtext = "#Stage2#" + netname + "#" + curauth[1] + "#" + encrypted_message + "#" + sendfifo.put(sendtext) + logging.info("auth: got Stage1 sending now Stage2") + logging.debug("auth: " + sendtext) + + if curauth[0] == "Stage2": + dec_message = priv_decrypt(curauth[3]) + splitmes = dec_message.split("#") + if splitmes[0] == "": + encrypted_message = pub_encrypt(splitmes[1], "#" + splitmes[2] + "#") + if encrypted_message == -1: + logging.error("auth: RSA Encryption Error") + else: + sendtext = "#Stage3#" + netname + "#" + curauth[1] + "#" + encrypted_message + "#" + sendfifo.put(sendtext) + logging.info("auth: got Stage2 sending now Stage3") + logging.debug("auth: " + sendtext) + + if curauth[0] == "Stage3": + line = findhostinlist(authlist, curauth[1], curauth[2]) + if line != -1: + dec_message = priv_decrypt(curauth[3]) + splitmes = dec_message.split("#") + logging.info("auth: checking challenge") + if splitmes[0] == "": + if splitmes[1] == str(authlist[line][2]): + timeoutfifo.put(["add", curauth[1], curauth[2]]) + del authlist[line] + logging.info("auth: Stage3 checked, sending now to timeout") + else: logging.error("auth: challenge checking failed") + else: logging.error("auth: decryption failed") + + else: + i = 0 + while i < len(authlist): + if time.time() - authlist[i][3] > 120: + del authlist[i] + logging.info("auth: deleting timeoutet auth") + else: + i += 1 + time.sleep(1) + except: + logging.error("auth: thread crashed") + +def process_start(): #starting of the process + #download and untar hostfile + logging.info("downloading hostfiles") + get_hostfiles("http://vpn.miefda.org/hosts.tar.gz", "http://vpn.miefda.org/hosts.md5") #Currently Hardcoded, should be editable by config or parameter + tar = subprocess.call(["tar -xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/"], shell=True) + + #initialize fifos + sendfifo = Queue.Queue() #sendtext + authfifo = Queue.Queue() #Stage{1, 2, 3} hostname ip enc_data + timeoutfifo = Queue.Queue() #State{tst, add} hostname ip + + #start threads + thread_recv = thread.start_new_thread(recvthread, (timeoutfifo, authfifo)) + thread_send = thread.start_new_thread(sendthread, (sendfifo, option.ghost)) + thread_timeout = thread.start_new_thread(timeoutthread, (timeoutfifo, authfifo)) + thread_auth = thread.start_new_thread(auththread, (authfifo, sendfifo, timeoutfifo)) + +def process_restart(signum, frame): + logging.error("root: restarting process") + with hostslock: + del hostslist[:] + #download and untar hostfile + logging.info("downloading hostfiles") + get_hostfiles("http://vpn.miefda.org/hosts.tar.gz", "http://vpn.miefda.org/hosts.md5") #Currently Hardcoded, should be editable by config or parameter + tar = subprocess.call(["tar -xzf /etc/tinc/" + netname + "/hosts/hosts.tar.gz -C /etc/tinc/" + netname + "/hosts/"], shell=True) + + logging.info("sending SIGHUP") + tincd_ALRM = subprocess.call(["tincd -n " + netname + " --kill=HUP" ],shell=True) + +def kill_process(signum, frame): + logging.error("got SIGINT/SIGTERM exiting now") + os.remove("/var/lock/retiolum." + netname) + if option.tinc != False: + stop_tincd = subprocess.call(["tincd -n " + netname + " -k"],shell=True) + sys.exit(0) + +#Program starts here! + +parser = OptionParser() +parser.add_option("-n", "--netname", dest="netname", help="the netname of the tinc network") +parser.add_option("-H", "--hostname", dest="hostname", default="default", help="your nodename, if not given, it will try too read it from tinc.conf") +parser.add_option("-t", "--timeout", dest="timeout", default=65536, help="timeout after retiolum gets restartet, default is 65536") +parser.add_option("-d", "--debug", dest="debug", default="0", help="debug level: 0,1,2,3 if empty debug level=0") +parser.add_option("-g", "--ghost", action="store_true", dest="ghost", default=False, help="deactivates active sending, keeps you anonymous in the public network") +parser.add_option("-T", "--Tinc", action="store_true", dest="tinc", default=False, help="starts tinc with this script") +(option, args) = parser.parse_args() + +if option.netname == None: + parser.error("Netname is required, use -h for help!") +if option.hostname == "default": + option.hostname = getHostname(option.netname) + +hostname = option.hostname +netname = option.netname +hostslist = [] +hostslock = thread.allocate_lock() + +#set process name +if not os.path.exists("/var/lock/retiolum." + netname): + pidfile = open("/var/lock/retiolum." + netname, "w") + pidfile.write(str(os.getpid())) + pidfile.close() +else: + logging.error("pidfile already exists") + sys.exit(0) + +#Logging stuff +LEVELS = {'3' : logging.DEBUG, + '2' : logging.INFO, + '1' : logging.ERROR, + '0' : logging.CRITICAL} + +level_name = option.debug +level = LEVELS.get(level_name, logging.NOTSET) +logging.basicConfig(level=level) + +#normally tinc doesnt start with retiolum +if option.tinc != False: + start_tincd = subprocess.call(["tincd -n " + netname ],shell=True) + +process_start() + +signal.signal(signal.SIGTERM, kill_process) +signal.signal(signal.SIGINT, kill_process) +signal.signal(signal.SIGUSR1, process_restart) + +while True: + time.sleep(float(option.timeout)) + process_restart(0, 0) diff --git a/retiolum/scripts/tinc_setup/README b/retiolum/scripts/tinc_setup/README new file mode 100644 index 00000000..11d6f6e9 --- /dev/null +++ b/retiolum/scripts/tinc_setup/README @@ -0,0 +1,18 @@ +This directory contains the build and install scripts for shack-retiolum + +1. build_arch + arch linux build script +2. build_debian + debian build script +3. build_debian_clean + debian script which builds a clean tinc daemon +4. build_ec2 + Amazon ec2 base instance build script +5. install.sh + configures the tinc daemon + $1 is the nickname + $2 is the ip-address + also writes a python file inside the tinc/retiolum folder which posts + the public key into the IRC:freenode/#tincspasm +6. build_no.de + nonfunct no.de smartmachine build script diff --git a/retiolum/scripts/tinc_setup/autoupdate_cron.sh b/retiolum/scripts/tinc_setup/autoupdate_cron.sh new file mode 100644 index 00000000..d5d41aaf --- /dev/null +++ b/retiolum/scripts/tinc_setup/autoupdate_cron.sh @@ -0,0 +1,7 @@ +cat <<EOF +# Add these lines to your crontab: + +12 23 * * * /home/node/usr/sbin/tincd -n retiolum &>/dev/null +12 23 * * * cd /home/node/etc/tinc/retiolum/hosts/ && /opt/local/bin/git pull && pkill -HUP tincd +EOF + diff --git a/retiolum/scripts/tinc_setup/bootstrap.sh b/retiolum/scripts/tinc_setup/bootstrap.sh new file mode 100644 index 00000000..32919e7d --- /dev/null +++ b/retiolum/scripts/tinc_setup/bootstrap.sh @@ -0,0 +1,11 @@ +if [ ! `id -u` -eq "0" ] +then + echo "not root, trying sudo" + exec sudo "$0" "$@" +fi + +mkdir -p /etc/tinc/retiolum/ +git clone git://github.com/miefda/retiolum.git /etc/tinc/retiolum/hosts +cd /etc/tinc/retiolum/hosts/.scripts + +echo "use the build script of your choice from /etc/tinc/retiolum/hosts/.scripts" diff --git a/retiolum/scripts/tinc_setup/build_arch.sh b/retiolum/scripts/tinc_setup/build_arch.sh new file mode 100755 index 00000000..5ef5d765 --- /dev/null +++ b/retiolum/scripts/tinc_setup/build_arch.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e +sudo pacman -S openssl gcc lzo +curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz +cd tinc-1.0.13 +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var +make +sudo make install +cd .. + +echo "overwriting python to python2" +sed 's/\/usr\/bin\/python/\/usr\/bin\/python2/g' install.sh >install2.sh +mv install2.sh install.sh + diff --git a/retiolum/scripts/tinc_setup/build_debian.sh b/retiolum/scripts/tinc_setup/build_debian.sh new file mode 100755 index 00000000..52e61390 --- /dev/null +++ b/retiolum/scripts/tinc_setup/build_debian.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -x +if [ ! "$MYIP" ] +then + MYIP=10.0.7.7.55 +fi +if [ ! "$MYHOSTNAME" ] +then + MYHOSTNAME="penis" +fi + +if [ "$MYHOSTNAME" = "penis" ]; +then + read -n1 -p "name is penis, are u sure? [yN]" + if [[ "$REPLY" != [yY] ]] + then + echo "then better RTFC" + echo "bailing out" + exit 0 + fi +fi +apt-get install tinc git curl python + +./install.sh "$MYHOSTNAME" "$MYIP" + +# for autostart +sed -i '/retiolum/d' /etc/tinc/nets.boot +echo "retiolum" >> /etc/tinc/nets.boot +sed -i '/EXTRA/d' /etc/tinc/nets.boot +echo "EXTRA=\"\"" >> /etc/default/tinc + +/etc/init.d/tinc start diff --git a/retiolum/scripts/tinc_setup/build_debian_clean.sh b/retiolum/scripts/tinc_setup/build_debian_clean.sh new file mode 100755 index 00000000..a7332f4e --- /dev/null +++ b/retiolum/scripts/tinc_setup/build_debian_clean.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -xe +MYIP=10.0.7.7.55 + +apt-get install tinc git curl gcc gcc-dev build-essential libssl-dev python + +git clone https://github.com/makefu/shack-retiolum.git + +mkdir build +cd build +curl http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz | tar +xz +cd lzo-2.04 +./configure --prefix=/usr +make +sudo make install +cd .. +curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz +cd tinc-1.0.13 +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var +make +sudo make install +cd ../.. + +cd shack-retiolum +./install.sh `hostname` $MYIP + +rm shack-retiolum +# for autostart +echo "retiolum" >> /etc/tinc/nets.boot +echo "EXTRA=\"--user=tincd --chroot\"" >> /etc/default/tinc diff --git a/retiolum/scripts/tinc_setup/build_ec2.sh b/retiolum/scripts/tinc_setup/build_ec2.sh new file mode 100755 index 00000000..79f2af28 --- /dev/null +++ b/retiolum/scripts/tinc_setup/build_ec2.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e +sudo yum install -y gcc openssl-devel +mkdir build +cd build +curl http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz | tar xz +cd lzo-2.04 +./configure --prefix=/usr +make +sudo make install +cd .. +curl http://www.tinc-vpn.org/packages/tinc-1.0.13.tar.gz | tar xz +cd tinc-1.0.13 +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var +make +sudo make install diff --git a/retiolum/scripts/tinc_setup/build_no.de.sh b/retiolum/scripts/tinc_setup/build_no.de.sh new file mode 100644 index 00000000..2976d3a2 --- /dev/null +++ b/retiolum/scripts/tinc_setup/build_no.de.sh @@ -0,0 +1 @@ +pkgin in lzo gcc-tools gcc-compiler gcc34 diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh new file mode 100755 index 00000000..9df38df7 --- /dev/null +++ b/retiolum/scripts/tinc_setup/install.sh @@ -0,0 +1,72 @@ +#! /bin/sh +# USE WITH GREAT CAUTION + +#make -C ../../ update +set -e +DIRNAME=`dirname $0` +CURR=`readlink -f ${DIRNAME}` +MYBIN=../../bin +netname=retiolum +# create configuration directory for $netname +mkdir -p /etc/tinc/$netname/hosts +cd /etc/tinc/$netname + +echo "added known hosts:" +ls -1 hosts | LC_ALL=C sort +echo "delete the nodes you do not trust!" + +myname="${1:-}" +if [ ! "$myname" ] +then + echo "select username: " + read myname +fi +if [ ! -e "hosts/$myname" ] +then + myipv4="${2:-}" + mynet4=10.7.7.0 + + if [ ! "$myipv4" ] + then + echo "select v4 subnet ip (1-255) :" + read v4num + myipv4=10.7.7.$v4num + if [ "$v4num" -gt 0 -a "$v4num" -lt "256" ]; + then + echo "check" + else + echo "you are made of stupid. bailing out" + exit 1 + fi + fi + echo "Subnet = $myipv4" > hosts/$myname + + myipv6=`${CURR}/../../bin/fillxx 42:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx`/128 + echo "Subnet = $myipv6" >> hosts/$myname +else + echo "own host file already exists! will not write again!" +fi + +cp $CURR/tinc-up /etc/tinc/$netname/ + +cat>tinc.conf<<EOF +Name = $myname +ConnectTo = supernode +ConnectTo = kaah +ConnectTo = pa_sharepoint +Device = /dev/net/tun +EOF + +if [ ! -e rsa_key.priv ] +then + echo "creating new keys" + tincd -n $netname -K + python ${CURR}/write_channel.py $myname || \ + echo "cannot write public key to IRC, you are on your own. Good Luck" +else + echo "key files already exist, skipping" + echo "if you know what you are doing, remove rsa_key.priv" +fi +# add user tincd +# this is what the setup scripts for the distribution has to do +#useradd tincd diff --git a/retiolum/scripts/tinc_setup/tinc-up b/retiolum/scripts/tinc_setup/tinc-up new file mode 100755 index 00000000..ae7c68e6 --- /dev/null +++ b/retiolum/scripts/tinc_setup/tinc-up @@ -0,0 +1,20 @@ +# source: krebscode/painload/retiolum/scripts/tinc_setup/tinc-up + +dirname="`dirname "$0"`" + +conf=$dirname/tinc.conf + +name=`sed -rn 's|^ *Name *= *([^ ]*) *$|\1|p' $conf` + +host=$dirname/hosts/$name + +route4=10.7.7.0/24 +addr4=`sed -rn 's|^ *Subnet *= *(10\.[^ ]*) *$|\1|p' $host` + +route6=42::/16 +addr6=`sed -rn 's|^ *Subnet *= *(42:[^ ]*) *$|\1|p' $host` + +ifconfig $INTERFACE up $addr4 +route add -net $route4 dev $INTERFACE +ip -6 addr add $addr6 dev $INTERFACE +ip -6 route add $route6 dev $INTERFACE diff --git a/retiolum/scripts/tinc_setup/write_channel.py b/retiolum/scripts/tinc_setup/write_channel.py new file mode 100644 index 00000000..a11d4605 --- /dev/null +++ b/retiolum/scripts/tinc_setup/write_channel.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +import random, sys, time, socket +try: + myname=sys.argv[1] +except: + print "you are made of stupid" + exit (23) + +CHANNEL = '#tincspasm' +HOST='irc.freenode.net' +FILE="/etc/tinc/retiolum/hosts/"+myname +PORT=6667 +NICK= myname+"_"+str(random.randint(23,666)) + +sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) +sock.connect((HOST,PORT)) +print NICK +sock.send("NICK %s\r\n" % NICK) +sock.send("USER %s %s bla : %s\r\n" %(NICK,HOST,NICK)) +sock.send("JOIN %s\r\n" % CHANNEL) +time.sleep(23) +f = open(FILE,'r') +a = [ sock.send("PRIVMSG %s : %s" % ( CHANNEL,line)) for line in f] +time.sleep(5) #because irc is so lazy +print "closing socket" +sock.close() diff --git a/roboctl/index.js b/roboctl/index.js new file mode 100644 index 00000000..ac92c969 --- /dev/null +++ b/roboctl/index.js @@ -0,0 +1,18 @@ + +nick = /(^|\n) *Name *= *(\S*) *($|\n)/ + .exec(require('fs').readFileSync('/etc/tinc/retiolum/tinc.conf'))[2]; + +var config = { + "nick": nick + '-krebs', + "server": "irc.freenode.net", + "port": 6667, + "channel": "#tincspasm" +}; + +irc = require('./lib/irc').createClient(config); + +// TODO call back when joined +irc.connect(function () { + console.log('like a boss: ' + nick); + //irc.write(); +}); diff --git a/roboctl/lib/irc.js b/roboctl/lib/irc.js new file mode 100644 index 00000000..5f904a74 --- /dev/null +++ b/roboctl/lib/irc.js @@ -0,0 +1,67 @@ + +var Client = function (config) { + var client = this; + var net = require('net'); + var sys = require('sys'); + var log = function (x) { + sys.puts('TCP server: ' + x); + }; + + client.connect = function (callback) { + var stream = net.createConnection(config.port, config.server); + stream.on('connect', function () { + stream.write( + 'NICK ' + config.nick + '\n' + + 'USER ' + config.nick + ' 0 *:Karl Koch\n' + + 'JOIN ' + config.channel + '\n' + ); + //client.write = function (text) { + // stream.write('PRIVMSG ' + config.channel + ' :' + text); + //}; + client.write = msg_start_send; + callback(); + }); + //stream.on('secure', function () { + //}); + + var msg = []; + + var msg_start_send = function (x) { + client.write = msg_append; + setTimeout(function () { + var x = msg.join('\n') + '\n'; + msg = []; + client.write = msg_start_send; + stream.write('PRIVMSG ' + config.channel + ' :' + x); + }, 1000); + }; + + var msg_append = function (x) { + msg[msg.length] = x; + }; + + + stream.on('data', function (data) { + data = String(data); + log('[35m' + data + '[m'); + if (data.substring(0,4) === 'PING') { + log('PONG!'); + stream.write('PONG ' + data.substring(4)); + } + }); + //stream.on('end', function () { + //}); + //stream.on('timeout', function () { + //}); + //stream.on('drain', function () { + //}); + //stream.on('error', function (exception) { + //}); + //stream.on('clonse', function (exception) { + //}); + }; +}; + +exports.createClient = function (config) { + return new Client(config); +}; diff --git a/streams/Makefile b/streams/Makefile new file mode 100644 index 00000000..9f3076c0 --- /dev/null +++ b/streams/Makefile @@ -0,0 +1,10 @@ +INITD = /etc/init.d/ +streams = groove deepmix radiotux +.PHONY: all +.PHONY: $(streams) + +all: $(streams) + update-rc.d groove defaults + +$(streams): + cp $@ $(INITD)$@ diff --git a/streams/README b/streams/README new file mode 100644 index 00000000..82300c24 --- /dev/null +++ b/streams/README @@ -0,0 +1,10 @@ +streams done right + +deepmix,groovesalad and radiotux are now init.d scrips which can be +started and stopped. + +scripts are dumped into /etc/init.d and groovesalad will be set as +default via update-rc.d + +mplayer will be started in a tmux session either by creating a new +session or starting a new window inside the first existing one diff --git a/streams/deepmix b/streams/deepmix new file mode 100755 index 00000000..b8f8fba8 --- /dev/null +++ b/streams/deepmix @@ -0,0 +1,26 @@ +#! /bin/bash +set -euf +CMD="mplayer http://deepmix.ru/deepmix128.pls" +function start() { + stop + tmux start-server + tmux new-session -d "$CMD" +} +function stop() { + pkill mplayer || : +} +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + *) + echo "aidsballs" + ;; +esac diff --git a/streams/groove b/streams/groove new file mode 100755 index 00000000..935a16d9 --- /dev/null +++ b/streams/groove @@ -0,0 +1,27 @@ +#! /bin/bash +set -euf +CMD="exec mplayer http://somafm.com/groovesalad.pls" +function start() { + stop + tmux start-server + tmux new-session -d "$CMD" +} +function stop() +{ + pkill mplayer || : +} + +case "$1" in + start) + start + stop) + stop + ;; + restart) + stop + start + ;; + *) + echo "aidsballs" + ;; +esac diff --git a/streams/radiotux b/streams/radiotux new file mode 100755 index 00000000..9d671493 --- /dev/null +++ b/streams/radiotux @@ -0,0 +1,29 @@ +#! /bin/bash +set -euf +function stop() +{ + pkill mplayer || true +} + +CMD="while true; do exec mplayer http://streams.xenim.de/radiotux.ogg; sleep 1;done" +case "$1" in + start) + stop + if tmux list-sessions; + then + tmux new-window "$CMD" & + else + tmux new-session "$CMD" & + fi + ;; + stop) + stop + ;; + restart) + stop + start + ;; + *) + echo "aidsballs" + ;; +esac diff --git a/submodules/github/NV/cssom b/submodules/github/NV/cssom new file mode 160000 +Subproject dacc6c3c9dc9676f68df056a44a0d5f92884cc0 diff --git a/submodules/github/mikeal/request b/submodules/github/mikeal/request new file mode 160000 +Subproject c99b8fcd706ae035f6248669b017ac2995e45f3 diff --git a/submodules/github/tautologistics/node-htmlparser b/submodules/github/tautologistics/node-htmlparser new file mode 160000 +Subproject d770be592d81d6b603d6197dc727ce89ad195d0 diff --git a/submodules/github/tmpvar/jsdom b/submodules/github/tmpvar/jsdom new file mode 160000 +Subproject 30bac996077fb0096ff2334f0e13939586ae31b diff --git a/submodules/github/visionmedia/query b/submodules/github/visionmedia/query new file mode 160000 +Subproject 02baed4f5eb2d22e3ebb0688243c97fe04e7b53 diff --git a/temper/.gitignore b/temper/.gitignore new file mode 100644 index 00000000..7e50641a --- /dev/null +++ b/temper/.gitignore @@ -0,0 +1 @@ +temper diff --git a/temper/99-tempsensor.rules b/temper/99-tempsensor.rules new file mode 100644 index 00000000..441a469e --- /dev/null +++ b/temper/99-tempsensor.rules @@ -0,0 +1 @@ +SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1130", ATTRS{idProduct}=="660c", MODE="666" diff --git a/temper/Makefile b/temper/Makefile new file mode 100644 index 00000000..79dc3216 --- /dev/null +++ b/temper/Makefile @@ -0,0 +1,18 @@ + +all: infest +infest: temper +CFLAGS = -O2 -Wall + +temper: temper.c rules-install + ${CC} -DUNIT_TEST -o $@ $^ -lusb + chmod +s temper + cp -a temper /usr/bin +clean: + rm -f temper *.o +rules-install: # must be superuser to do this + cp 99-tempsensor.rules /etc/udev/rules.d +debian-prereq: + apt-get install libusb-dev +uninstall: + rm -f /etc/udev/rules.d/99-tempsensor.rules /usr/bin/temper + diff --git a/temper/temper.c b/temper/temper.c new file mode 100644 index 00000000..390f9056 --- /dev/null +++ b/temper/temper.c @@ -0,0 +1,277 @@ +#include <stdio.h> +#include <string.h> +#include <usb.h> +#include <errno.h> + +/* + * Temper.c by Robert Kavaler (c) 2009 (relavak.com) + * All rights reserved. + * + * Temper driver for linux. This program can be compiled either as a library + * or as a standalone program (-DUNIT_TEST). The driver will work with some + * TEMPer usb devices from RDing (www.PCsensor.com). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "temper.h" + +#define VENDOR_ID 0x1130 +#define PRODUCT_ID 0x660c + +struct Temper { + struct usb_device *device; + usb_dev_handle *handle; + int debug; + int timeout; +}; + + Temper * +TemperCreate(struct usb_device *dev, int timeout, int debug) +{ + Temper *t; + int ret; + + t = calloc(1, sizeof(*t)); + t->device = dev; + t->debug = debug; + t->timeout = timeout; + t->handle = usb_open(t->device); + if(!t->handle) { + free(t); + return NULL; + } + if(t->debug) { + printf("Trying to detach kernel driver\n"); + } + + ret = usb_detach_kernel_driver_np(t->handle, 0); + if(ret) { + if(errno == ENODATA) { + if(t->debug) { + printf("Device already detached\n"); + } + } else { + if(t->debug) { + printf("Detach failed: %s[%d]\n", + strerror(errno), errno); + printf("Continuing anyway\n"); + } + } + } else { + if(t->debug) { + printf("detach successful\n"); + } + } + ret = usb_detach_kernel_driver_np(t->handle, 1); + if(ret) { + if(errno == ENODATA) { + if(t->debug) + printf("Device already detached\n"); + } else { + if(t->debug) { + printf("Detach failed: %s[%d]\n", + strerror(errno), errno); + printf("Continuing anyway\n"); + } + } + } else { + if(t->debug) { + printf("detach successful\n"); + } + } + + if(usb_set_configuration(t->handle, 1) < 0 || + usb_claim_interface(t->handle, 0) < 0 || + usb_claim_interface(t->handle, 1)) { + usb_close(t->handle); + free(t); + return NULL; + } + return t; +} + + Temper * +TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug) +{ + struct usb_bus *bus; + int n; + + n = 0; + for(bus=usb_get_busses(); bus; bus=bus->next) { + struct usb_device *dev; + + for(dev=bus->devices; dev; dev=dev->next) { + if(debug) { + printf("Found device: %04x:%04x\n", + dev->descriptor.idVendor, + dev->descriptor.idProduct); + } + if(dev->descriptor.idVendor == VENDOR_ID && + dev->descriptor.idProduct == PRODUCT_ID) { + if(debug) { + printf("Found deviceNum %d\n", n); + } + if(n == deviceNum) { + return TemperCreate(dev, timeout, debug); + } + n++; + } + } + } + return NULL; +} + + void +TemperFree(Temper *t) +{ + if(t) { + if(t->handle) { + usb_close(t->handle); + } + free(t); + } +} + + static int +TemperSendCommand(Temper *t, int a, int b, int c, int d, int e, int f, int g, int h) +{ + unsigned char buf[32]; + int ret; + + bzero(buf, 32); + buf[0] = a; + buf[1] = b; + buf[2] = c; + buf[3] = d; + buf[4] = e; + buf[5] = f; + buf[6] = g; + buf[7] = h; + + if(t->debug) { + printf("sending bytes %d, %d, %d, %d, %d, %d, %d, %d\n", + a, b, c, d, e, f, g, h); + } + + ret = usb_control_msg(t->handle, 0x21, 9, 0x200, 0x01, + (char *) buf, 32, t->timeout); + if(ret != 32) { + perror("usb_control_msg failed"); + return -1; + } + return 0; +} + + static int +TemperGetData(Temper *t, char *buf, int len) +{ + int ret; + + return usb_control_msg(t->handle, 0xa1, 1, 0x300, 0x01, + (char *) buf, len, t->timeout); +} + + int +TemperGetTemperatureInC(Temper *t, float *tempC) +{ + char buf[256]; + int ret, temperature, i; + + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x54, 0, 0, 0, 0, 0, 0, 0); + for(i = 0; i < 7; i++) { + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + } + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); + ret = TemperGetData(t, buf, 256); + if(ret < 2) { + return -1; + } + + temperature = (buf[1] & 0xFF) + (buf[0] << 8); + temperature += 1152; // calibration value + *tempC = temperature * (125.0 / 32000.0); + return 0; +} + + int +TemperGetOtherStuff(Temper *t, char *buf, int length) +{ + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x52, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 1, 0); + return TemperGetData(t, buf, length); +} + + +#define USB_TIMEOUT 1000 /* milliseconds */ +#define DEBUG_MODE 0 +#define SLEEP_TIMEOUT 10 + + int +main(int argv,char** args) +{ + + + Temper *t; + char buf[256]; + int i, ret,oneshot=0; + if (argv == 2 && (args[1][1] == 'h' || args[1][0] == 'h')) + { + printf("Temper, does the right thing in C\n"); + printf("recompile with DEBUG_MODE = 1 for all the debug printing\n"); + printf("recompile with SLEEP_TIMEOUT = XX for a different polling interval\n"); + exit(0); + } + + usb_set_debug(DEBUG_MODE); + usb_init(); + usb_find_busses(); + usb_find_devices(); + + t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, DEBUG_MODE); + if(!t) { + perror("TemperCreate"); + exit(-1); + } + + /* + TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); + TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); + */ + + bzero(buf, 256); + ret = TemperGetOtherStuff(t, buf, 256); + + float tempc; + + if(TemperGetTemperatureInC(t, &tempc) < 0) { + perror("TemperGetTemperatureInC"); + exit(1); + } + + printf("%.2f\n", tempc); + return 0; +} diff --git a/temper/temper.h b/temper/temper.h new file mode 100644 index 00000000..7ea6280a --- /dev/null +++ b/temper/temper.h @@ -0,0 +1,39 @@ +#ifndef TEMPER_H +#define TEMPER_H + +/* + * Temper.h by Robert Kavaler (c) 2009 (relavak.com) + * All rights reserved. + * + * Temper driver for linux. This program can be compiled either as a library + * or as a standalone program (-DUNIT_TEST). The driver will work with some + * TEMPer usb devices from RDing (www.PCsensor.com). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY Robert Kavaler ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +typedef struct Temper Temper; + + +Temper *TemperCreateFromDeviceNumber(int deviceNum, int timeout, int debug); +void TemperFree(Temper *t); + +int TemperGetTemperatureInC(Temper *t, float *tempC); +int TempterGetOtherStuff(Temper *t, char *buf, int length); + +#endif diff --git a/uino/morse/morse.pde b/uino/morse/morse.pde new file mode 100644 index 00000000..685f5092 --- /dev/null +++ b/uino/morse/morse.pde @@ -0,0 +1,164 @@ +#include <SoftwareSerial.h> + +/* + Implementes the Morse algorithm for a simple speaker + + @author Felix + @date 07.05.2011 + */ +int inByte = 0; +int i = 0; +int j = 0; +int char_avail = 0; + +/* You can touch this: */ +#define DIT_DELAY 50 + + +/* But you cannot touch this: */ +#define WORD_DELAY (DIT_DELAY * 7) +#define DIT_CYCLES (DIT_DELAY/2) +#define CHAR_DELAY (DIT_DELAY * 3) + +#define dsym() delay(DIT_DELAY); +#define char_delay() delay(CHAR_DELAY); +#define word_delay() delay(WORD_DELAY); + + +static char* latin_upper[] = { + ". -\0" , /* A */ + "- . . .\0" + "- . . .\0", + "- . - .\0", + "- . .\0", + ".\0", + ". . - .\0", + "- - .\0", + ". . . .\0", + ". .\0", + ". - - -\0", + "- . -\0", + ". - . .\0", + "- -\0", + "- .\0", + "- - -\0", + ". - - .\0", + "- - . -\0", + ". - .\0", + ". . .\0", + "-\0", + ". . -\0", + ". . . -\0", + ". - -\0", + "- . . -\0", + "- . - -\0", + "- - . .\0" /* Z */ +}; +static char* numbers[] = { + "- - - - -\0", /* 0 */ + ". - - - -\0", + ". . - - -\0", + ". . . - -\0", + ". . . . -\0", + ". . . . .\0", + "- . . . .\0", + "- - . . .\0", + "- - - . .\0", + "- - - - .\0" /* 9 */ +}; + +void setup() { + // initialize the digital pin as an output. + // Pin 13 has an LED connected on most Arduino boards: + pinMode(13, OUTPUT); + Serial.begin(9600); +} + + + +void loop() { + char_avail = Serial.available(); + + if(char_avail > 0) { + for (j = 0; j < char_avail;j++) + { + char on_line = Serial.read(); + to_beep(on_line); + char_delay(); + } + } +} + +void to_beep(char data) +{ + char* mdata; + if (data == ' ') + { + word_delay(); + Serial.println("word end"); + return; + } + else{ + if (data == '\n') { + word_delay(); + Serial.println("EOL"); + return; + } else + if (data >= 'A' && data <= 'Z' ) + mdata = latin_upper[data-'A']; + else + if (data >= 'a' && data <= 'z' ) + mdata = latin_upper[data-'a']; + else + if (data >= '0' && data <= '9') + mdata = numbers[data-'0']; + else + { + Serial.print(data); + Serial.println(": not implemented"); + return; + } + } + + Serial.println(mdata); + int sdata = strlen( mdata); + for( char i = 0; i < sdata; i ++) + { + + char token = mdata[i]; + if (token == '.') + { + dit(); + } + if (token == '-') + { + dah(); + } + if (token == ' ') + { + dsym(); + } + + } + +} +void dah() { + for (int i=0;i<3;i++) + { + dit(); + } +} + +void dit(){ + + for (int i=0;i<DIT_CYCLES;i++) // Number of DIT Cycles , sleep 2 milliseconds in a cycle + { + digitalWrite(13, HIGH); // set the LED on + delay(1); + + digitalWrite(13, LOW); // set the LED off + delay(1); + } +} + + diff --git a/util/bin/anonbox.net b/util/bin/anonbox.net new file mode 100755 index 00000000..d038cd0a --- /dev/null +++ b/util/bin/anonbox.net @@ -0,0 +1,57 @@ +#! /bin/bash +#### anonbox.net [--check] +#### anonbox account creator +set -euf + +## +script_begin_date="`date --rfc-3339=ns`" + +## +GET() { + wget --quiet --no-check-certificate -O- https://anonbox.net/en/ +} + +## retrieve data +eval "$(${GET-GET} | + sed -rn ' +s^<dd><p>([[:alnum:]@.]+)</p></dd>$\ + email="\1" ; p +s^<dd><p><a href="([^"\\]+)">.*</a></p></dd>$\ + uri="\1/" ; p +s^<dd><p>([0-9]+)/([0-9]+)/([0-9]+) ([0-9]+):([0-9]+) ([ap]).m.</p></dd>$\ + Y=20\3 ; \ + m=\1 ; \ + d=\2 ; \ + H=\4 ; \ + M=\5 ; \ + p=\6 ; p')" + +## make best-before-date RFC-3339-(seconds)-conform +case "$p" in + p) H="`echo $H+12 | bc`" ;; +esac +s=00 +z=+02:00 +best_before="$Y-$m-$d $H:$M$z" + +## +script_end_date="`date --rfc-3339=ns`" + +## +for key in email uri best_before script_begin_date script_end_date ; do + eval "val=\"\$$key\"" + echo "$key=\"$val\"" +done + +## +if echo "$*" | tr "$IFS" ' ' | egrep -q "(^| )--check( |$)"; then + file="/tmp/save-$email" + echo "file=\"$file\"" + echo >&2 + echo "# downloading email..." >&2 + while ! curl -ksS "$uri" | tee "$file" | grep .; do + sleep 10 + done +fi + +#### end of file. diff --git a/util/bin/google.suggest b/util/bin/google.suggest new file mode 100755 index 00000000..9bde17dc --- /dev/null +++ b/util/bin/google.suggest @@ -0,0 +1,8 @@ +#! /bin/sh + +uri="http://google.com/complete/search?output=json&q=$*" + +curl -sS "$uri" | sed -n ' + s:^window.google.ac.h(\|)$::gp +' +echo diff --git a/util/bin/krebdate b/util/bin/krebdate new file mode 100755 index 00000000..b2aa02d2 --- /dev/null +++ b/util/bin/krebdate @@ -0,0 +1,10 @@ +#! /bin/sh +set -euf + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + +date --date="`ssh krebs 'date --rfc-3339=s'`" diff --git a/util/bin/make-data-url b/util/bin/make-data-url new file mode 100755 index 00000000..a9d014e6 --- /dev/null +++ b/util/bin/make-data-url @@ -0,0 +1,7 @@ +#! /bin/sh +set -euf +for path; do + type="`file -bi "$path"`" + data="`base64 -w 0 "$path"`" + echo "data:$type;base64,$data" +done diff --git a/util/bin/my-global-ipv4-addr b/util/bin/my-global-ipv4-addr new file mode 100755 index 00000000..305d3f80 --- /dev/null +++ b/util/bin/my-global-ipv4-addr @@ -0,0 +1,51 @@ +#! /bin/sh +# +# usage: my-global-ipv4-addr [URL] +# +# if URL is provided then fetch and parse it for IPv4 addrs +# else try all known urls +# +if test $# = 1; then + has() { type "$1" 1>/dev/null 2>/dev/null; } + parse() { + sed -rn 's/.*((1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])\.(1?[0-9][0-9]|2[0-5][0-9])).*/\1/p' | grep . + } + get () { + # TODO get random valid user agent + if has curl; then + curl -m 1 -A Mozilla -sS "$1" 2>/dev/null + elif has wget; then + wget -T 1 -U Mozilla -O "$1" 2>/dev/null + else + echo 'Error 1: You are made of stupid!' >&2 + exit 23 + fi + } + + #addrs="`get "$1" | parse`" + #echo "$1:" $addrs >&2 + #echo "$addrs" + get "$1" | parse +else + + vote() { + sort | uniq -c | sort -r -n + } + winner() { + head -n 1 | awk '{print$2}' + } + + grep -v ^# | + sed -n '1,$p' | + xargs -P 42 -n 1 "$0" | vote | winner +fi<<EOF +checkip.dyndns.com +www.whatismyip.de +www.eigene-ip.de +whatismyip.org +www.ipaddressworld.com +http://ip-check.info/?lang=de +http://www.ip-adress.com/what_is_my_ip/ +http://www.spyber.com/ +http://www.ipchicken.com/ +EOF diff --git a/util/bin/randline b/util/bin/randline new file mode 100755 index 00000000..df36b344 --- /dev/null +++ b/util/bin/randline @@ -0,0 +1,2 @@ +#! /bin/sh +cat | shuf | head -n 1 diff --git a/util/bin/translate.google b/util/bin/translate.google new file mode 100755 index 00000000..1a1be6b6 --- /dev/null +++ b/util/bin/translate.google @@ -0,0 +1,44 @@ +#! /bin/sh +set -euf + +A=Mozilla +url=http://translate.google.com/ + +pwd="$(dirname "$(readlink -f "$0")")" + +for x in \ + "$pwd/../../submodules/github/tmpvar" \ + "$pwd/../../submodules/github/mikeal" \ + "$pwd/../../submodules/github/NV" \ + "$pwd/../../submodules/github/tautologistics" \ +; do + export NODE_PATH="`readlink -f "$x"`${NODE_PATH+:$NODE_PATH}" +done + +# ensure query is ready +(cd "$pwd/../.." && git submodule update --init) + +{ + for arg; do echo "$arg"; done | sed -rn ' + s/^--(.*=.*)/\1/p;t + s/.*/text="${text+$text }&"/p;t + ' + cat<<EOF + query() { + node "$(readlink -f "$pwd/../../submodules/github/visionmedia/query")" "\$@" + } + curl -sS -A "\${A-Mozilla}" \\ + -d "js=\${js-n}" \\ + -d "prev=\${prev-_t}" \\ + -d "hl=\${hl-en}" \\ + -d "layout=\${layout-2}" \\ + -d "eotf=\${eotf-1}" \\ + -d "ie=UTF-8" \\ + -d "oe=UTF-8" \\ + -d "sl=\${sl-auto}" \\ + -d "tl=\${tl-en}" \\ + -d "text=\$text" \\ + "$url" | + query '#result_box' text +EOF +} | sh diff --git a/webcams/cam1.sh b/webcams/cam1.sh new file mode 100755 index 00000000..9cf709e6 --- /dev/null +++ b/webcams/cam1.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 diff --git a/zoneminder/Makefile b/zoneminder/Makefile new file mode 100644 index 00000000..27302715 --- /dev/null +++ b/zoneminder/Makefile @@ -0,0 +1,14 @@ + +.PHONY: fix it so hard +it: so +so: it hard fix + apt-get install --yes zoneminder libv4l-0 + +hard: /etc/sysctl.d/zoneminder.conf +/etc/sysctl.d/zoneminder.conf: zoneminder.conf + cp $< $@ + sysctl -p $@ + +fix: zmdc.pl-LD_PRELOAD.patch + (cd /usr/bin && patch -N) < $< || : + diff --git a/zoneminder/zmdc.pl-LD_PRELOAD.patch b/zoneminder/zmdc.pl-LD_PRELOAD.patch new file mode 100644 index 00000000..b00fc673 --- /dev/null +++ b/zoneminder/zmdc.pl-LD_PRELOAD.patch @@ -0,0 +1,10 @@ +--- /usr/bin/zmdc.pl 2011-05-23 22:28:57.505247793 +0200 ++++ /usr/bin/zmdc.pl 2011-05-23 22:29:45.597248242 +0200 +@@ -62,6 +62,7 @@ + $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; + delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; + ++$ENV{LD_PRELOAD} = '/usr/lib/libv4l/v4l2convert.so'; + my @daemons = ( + 'zmc', + 'zma', diff --git a/zoneminder/zoneminder.conf b/zoneminder/zoneminder.conf new file mode 100644 index 00000000..1eec6fd9 --- /dev/null +++ b/zoneminder/zoneminder.conf @@ -0,0 +1,2 @@ +kernel.shmall = 134217728 +kernel.shmmax = 134217728 |