tnich/honssh

Errors with Docker customisation

unixfox opened this issue · 21 comments

Related to this commit: f3c9e60


Since the customisation of the docker container, I can't launch honSSH without completing the fields inside the honssh.cfg.
The validation obliges/requires me to fill the fields:

[VALIDATION] - [honeypot-docker][shm_size] must not be blank.
[VALIDATION] - [honeypot-docker][cpu_period] must not be blank.

Strangly according to the configuration, it isn't required to fill the fiels (https://github.com/tnich/honssh/blob/master/honssh.cfg.default#L168) and it worked like this when I tested this pull request with a friend: #91

tnich commented

Sorry, got rid of the extra validation, fixed now.

Thank you but I'm getting this error after launching honSSH:

2016-11-06T17:52:25+0100 [honssh.server.HonsshServerFactory] [PLUGIN][HONEYPOT-DOCKER] - GET_PRE_AUTH_DETAILS
2016-11-06T17:52:25+0100 [honssh.server.HonsshServerFactory] [PLUGIN][HONEYPOT-DOCKER][ERR] - invalid literal for int() with base 10: ''
tnich commented

Any idea which config item is doing it?

@tnich I'll try to diagnostic by removing and adding the value of each fields.

tnich commented

Thank you 😄

I removed every fields related to docker customisation:

#-----------------------#
#   HONEYPOT DOCKER     #
#-----------------------#
[honeypot-docker]
# Documentation to come
enabled = true

# Should HonSSH use this plugin to get the honeypot details (before authentication)
pre-auth = true

# Should HonSSH use this plugin to get the honeypot details (after authentication)
post-auth = true

# image: image id/name to use for honeypot container
# required: if enabled = true
image = rastasheep/ubuntu-sshd:14.04

# uri: socket to interact with container daemon
# required: if enabled = true
# default: unix://var/run/docker.sock
uri = unix://var/run/docker.sock

# honey_hostname: the hostname for the container
# required: if enabled = true
hostname = digitalocean

# launch_cmd: command to run when container is first launched
# required: if enabled = true
# default = service ssh start
launch_cmd = echo connected

# SSH port of the honeypot.
#
# input: Number
# required: YES
# default: 22
honey_port = 22

# Pid limit of the honeypot (-1 for unlimited)
#
# input: Number
# required: NO
# default: -1
pids_limit =

# Memory limit of the honeypot
# Example: 1G
#
# required: NO
mem_limit =

# Swap limit of the honeypot
# Example: 1G
#
# required: NO
memswap_limit =

# Shm size limit of the honeypot
# Example: 1G
#
# required: NO
shm_size =

# Microseconds of CPU time that the container can get in a CPU period of the honeypot
#
# input: Number
# required: NO
cpu_period =

# CPU shares (relative weight) of the honeypot
# Example: Percentage * value of cat /sys/fs/cgroup/cpu/docker/cpu.shares
#
# required: NO
cpu_shares =

# CPUs in which to allow execution of the honeypot
# Example: 0-3, 0,1
#
# required: NO
cpuset_cpus =

But I'm getting the same error message. I had the same error when I tried the modifications @DeltaEvolution with him. I'll poke him to reply here.

@tnich you have added some properties to validate_config, but these are not required
https://github.com/tnich/honssh/blob/master/honssh/honeypot/honeypot-docker.py#L91

tnich commented

Yeah, I realized that, I've got rid of them in the last commit.

I guess a '' is being passed to connection.create_host_config and it doesn't like it?

tnich commented

What about the strings?

There is an error here no ? https://github.com/tnich/honssh/blob/master/honssh/config.py#L126 the is_digit with int() ?
Edit: it's the error, in python print int(True) and print int(False) work so the check_valid_number dosen't work

tnich commented

Whoops, yeah thanks, I have removed the is_digit. I don't have docker setup on this computer, so can't test it myself currently.

tnich commented

Just set up Docker and it seems to be behaving again. Thanks for you assistance @unixfox and @DeltaEvolution.

@tnich Are you sure?
I'm getting another weird error
:

