From 01b4e876841f0d2b20ea47fd7b4afa2a610419a9 Mon Sep 17 00:00:00 2001 From: klemou Date: Wed, 28 Dec 2022 15:30:35 +0100 Subject: [PATCH] I'm retarded but now it's work --- tools/RunFinger.py | 388 ++++++++++++++++++++++++--------------------- 1 file changed, 204 insertions(+), 184 deletions(-) diff --git a/tools/RunFinger.py b/tools/RunFinger.py index 7a9cd5f7..ad570360 100755 --- a/tools/RunFinger.py +++ b/tools/RunFinger.py @@ -32,7 +32,9 @@ 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('-f','--filename', action="store", help="Target file", dest="Filename", metavar="ips.txt", default=None) +parser.add_option('-o','--outfile', action="store", help="Output file", dest="OutFilename", metavar="output.txt", default=None) parser.add_option('-t','--timeout', action="store", help="Timeout for all connections. Use this option to fine tune Runfinger.", dest="Timeout", type="float", metavar="0.9", default=2) +parser.add_option('-s','--smbv1', action='store_true', help="Enable smbv1 scan", dest="Smbv1", default=False) options, args = parser.parse_args() @@ -44,9 +46,11 @@ Timeout = options.Timeout Host = options.TARGET Filename = options.Filename +Outputfile = None if options.OutFilename==None else open(options.OutFilename,"w") SMB1 = "True" SMB2signing = "False" DB = os.path.abspath(os.path.join(os.path.dirname(__file__)))+"/RunFinger.db" +SCAN_SMBV1 = options.Smbv1 class Packet(): fields = OrderedDict([ @@ -69,10 +73,10 @@ def __str__(self): if not os.path.exists(DB): - cursor = sqlite3.connect(DB) - cursor.execute('CREATE TABLE RunFinger (timestamp TEXT, Protocol TEXT, Host TEXT, WindowsVersion TEXT, OsVer TEXT, DomainJoined TEXT, Bootime TEXT, Signing TEXT, NullSess TEXT, IsRDPOn TEXT, SMB1 TEXT, MSSQL TEXT)') - cursor.commit() - cursor.close() + cursor = sqlite3.connect(DB) + cursor.execute('CREATE TABLE RunFinger (timestamp TEXT, Protocol TEXT, Host TEXT, WindowsVersion TEXT, OsVer TEXT, DomainJoined TEXT, Bootime TEXT, Signing TEXT, NullSess TEXT, IsRDPOn TEXT, SMB1 TEXT, MSSQL TEXT)') + cursor.commit() + cursor.close() def StructWithLenPython2or3(endian,data): #Python2... @@ -99,104 +103,107 @@ def longueur(payload): return length def ParseNegotiateSMB2Ans(data): - if data[4:8] == b"\xfeSMB": - return True - else: - return False + if data[4:8] == b"\xfeSMB": + return True + else: + return False def SMB2SigningMandatory(data): - global SMB2signing - if data[70] == "\x03": - SMB2signing = "True" - else: - SMB2signing = "False" + global SMB2signing + if data[70] == "\x03": + SMB2signing = "True" + else: + SMB2signing = "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') + 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("