mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
Added Redirection code.
This commit is contained in:
@ -9,6 +9,7 @@ import os
|
|||||||
import shlex
|
import shlex
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
|
|
||||||
from twisted.python import log, failure
|
from twisted.python import log, failure
|
||||||
|
|
||||||
@ -24,11 +25,45 @@ class HoneyPotCommand(object):
|
|||||||
self.protocol = protocol
|
self.protocol = protocol
|
||||||
self.args = args
|
self.args = args
|
||||||
self.environ = self.protocol.cmdstack[0].environ
|
self.environ = self.protocol.cmdstack[0].environ
|
||||||
self.writeln = self.protocol.writeln
|
self.writeln = self.writeln
|
||||||
self.write = self.protocol.terminal.write
|
self.write = self.write
|
||||||
self.nextLine = self.protocol.terminal.nextLine
|
self.nextLine = self.protocol.terminal.nextLine
|
||||||
self.fs = self.protocol.fs
|
self.fs = self.protocol.fs
|
||||||
|
|
||||||
|
def write(self,data):
|
||||||
|
if ">" in self.args:
|
||||||
|
try:
|
||||||
|
self.writeToFile(data,"")
|
||||||
|
except:
|
||||||
|
self.protocol.terminal.write(data)
|
||||||
|
else:
|
||||||
|
self.protocol.terminal.write(data)
|
||||||
|
|
||||||
|
def writeToFile(self,data,line):
|
||||||
|
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"))
|
||||||
|
|
||||||
|
index = self.args.index(">")
|
||||||
|
data = data.replace(" > ","")
|
||||||
|
data = data.replace(self.args[(index+1)],"")
|
||||||
|
file = open(safeoutfile, "a")
|
||||||
|
file.write(data + line)
|
||||||
|
file.close()
|
||||||
|
outfile = self.fs.resolve_path(str(self.args[(index + 1)]), self.protocol.cwd)
|
||||||
|
self.fs.mkfile(outfile, 0, 0, len(data), 33188)
|
||||||
|
self.fs.update_realfile(self.fs.getfile(outfile), safeoutfile)
|
||||||
|
|
||||||
|
def writeln(self, data):
|
||||||
|
if ">" in self.args:
|
||||||
|
try:
|
||||||
|
self.writeToFile(data,"\n")
|
||||||
|
except:
|
||||||
|
self.protocol.writeln(data)
|
||||||
|
else:
|
||||||
|
self.protocol.writeln(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user