mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-17 14:04:28 +01:00
ssh improvements
git-svn-id: https://kippo.googlecode.com/svn/trunk@22 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
from core.Kippo import HoneyPotCommand
|
from core.Kippo import HoneyPotCommand
|
||||||
|
from twisted.internet import reactor
|
||||||
|
import time
|
||||||
|
|
||||||
class command_ssh(HoneyPotCommand):
|
class command_ssh(HoneyPotCommand):
|
||||||
def start(self):
|
def start(self):
|
||||||
@@ -11,35 +13,43 @@ class command_ssh(HoneyPotCommand):
|
|||||||
' [-R [bind_address:]port:host:hostport] [-S ctl_path]',
|
' [-R [bind_address:]port:host:hostport] [-S ctl_path]',
|
||||||
' [-w local_tun[:remote_tun]] [user@]hostname [command]',
|
' [-w local_tun[:remote_tun]] [user@]hostname [command]',
|
||||||
):
|
):
|
||||||
self.honeypot.writeln(l)
|
self.writeln(l)
|
||||||
self.exit()
|
self.exit()
|
||||||
return
|
return
|
||||||
self.host = self.args.strip()
|
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.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.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.write('Are you sure you want to continue connecting (yes/no)? ')
|
||||||
self.callbacks = [self.yesno, self.finish]
|
self.callbacks = [self.yesno, self.wait]
|
||||||
|
|
||||||
def yesno(self, args):
|
def yesno(self, args):
|
||||||
host = args.strip()
|
host = args.strip()
|
||||||
self.honeypot.writeln(
|
self.writeln(
|
||||||
'Warning: Permanently added \'%s\' (RSA) to the list of known hosts.' % \
|
'Warning: Permanently added \'%s\' (RSA) to the list of known hosts.' % \
|
||||||
host)
|
host)
|
||||||
self.honeypot.terminal.write('%s\'s password: ' % self.host)
|
self.write('%s\'s password: ' % self.host)
|
||||||
self.honeypot.password_input = True
|
self.honeypot.password_input = True
|
||||||
|
|
||||||
|
def wait(self, line):
|
||||||
|
reactor.callLater(2, self.finish, line)
|
||||||
|
|
||||||
def finish(self, args):
|
def finish(self, args):
|
||||||
|
self.pause = False
|
||||||
user, rest, host = 'root', self.host, 'localhost'
|
user, rest, host = 'root', self.host, 'localhost'
|
||||||
if self.host.count('@'):
|
if self.host.count('@'):
|
||||||
user, rest = self.host.split('@', 1)
|
user, rest = self.host.split('@', 1)
|
||||||
rest = rest.strip().split('.')
|
rest = rest.strip().split('.')
|
||||||
if len(rest) and rest[0].isalpha():
|
if len(rest) and rest[0].isalpha():
|
||||||
host = rest[0]
|
host = rest[0]
|
||||||
|
|
||||||
self.honeypot.hostname = host
|
self.honeypot.hostname = host
|
||||||
self.honeypot.password_input = False
|
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()
|
self.exit()
|
||||||
|
|
||||||
def lineReceived(self, line):
|
def lineReceived(self, line):
|
||||||
print 'ssh input:', line
|
if len(self.callbacks):
|
||||||
self.callbacks.pop(0)(line)
|
self.callbacks.pop(0)(line)
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class HoneyPotCommand(object):
|
|||||||
def __init__(self, honeypot, args):
|
def __init__(self, honeypot, args):
|
||||||
self.honeypot = honeypot
|
self.honeypot = honeypot
|
||||||
self.args = args
|
self.args = args
|
||||||
|
self.writeln = self.honeypot.writeln
|
||||||
|
self.write = self.honeypot.terminal.write
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.call(self.args)
|
self.call(self.args)
|
||||||
|
|||||||
Reference in New Issue
Block a user