Skip to content

Instantly share code, notes, and snippets.

@mjmckinnon
Created July 6, 2016 03:40
Show Gist options
  • Save mjmckinnon/080875a26f569d8b38b2d3c12299e6a8 to your computer and use it in GitHub Desktop.
Save mjmckinnon/080875a26f569d8b38b2d3c12299e6a8 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Written by: Michael McKinnon @bigmac
# Part two of a quick and dirty script
# to get a cowrie SSH honeypot up and running
# Yes, this needs to run as root.
# Init - a name for your juicy looking honeypot and ssh port
HONEYPOTNAME = "usd-bank-01"
HONEYPOTPORT = 22
# Install a bunch of required packages
sudo apt-get -y install python-twisted python-crypto python-pyasn1 \
python-gmpy2 python-mysqldb python-zope.interface \
authbind
# Add our under privileged user
adduser --disabled-password cowrie
# Go to cowrie's home and download the repo
cd ~cowrie/
git clone http://github.com/micheloosterhof/cowrie
chown -R cowrie.cowrie cowrie/
# Let's create and edit the cowrie.cfg file
# just the basic stuff - name and port only
cd cowrie/
cp -p cowrie.cfg.dist cowrie.cfg
sed -i 's/^hostname =.*/hostname = $HONEYPOTNAME/g' cowrie.cfg
sed -i 's/^#listen_port =.*/listen_port = $HONEYPOTPORT/' cowrie.cfg
chown cowrie.cowrie cowrie.cfg
# Configure the authbind settings so we can listen on Port 22
sed -i "s/AUTHBIND_ENABLED=/AUTHBIND_ENABLED=yes/" start.sh
touch /etc/authbind/byport/$HONEYPOTPORT
chown cowrie:cowrie /etc/authbind/byport/$HONEYPOTPORT
chmod 770 /etc/authbind/byport/$HONEYPOTPORT
# Ready to go!
echo "Done. Your Honey awaits. Or something."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment