-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpo_ntlmv1.py
More file actions
64 lines (49 loc) · 2.11 KB
/
Copy pathgpo_ntlmv1.py
File metadata and controls
64 lines (49 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from io import BytesIO
class NXCModule:
"""
Find which GPO enbale NTLMv1 usage
Module by @KlemouLeZoZo
"""
name = "gpo_ntlmv1"
category = CATEGORY.ENUMERATION
description = "Find which GPO enbale NTLMv1 usage"
supported_protocols = ['smb']
opsec_safe = True
multiple_hosts = True
def __init__(self):
self.context = None
self.module_options = None
self.key_name = "LmCompatibilityLevel"
def options(self, context, module_options):
"""
"""
pass
def on_login(self, context, connection):
"""Concurrent.
Required if on_admin_login is not present. This gets called on each authenticated connection
"""
shares = connection.shares()
for share in shares:
if share["name"] == "SYSVOL" and "READ" in share["access"]:
context.log.success("Found SYSVOL share")
context.log.display(f"Searching for {self.key_name} related GPO")
paths = connection.spider(
"SYSVOL",
pattern=[
"GptTmpl.inf",
],
)
for path in paths:
gpo_id = path.split('/')[2]
buf = BytesIO()
connection.conn.getFile("SYSVOL", path, buf.write)
file_content = buf.getvalue().decode("utf16")
if (index:=file_content.find(self.key_name)) != -1:
hive_value = file_content[index+len(self.key_name):].replace(" ","").replace("=","").split("\r\n")[0] #remove space and = and take firstline
if hive_value.count(",") != 1:
raise Exception("Invalide hive value")
_, value = hive_value.split(",")
if not value.isnumeric():
raise Exception("Invalide hive value")
if int(value) < 3:
context.log.highlight(f"{gpo_id} enable NTLMv1 usage")