diff --git a/kippo/commands/ssh.py b/kippo/commands/ssh.py index cc94ce0..492e83d 100644 --- a/kippo/commands/ssh.py +++ b/kippo/commands/ssh.py @@ -3,7 +3,7 @@ from kippo.core.honeypot import HoneyPotCommand from twisted.internet import reactor -import time +import time, re, md5 commands = {} @@ -21,8 +21,23 @@ class command_ssh(HoneyPotCommand): self.writeln(l) self.exit() return - self.host = self.args[0].strip() - self.writeln('The authenticity of host \'187.42.2.9 (187.42.2.9)\' can\'t be established.') + arg = self.args[0].strip() + if arg.count('@'): + user, host = arg.split('@', 1) + else: + user, host = 'root', arg + + if re.match('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', host): + self.ip = host + else: + s = md5.md5(host).hexdigest() + self.ip = '.'.join([str(int(x, 16)) for x in + (s[0:2], s[2:4], s[4:6], s[6:8])]) + self.host = host + self.user = user + + self.writeln('The authenticity of host \'%s (%s)\' can\'t be established.' % \ + (self.host, self.ip)) self.writeln('RSA key fingerprint is 9d:30:97:8a:9e:48:0d:de:04:8d:76:3a:7b:4b:30:f8.') self.write('Are you sure you want to continue connecting (yes/no)? ') self.callbacks = [self.yesno, self.wait] @@ -32,7 +47,7 @@ class command_ssh(HoneyPotCommand): self.writeln( 'Warning: Permanently added \'%s\' (RSA) to the list of known hosts.' % \ host) - self.write('%s\'s password: ' % self.host) + self.write('%s@%s\'s password: ' % (self.user, self.host)) self.honeypot.password_input = True def wait(self, line): @@ -40,10 +55,8 @@ class command_ssh(HoneyPotCommand): def finish(self, line): self.pause = False - user, rest, host = 'root', self.host, 'localhost' - if self.host.count('@'): - user, rest = self.host.split('@', 1) - rest = rest.strip().split('.') + rest, host = self.host, 'localhost' + rest = self.host.strip().split('.') if len(rest) and rest[0].isalpha(): host = rest[0] self.honeypot.hostname = host