diff --git a/cowrie/core/protocol.py b/cowrie/core/protocol.py index 5a5aae5..3942359 100644 --- a/cowrie/core/protocol.py +++ b/cowrie/core/protocol.py @@ -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)