Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MHN Docker Container #169

Closed
Epicism opened this issue Jun 10, 2015 · 4 comments
Closed

MHN Docker Container #169

Epicism opened this issue Jun 10, 2015 · 4 comments

Comments

@Epicism
Copy link

Epicism commented Jun 10, 2015

Hello all,

This isn't an issue as much as sharing post. I have hacked my way into configuring MHN on a docker container for simplicity. Because docker doesn't use standard services, I had to hack supervisord to start services at appropriate times.

To start a docker container, use the command

docker run -p 10000:10000 -p 80:80 -p 3000:3000 -p 8089:8089 --restart unless-stopped --name mhn -t -i ubuntu:14.04.2 /bin/bash

*Note: 8089 is if you are using the Splunk forwarder, and you can chose between 80 and 443. You can also make the host OS' port separate from the docker container's port by using [hostport]:[dockerport], which is convenient for honeypots.

Next, create and run the following script:

#!/bin/bash

set -x

apt-get update 
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
cd /opt/ 
git clone https://github.com/threatstream/mhn.git 
cd mhn

cat > /etc/supervisor/conf.d/mhntodocker.conf <<EOF
[program:mongod]
command=/usr/bin/mongod
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
autostart=true

[program:nginx]
command=/usr/sbin/nginx
stdout_events_enabled=true
stderr_events_enabled=true
autostart=true
autorestart=true

EOF

mkdir -p /data/db /var/log/mhn /var/log/supervisor

supervisord &

#Starts the mongod service after installation
echo supervisorctl start mongod >> /opt/mhn/scripts/install_mongo.sh

./install.sh

supervisorctl restart all

I haven't started deploying honeypots yet, which is my next task. Unfortunately, due to the interactive nature of MHN's installation, supervisord is manually running in the background instead of as a started service. To restart the container later use

docker start <containerID> 
docker exec <containerID> supervisord &

Don't forget to reference the host's IP address or Hostname as the MHN server's IP unless you are using Docker's internal networking. You could also pass the script during the docker container creation, but since you have to execute it inside of the container it doesn't really matter.

If there is enough interest in this my hope is that we can create a process to generate a docker image/honeypot images on the fly, perhaps by passing a simple config file to the image on run which configures the server as required.

Cheers.
Epic

@jatrost
Copy link
Collaborator

jatrost commented Jun 11, 2015

Thats awesome. Thanks for Sharing!

@cloughrm
Copy link
Contributor

Thank you @Epicism! I have added this to the wiki here: https://github.com/threatstream/mhn/wiki/Running-MHN-in-Docker

@Epicism
Copy link
Author

Epicism commented Jan 15, 2016

My pleasure :)

On Fri, Jan 15, 2016 at 1:24 PM, Ryan Clough [email protected]
wrote:

Thank you @Epicism https://github.com/Epicism! I have added this to the
wiki here: https://github.com/threatstream/mhn/wiki/Running-MHN-in-Docker


Reply to this email directly or view it on GitHub
https://github.com/threatstream/mhn/issues/169#issuecomment-172042971.

@Epicism
Copy link
Author

Epicism commented Feb 4, 2017

Hello all,

I had to rebuild my MHN server and I thought that I would complete the instructions towards how to install the remaining containers. The container setup is based on my environment configuration so please feel free to modify it to your requirements.

#Create the Kippo container:
docker run -p 2222:22 --restart unless-stopped --name kippo -h kippo.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
apt-get install --yes --force-yes -y openssh-server
supervisord &
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=7" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

Then create a Supervisord script to manage MHN:

cat > /etc/supervisor/conf.d/mhntodocker.conf <<EOF
[program:kippo]
command=/opt/kippo/start.sh
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
autostart=true
EOF
supervisord &

#Create the Wordpot container:
docker run -p 8080:80 --restart unless-stopped --name wordpot -h wordpot.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
supervisord &

wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=17" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

#Create the cowrie container:
docker run -p 23:22 --restart unless-stopped --name cowrie -h cowrie.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
apt-get install --yes --force-yes -y openssh-server
supervisord &
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=14" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

#Create the Dionaea container:
docker run -p 3306:3306 -p 42:42 -p 8081:80 -p 21:21 -p 1433:1433 -p 2443:443 -p 445:445 -p 5060:5060 -p 5061:5061 -p 135:135 -p 5060:5060/udp -p 69:69/udp --restart unless-stopped --name dionaea -h dionaea.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
supervisord &
apt-get install software-properties-common -y
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=4" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

#Create the Shockpot container:
docker run -p 8082:80 --restart unless-stopped --name shockpot -h shockpot.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
supervisord &

wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=15" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

#Create the conpot container:
docker run -p 82:80 -p 502:502 -p 102:102 -p 623:623/udp -p 47808:47808/udp -p 161:161/udp --restart unless-stopped --name conpot -h conpot.domain.local -t -i ubuntu:14.04.5 /bin/bash

#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
supervisord &

wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=9" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

#Create the elastichoney container:
docker run -p 9200:9200 --restart unless-stopped --name elastichoney -h elastichoney.domain.local -t -i ubuntu:14.04.5 /bin/bash
#In the docker container, run the following commands:

apt-get update
apt-get upgrade -y 
apt-get install git wget gcc supervisor -y 
supervisord &

wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=6" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>
wget "http://xxx.xxx.xxx.xxx/api/script/?text=true&script_id=16" -O deploy.sh && sudo bash deploy.sh http://xxx.xxx.xxx.xxx <KEY>

Step 4. ???

Step 5. Profit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants