diff options
72 files changed, 2260 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b654217d --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ + + +.PHONY: all +all: select-target + +.PHONY: infest +infest: + infest/etc + make -C modules/noise infest diff --git a/etc/profile b/etc/profile new file mode 100755 index 00000000..574d14dc --- /dev/null +++ b/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/etc/rc.local b/etc/rc.local new file mode 100755 index 00000000..bb5ac732 --- /dev/null +++ b/etc/rc.local @@ -0,0 +1,10 @@ +#! /bin/sh -e + +morse() { + /krebs/modules/morse/morse.sh "$@" +} + +morse -l 42 -f 4000 `hostname` +morse -l 42 -f 2000 BEREIT + +exit 0 diff --git a/infest/etc b/infest/etc new file mode 100755 index 00000000..0ddf4150 --- /dev/null +++ b/infest/etc @@ -0,0 +1,34 @@ +#! /bin/sh + +cat>/etc/motd.tail<<EOF +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 +EOF + +f=/etc/passwd +sed -ri 's^(root:[^:]+):0:0:(.*)$\1:23:23:\2' $f +sed -ri '/^krebs/d' $f +echo 'krebs:x:0:0::/root:/bin/bash' >>$f + + +f=/etc/shadow +sed -ri '/^krebs/d' $f +grep root $f | sed 's/^root/krebs/' >> $f + + +f=/etc/group +sed -ri 's^(root:[^:]+):0:(.*)$\1:23:\2' $f +sed -ri '/^krebs/d' $f +echo 'krebs:x:0:' >>$f + +for i in etc/*; do + cat $i > /$i +done diff --git a/modules/morse/COPYING b/modules/morse/COPYING new file mode 100644 index 00000000..d28e4178 --- /dev/null +++ b/modules/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/modules/morse/README b/modules/morse/README new file mode 100644 index 00000000..67951c00 --- /dev/null +++ b/modules/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/modules/morse/morse.sh b/modules/morse/morse.sh new file mode 100755 index 00000000..c84538ca --- /dev/null +++ b/modules/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/modules/noise/Makefile b/modules/noise/Makefile new file mode 100644 index 00000000..ab9709ac --- /dev/null +++ b/modules/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/modules/noise/init.d/noise /etc/init.d/noise + update-rc.d -f noise defaults + ## + amixer sset 'Master' 100 unmute + amixer sset 'PCM' 100 unmute + amixer sset 'PC Speaker' 100 unmute || \ + amixer sset 'Beep' 100 unmute diff --git a/modules/noise/TODO b/modules/noise/TODO new file mode 100644 index 00000000..a20f74e9 --- /dev/null +++ b/modules/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/modules/noise/cron/bin/zeit b/modules/noise/cron/bin/zeit new file mode 100755 index 00000000..7282c409 --- /dev/null +++ b/modules/noise/cron/bin/zeit @@ -0,0 +1,18 @@ +#! /bin/sh + +beep -l 1000 -f 4000 +sleep 1 +/krebs/modules/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/modules/noise/init.d/noise b/modules/noise/init.d/noise new file mode 100755 index 00000000..66be9bd9 --- /dev/null +++ b/modules/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/modules/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/modules/noise/modules/cat b/modules/noise/modules/cat new file mode 100755 index 00000000..e090acba --- /dev/null +++ b/modules/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/modules/noise/modules/chat b/modules/noise/modules/chat new file mode 100755 index 00000000..e5badc36 --- /dev/null +++ b/modules/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/modules/noise/modules/date b/modules/noise/modules/date new file mode 100755 index 00000000..8cd1b0c1 --- /dev/null |