mirror of https://github.com/cowrie/cowrie.git
prettier commands
git-svn-id: https://kippo.googlecode.com/svn/trunk@23 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
parent
27cb7d4eda
commit
5c0191e28b
|
@ -4,22 +4,21 @@ from core.fstypes import *
|
|||
|
||||
class command_whoami(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln(self.honeypot.user.username)
|
||||
self.writeln(self.honeypot.user.username)
|
||||
|
||||
class command_cat(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
path = self.honeypot.fs.resolve_path(args, self.honeypot.cwd)
|
||||
|
||||
if not path or not self.honeypot.fs.exists(path):
|
||||
self.honeypot.writeln(
|
||||
'bash: cat: %s: No such file or directory' % args)
|
||||
self.writeln('bash: cat: %s: No such file or directory' % args)
|
||||
return
|
||||
|
||||
fakefile = './honeyfs/%s' % path
|
||||
if os.path.exists(fakefile) and \
|
||||
not os.path.islink(fakefile) and os.path.isfile(fakefile):
|
||||
f = file(fakefile, 'r')
|
||||
self.honeypot.terminal.write(f.read())
|
||||
self.write(f.read())
|
||||
f.close()
|
||||
|
||||
class command_cd(HoneyPotCommand):
|
||||
|
@ -34,8 +33,7 @@ class command_cd(HoneyPotCommand):
|
|||
newdir = None
|
||||
|
||||
if newdir is None:
|
||||
self.honeypot.writeln(
|
||||
'bash: cd: %s: No such file or directory' % args)
|
||||
self.writeln('bash: cd: %s: No such file or directory' % args)
|
||||
return
|
||||
self.honeypot.cwd = newpath
|
||||
|
||||
|
@ -46,7 +44,7 @@ class command_rm(HoneyPotCommand):
|
|||
try:
|
||||
dir = self.honeypot.fs.get_path('/'.join(path.split('/')[:-1]))
|
||||
except IndexError:
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
'rm: cannot remove `%s\': No such file or directory' % f)
|
||||
continue
|
||||
basename = path.split('/')[-1]
|
||||
|
@ -54,7 +52,7 @@ class command_rm(HoneyPotCommand):
|
|||
for i in dir[:]:
|
||||
if i[A_NAME] == basename:
|
||||
if i[A_TYPE] == T_DIR:
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
'rm: cannot remove `%s\': Is a directory' % \
|
||||
i[A_NAME])
|
||||
else:
|
||||
|
@ -67,38 +65,38 @@ class command_mkdir(HoneyPotCommand):
|
|||
try:
|
||||
dir = self.honeypot.fs.get_path('/'.join(path.split('/')[:-1]))
|
||||
except IndexError:
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
'mkdir: cannot create directory `%s\': ' % f + \
|
||||
'No such file or directory')
|
||||
return
|
||||
if f in [x[A_NAME] for x in dir]:
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
'mkdir: cannot create directory `test\': File exists')
|
||||
return
|
||||
dir.append([f, T_DIR, 0, 0, 4096, 16877, time.time(), [], None])
|
||||
|
||||
class command_uptime(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
' %s up 14 days, 3:53, 0 users, load average: 0.08, 0.02, 0.01' % \
|
||||
time.strftime('%T'))
|
||||
#self.honeypot.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT')
|
||||
#self.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT')
|
||||
|
||||
class command_w(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln(
|
||||
self.writeln(
|
||||
' %s up 14 days, 3:53, 0 users, load average: 0.08, 0.02, 0.01' % \
|
||||
time.strftime('%T'))
|
||||
self.honeypot.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT')
|
||||
self.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT')
|
||||
|
||||
class command_echo(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln(args)
|
||||
self.writeln(args)
|
||||
|
||||
class command_quit(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.terminal.reset()
|
||||
self.honeypot.writeln('Connection to server closed.')
|
||||
self.writeln('Connection to server closed.')
|
||||
self.honeypot.hostname = 'localhost'
|
||||
|
||||
class command_clear(HoneyPotCommand):
|
||||
|
@ -107,18 +105,18 @@ class command_clear(HoneyPotCommand):
|
|||
|
||||
class command_vi(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln('E558: Terminal entry not found in terminfo')
|
||||
self.writeln('E558: Terminal entry not found in terminfo')
|
||||
|
||||
class command_uname(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
if args.strip() == '-a':
|
||||
self.honeypot.writeln('Linux sales 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux')
|
||||
self.writeln('Linux sales 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux')
|
||||
else:
|
||||
self.honeypot.writeln('Linux')
|
||||
self.writeln('Linux')
|
||||
|
||||
class command_id(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln('uid=0(root) gid=0(root) groups=0(root)')
|
||||
self.writeln('uid=0(root) gid=0(root) groups=0(root)')
|
||||
|
||||
class command_mount(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
|
@ -133,27 +131,27 @@ class command_mount(HoneyPotCommand):
|
|||
'tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)',
|
||||
'devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)',
|
||||
]:
|
||||
self.honeypot.writeln(i)
|
||||
self.writeln(i)
|
||||
|
||||
class command_pwd(HoneyPotCommand):
|
||||
def call(self, args):
|
||||
self.honeypot.writeln(self.honeypot.cwd)
|
||||
self.writeln(self.honeypot.cwd)
|
||||
|
||||
class command_passwd(HoneyPotCommand):
|
||||
def start(self):
|
||||
self.honeypot.terminal.write('Enter new UNIX password: ')
|
||||
self.write('Enter new UNIX password: ')
|
||||
self.honeypot.password_input = True
|
||||
self.callbacks = [self.ask_again, self.finish]
|
||||
|
||||
def ask_again(self):
|
||||
self.honeypot.terminal.write('Retype new UNIX password: ')
|
||||
self.write('Retype new UNIX password: ')
|
||||
|
||||
def finish(self):
|
||||
self.honeypot.password_input = False
|
||||
self.honeypot.writeln('Sorry, passwords do not match')
|
||||
self.honeypot.writeln(
|
||||
self.writeln('Sorry, passwords do not match')
|
||||
self.writeln(
|
||||
'passwd: Authentication information cannot be recovered')
|
||||
self.honeypot.writeln('passwd: password unchanged')
|
||||
self.writeln('passwd: password unchanged')
|
||||
self.exit()
|
||||
|
||||
def lineReceived(self, line):
|
||||
|
|
Loading…
Reference in New Issue