From f7cd4fd954ba37f63eff2b0a86ad5c628fb22f08 Mon Sep 17 00:00:00 2001 From: Andris Raugulis Date: Tue, 6 Sep 2016 15:25:29 +0300 Subject: [PATCH] Better packet parsing error output (e.g., protocol mismatch). --- ssh-audit.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ssh-audit.py b/ssh-audit.py index 599ad9c..f2f97c7 100755 --- a/ssh-audit.py +++ b/ssh-audit.py @@ -280,6 +280,8 @@ class SSH(object): while self.unread_len < self.__block_size: s, e = self.recv() if s < 0: + if e is None: + e = self.read(self.unread_len).strip() return -1, e header = self.read(self.__block_size) if len(header) == 0: @@ -297,6 +299,8 @@ class SSH(object): while self.unread_len < rlen: s, e = self.recv() if s < 0: + if e is None: + e = (header + self.read(self.unread_len)).strip() return -1, e buf = self.read(rlen) packet = rest[2:] + buf[0:packet_size - lrest]