From b0f044fe4e710597ae73e6f1af87ea246b0cd365 Mon Sep 17 00:00:00 2001 From: lgandx Date: Mon, 8 Feb 2021 22:18:41 -0300 Subject: [PATCH] added smb filetime support --- packets.py | 18 +++++++++--------- settings.py | 2 +- utils.py | 10 ++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packets.py b/packets.py index 9939af0..6525497 100644 --- a/packets.py +++ b/packets.py @@ -18,10 +18,10 @@ import struct import settings import codecs - +from os import urandom from base64 import b64decode, b64encode from odict import OrderedDict -from utils import HTTPCurrentDate, RespondWithIPAton, StructPython2or3, NetworkRecvBufferPython2or3, StructWithLenPython2or3 +from utils import HTTPCurrentDate, SMBTime, RespondWithIPAton, StructPython2or3, NetworkRecvBufferPython2or3, StructWithLenPython2or3 # Packet class handling all packet generation (see odict.py). class Packet(): @@ -980,7 +980,7 @@ class SMBNegoAnsLM(Packet): ("Maxrawbuff", "\x00\x00\x01\x00"), ("Sessionkey", "\x00\x00\x00\x00"), ("Capabilities", "\xfc\x3e\x01\x00"), - ("Systemtime", "\x84\xd6\xfb\xa3\x01\x35\xcd\x01"), + ("Systemtime", SMBTime()), ("Srvtimezone", "\x2c\x01"), ("Keylength", "\x08"), ("Bcc", "\x10\x00"), @@ -1009,11 +1009,11 @@ class SMBNegoAns(Packet): ("MaxRawBuff", "\x00\x00\x01\x00"), ("SessionKey", "\x00\x00\x00\x00"), ("Capabilities", "\xfd\xf3\x01\x80"), - ("SystemTime", "\x84\xd6\xfb\xa3\x01\x35\xcd\x01"), + ("SystemTime", SMBTime()), ("SrvTimeZone", "\xf0\x00"), ("KeyLen", "\x00"), ("Bcc", "\x57\x00"), - ("Guid", "\xc8\x27\x3d\xfb\xd4\x18\x55\x4f\xb2\x40\xaf\xd7\x61\x73\x75\x3b"), + ("Guid", urandom(16).decode('latin-1')), ("InitContextTokenASNId", "\x60"), ("InitContextTokenASNLen", "\x5b"), ("ThisMechASNId", "\x06"), @@ -1076,7 +1076,7 @@ class SMBNegoKerbAns(Packet): ("SrvTimeZone", "\xf0\x00"), ("KeyLen", "\x00"), ("Bcc", "\x57\x00"), - ("Guid", "\xc8\x27\x3d\xfb\xd4\x18\x55\x4f\xb2\x40\xaf\xd7\x61\x73\x75\x3b"), + ("Guid", urandom(16).decode('latin-1')), ("InitContextTokenASNId", "\x60"), ("InitContextTokenASNLen", "\x5b"), ("ThisMechASNId", "\x06"), @@ -1377,8 +1377,8 @@ class SMB2NegoAns(Packet): ("MaxTransSize", "\x00\x00\x10\x00"), ("MaxReadSize", "\x00\x00\x10\x00"), ("MaxWriteSize", "\x00\x00\x10\x00"), - ("SystemTime", "\x27\xfb\xea\xd7\x50\x09\xd2\x01"), - ("BootTime", "\x22\xfb\x80\x01\x40\x09\xd2\x01"), + ("SystemTime", SMBTime()), + ("BootTime", SMBTime()), ("SecBlobOffSet", "\x80\x00"), ("SecBlobLen", "\x78\x00"), ("Reserved2", "\x00\x00\x00\x00"), @@ -1522,7 +1522,7 @@ class SMB2Session1Data(Packet): ("NTLMSSPNTLMChallengeAVPairs5UnicodeStr","SMB3.local"), ("NTLMSSPNTLMChallengeAVPairs7Id","\x07\x00"), ("NTLMSSPNTLMChallengeAVPairs7Len","\x08\x00"), - ("NTLMSSPNTLMChallengeAVPairs7UnicodeStr","\xc0\x65\x31\x50\xde\x09\xd2\x01"), + ("NTLMSSPNTLMChallengeAVPairs7UnicodeStr",SMBTime()), ("NTLMSSPNTLMChallengeAVPairs6Id","\x00\x00"), ("NTLMSSPNTLMChallengeAVPairs6Len","\x00\x00"), ]) diff --git a/settings.py b/settings.py index 16bbad4..1a5a2b1 100644 --- a/settings.py +++ b/settings.py @@ -23,7 +23,7 @@ import subprocess from utils import * -__version__ = 'Responder 3.0.2.0' +__version__ = 'Responder 3.0.3.0' class Settings: diff --git a/utils.py b/utils.py index 3b88412..0192dea 100644 --- a/utils.py +++ b/utils.py @@ -24,6 +24,7 @@ import settings import datetime import codecs import struct +from calendar import timegm def RandomChallenge(): if settings.Config.PY2OR3 == "PY3": @@ -50,6 +51,15 @@ def RandomChallenge(): def HTTPCurrentDate(): Date = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT') return Date + +def SMBTime(): + dt = datetime.datetime.now() + dt = dt.replace(tzinfo=None) + if settings.Config.PY2OR3 == "PY3": + return struct.pack("