summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/tinc_setup
diff options
context:
space:
mode:
authoreuer <root@euer.krebsco.de>2012-12-07 22:53:52 +0100
committereuer <root@euer.krebsco.de>2012-12-07 22:53:52 +0100
commitd263d0e9e7e6c37f793eb3ec1908d188849f5d02 (patch)
tree1636d12349ebb4c3ff16ec755771fccb1e46f823 /retiolum/scripts/tinc_setup
parentd3d49099cbe570dee7f6cbfab2723bc04d81ac79 (diff)
parent253f0a908b190f0ff6d2f71023d050c088533c02 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts/tinc_setup')
-rwxr-xr-xretiolum/scripts/tinc_setup/install.sh2
-rwxr-xr-xretiolum/scripts/tinc_setup/new_install.sh158
-rw-r--r--retiolum/scripts/tinc_setup/write_channel.py27
3 files changed, 159 insertions, 28 deletions
diff --git a/retiolum/scripts/tinc_setup/install.sh b/retiolum/scripts/tinc_setup/install.sh
index a6b50b8a..2e36b83a 100755
--- a/retiolum/scripts/tinc_setup/install.sh
+++ b/retiolum/scripts/tinc_setup/install.sh
@@ -73,7 +73,7 @@ if [ ! -e rsa_key.priv ]
then
echo "creating new keys"
tincd -n $netname -K
- python ${CURR}/write_channel.py $myname || \
+ $MYBIN/announce_pubkey $myname || \
echo "cannot write public key to IRC, you are on your own. Good Luck"
else
echo "key files already exist, skipping"
diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh
new file mode 100755
index 00000000..ab42aedc
--- /dev/null
+++ b/retiolum/scripts/tinc_setup/new_install.sh
@@ -0,0 +1,158 @@
+#!/bin/sh
+
+usage()
+{
+cat << EOF
+usage $0 options
+This script gets you into the KREBS Darknet
+all parameters are optional
+
+Options:
+ -h Show this message(haha)
+ -4 \$ipv4 specify an ip(version 4), this also disables random ip mode, default is random
+ -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu
+ -o \$HOST Choose another Hostname, default is your system hostname
+ -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum
+ -s \$SUBNET Choose another Subnet(version4), default is 10.243.
+ -m \$MASK Choose another Subnet Mask(version4), default is /16
+ -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz
+EOF
+}
+
+#check if ip is valid ipv4 function
+check_ip_valid4()
+{
+ if [ "$(echo $1 | awk -F"\." ' $0 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/ && $1 <=255 && $2 <= 255 && $3 <= 255 && $4 <= 255 ' 2>/dev/null)" == "$1" ] && [ ${1:0:${#SUBNET4}} == $SUBNET4 ]
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
+#check if ip is taken function
+check_ip_taken()
+{
+ if grep -q -E "$1(#|/)" $TEMPDIR/hosts/* ;then
+ echo $1 is taken
+ return 1
+ else
+ echo $1 seems free
+ return 0
+ fi
+}
+
+#if hostname is taken, count upwards until it isn't taken function
+check_hostname()
+{
+ TSTFILE=$TEMPDIR/hosts/$1
+ LCOUNTER=0
+ if test -e $TSTFILE; then
+ while test -e $TSTFILE; do
+ let LCOUNTER=LCOUNTER+1
+ TSTFILE=$TEMPDIR/hosts/$1$LCOUNTER
+ done
+ HOSTN=$1$LCOUNTER
+ else
+ HOSTN=$1
+ fi
+}
+
+TEMPDIR=/tmp/tinc-install-fu
+HOSTN=$(hostname)
+NETNAME=retiolum
+SUBNET4=10.243.
+MASK4=/16
+RAND=1
+URL=euer.krebsco.de/retiolum/hosts.tar.gz
+
+#check if everything is installed
+if $(! test -e "/usr/sbin/tincd"); then
+ echo "Please install tinc"
+ exit 1
+fi
+
+if $(! test -e /usr/bin/awk); then
+ echo "Please install awk"
+ exit 1
+fi
+
+if $(! test -e /usr/bin/curl); then
+ echo "Please install curl"
+ exit 1
+fi
+
+if $(! /bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then
+ echo "Cant reach euer, check if your internet is working"
+ exit 1
+fi
+
+
+#parse options
+while getopts "h4:t:o:n:s:m:u:" OPTION
+do
+ case $OPTION in
+ h)
+ usage
+ exit 1
+ ;;
+ 4)
+ IP4=$OPTARG
+ RAND=0
+ if ! check_ip_valid4 $IP4; then echo "ip is invalid" && exit 1; fi
+ ;;
+ t)
+ TEMPDIR=$OPTARG
+ ;;
+ o)
+ HOSTN=$OPTARG
+ ;;
+ n)
+ NETNAME=$OPTARG
+ ;;
+ s)
+ SUBNET4=$OPTARG
+ ;;
+ m)
+ MASK4=$OPTARG
+ ;;
+ u)
+ URL=$OPTARG
+ if $(! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null); then
+ echo "url not reachable"
+ exit 1
+ fi
+ ;;
+
+ esac
+done
+
+#test if tinc directory already exists
+if test -e /etc/tinc/$NETNAME; then
+ echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart"
+ exit 1
+fi
+
+#get tinc-hostfiles
+mkdir -p $TEMPDIR/hosts
+curl euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/
+
+#check for free ip
+until check_ip_taken $IP4; do
+ if [ $RAND -eq 1 ]; then
+ IP4="10.243.$((RANDOM%255)).$((RANDOM%255))"
+ else
+ printf 'choose new ip: '
+ read IP4
+ while ! check_ip_valid4 $IP4; do
+ printf 'the ip is invalid, retard, choose a valid ip: '
+ read IP4
+ done
+ fi
+done
+
+#check for free hostname
+check_hostname $HOSTN
+
+echo "your ip is $IP4"
+echo "your hostname is $HOSTN"
diff --git a/retiolum/scripts/tinc_setup/write_channel.py b/retiolum/scripts/tinc_setup/write_channel.py
deleted file mode 100644
index 8299fa8d..00000000
--- a/retiolum/scripts/tinc_setup/write_channel.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-import random, sys, time, socket
-try:
- myname=sys.argv[1]
-except:
- print("you are made of stupid")
- exit (23)
-
-CHANNEL = '#krebsco'
-HOST='irc.freenode.net'
-FILE="/etc/tinc/retiolum/hosts/"+myname
-PORT=6667
-NICK= myname+"_"+str(random.randint(23,666))
-
-print("Connecting...")
-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()