* show client ip address in "w"

* a little shell tweak


git-svn-id: https://kippo.googlecode.com/svn/trunk@79 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
desaster
2009-11-25 19:02:16 +00:00
parent 6b1120824a
commit 04fd72b436
2 changed files with 14 additions and 5 deletions

View File

@@ -117,17 +117,18 @@ commands['/bin/rmdir'] = command_rmdir
class command_uptime(HoneyPotCommand):
def call(self):
self.writeln(
' %s up 14 days, 3:53, 0 users, load average: 0.08, 0.02, 0.01' % \
self.writeln(' %s up 14 days, 3:53, 0 users, load average: 0.08, 0.02, 0.01' % \
time.strftime('%H:%M:%S'))
commands['/usr/bin/uptime'] = command_uptime
class command_w(HoneyPotCommand):
def call(self):
self.writeln(
' %s up 14 days, 3:53, 0 users, load average: 0.08, 0.02, 0.01' % \
self.writeln(' %s up 14 days, 3:53, 1 user, load average: 0.08, 0.02, 0.01' % \
time.strftime('%H:%M:%S'))
self.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT')
self.writeln('root pts/0 %s %s 0.00s 0.00s 0.00s w' % \
(self.honeypot.clientIP[:17].ljust(17),
time.strftime('%H:%M', time.localtime(self.honeypot.logintime))))
commands['/usr/bin/w'] = command_w
commands['/usr/bin/who'] = command_w

View File

@@ -98,6 +98,9 @@ class HoneyPotShell(object):
else:
if len(i):
self.honeypot.writeln('bash: %s: command not found' % cmd)
if len(self.cmdpending):
self.runCommand()
else:
self.showPrompt()
def resume(self):
@@ -134,6 +137,11 @@ class HoneyPotProtocol(recvline.HistoricRecvLine):
recvline.HistoricRecvLine.connectionMade(self)
self.cmdstack = [HoneyPotShell(self)]
# You are in a maze of twisty little passages, all alike
p = self.terminal.transport.session.conn.transport.transport.getPeer()
self.clientIP = p[1]
self.logintime = time.time()
def connectionLost(self, reason):
recvline.HistoricRecvLine.connectionLost(self, reason)
# not sure why i need to do this: