From d602ac4b46af08913e0dcaf8a6098a858905635a Mon Sep 17 00:00:00 2001 From: davegermiquet Date: Thu, 2 Jun 2016 17:56:54 -0400 Subject: [PATCH 1/2] ADD IF CONDITION In case connection was lost, or something happens to write terminal to be null --- cowrie/core/honeypot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cowrie/core/honeypot.py b/cowrie/core/honeypot.py index 66bba5be..6e25722f 100644 --- a/cowrie/core/honeypot.py +++ b/cowrie/core/honeypot.py @@ -484,7 +484,9 @@ class StdOutStdErrEmulationProtocol(object): """ self.data = self.data + data if not self.next_protocol: - self.protocol.terminal.write(data) + if not self.protocol is None and not self.protocol.terminal is None: + log.msg("Connection was probably lost. Could not write to terminal") + self.protocol.terminal.write(data) def errReceived(self, data): From 4a485074919c0a123c5d7f7febbee7345f4a5c9d Mon Sep 17 00:00:00 2001 From: davegermiquet Date: Thu, 2 Jun 2016 18:52:05 -0400 Subject: [PATCH 2/2] Fixed if/Else Statement --- cowrie/core/honeypot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cowrie/core/honeypot.py b/cowrie/core/honeypot.py index 6e25722f..023b7a39 100644 --- a/cowrie/core/honeypot.py +++ b/cowrie/core/honeypot.py @@ -485,8 +485,9 @@ class StdOutStdErrEmulationProtocol(object): self.data = self.data + data if not self.next_protocol: if not self.protocol is None and not self.protocol.terminal is None: - log.msg("Connection was probably lost. Could not write to terminal") self.protocol.terminal.write(data) + else: + log.msg("Connection was probably lost. Could not write to terminal") def errReceived(self, data):