Skip to content

Commit 9259825

Browse files
Merge branch 'main' into marshall-db-ip-fix
2 parents ec8abe6 + 0063ec0 commit 9259825

6 files changed

Lines changed: 936 additions & 894 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- name: Install poetry
2121
run: |
22-
pipx install poetry==1.8.4
22+
pipx install poetry
23+
poetry --version
24+
poetry env info
2325
- name: NetExec set up python ${{ matrix.python-version }} on ${{ matrix.os }}
2426
uses: actions/setup-python@v5
2527
with:
@@ -29,11 +31,6 @@ jobs:
2931
- name: Install with pipx
3032
run: |
3133
pipx install . --python python${{ matrix.python-version }}
32-
- name: Install poetry
33-
run: |
34-
pipx install poetry --python python${{ matrix.python-version }}
35-
poetry --version
36-
poetry env info
3734
- name: Install libraries with dev group
3835
run: |
3936
poetry install --with dev
@@ -48,4 +45,4 @@ jobs:
4845
poetry run netexec mssql 127.0.0.1
4946
poetry run netexec ssh 127.0.0.1
5047
poetry run netexec ftp 127.0.0.1
51-
poetry run netexec smb 127.0.0.1 -M veeam
48+
poetry run netexec smb 127.0.0.1 -L

nxc/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ def gen_cli_args():
1919

2020
try:
2121
VERSION, COMMIT = importlib.metadata.version("netexec").split("+")
22+
DISTANCE, COMMIT = COMMIT.split(".")
2223
except ValueError:
2324
VERSION = importlib.metadata.version("netexec")
2425
COMMIT = ""
26+
DISTANCE = ""
2527
CODENAME = "NeedForSpeed"
26-
nxc_logger.debug(f"NXC VERSION: {VERSION} - {CODENAME} - {COMMIT}")
28+
nxc_logger.debug(f"NXC VERSION: {VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
2729

2830
generic_parser = argparse.ArgumentParser(add_help=False, formatter_class=DisplayDefaultsNotNone)
2931
generic_group = generic_parser.add_argument_group("Generic", "Generic options for nxc across protocols")
@@ -130,7 +132,7 @@ def gen_cli_args():
130132
sys.exit(1)
131133

132134
if args.version:
133-
print(f"{VERSION} - {CODENAME} - {COMMIT}")
135+
print(f"{VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
134136
sys.exit(1)
135137

136138
# Multiply output_tries by 10 to enable more fine granural control, see exec methods

nxc/modules/remote-uac.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from impacket.dcerpc.v5 import rrp
2+
from impacket.examples.secretsdump import RemoteOperations
3+
4+
5+
class NXCModule:
6+
"""Module by @Defte_"""
7+
name = "remote-uac"
8+
description = "Enable or disable remote UAC"
9+
supported_protocols = ["smb"]
10+
opsec_safe = True
11+
multiple_hosts = True
12+
13+
def __init__(self, context=None, module_options=None):
14+
self.context = context
15+
self.module_options = module_options
16+
self.action = None
17+
18+
def options(self, context, module_options):
19+
"""
20+
Enables UAC (prevent non RID500 account to get high priv token remotely)
21+
Disables UAC (allow non RID500 account to get high priv token remotely)
22+
23+
ACTION: "enable" or "disable" (required)
24+
"""
25+
if "ACTION" not in module_options:
26+
context.log.fail("ACTION option not specified!")
27+
return
28+
29+
if module_options["ACTION"].lower() not in ["enable", "disable"]:
30+
context.log.fail("ACTION must be either enable, disable or query")
31+
return
32+
self.action = module_options["ACTION"].lower()
33+
34+
def on_admin_login(self, context, connection):
35+
try:
36+
remoteOps = RemoteOperations(connection.conn, False)
37+
remoteOps.enableRegistry()
38+
if remoteOps._RemoteOperations__rrp:
39+
ans = rrp.hOpenLocalMachine(remoteOps._RemoteOperations__rrp)
40+
regHandle = ans["phKey"]
41+
42+
keyHandle = rrp.hBaseRegOpenKey(remoteOps._RemoteOperations__rrp, regHandle, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")["phkResult"]
43+
44+
# Checks if the key already exists or not
45+
try:
46+
rrp.hBaseRegQueryValue(remoteOps._RemoteOperations__rrp, keyHandle, "LocalAccountTokenFilterPolicy\x00")
47+
except Exception as e:
48+
if "ERROR_FILE_NOT_FOUND" in str(e):
49+
context.log.debug("Registry key 'LocalAccountTokenFilterPolicy' does not exist, creating it")
50+
ans = rrp.hBaseRegCreateKey(remoteOps._RemoteOperations__rrp, keyHandle, "LocalAccountTokenFilterPolicy\x00")
51+
52+
# Disable remote UAC
53+
if self.action == "disable":
54+
rrp.hBaseRegSetValue(remoteOps._RemoteOperations__rrp, keyHandle, "LocalAccountTokenFilterPolicy\x00", rrp.REG_DWORD, 1)
55+
context.log.highlight("Remote UAC disabled")
56+
57+
# Enable remote UAC
58+
if self.action == "enable":
59+
rrp.hBaseRegSetValue(remoteOps._RemoteOperations__rrp, keyHandle, "LocalAccountTokenFilterPolicy\x00", rrp.REG_DWORD, 0)
60+
context.log.highlight("Remote UAC enabled")
61+
62+
except Exception as e:
63+
context.log.debug(f"Error {e}")
64+
finally:
65+
remoteOps.finish()

nxc/protocols/ldap.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import hashlib
44
import hmac
55
import os
6+
from errno import EHOSTUNREACH
67
from binascii import hexlify
78
from datetime import datetime
89
from re import sub, I
@@ -209,7 +210,11 @@ def create_conn_obj(self):
209210
self.logger.debug(f"{e} on host {self.host}")
210211
return False
211212
except OSError as e:
212-
self.logger.error(f"Error getting ldap info {e}")
213+
if e.errno == EHOSTUNREACH:
214+
self.logger.info(f"Error connecting to {self.host} - {e}")
215+
return False
216+
else:
217+
self.logger.error(f"Error getting ldap info {e}")
213218

214219
self.logger.debug(f"Target: {target}; target_domain: {target_domain}; base_dn: {base_dn}")
215220
self.target = target

0 commit comments

Comments
 (0)