From 91498f836ca5baccd4a39c219a21772470414eb9 Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Wed, 13 Apr 2016 20:32:35 +0400 Subject: [PATCH] harmonize artifact filenames. use transport + sessionid --- cowrie/core/honeypot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cowrie/core/honeypot.py b/cowrie/core/honeypot.py index 3cd45d4f..505531f5 100644 --- a/cowrie/core/honeypot.py +++ b/cowrie/core/honeypot.py @@ -36,8 +36,12 @@ class HoneyPotCommand(object): index = self.args.index(">") self.outfile = self.fs.resolve_path(str(self.args[(index + 1)]), self.protocol.cwd) del self.args[index:] - self.safeoutfile = '%s/%s_%s' % (self.protocol.cfg.get('honeypot', 'download_path'), - time.strftime('%Y%m%d%H%M%S'), re.sub('[^A-Za-z0-9]', '_', "tmpecho")) + self.safeoutfile = '%s/%s-%s-%s-redir_%s' % ( + self.protocol.cfg.get('honeypot', 'download_path'), + time.strftime('%Y%m%d-%H%M%S'), + self.protocol.terminal.transport.session.conn.transport.transportId, + self.protocol.terminal.transport.session.id, + re.sub('[^A-Za-z0-9]', '_', self.outfile)) perm = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH self.fs.mkfile(self.outfile, 0, 0, 0, stat.S_IFREG | perm) with open(self.safeoutfile, 'a'):