mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-17 14:04:28 +01:00
Reimplement running commands in a bit more sane way - should allow for easier
interactive commands (eg. passwd). Fix history (uparrow) git-svn-id: https://kippo.googlecode.com/svn/trunk@20 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from core.Kippo import HoneyPotCommand
|
||||
|
||||
class command_ssh(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
if not len(args.strip()):
|
||||
def start(self):
|
||||
if not len(self.args.strip()):
|
||||
for l in (
|
||||
'usage: ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]',
|
||||
' [-D [bind_address:]port] [-e escape_char] [-F configfile]',
|
||||
@@ -12,33 +12,34 @@ class command_ssh(HoneyPotCommand):
|
||||
' [-w local_tun[:remote_tun]] [user@]hostname [command]',
|
||||
):
|
||||
self.honeypot.writeln(l)
|
||||
self.exit()
|
||||
return
|
||||
self.honeypot.writeln('The authenticity of host \'127.0.0.4 (127.0.0.4)\' can\'t be established.')
|
||||
self.honeypot.writeln('RSA key fingerprint is 9c:30:97:8e:9e:f8:0d:de:04:8d:76:3a:7b:4b:30:f8.')
|
||||
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.callback = (callback_connect, args)
|
||||
self.callbacks = [self.yesno, self.finish]
|
||||
|
||||
class callback_connect(HoneyPotCommand):
|
||||
def call(self, line, args):
|
||||
def yesno(self, args):
|
||||
host = args.strip()
|
||||
self.honeypot.writeln(
|
||||
'Warning: Permanently added \'%s\' (RSA) to the list of known hosts.' % \
|
||||
host)
|
||||
self.honeypot.terminal.write('%s\'s password: ' % args)
|
||||
self.honeypot.terminal.write('%s\'s password: ' % self.host)
|
||||
self.honeypot.password_input = True
|
||||
self.callback = (callback_done, args)
|
||||
|
||||
class callback_done(HoneyPotCommand):
|
||||
def call(self, line, args):
|
||||
user = 'root'
|
||||
if args.count('@'):
|
||||
user, rest = args.split('@', 1)
|
||||
else:
|
||||
rest = args
|
||||
host = rest.strip().split('.')
|
||||
if len(host) and host[0].isalpha():
|
||||
host = host[0]
|
||||
else:
|
||||
host = 'localhost'
|
||||
def finish(self, args):
|
||||
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.honeypot.prompt = '%s:%%(path)s# ' % host
|
||||
self.exit()
|
||||
|
||||
def lineReceived(self, line):
|
||||
print 'ssh input:', line
|
||||
self.callbacks.pop(0)(line)
|
||||
|
||||
Reference in New Issue
Block a user