From 0eaf51c48e77e3908d0eb4caf2af910ebca32d8c Mon Sep 17 00:00:00 2001 From: desaster Date: Sun, 8 Apr 2012 16:41:34 +0000 Subject: [PATCH] Update the uptime command to display real uptime of the honeypot, and zero load. This closes issue #47 Also added a small change to ps output. git-svn-id: https://kippo.googlecode.com/svn/trunk@217 951d7100-d841-11de-b865-b3884708a8e2 --- kippo/commands/base.py | 15 ++++++++++----- kippo/core/honeypot.py | 11 ++++++++++- kippo/core/utils.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/kippo/commands/base.py b/kippo/commands/base.py index ceddab1..a720785 100644 --- a/kippo/commands/base.py +++ b/kippo/commands/base.py @@ -6,6 +6,7 @@ from kippo.core.honeypot import HoneyPotCommand from twisted.internet import reactor from kippo.core.config import config from kippo.core.userdb import UserDB +from kippo.core import utils commands = {} @@ -16,14 +17,17 @@ commands['/usr/bin/whoami'] = command_whoami 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' % \ - time.strftime('%H:%M:%S')) + if len(self.args): + secs = int(self.args[0]) + self.honeypot.uptime(time.time() - secs) + self.writeln(' %s up %s, 1 user, load average: 0.00, 0.00, 0.00' % \ + (time.strftime('%H:%M:%S'), utils.uptime(self.honeypot.uptime()))) commands['/usr/bin/uptime'] = command_uptime class command_w(HoneyPotCommand): def call(self): - 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(' %s up %s, 1 user, load average: 0.00, 0.00, 0.00' % \ + (time.strftime('%H:%M:%S'), utils.uptime(self.honeypot.uptime()))) self.writeln('USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT') self.writeln('%-8s pts/0 %s %s 0.00s 0.00s 0.00s w' % \ (self.honeypot.user.username, @@ -116,7 +120,7 @@ class command_ps(HoneyPotCommand): ('root ', '2110', ' 0.0', ' 0.0', ' 1764', ' 504', ' tty5 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty5',), ('root ', '2112', ' 0.0', ' 0.0', ' 1764', ' 508', ' tty6 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty6',), ('root ', '2133', ' 0.0', ' 0.1', ' 2180', ' 620', ' ? ', 'S 0: + s += str(days) + " " + (days == 1 and "day" or "days" ) + ", " + if len(s) > 0 or hours > 0: + s += '%s:%s' % (str(hours).rjust(2), str(minutes).rjust(2, '0')) + else: + s += '%s min' % (str(minutes)) + return s # vim: set sw=4 et: