From 27cb7d4edacbf631eaae2c36a23c66c200b10a54 Mon Sep 17 00:00:00 2001 From: desaster Date: Wed, 18 Nov 2009 05:57:34 +0000 Subject: [PATCH] ssh improvements git-svn-id: https://kippo.googlecode.com/svn/trunk@22 951d7100-d841-11de-b865-b3884708a8e2 --- commands/ssh.py | 34 ++++++++++++++++++++++------------ core/Kippo.py | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/commands/ssh.py b/commands/ssh.py index 38fd948..d9ed661 100644 --- a/commands/ssh.py +++ b/commands/ssh.py @@ -1,4 +1,6 @@ from core.Kippo import HoneyPotCommand +from twisted.internet import reactor +import time class command_ssh(HoneyPotCommand): def start(self): @@ -11,35 +13,43 @@ class command_ssh(HoneyPotCommand): ' [-R [bind_address:]port:host:hostport] [-S ctl_path]', ' [-w local_tun[:remote_tun]] [user@]hostname [command]', ): - self.honeypot.writeln(l) - self.exit() - return + self.writeln(l) + self.exit() + return self.host = self.args.strip() - self.honeypot.writeln('The authenticity of host \'187.42.2.9 (187.42.2.9)\' can\'t be established.') - self.honeypot.writeln('RSA key fingerprint is 9d:30:97:8a:9e:48:0d:de:04:8d:76:3a:7b:4b:30:f8.') - self.honeypot.terminal.write('Are you sure you want to continue connecting (yes/no)? ') - self.callbacks = [self.yesno, self.finish] + self.writeln('The authenticity of host \'187.42.2.9 (187.42.2.9)\' can\'t be established.') + 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] def yesno(self, args): host = args.strip() - self.honeypot.writeln( + self.writeln( 'Warning: Permanently added \'%s\' (RSA) to the list of known hosts.' % \ host) - self.honeypot.terminal.write('%s\'s password: ' % self.host) + self.write('%s\'s password: ' % self.host) self.honeypot.password_input = True + def wait(self, line): + reactor.callLater(2, self.finish, line) + def finish(self, args): + self.pause = False user, rest, host = 'root', self.host, 'localhost' if self.host.count('@'): user, rest = self.host.split('@', 1) rest = rest.strip().split('.') if len(rest) and rest[0].isalpha(): host = rest[0] - self.honeypot.hostname = host self.honeypot.password_input = False + self.writeln( + 'Linux %s 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686' % \ + self.honeypot.hostname) + self.writeln('Last login: %s from 192.168.9.4' % \ + time.ctime(time.time() - 123123)) self.exit() def lineReceived(self, line): - print 'ssh input:', line - self.callbacks.pop(0)(line) + if len(self.callbacks): + self.callbacks.pop(0)(line) diff --git a/core/Kippo.py b/core/Kippo.py index d37ea76..bb29359 100644 --- a/core/Kippo.py +++ b/core/Kippo.py @@ -18,6 +18,8 @@ class HoneyPotCommand(object): def __init__(self, honeypot, args): self.honeypot = honeypot self.args = args + self.writeln = self.honeypot.writeln + self.write = self.honeypot.terminal.write def start(self): self.call(self.args)