mirror of
https://github.com/aljazceru/cowrie.git
synced 2026-01-06 07:44:28 +01:00
limt download size
This commit is contained in:
@@ -375,6 +375,12 @@ class LoggingServerProtocol(insults.ServerProtocol):
|
||||
def __init__(self, prot=None, *a, **kw):
|
||||
insults.ServerProtocol.__init__(self, prot, *a, **kw)
|
||||
self.cfg = a[0].cfg
|
||||
self.dataReceived = 0
|
||||
|
||||
try:
|
||||
self.dataReceivedLimit = int(self.cfg.get('honeypot', 'download_limit_size'))
|
||||
except:
|
||||
self.dataReceivedLimit = 0
|
||||
|
||||
|
||||
def connectionMade(self):
|
||||
@@ -417,6 +423,10 @@ class LoggingServerProtocol(insults.ServerProtocol):
|
||||
def dataReceived(self, data):
|
||||
"""
|
||||
"""
|
||||
self.dataReceived += len(data)
|
||||
if self.dataReceivedLimit and self.dataReceived > self.dataReceivedLimit:
|
||||
self.transport.loseConnection()
|
||||
|
||||
if self.stdinlog_open:
|
||||
with file(self.stdinlog_file, 'ab') as f:
|
||||
f.write(data)
|
||||
|
||||
Reference in New Issue
Block a user