2016-11-06T19:47:53+0100 [-] Loading honssh.tac...
2016-11-06T19:47:54+0100 [-] [PLUGIN][OUTPUT-TXTLOG] - VALIDATE_CONFIG
2016-11-06T19:47:54+0100 [-] [PLUGIN][OUTPUT-CONTRIBUTE] - VALIDATE_CONFIG
2016-11-06T19:47:54+0100 [-] [PLUGIN][HONEYPOT-DOCKER] - VALIDATE_CONFIG
2016-11-06T19:47:54+0100 [-] [SERVER] - Using ssh_banner for SSH Version String: SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u3
2016-11-06T19:47:54+0100 [-] [HONSSH] - HonSSH Boot Sequence Complete - Ready for attacks!
2016-11-06T19:47:54+0100 [-] Loaded.
2016-11-06T19:47:54+0100 [twisted.scripts._twistd_unix.UnixAppLogger#info] twistd 16.5.0 (/usr/bin/python 2.7.12) starting up.
2016-11-06T19:47:54+0100 [twisted.scripts._twistd_unix.UnixAppLogger#info] reactor class: twisted.internet.epollreactor.EPollReactor.
2016-11-06T19:47:54+0100 [-] HonsshServerFactory starting on 22
2016-11-06T19:47:54+0100 [honssh.server.HonsshServerFactory#info] Starting factory <honssh.server.HonsshServerFactory instance at 0x7f1430363fc8>
2016-11-06T19:47:54+0100 [-] Factory starting on 5123
2016-11-06T19:47:54+0100 [twisted.internet.protocol.Factory#info] Starting factory <twisted.internet.protocol.Factory instance at 0x7f1430327e18>
2016-11-06T19:47:56+0100 [honssh.server.HonsshServerFactory] [PLUGIN][HONEYPOT-DOCKER] - GET_PRE_AUTH_DETAILS
2016-11-06T19:47:56+0100 [stdout#info] [VALIDATION] - [honeypot-docker][cpu_period] should be number.
2016-11-06T19:47:56+0100 [stdout#info] [VALIDATION] - [honeypot-docker][cpu_shares] should be number.
2016-11-06T19:47:56+0100 [HonsshServerTransport,0,62.235.25.147] kex alg, key alg: 'diffie-hellman-group14-sha1' 'ssh-rsa'
2016-11-06T19:47:56+0100 [HonsshServerTransport,0,62.235.25.147] outgoing: 'aes128-ctr' 'hmac-sha1' 'none'
2016-11-06T19:47:56+0100 [HonsshServerTransport,0,62.235.25.147] incoming: 'aes128-ctr' 'hmac-sha1' 'none'
2016-11-06T19:47:56+0100 [HonsshServerTransport,0,62.235.25.147] NEW KEYS
2016-11-06T19:47:56+0100 [HonsshServerTransport,0,62.235.25.147] [SERVER] - CONNECTION TO HONEYPOT NOT READY, BUFFERING PACKET
2016-11-06T19:47:57+0100 [honssh.server.HonsshServerFactory] [PLUGIN][HONEYPOT-DOCKER][ERR] - 
2016-11-06T19:47:57+0100 [-] [PRE_AUTH][ERROR] - PLUGIN ERROR - DISCONNECTING ATTACKER
2016-11-06T19:47:57+0100 [-] Disconnecting with error, code 10
    reason: user closed connection

My configuration: http://hastebin.com/uwecacepev.ini

nvm, I forgot to add a field inside my configuration.

tnich commented

😄

hi can anyone help me how to solve this error

honsshctrl.sh[15102]: Starting honssh in background...
2017-08-13 10:01:12+0000 [-] Log opened.
2017-08-13 10:01:12+0000 [-] twistd 13.2.0 (/usr/bin/python 2.7.6) starting up.
2017-08-13 10:01:12+0000 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2017-08-13 10:01:12+0000 [-] HonsshServerFactory starting on 2222
2017-08-13 10:01:12+0000 [-] Starting factory <honssh.server.HonsshServerFactory instance at 0x7f3616ab2d40>
2017-08-13 10:01:26+0000 [-] [PRE_AUTH][ERROR] - PLUGIN ERROR - DISCONNECTING ATTACKER
2017-08-13 10:01:26+0000 [-] Disconnecting with error, code 10
reason: user closed connection
2017-08-13 10:01:26+0000 [HonsshServerTransport,0,45.242.210.107] connection lost
2017-08-13 10:05:32+0000 [-] [PRE_AUTH][ERROR] - PLUGIN ERROR - DISCONNECTING ATTACKER
2017-08-13 10:05:32+0000 [-] Disconnecting with error, code 10
reason: user closed connection
2017-08-13 10:05:32+0000 [HonsshServerTransport,1,45.242.249.26] connection lost
2017-08-13 10:14:44+0000 [-] Received SIGTERM, shutting down.
2017-08-13 10:14:44+0000 [-] (TCP Port 2222 Closed)
2017-08-13 10:14:44+0000 [-] Stopping factory <honssh.server.HonsshServerFactory instance at 0x7f3616ab2d40>
2017-08-13 10:14:44+0000 [-] Main loop terminated.
2017-08-13 10:14:44+0000 [-] Server Shut Down.
2017-08-13 10:14:48+0000 [-] Log opened.
2017-08-13 10:14:48+0000 [-] twistd 13.2.0 (/usr/bin/python 2.7.6) starting up.
2017-08-13 10:14:48+0000 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2017-08-13 10:14:48+0000 [-] HonsshServerFactory starting on 2222
2017-08-13 10:14:48+0000 [-] Starting factory <honssh.server.HonsshServerFactory instance at 0x7f8c39a2ed40>
2017-08-13 10:15:02+0000 [-] [PRE_AUTH][ERROR] - PLUGIN ERROR - DISCONNECTING ATTACKER
2017-08-13 10:15:02+0000 [-] Disconnecting with error, code 10
reason: user closed connection
2017-08-13 10:15:02+0000 [HonsshServerTransport,0,45.242.249.26] connection lost

tnich commented

Hi,

It looks like your pre auth plugin is failing. Can you email me your configuration file and what you are trying to achieve and I'll try and find time to look into it.

Also, if you're the same person that emailed me a while ago and I didn't reply, sorry!

tnich commented

Have you tried just doing a static deployment with honssh, without docker?
If you've just started with honeypots, this may be a good place to start.

Have you tested docker is working locally on the honssh box?