Skip to content

Commit e7e6da5

Browse files
authored
Merge branch 'fortra:master' into master
2 parents 75249aa + 4a72cb8 commit e7e6da5

11 files changed

Lines changed: 1974 additions & 69 deletions

File tree

examples/smbclient.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def main():
5151
group.add_argument('-aesKey', action="store", metavar = "hex key", help='AES key to use for Kerberos Authentication '
5252
'(128 or 256 bits)')
5353

54+
group = parser.add_argument_group('dfs')
55+
56+
group.add_argument('-dfs-follow', action='store_true', default=False,
57+
help='Automatically follow DFS links by creating new SMB connections to target servers. '
58+
'Disabled by default for OPSEC reasons (use dfs_mode command in shell to toggle at runtime)')
59+
5460
group = parser.add_argument_group('connection')
5561

5662
group.add_argument('-dc-ip', action='store', metavar="ip address",
@@ -98,7 +104,7 @@ def main():
98104
else:
99105
smbClient.login(username, password, domain, lmhash, nthash)
100106

101-
shell = MiniImpacketShell(smbClient, None, options.outputfile)
107+
shell = MiniImpacketShell(smbClient, None, options.outputfile, dfs_auto_follow=options.dfs_follow)
102108

103109
if options.outputfile is not None:
104110
f = open(options.outputfile, 'a')

impacket/dcerpc/v5/epm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ def __str__( self ):
642642
'F093FE3D-8131-4B73-A742-EF54C20B337B':'[MS-ISTM]: iSCSI Software Target Management Protocol',
643643
'28BC8D5E-CA4B-4F54-973C-ED9622D2B3AC':'[MS-ISTM]: iSCSI Software Target Management Protocol',
644644
'22E5386D-8B12-4BF0-B0EC-6A1EA419E366':'[MS-LREC]: Live Remote Event Capture (LREC) Protocol',
645-
'12345778-1234-ABCD-EF00-0123456789AB':'[MS-LSAD]: Local Security Authority (Domain Policy) Remote Protocol',
646-
'12345778-1234-ABCD-EF00-0123456789AB':'[MS-LSAT]: Local Security Authority (Translation Methods) Remote',
645+
'12345778-1234-ABCD-EF00-0123456789AB':'[MS-LSAD]/[MS-LSAT]: Local Security Authority (Domain Policy / Translation Methods) Remote Protocol',
647646
'708CCA10-9569-11D1-B2A5-0060977D8118':'[MS-MQDS]: Message Queuing (MSMQ):',
648647
'77DF7A80-F298-11D0-8358-00A024C480A8':'[MS-MQDS]: Message Queuing (MSMQ):',
649648
'76D12B80-3467-11D3-91FF-0090272F9EA3':'[MS-MQMP]: Message Queuing (MSMQ):',
@@ -715,7 +714,6 @@ def __str__( self ):
715714
'DB90832F-6910-4D46-9F5E-9FD6BFA73903':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
716715
'4E934F30-341A-11D1-8FB1-00A024CB6019':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
717716
'879C8BBE-41B0-11D1-BE11-00C04FB6BF70':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
718-
'00000000-0000-0000-C000-000000000046':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
719717
'69AB7050-3059-11D1-8FAF-00A024CB6019':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
720718
'7D07F313-A53F-459A-BB12-012C15B1846E':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',
721719
'BB39332C-BFEE-4380-AD8A-BADC8AFF5BB6':'[MS-RSMP]: Removable Storage Manager (RSM) Remote Protocol',

impacket/examples/ntlmrelayx/attacks/httpattacks/sccmpoliciesattack.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def mscrypt_derive_key_sha1(secret:bytes):
281281
digest2.update(buf2)
282282
hash2 = digest2.finalize()
283283

284-
derived_key = hash1 + hash2[:4]
284+
derived_key = hash1 + hash2
285285
return derived_key
286286

287287
def deobfuscate_secret_policy_blob(output):
@@ -292,12 +292,20 @@ def deobfuscate_secret_policy_blob(output):
292292
buffer = output[64:64+data_length]
293293

294294
key = mscrypt_derive_key_sha1(output[4:4+0x28])
295-
iv = bytes([0] * 8)
296-
cipher = Cipher(algorithms.TripleDES(key), modes.CBC(iv), backend=default_backend())
295+
blob_prefix = output[:2]
296+
297+
if blob_prefix == b'\x89\x13':
298+
block_cipher_algorithm = algorithms.TripleDES(key[:24])
299+
elif blob_prefix == b'\x8a\x13':
300+
block_cipher_algorithm = algorithms.AES256(key[:32])
301+
302+
iv = bytes([0] * (block_cipher_algorithm.block_size // 8))
303+
cipher = Cipher(block_cipher_algorithm, modes.CBC(iv), backend=default_backend())
304+
297305
decryptor = cipher.decryptor()
298306
decrypted_data = decryptor.update(buffer) + decryptor.finalize()
299307

300-
padder = padding.PKCS7(64).unpadder() # 64 is the block size in bits for DES3
308+
padder = padding.PKCS7(block_cipher_algorithm.block_size).unpadder()
301309
decrypted_data = padder.update(decrypted_data) + padder.finalize()
302310

303311
try:
@@ -545,7 +553,22 @@ def secret_policy_process(self, policyID, policy, private_key, client_guid, loot
545553

546554
LOG.debug(f"Found {len(blobs_set.keys())} obfuscated blob(s) in secret policy.")
547555
for i, blob_name in enumerate(blobs_set.keys()):
548-
data = deobfuscate_secret_policy_blob(blobs_set[blob_name])
556+
blob_prefix = bytes.fromhex(blobs_set[blob_name])[:2]
557+
if blob_prefix in (b'\x89\x13', b'\x8a\x13'):
558+
data = deobfuscate_secret_policy_blob(blobs_set[blob_name])
559+
else:
560+
LOG.debug(f"Unable to decrypt obfuscated blob due to unknown blob type with prefix '{blob_prefix.hex()}'.")
561+
continue
562+
563+
# Attempt to pretty-print decrypted XML task sequence blobs prior to file write.
564+
if blob_name == "TS_Sequence":
565+
try:
566+
blobroot = ET.fromstring(clean_junk_in_XML(data))
567+
ET.indent(blobroot)
568+
data = ET.tostring(blobroot, encoding="unicode")
569+
except:
570+
pass
571+
549572
filename = f'{loot_dir}/{policyID}/secretBlob_{str(i+1)}-{blob_name}.txt'
550573
with open(filename, 'w') as f:
551574
f.write(f"Secret property name: {blob_name}\n\n")

0 commit comments

Comments
 (0)