Created
October 27, 2018 00:27
-
-
Save seanthegeek/7e89b6e4085eaacf7530485a83ddb53d to your computer and use it in GitHub Desktop.
Old cuckooboot.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CUCKOO_USER="cuckoo" | |
CUCKOO_PATH="/opt/cuckoo" | |
VIRBR_IP="192.168.100.1" | |
INETSIM_DNS_PORT="5342" | |
VIRBR_DEV="virbr0" | |
su $CUCKOO_USER -c "pkill gunicorn" >/dev/null 2>&1 | |
su $CUCKOO_USER -c "pkill python" > /dev/null 2>&1 | |
/usr/bin/curl -s http://$VIRBR_IP:8080/ > /dev/null | |
# Wait for the virtual bridge to become active before (re)starting services | |
while [ $? -ne 0 ] | |
do | |
sleep 5 | |
/usr/sbin/service nginx restart | |
/usr/bin/curl -s http://$VIRBR_IP:8080/ > /dev/null | |
done | |
# Restart services that bind to the bridge | |
/usr/sbin/service tor restart | |
/usr/sbin/service inetsim restart | |
/usr/sbin/service vsftpd restart | |
# Start Cuckoo | |
cd $CUCKOO_PATH | |
su $CUCKOO_USER -c "./cuckoo.py &" | |
# Start the Cuckoo web UI | |
cd web | |
su $CUCKOO_USER -c "gunicorn --reload -D -w 4 -b 127.0.0.1:8000 web.wsgi" | |
# Start the legacy upstream API | |
cd ../utils | |
su $CUCKOO_USER -c "gunicorn --reload -D -w 4 -b 127.0.0.1:8001 api" | |
# Redirect libvirt VM DNS quires to inetsim's DNS port | |
/sbin/iptables -t nat -C PREROUTING -d $VIRBR_IP -p udp --dport 53 -j REDIRECT --to-ports $INETSIM_DNS_PORT >/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
/sbin/iptables -t nat -I PREROUTING -d $VIRBR_IP -p udp --dport 53 -j REDIRECT --to-ports $INETSIM_DNS_PORT | |
fi | |
# Allow inetsim to accept traffic for any IP address | |
/sbin/iptables -t nat -C PREROUTING -i $VIRBR_DEV -j REDIRECT >/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
/sbin/iptables -t nat -A PREROUTING -i $VIRBR_DEV -j REDIRECT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment