From e36bb9721d35af48163d40b34224a9986dfa5aed Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 16 Oct 2019 18:27:14 +0300 Subject: [PATCH] Sambacry fixes --- monkey/infection_monkey/exploit/sambacry.py | 2 ++ monkey/infection_monkey/network/smbfinger.py | 21 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/monkey/infection_monkey/exploit/sambacry.py b/monkey/infection_monkey/exploit/sambacry.py index 762cc14b5..16366c586 100644 --- a/monkey/infection_monkey/exploit/sambacry.py +++ b/monkey/infection_monkey/exploit/sambacry.py @@ -216,6 +216,8 @@ class SambaCryExploiter(HostExploiter): pattern = re.compile(r'\d*\.\d*\.\d*') smb_server_name = self.host.services[SMB_SERVICE].get('name') + if not smb_server_name: + return False samba_version = "unknown" pattern_result = pattern.search(smb_server_name) is_vulnerable = False diff --git a/monkey/infection_monkey/network/smbfinger.py b/monkey/infection_monkey/network/smbfinger.py index b39ffef7a..1e765114c 100644 --- a/monkey/infection_monkey/network/smbfinger.py +++ b/monkey/infection_monkey/network/smbfinger.py @@ -120,27 +120,26 @@ class SMBFinger(HostFinger): n = SMBNego(data=SMBNegoFingerData()) n.calculate() - Packet = str(h) + str(n) - Buffer = struct.pack(">i", len(''.join(Packet))) + Packet - s.send(Buffer) + packet_ = str(h) + str(n) + buffer = struct.pack(">i", len(packet_)) + packet_.encode() + s.send(buffer) data = s.recv(2048) if data[8:10] == "\x72\x00": - Header = SMBHeader(cmd="\x73", flag1="\x18", flag2="\x17\xc8", uid="\x00\x00") - Body = SMBSessionFingerData() - Body.calculate() + header = SMBHeader(cmd="\x73", flag1="\x18", flag2="\x17\xc8", uid="\x00\x00") + body = SMBSessionFingerData() + body.calculate() - Packet = str(Header) + str(Body) - Buffer = struct.pack(">i", len(''.join(Packet))) + Packet + packet_ = str(header) + str(body) + buffer = struct.pack(">i", len(packet_)) + packet_.encode() - s.send(Buffer) + s.send(buffer) data = s.recv(2048) if data[8:10] == "\x73\x16": length = struct.unpack('