diff --git a/installer/bin/check.sh b/installer/bin/check.sh new file mode 100755 index 00000000..e147dd69 --- /dev/null +++ b/installer/bin/check.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +######################################################## +# T-Pot Community Edition # +# Check container and services script # +# # +# v0.10 by mo, DTAG, 2015-01-27 # +######################################################## + +if [ -f /var/run/check.lock ]; + then exit +fi + +touch /var/run/check.lock + +myUPTIME=$(awk '{print int($1/60)}' /proc/uptime) +for i in dionaea elk ews glastopf honeytrap kippo suricata +do + myCIDSTATUS=$(docker exec -i $i supervisorctl status) + if [ $? -ne 0 ]; then + myCIDSTATUS=1 + else + myCIDSTATUS=$(echo $myCIDSTATUS | egrep -c "(STOPPED|FATAL)") + fi + if [ $myCIDSTATUS -gt 0 ]; then + if [ $myUPTIME -gt 5 ]; then + service docker stop + docker rm $(docker ps -aq) + service docker start + for j in dionaea glastopf honeytrap kippo suricata ews elk + do + sleep 10 + service $j start + done + rm /var/run/check.lock + exit 0 + fi + fi +done + +rm /var/run/check.lock + diff --git a/installer/bin/status.sh b/installer/bin/status.sh new file mode 100755 index 00000000..7a72c0b3 --- /dev/null +++ b/installer/bin/status.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +######################################################## +# T-Pot Community Edition # +# Container and services status script # +# # +# v0.10 by mo, DTAG, 2015-01-27 # +######################################################## +myCOUNT=1 +while true +do + if ! [ -f /var/run/check.lock ]; + then break + fi + sleep 0.1 + if [ $myCOUNT = 1 ]; + then + echo -n "Waiting for services " + else echo -n . + fi + myCOUNT=$[$myCOUNT +1] +done +echo +echo +echo "****************** $(date) ******************" +echo +echo +for i in dionaea elk ews glastopf honeytrap kippo suricata +do + echo "======| Container:" $i "|======" + docker exec -i $i supervisorctl status | GREP_COLORS='mt=01;32' egrep --color=always "(RUNNING)|$" | GREP_COLORS='mt=01;31' egrep --color=always "(STOPPED|FATAL)|$" + echo +done diff --git a/installer/etc/issue b/installer/etc/issue new file mode 100644 index 00000000..99a2e813 --- /dev/null +++ b/installer/etc/issue @@ -0,0 +1,16 @@ +T-Pot Community Edition (Beta) +Hostname: \n +IP: 10.4.122.95 + + +___________ _____________________________ +\\__ ___/ \\______ \\_____ \\__ ___/ + | | ______ | ___// | \\| | + | | /_____/ | | / | \\ | + |____| |____| \\_______ /____| + \\/ + + +CTRL+ALT+F2 - Display current container status +CTRL+ALT+F1 - Return to this screen + diff --git a/installer/home/2fa_enable.sh b/installer/home/2fa_enable.sh new file mode 100755 index 00000000..e3c8e409 --- /dev/null +++ b/installer/home/2fa_enable.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +######################################################## +# T-Pot Community Edition # +# Two-Factor authentication enable script # +# # +# v0.20 by mo, DTAG, 2015-01-27 # +######################################################## + +echo "### This script will enable Two-Factor-Authentication based on Google Authenticator for SSH." +while true +do + echo -n "### Do you want to continue (y/n)? "; read myANSWER; + case $myANSWER in + n) + echo "### Exiting." + exit 0; + ;; + y) + break + ;; + esac +done +if [ -f /etc/pam.d/sshd.bak ]; + then echo "### Already enabled. Exiting." + exit 1; +fi +sudo sed -i.bak '\# PAM#aauth required pam_google_authenticator.so' /etc/pam.d/sshd +sudo sed -i.bak 's#ChallengeResponseAuthentication no#ChallengeResponseAuthentication yes#' /etc/ssh/sshd_config +google-authenticator -t -d -f -r 3 -R 30 -w 21 +echo "### Please do not forget to run the ssh_enable script." diff --git a/installer/home/ssh_enable.sh b/installer/home/ssh_enable.sh new file mode 100755 index 00000000..5c97efc8 --- /dev/null +++ b/installer/home/ssh_enable.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +######################################################## +# T-Pot Community Edition # +# SSH enable script # +# # +# v0.21 by mo, DTAG, 2015-01-27 # +######################################################## + +if ! [ -f /etc/init/ssh.override ]; + then echo "### SSH is already enabled. Exiting." + exit 1; +fi + +echo "### This script will enable the ssh service (default port tcp/64295)." +echo "### Password authentication is disabled by default." + +while true +do + echo -n "### Do you want to continue (y/n)? "; read myANSWER; + case $myANSWER in + n) + echo "### Exiting." + exit 0; + ;; + y) + break + ;; + esac +done +sudo rm /etc/init/ssh.override +sudo service ssh start diff --git a/installer/install1.sh b/installer/install1.sh index b502ec57..5682f884 100755 --- a/installer/install1.sh +++ b/installer/install1.sh @@ -4,7 +4,7 @@ # and consoleblank permanently # # Ubuntu server 14.04.1, x64 # # # -# v0.07 by mo, DTAG, 2015-01-20 # +# v0.10 by mo, DTAG, 2015-01-20 # ############################################################# # Let's replace "quiet splash" options and update grub diff --git a/installer/install2.sh b/installer/install2.sh index 26b2515e..a7b19a74 100755 --- a/installer/install2.sh +++ b/installer/install2.sh @@ -3,7 +3,7 @@ # T-Pot Community Edition post install script # # Ubuntu server 14.04, x64 # # # -# v0.21 by mo, DTAG, 2015-01-22 # +# v0.30 by mo, DTAG, 2015-01-27 # ######################################################## # Let's make sure there is a warning if running for a second time @@ -55,15 +55,18 @@ adduser --system --no-create-home --uid 2000 --disabled-password --disabled-logi fuECHO "### Creating some files and folders." mkdir -p /data/ews/log /data/ews/conf /data/elk/data /data/elk/log -# Let's modify the ownership / access rights +# Let's modify some ownership / access rights chmod 760 -R /data chown tpot:tpot -R /data +chmod 700 /home/tsec/*.sh +chown tsec:tsec /home/tsec/*.sh + # Let's set the hostname fuECHO "### Setting a new hostname." myHOST=ce$(date +%s)$RANDOM hostnamectl set-hostname $myHOST -sed -i 's/127.0.1.1.*/127.0.1.1\t'"$myHOST"'/g' /etc/hosts +sed -i 's#127.0.1.1.*#127.0.1.1\t'"$myHOST"'#g' /etc/hosts # Let's patch sshd_config fuECHO "### Patching sshd_config to listen on port 64295 and deny password authentication." @@ -71,67 +74,7 @@ sed -i 's#Port 22#Port 64295#' /etc/ssh/sshd_config sed -i 's#\#PasswordAuthentication yes#PasswordAuthentication no#' /etc/ssh/sshd_config # Let's disable ssh service -mv /etc/init/ssh.conf /etc/init/ssh.conf.disable - -# Let's create the 2FA enable script -fuECHO "### Creating 2FA enable script." -tee /home/tsec/2fa_enable.sh <> /etc/init/ssh.override # Let's patch docker defaults, so we can run images as service fuECHO "### Patching docker defaults." @@ -139,144 +82,6 @@ tee -a /etc/default/docker < /dev/tty2; date > /dev/tty2; docker ps > /dev/tty2; echo > /dev/tty2 -EOF - -# Let's add a nice and useful issue text and update rc.local accordingly -fuECHO "### Adding a nice and useful issue text and updating rc.local accordingly." -tee /etc/issue < /dev/tty2 + +# Check if containers and services are up +*/5 * * * * root /usr/bin/check.sh EOF +# Let's update rc.local +fuECHO "### Updating rc.local." tee /etc/rc.local.new <