mirror of
https://github.com/aljazceru/cowrie.git
synced 2026-02-23 07:14:24 +01:00
Callback changes
New command: ssh git-svn-id: https://kippo.googlecode.com/svn/trunk@16 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
@@ -141,13 +141,13 @@ class command_pwd(HoneyPotCommand):
|
||||
class command_passwd(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.terminal.write('Enter new UNIX password: ')
|
||||
self.honeypot.next_callback = callback_passwd1
|
||||
self.callback = callback_passwd1
|
||||
self.honeypot.password_input = True
|
||||
|
||||
class callback_passwd1(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.terminal.write('Retype new UNIX password: ')
|
||||
self.honeypot.next_callback = callback_passwd2
|
||||
self.callback = callback_passwd2
|
||||
|
||||
class callback_passwd2(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
|
||||
44
commands/ssh.py
Normal file
44
commands/ssh.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from core.Kippo import HoneyPotCommand
|
||||
|
||||
class command_ssh(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
if not len(args.strip()):
|
||||
for l in (
|
||||
'usage: ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]',
|
||||
' [-D [bind_address:]port] [-e escape_char] [-F configfile]',
|
||||
' [-i identity_file] [-L [bind_address:]port:host:hostport]',
|
||||
' [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]',
|
||||
' [-R [bind_address:]port:host:hostport] [-S ctl_path]',
|
||||
' [-w local_tun[:remote_tun]] [user@]hostname [command]',
|
||||
):
|
||||
self.honeypot.writeln(l)
|
||||
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.honeypot.terminal.write('Are you sure you want to continue connecting (yes/no)? ')
|
||||
self.callback = (callback_connect, args)
|
||||
|
||||
class callback_connect(HoneyPotCommand):
|
||||
def call(self, line, 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.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'
|
||||
self.honeypot.password_input = False
|
||||
self.honeypot.prompt = '%s:%%(path)s# ' % host
|
||||
@@ -67,10 +67,16 @@ class HoneyPotProtocol(recvline.HistoricRecvLine):
|
||||
if self.next_callback:
|
||||
print 'INPUT: %s' % line
|
||||
cmd = self.next_callback
|
||||
self.next_callback = None
|
||||
args = None
|
||||
if type(()) == type(cmd):
|
||||
cmd, args = cmd
|
||||
obj = cmd(self)
|
||||
try:
|
||||
obj.call(line)
|
||||
if args:
|
||||
obj.call(line, args)
|
||||
else:
|
||||
obj.call(line)
|
||||
self.next_callback = obj.callback
|
||||
del obj
|
||||
except Exception, e:
|
||||
print e
|
||||
@@ -86,6 +92,7 @@ class HoneyPotProtocol(recvline.HistoricRecvLine):
|
||||
if obj:
|
||||
try:
|
||||
obj.call(args)
|
||||
self.next_callback = obj.callback
|
||||
del obj
|
||||
except Exception, e:
|
||||
print e
|
||||
@@ -118,6 +125,7 @@ class HoneyPotProtocol(recvline.HistoricRecvLine):
|
||||
class HoneyPotCommand(object):
|
||||
def __init__(self, honeypot):
|
||||
self.honeypot = honeypot
|
||||
self.callback = None
|
||||
|
||||
def call(self, *args):
|
||||
self.honeypot.writeln('Hello World!')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from commands import base, ls, wget, tar
|
||||
from commands import base, ls, wget, tar, ssh
|
||||
|
||||
cmdl = {
|
||||
'/bin/echo': base.command_echo,
|
||||
@@ -21,6 +21,7 @@ cmdl = {
|
||||
'/usr/bin/vim': base.command_vi,
|
||||
'/usr/bin/id': base.command_id,
|
||||
'/usr/bin/passwd': base.command_passwd,
|
||||
'/usr/bin/ssh': ssh.command_ssh,
|
||||
'set': base.command_nop,
|
||||
'unset': base.command_nop,
|
||||
'history': base.command_nop,
|
||||
|
||||
Reference in New Issue
Block a user