mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-19 06:54:19 +01:00
last improvements + last now uses a plain text file instead of anydbm
git-svn-id: https://kippo.googlecode.com/svn/trunk@150 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
@@ -11,14 +11,21 @@ commands = {}
|
||||
|
||||
class command_last(HoneyPotCommand):
|
||||
def call(self):
|
||||
db = anydbm.open('%s/lastlog.db' % \
|
||||
config().get('honeypot', 'data_path'), 'c')
|
||||
count = 0
|
||||
for k in sorted(db.keys(), key=int, reverse=True):
|
||||
self.writeln(db[k])
|
||||
count += 1
|
||||
if count >= 25:
|
||||
break
|
||||
fn = '%s/lastlog.txt' % (config().get('honeypot', 'data_path'),)
|
||||
if not os.path.exists(fn):
|
||||
return
|
||||
l = list(self.args)
|
||||
numlines = 25
|
||||
while len(l):
|
||||
arg = l.pop(0)
|
||||
if not arg.startswith('-'):
|
||||
continue
|
||||
elif arg[1:].isdigit():
|
||||
numlines = int(arg[1:])
|
||||
elif arg == '-n' and len(l) and l[0].isdigit():
|
||||
numlines = int(l.pop(0))
|
||||
data = utils.tail(file(fn), numlines)
|
||||
self.writeln(''.join(data))
|
||||
commands['/usr/bin/last'] = command_last
|
||||
|
||||
# vim: set sw=4 et:
|
||||
|
||||
Reference in New Issue
Block a user