#!/bin/bash ######################################################## # T-Pot post install script # # Ubuntu server 14.04.3, x64 # # # # v16.03.7 by mo, DTAG, 2016-02-11 # ######################################################## # Type of install, SENSOR, INDUSTRIAL or FULL? myFLAVOR="INDUSTRIAL" # Some global vars myPROXYFILEPATH="/root/tpot/etc/proxy" myNTPCONFPATH="/root/tpot/etc/ntp" myPFXPATH="/root/tpot/keys/8021x.pfx" myPFXPWPATH="/root/tpot/keys/8021x.pw" myPFXHOSTIDPATH="/root/tpot/keys/8021x.id" # Let's create a function for colorful output fuECHO () { local myRED=1 local myWHT=7 tput setaf $myRED echo $1 "$2" tput setaf $myWHT } # Let's make sure there is a warning if running for a second time if [ -f install.log ]; then fuECHO "### Running more than once may complicate things. Erase install.log if you are really sure." exit 1; fi # Let's log for the beauty of it set -e exec 2> >(tee "install.err") exec > >(tee "install.log") # Let's setup the proxy for env if [ -f $myPROXYFILEPATH ]; then fuECHO "### Setting up the proxy." myPROXY=$(cat $myPROXYFILEPATH) tee -a /etc/environment < # wpa-ap-scan 1 # wpa-proto RSN # wpa-pairwise CCMP # wpa-group CCMP # wpa-key-mgmt WPA-PSK # wpa-psk "" EOF # Let's modify the sources list sed -i '/cdrom/d' /etc/apt/sources.list # Let's make sure SSH roaming is turned off (CVE-2016-0777, CVE-2016-0778) fuECHO "### Let's make sure SSH roaming is turned off." tee -a /etc/ssh/ssh_config <> /etc/init/ssh.override # Let's patch docker defaults, so we can run images as service fuECHO "### Patching docker defaults." tee -a /etc/default/docker < /dev/tty2 # Check if containers and services are up */5 * * * * root check.sh # Check if updated images are available and download them 27 1 * * * root for i in \$(cat /data/images.conf); do docker pull dtagdevsec/\$i:latest1603; done # Restart docker service and containers 27 3 * * * root dcres.sh # Delete elastic indices older than 30 days 27 4 * * * root docker exec elk bash -c '/usr/local/bin/curator --host 127.0.0.1 delete --older-than 30' # Update IP and erase check.lock if it exists 27 15 * * * root /etc/rc.local # Check for updated packages every sunday, upgrade and reboot 27 16 * * 0 root sleep \$((RANDOM %600)); apt-get autoclean -y; apt-get autoremove -y; apt-get update -y; apt-get upgrade -y; sleep 5; reboot EOF # Let's create some files and folders fuECHO "### Creating some files and folders." mkdir -p /data/ews/log /data/ews/conf /data/ews/dionaea /data/ews/emobility \ /data/cowrie/log/tty/ /data/cowrie/downloads/ /data/cowrie/keys/ /data/cowrie/misc/ \ /data/elasticpot/log \ /data/dionaea/log /data/dionaea/bistreams /data/dionaea/binaries /data/dionaea/rtp /data/dionaea/wwwroot \ /data/elk/data /data/elk/log /data/glastopf /data/honeytrap/log/ /data/honeytrap/attacks/ /data/honeytrap/downloads/ \ /data/suricata/log /home/tsec/.ssh/ \ /data/emobility/log # Let's take care of some files and permissions before copying chmod 500 /root/tpot/bin/* chmod 600 /root/tpot/data/* chmod 644 /root/tpot/etc/issue chmod 755 /root/tpot/etc/rc.local chmod 700 /root/tpot/home/* chown tsec:tsec /root/tpot/home/* chmod 644 /root/tpot/data/upstart/* # Let's copy some files cp -R /root/tpot/bin/* /usr/bin/ cp -R /root/tpot/data/* /data/ cp -R /root/tpot/etc/issue /etc/ cp -R /root/tpot/home/* /home/tsec/ cp /root/tpot/keys/authorized_keys /home/tsec/.ssh/authorized_keys for i in $(cat /data/images.conf); do cp /data/upstart/$i.conf /etc/init/; done # Let's take care of some files and permissions chmod 760 -R /data chown tpot:tpot -R /data chmod 600 /home/tsec/.ssh/authorized_keys chown tsec:tsec /home/tsec/*.sh /home/tsec/.ssh /home/tsec/.ssh/authorized_keys # Let's clean up apt apt-get autoclean -y apt-get autoremove -y # Let's replace "quiet splash" options, set a console font for more screen canvas and update grub sed -i 's#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"#GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0"#' /etc/default/grub sed -i 's#\#GRUB_GFXMODE=640x480#GRUB_GFXMODE=800x600x32#' /etc/default/grub tee -a /etc/default/grub <