From 673b88b2b1c8076a611dcfcc4f66b199f4d3f06e Mon Sep 17 00:00:00 2001 From: Andris Raugulis Date: Wed, 7 Sep 2016 12:22:51 +0300 Subject: [PATCH] Select the least protocol if banner has double protocol. --- ssh-audit.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ssh-audit.py b/ssh-audit.py index 3b03e46..0d6c70f 100755 --- a/ssh-audit.py +++ b/ssh-audit.py @@ -246,6 +246,12 @@ class SSH(object): @classmethod def parse(cls, banner): + mx = re.match(r'^SSH-(\d)\.\s*?(\d+)-SSH-(\d)\.\s*?(\d+)(|-.*)$', banner) + if mx is not None: + p1 = (int(mx.group(1)), int(mx.group(2))) + p2 = (int(mx.group(3)), int(mx.group(4))) + protocol = p1 if p1 < p2 else p2 + banner = 'SSH-{0}.{1}{2}'.format(protocol[0], protocol[1], mx.group(5)) mx = re.match(r'^SSH-(\d)\.\s*?(\d+)(|-([^\s]*)(\s+(.*))?)$', banner) if mx is None: return None