From 7b47c8fe4edcb53b035465985d92500b96fb1a84 Mon Sep 17 00:00:00 2001 From: ThePirateWhoSmellsOfSunflowers Date: Tue, 13 Oct 2020 11:47:33 +0200 Subject: [PATCH 1/6] fix custom challenge in python3 --- settings.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/settings.py b/settings.py index 1314f11..8176a63 100644 --- a/settings.py +++ b/settings.py @@ -210,12 +210,16 @@ class Settings: print(utils.color("[!] The challenge must be exactly 16 chars long.\nExample: 1122334455667788", 1)) sys.exit(-1) - self.Challenge = "" + self.Challenge = b'' if self.NumChal.lower() == 'random': pass - else: - for i in range(0, len(self.NumChal),2): - self.Challenge += self.NumChal[i:i+2].decode("hex") + else: + if self.PY2OR3 == 'PY2': + for i in range(0, len(self.NumChal),2): + self.Challenge += self.NumChal[i:i+2].decode("hex") + else: + self.Challenge += bytes.fromhex(self.NumChal) + # Set up logging logging.basicConfig(filename=self.SessionLogFile, level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') From f581d4dd0e7aa709367636c17b32e7956d6909b5 Mon Sep 17 00:00:00 2001 From: ThePirateWhoSmellsOfSunflowers Date: Tue, 13 Oct 2020 13:08:45 +0200 Subject: [PATCH 2/6] small fix --- settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.py b/settings.py index 8176a63..03457fc 100644 --- a/settings.py +++ b/settings.py @@ -218,7 +218,7 @@ class Settings: for i in range(0, len(self.NumChal),2): self.Challenge += self.NumChal[i:i+2].decode("hex") else: - self.Challenge += bytes.fromhex(self.NumChal) + self.Challenge = bytes.fromhex(self.NumChal) # Set up logging From d2e5642d58a70a182fa319f9245a3c32442b1f72 Mon Sep 17 00:00:00 2001 From: lgandx Date: Thu, 31 Dec 2020 01:13:27 -0300 Subject: [PATCH 3/6] Added SMB2 support for RunFinger and various other checks. --- tools/RunFinger.py | 221 ++++++++++++++++++++++++++++---------- tools/RunFingerPackets.py | 206 +++++++++++++++++++++++++++++++++++ 2 files changed, 371 insertions(+), 56 deletions(-) diff --git a/tools/RunFinger.py b/tools/RunFinger.py index 33669f9..d13dabb 100755 --- a/tools/RunFinger.py +++ b/tools/RunFinger.py @@ -19,14 +19,16 @@ import datetime import multiprocessing from socket import * from odict import OrderedDict +import errno import optparse from RunFingerPackets import * -__version__ = "1.0" +__version__ = "1.2" parser = optparse.OptionParser(usage='python %prog -i 10.10.10.224\nor:\npython %prog -i 10.10.10.0/24', version=__version__, prog=sys.argv[0]) parser.add_option('-i','--ip', action="store", help="Target IP address or class C", dest="TARGET", metavar="10.10.10.224", default=None) -parser.add_option('-g','--grep', action="store_true", dest="grep_output", default=False, help="Output in grepable format") +#Way better to have grepable output by default... +#parser.add_option('-g','--grep', action="store_true", dest="grep_output", default=False, help="Output in grepable format") options, args = parser.parse_args() if options.TARGET is None: @@ -36,6 +38,7 @@ if options.TARGET is None: Timeout = 2 Host = options.TARGET +SMB1 = "Enabled" class Packet(): fields = OrderedDict([ @@ -80,14 +83,67 @@ def longueur(payload): length = StructWithLenPython2or3(">i", len(''.join(payload))) return length +def ParseNegotiateSMB2Ans(data): + if data[4:8] == b"\xfeSMB": + return True + else: + return False + +def WorkstationFingerPrint(data): + return { + b"\x04\x00" :"Windows 95", + b"\x04\x0A" :"Windows 98", + b"\x04\x5A" :"Windows ME", + b"\x05\x00" :"Windows 2000", + b"\x05\x01" :"Windows XP", + b"\x05\x02" :"Windows XP(64-Bit)/Windows 2003", + b"\x06\x00" :"Windows Vista/Server 2008", + b"\x06\x01" :"Windows 7/Server 2008R2", + b"\x06\x02" :"Windows 8/Server 2012", + b"\x06\x03" :"Windows 8.1/Server 2012R2", + b"\x0A\x00" :"Windows 10/Server 2016/2019 (check build)", + }.get(data, 'Other than Microsoft') + +def GetOsBuildNumber(data): + ProductBuild = struct.unpack(" Date: Thu, 31 Dec 2020 01:27:43 -0300 Subject: [PATCH 4/6] Added SMB2 support for RunFinger and various other checks. --- packets.py | 36 ------------------------------------ tools/RunFingerPackets.py | 2 +- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/packets.py b/packets.py index f27bc4a..9939af0 100644 --- a/packets.py +++ b/packets.py @@ -1611,42 +1611,6 @@ class SMB2Session2Data(Packet): ]) -######################FindSMBTime.py########################## -class SMBHeaderReq(Packet): - fields = OrderedDict([ - ("Proto", "\xff\x53\x4d\x42"), - ("Cmd", "\x72"), - ("Error-Code", "\x00\x00\x00\x00" ), - ("Flag1", "\x10"), - ("Flag2", "\x00\x00"), - ("Pidhigh", "\x00\x00"), - ("Signature", "\x00\x00\x00\x00\x00\x00\x00\x00"), - ("Reserved", "\x00\x00"), - ("TID", "\x00\x00"), - ("PID", "\xff\xfe"), - ("UID", "\x00\x00"), - ("MID", "\x00\x00"), - ]) - -class SMB2NegoReq(Packet): - fields = OrderedDict([ - ("Wordcount", "\x00"), - ("Bcc", "\x62\x00"), - ("Data", "") - ]) - - def calculate(self): - self.fields["Bcc"] = StructWithLenPython2or3(" Date: Thu, 31 Dec 2020 08:52:18 -0300 Subject: [PATCH 5/6] minor bugfix --- tools/RunFinger.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/RunFinger.py b/tools/RunFinger.py index d13dabb..e7897e8 100755 --- a/tools/RunFinger.py +++ b/tools/RunFinger.py @@ -392,9 +392,7 @@ def RunFinger(Host): threads.append(p) p.start() else: - if options.grep_output: - ShowSmallResults(Host) - else: - ShowResults(Host) + ShowSmallResults(Host) + RunFinger(Host) From 24e7b7c667c3c9feb1cd3a25b16bd8d9c2df5ec6 Mon Sep 17 00:00:00 2001 From: lgandx Date: Thu, 31 Dec 2020 09:39:15 -0300 Subject: [PATCH 6/6] Added support for SMB2 signing --- tools/RunFinger.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/RunFinger.py b/tools/RunFinger.py index e7897e8..745f2f0 100755 --- a/tools/RunFinger.py +++ b/tools/RunFinger.py @@ -39,6 +39,7 @@ if options.TARGET is None: Timeout = 2 Host = options.TARGET SMB1 = "Enabled" +SMB2signing = "False" class Packet(): fields = OrderedDict([ @@ -89,6 +90,13 @@ def ParseNegotiateSMB2Ans(data): else: return False +def SMB2SigningMandatory(data): + global SMB2signing + if data[70] == "\x03": + SMB2signing = "True" + else: + SMB2signing = "False" + def WorkstationFingerPrint(data): return { b"\x04\x00" :"Windows 95", @@ -108,7 +116,7 @@ def GetOsBuildNumber(data): ProductBuild = struct.unpack("