more realistic looking ssh

git-svn-id: https://kippo.googlecode.com/svn/trunk@77 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster
2009-11-25 17:09:13 +00:00
parent 51da3b27fd
commit a3dd5c0d6e

View File

@@ -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