I got side tracked by other projects, but finally got a chance to play around with cowrie today. The deployment script I use is pretty much the same one as the stock kippo script (attached below), the config file is slightly different and I changed the hpfeeds session to be "kippo" instead of "cowrie" so it's more of a drop-in replacement in mhn. The config has some interesting authentication options to play around with,
has more details on possible settings.
#!/bin/bash
set -e
set -x
if [ $# -ne 2 ]
then
echo "Wrong number of arguments supplied."
echo "Usage: $0 <server_url> <deploy_key>."
exit 1
fi
server_url=$1
deploy_key=$2
wget $server_url/static/registration.txt -O registration.sh
chmod 755 registration.sh
# Note: this will export the HPF_* variables
. ./registration.sh $server_url $deploy_key "cowrie"
apt-get update
apt-get -y install python-dev openssl python-openssl python-pyasn1 python-twisted git python-pip supervisor authbind
# Create Cowrie user
useradd -d /home/cowrie -s /bin/bash -m cowrie -g users
# Get the Cowrie source
cd /opt
cd cowrie
# Configure Cowrie
HONEYPOT_HOSTNAME="server-123"
HONEYPOT_SSH_VERSION="SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.3"
cat > /opt/cowrie/cowrie.cfg <<EOF
[honeypot]
listen_addr = 0.0.0.0
listen_port = 22
hostname = ${HONEYPOT_HOSTNAME}
log_path = log
download_path = dl
contents_path = honeyfs
filesystem_file = data/fs.pickle
data_path = data
auth_class = UserDB
auth_none_enabled = false
txtcmds_path = txtcmds
rsa_public_key = data/ssh_host_rsa_key.pub
rsa_private_key = data/ssh_host_rsa_key
dsa_public_key = data/ssh_host_dsa_key.pub
dsa_private_key = data/ssh_host_dsa_key
ssh_version_string = ${HONEYPOT_SSH_VERSION}
sftp_enabled = true
exec_enabled = true
interact_enabled = false
interact_port = 5123
[database_hpfeeds]
server = $HPF_HOST
port = $HPF_PORT
identifier = $HPF_IDENT
secret = $HPF_SECRET
debug = false
EOF
sed -i "s/KIPPOCHAN = .*/KIPPOCHAN = 'kippo.sessions'/" cowrie/dblog/hpfeeds.py
# Fix permissions for cowrie
chown -R cowrie:users /opt/cowrie
touch /etc/authbind/byport/22
chown cowrie /etc/authbind/byport/22
chmod 777 /etc/authbind/byport/22
# Setup cowrie to start at boot
cp start.sh start.sh.backup
cat > start.sh <<EOF
#!/bin/sh
cd /opt/cowrie
su cowrie -c "authbind --deep twistd -n -l log/cowrie.log --pidfile cowrie.pid cowrie"
EOF
chmod +x start.sh
# Config for supervisor.
cat > /etc/supervisor/conf.d/cowrie.conf <<EOF
[program:cowrie]
command=/opt/cowrie/start.sh
directory=/opt/cowrie
stdout_logfile=/opt/cowrie/log/cowrie.out
stderr_logfile=/opt/cowrie/log/cowrie.err
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
EOF
supervisorctl update