diff options
author | makefu <root@pigstarter.de> | 2014-03-16 15:01:22 +0100 |
---|---|---|
committer | makefu <root@pigstarter.de> | 2014-03-16 15:01:22 +0100 |
commit | c503a92fd711a73762a44ea08cf10438ed03fa55 (patch) | |
tree | cc9c5f345ad2497563cc9f1b5552d7e09e2c9276 | |
parent | d40950a555d594365307fca7a5a23a360a15645c (diff) | |
parent | e2cf4fc92569487e21d096ac6879177aac8f73c1 (diff) |
filehooker: add tor_announce
-rw-r--r-- | Reaktor/IRC/ircasy.py | 17 | ||||
-rw-r--r-- | ship/lib/filehooker | 25 | ||||
-rw-r--r-- | ship/src/filehooker_configure_netshare | 5 | ||||
-rwxr-xr-x | ship/src/filehooker_install | 56 | ||||
-rw-r--r-- | ship/src/install_tor_announce | 5 |
5 files changed, 82 insertions, 26 deletions
diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/IRC/ircasy.py index fd261ae9..57ec9189 100644 --- a/Reaktor/IRC/ircasy.py +++ b/Reaktor/IRC/ircasy.py @@ -85,7 +85,10 @@ class asybot(asychat): alarm(self.hammer_interval) def collect_incoming_data(self, data): - self.data += data.decode() + try: + self.data += data.decode() + except Exception as e: + print('error decoding message: ' + str(e)); def found_terminator(self): self.log.debug('<< %s' % self.data) @@ -173,8 +176,10 @@ class asybot(asychat): pass def on_nickinuse(self, prefix, command, params, rest): - _, nickname, int, _ = split('^.*[^0-9]([0-9]+)$', self.nickname) \ - if search('[0-9]$', self.nickname) \ - else ['', self.nickname, 0, ''] - self.nickname = nickname + str(int + 1) - self.handle_connect() + regex = search('(\d+)$', self.nickname) + if regex: + theint = int(regex.group(0)) + self.nickname = self.nickname.strip(str(theint)) + str(theint + 1) + else: + self.nickname = self.nickname + '0' + self.handle_connect() diff --git a/ship/lib/filehooker b/ship/lib/filehooker index a2fba840..3c881f91 100644 --- a/ship/lib/filehooker +++ b/ship/lib/filehooker @@ -1,4 +1,5 @@ #@include core +#@include network ncdc_user=${ncdc_user:-hooker} ncdc_bin=${ncdc_bin:-/usr/bin/ncdc} @@ -90,3 +91,27 @@ prepare_netshares(){ fi done } +install_tor_announce(){ +# systemd only +info "writing tor_announce.service" +cat > /etc/systemd/system/tor_announce.service<<EOF +[Unit] +Description=Announce Tor Hidden Address +After=network.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/tor_announce + +[Install] +WantedBy=multi-user.target +EOF +info "writing tor_announce to /usr/bin/tor_announce" +printf '#!/bin/sh\nsleep 20\n' > /usr/bin/tor_announce +http_get conf.krebsco.de/tor_publish_ssh >> /usr/bin/tor_announce +chmod +x /usr/bin/tor_announce +info "enable tor_announce" +systemctl enable tor_announce +#systemctl start tor_announce +} diff --git a/ship/src/filehooker_configure_netshare b/ship/src/filehooker_configure_netshare index ffd53e08..438ac133 100644 --- a/ship/src/filehooker_configure_netshare +++ b/ship/src/filehooker_configure_netshare @@ -2,5 +2,6 @@ #@info #@strict #@include filehooker - -ncdc_configure_netshare "${1?provide share folder}" +for i in $(prepare_netshares) ;do + ncdc_configure_netshare "$i" "${i##*/}" +done diff --git a/ship/src/filehooker_install b/ship/src/filehooker_install index 1b9717f1..eb2d5fd1 100755 --- a/ship/src/filehooker_install +++ b/ship/src/filehooker_install @@ -12,13 +12,31 @@ ## for ncdc #@include filehooker pass=lolwut.aidsballs +# 20gig +#min_netshare_size=20000000000 admin=pimp extra_pkg="vim sudo grub-bios ntp tor openssh btrfs-progs tmux" info "writing stdout to /tmp/install.log" -rootdisk=${1?please provide the root disk via \$1} +installer_disk(){ + find /dev/disk/by-label/ -name ARCH_\* 2>/dev/null | xargs readlink +} + +find_rootdisk(){ + for i in sd vd hd;do + for j in a b c;do + dsk="/dev/$i$j" + test ! -e "$dsk" && continue + test "$(installer_disk)" == "$dsk" && continue + test "$(get_disksize $dsk)" -gt "$min_netshare_size" && info "not using $dsk as it is too big" && continue + echo "$dsk" && return + done + done +} + +rootdisk=$(find_rootdisk) test "$rootdisk" || die "cannot find your root disk" info "Your rootdisk is $rootdisk" @@ -36,21 +54,16 @@ sleep 1 info "generating filesystem on /boot" mkfs.ext2 ${rootdisk}1 info "Done" +sleep 3 +sync +vgchange -an +info "generating filesystems" +mkfs.btrfs -f ${rootdisk}2 sleep 1 -info "starting LVM magic" -vgchange -an ||: -vgremove -f pool0 ||: -pvcreate ${rootdisk}2 -vgcreate -ff pool0 ${rootdisk}2 -lvcreate -l 100%free -n root pool0 -info "finished creating LVM" -sleep 1 -info "generating filesystems on the LVM" -mkfs.ext4 /dev/mapper/pool0-root info "finished generating filesystems" sleep 1 info "mounting" -mount /dev/mapper/pool0-root /mnt +mount ${rootdisk}2 /mnt mkdir /mnt/boot mount ${rootdisk}1 /mnt/boot @@ -66,7 +79,7 @@ if [ -n "${user_pkg:-}" ] ;then else info "No additional packages set by user (\$user_pkg unset)" fi -pacstrap /mnt base base-devel $extra_pkg ${user_pkg:-} +pacstrap /mnt base $extra_pkg ${user_pkg:-} info "installation done" sleep 1 info "generating configs" @@ -86,9 +99,8 @@ echo "LANG=en_US.UTF-8" >> /etc/locale.conf echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen locale-gen echo "filehooker$RANDOM" > /etc/hostname -sed -i 's/block/& lvm2/g' /etc/mkinitcpio.conf info "Done! " -mkinitcpio -p linux +mkinitcpio -p linux || info "setting root password" printf "${pass}\n${pass}\n" | (passwd ) info "adding user" @@ -111,13 +123,21 @@ useradd -m hooker exit EOF ######## END CHROOT ########## +sync info "configuring tor" torrc=/mnt/etc/tor/torrc hidden_service_dir=/var/lib/tor/hidden_service/ configure_hidden_service -info "publishing hidden service address" -cat $hidden_service_dir/hostname | send_irc +#info "publishing hidden service address" +#cat $hidden_service_dir/hostname | send_irc info "configure ncdc" curl conf.krebsco.de/filehooker_configure_ncdc | arch-chroot /mnt -info "We're all done, simply reboot!" +info "configuring netshares" +( curl conf.krebsco.de/filehooker_configure_netshare )| arch-chroot /mnt +info "configuring tor announce" +curl conf.krebsco.de/install_tor_announce | arch-chroot /mnt +info "We're all done, rebooting!" +sync +sleep 5 +reboot diff --git a/ship/src/install_tor_announce b/ship/src/install_tor_announce new file mode 100644 index 00000000..b7b3662e --- /dev/null +++ b/ship/src/install_tor_announce @@ -0,0 +1,5 @@ +#!/bin/sh +#@strict +#@include filehooker + +install_tor_announce |