mirror of https://github.com/cowrie/cowrie.git
Report actual path in redir event (#520)
This commit is contained in:
parent
e13286a768
commit
e81fa0284b
|
@ -204,7 +204,10 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
|
||||||
obj.start()
|
obj.start()
|
||||||
if hasattr(obj, 'safeoutfile'):
|
if hasattr(obj, 'safeoutfile'):
|
||||||
if obj.safeoutfile:
|
if obj.safeoutfile:
|
||||||
self.terminal.redirFiles.add(obj.safeoutfile)
|
if hasattr(obj, 'outfile'):
|
||||||
|
self.terminal.redirFiles.add((obj.safeoutfile, obj.outfile))
|
||||||
|
else:
|
||||||
|
self.terminal.redirFiles.add((obj.safeoutfile, ''))
|
||||||
if self.pp:
|
if self.pp:
|
||||||
self.pp.outConnectionLost()
|
self.pp.outConnectionLost()
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
|
||||||
"""
|
"""
|
||||||
stdinlogOpen = False
|
stdinlogOpen = False
|
||||||
ttylogOpen = False
|
ttylogOpen = False
|
||||||
|
redirlogOpen = False # it will be set at core/protocol.py
|
||||||
|
|
||||||
def __init__(self, prot=None, *a, **kw):
|
def __init__(self, prot=None, *a, **kw):
|
||||||
insults.ServerProtocol.__init__(self, prot, *a, **kw)
|
insults.ServerProtocol.__init__(self, prot, *a, **kw)
|
||||||
|
@ -163,7 +164,15 @@ class LoggingServerProtocol(insults.ServerProtocol):
|
||||||
self.stdinlogOpen = False
|
self.stdinlogOpen = False
|
||||||
|
|
||||||
if self.redirFiles:
|
if self.redirFiles:
|
||||||
for rf in self.redirFiles:
|
for rp in self.redirFiles:
|
||||||
|
|
||||||
|
rf = rp[0]
|
||||||
|
|
||||||
|
if rp[1]:
|
||||||
|
url = rp[1]
|
||||||
|
else:
|
||||||
|
url = rf[rf.find('redir_')+len('redir_'):]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(rf):
|
if not os.path.exists(rf):
|
||||||
continue
|
continue
|
||||||
|
@ -183,7 +192,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
|
||||||
os.symlink(shasum, rf)
|
os.symlink(shasum, rf)
|
||||||
log.msg(eventid='cowrie.session.file_download',
|
log.msg(eventid='cowrie.session.file_download',
|
||||||
format='Saved redir contents with SHA-256 %(shasum)s to %(outfile)s',
|
format='Saved redir contents with SHA-256 %(shasum)s to %(outfile)s',
|
||||||
url='redir',
|
url=url,
|
||||||
outfile=shasumfile,
|
outfile=shasumfile,
|
||||||
shasum=shasum)
|
shasum=shasum)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
Loading…
Reference in New Issue