Skip to content

Commit f7f343e

Browse files
authored
Merge branch 'main' into SMB]-Add-the-recyclebin-module
2 parents 899c516 + 4f028ea commit f7f343e

118 files changed

Lines changed: 6873 additions & 3791 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md renamed to .github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
---
2-
name: Pull request
3-
about: Update code to fix a bug or add an enhancement/feature
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
8-
---
91
## Description
102

113
Please include a summary of the change and which issue is fixed, or what the enhancement does.

.github/workflows/build-binaries.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest, macOS-latest, windows-latest]
13-
python-version: ["3.11"]
13+
python-version: ["3.13"]
1414
#python-version: ["3.8", "3.9", "3.10", "3.11"] # for binary builds we only need one version
1515
steps:
1616
- uses: actions/checkout@v4
@@ -20,18 +20,18 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Build Native Binary
2222
run: |
23-
pip install pyinstaller
23+
pip install pyinstaller pillow
2424
pip install .
2525
pyinstaller netexec.spec
2626
- name: Upload Windows Binary
2727
if: runner.os == 'windows'
28-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
2929
with:
3030
name: nxc.exe
3131
path: dist/nxc.exe
3232
- name: Upload Nix/OSx Binary
3333
if: runner.os != 'windows'
34-
uses: actions/upload-artifact@v3
34+
uses: actions/upload-artifact@v4
3535
with:
3636
name: nxc-${{ matrix.os }}
3737
path: dist/nxc

.github/workflows/build-zipapps.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest, macOS-latest, windows-latest]
13-
python-version: ["3.8", "3.9", "3.10", "3.11"]
13+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: NetExec set up python on ${{ matrix.os }}
@@ -22,12 +22,12 @@ jobs:
2222
pip install shiv
2323
python build_collector.py
2424
- name: Upload nxc ZipApp
25-
uses: actions/upload-artifact@v3
25+
uses: actions/upload-artifact@v4
2626
with:
2727
name: nxc-zipapp-${{ matrix.os }}-${{ matrix.python-version }}
2828
path: bin/nxc
2929
- name: Upload nxcdb ZipApp
30-
uses: actions/upload-artifact@v3
30+
uses: actions/upload-artifact@v4
3131
with:
3232
name: nxcdb-zipapp-${{ matrix.os }}-${{ matrix.python-version }}
3333
path: bin/nxcdb

.github/workflows/lint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ name: Lint Python code with ruff
44
on:
55
push:
66
workflow_dispatch:
7+
pull_request_review:
8+
types: [submitted]
79

810
jobs:
911
lint:
1012
runs-on: ubuntu-latest
1113
if:
12-
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
14+
github.event_name == 'push' || github.event.review.state == 'APPROVED' || github.event_name == 'workflow_dispatch'
1315

1416
steps:
1517
- uses: actions/checkout@v4
@@ -19,7 +21,7 @@ jobs:
1921
- name: Set up Python
2022
uses: actions/setup-python@v5
2123
with:
22-
python-version: 3.11
24+
python-version: 3.13
2325
cache: poetry
2426
cache-dependency-path: poetry.lock
2527
- name: Install dependencies with dev group

.github/workflows/test.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ on:
88
jobs:
99
build:
1010
name: Test for Py${{ matrix.python-version }}
11-
if: github.event.review.state == 'APPROVED'
11+
if: github.event.review.state == 'APPROVED' || github.event_name == 'workflow_dispatch'
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
max-parallel: 5
1515
matrix:
1616
os: [ubuntu-latest]
17-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Install poetry
2121
run: |
2222
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

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2023, Marshall-Hallenbeck, NeffIsBack, zblurx, mpgn_x64
1+
Copyright (c) 2025, Marshall-Hallenbeck, NeffIsBack, zblurx, mpgn_x64
22
Copyright (c) 2022, byt3bl33d3r
33
All rights reserved.
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Supported Python versions](https://img.shields.io/badge/python-3.8+-blue.svg)
1+
![Supported Python versions](https://img.shields.io/badge/python-3.10+-blue.svg)
22
[![Twitter](https://img.shields.io/twitter/follow/al3xn3ff?label=al3x_n3ff&style=social)](https://twitter.com/intent/follow?screen_name=al3x_n3ff)
33
[![Twitter](https://img.shields.io/twitter/follow/_zblurx?label=_zblurx&style=social)](https://twitter.com/intent/follow?screen_name=_zblurx)
44
[![Twitter](https://img.shields.io/twitter/follow/MJHallenbeck?label=MJHallenbeck&style=social)](https://twitter.com/intent/follow?screen_name=MJHallenbeck)

netexec.spec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ a = Analysis(
2020
'aardwolf.commons.target',
2121
'aardwolf.protocol.x224.constants',
2222
'impacket.examples.secretsdump',
23+
'impacket.examples.regsecrets',
2324
'impacket.dcerpc.v5.lsat',
2425
'impacket.dcerpc.v5.transport',
2526
'impacket.dcerpc.v5.lsad',
@@ -30,8 +31,8 @@ a = Analysis(
3031
'impacket.tds',
3132
'impacket.version',
3233
'impacket.ldap.ldap',
34+
'jwt',
3335
'nxc.connection',
34-
'nxc.servers.smb',
3536
'nxc.protocols.smb.wmiexec',
3637
'nxc.protocols.smb.atexec',
3738
'nxc.protocols.smb.smbexec',
@@ -46,7 +47,6 @@ a = Analysis(
4647
'nxc.helpers.ntlm_parser',
4748
'paramiko',
4849
'pypsrp.client',
49-
'pywerview.cli.helpers',
5050
'pylnk3',
5151
'pypykatz',
5252
'pyNfsClient',
@@ -71,6 +71,7 @@ a = Analysis(
7171
'dploot.triage.masterkeys',
7272
'dploot.triage.mobaxterm',
7373
'dploot.triage.backupkey',
74+
'dploot.triage.wam',
7475
'dploot.triage.wifi',
7576
'dploot.triage.sccm',
7677
'dploot.lib.target',

nxc/cli.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,48 @@
1616

1717
def gen_cli_args():
1818
setup_debug_logging()
19-
19+
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 = ""
25-
CODENAME = "NeedForSpeed"
26-
nxc_logger.debug(f"NXC VERSION: {VERSION} - {CODENAME} - {COMMIT}")
27-
26+
DISTANCE = ""
27+
CODENAME = "SmoothOperator"
28+
nxc_logger.debug(f"NXC VERSION: {VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
29+
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")
3032
generic_group.add_argument("--version", action="store_true", help="Display nxc version")
3133
generic_group.add_argument("-t", "--threads", type=int, dest="threads", default=256, help="set how many concurrent threads to use")
3234
generic_group.add_argument("--timeout", default=None, type=int, help="max timeout in seconds of each thread")
3335
generic_group.add_argument("--jitter", metavar="INTERVAL", type=str, help="sets a random delay between each authentication")
34-
36+
3537
output_parser = argparse.ArgumentParser(add_help=False, formatter_class=DisplayDefaultsNotNone)
3638
output_group = output_parser.add_argument_group("Output", "Options to set verbosity levels and control output")
3739
output_group.add_argument("--verbose", action="store_true", help="enable verbose output")
3840
output_group.add_argument("--debug", action="store_true", help="enable debug level information")
3941
output_group.add_argument("--no-progress", action="store_true", help="do not displaying progress bar during scan")
4042
output_group.add_argument("--log", metavar="LOG", help="export result into a custom file")
41-
43+
4244
dns_parser = argparse.ArgumentParser(add_help=False, formatter_class=DisplayDefaultsNotNone)
4345
dns_group = dns_parser.add_argument_group("DNS")
4446
dns_group.add_argument("-6", dest="force_ipv6", action="store_true", help="Enable force IPv6")
4547
dns_group.add_argument("--dns-server", action="store", help="Specify DNS server (default: Use hosts file & System DNS)")
4648
dns_group.add_argument("--dns-tcp", action="store_true", help="Use TCP instead of UDP for DNS queries")
4749
dns_group.add_argument("--dns-timeout", action="store", type=int, default=3, help="DNS query timeout in seconds")
48-
50+
4951
parser = argparse.ArgumentParser(
5052
description=rf"""
5153
. .
5254
.| |. _ _ _ _____
5355
|| || | \ | | ___ | |_ | ____| __ __ ___ ___
5456
\\( )// | \| | / _ \ | __| | _| \ \/ / / _ \ / __|
5557
.=[ ]=. | |\ | | __/ | |_ | |___ > < | __/ | (__
56-
/ /ॱ-ॱ\ \ |_| \_| \___| \__| |_____| /_/\_\ \___| \___|
57-
\ /
58-
58+
/ /˙-˙\ \ |_| \_| \___| \__| |_____| /_/\_\ \___| \___|
59+
˙ \ / ˙
60+
˙ ˙
5961
6062
The network execution tool
6163
Maintained as an open source project by @NeffIsBack, @MJHallenbeck, @_zblurx
@@ -98,12 +100,13 @@ def gen_cli_args():
98100
kerberos_group.add_argument("--use-kcache", action="store_true", help="Use Kerberos authentication from ccache file (KRB5CCNAME)")
99101
kerberos_group.add_argument("--aesKey", metavar="AESKEY", nargs="+", help="AES key to use for Kerberos Authentication (128 or 256 bits)")
100102
kerberos_group.add_argument("--kdcHost", metavar="KDCHOST", help="FQDN of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter")
101-
102-
server_group = std_parser.add_argument_group("Servers", "Options for nxc servers")
103-
server_group.add_argument("--server", choices={"http", "https"}, default="https", help="use the selected server")
104-
server_group.add_argument("--server-host", type=str, default="0.0.0.0", metavar="HOST", help="IP to bind the server to")
105-
server_group.add_argument("--server-port", metavar="PORT", type=int, help="start the server on the specified port")
106-
server_group.add_argument("--connectback-host", type=str, metavar="CHOST", help="IP for the remote system to connect back to")
103+
104+
certificate_group = std_parser.add_argument_group("Certificate", "Options for certificate authentication")
105+
certificate_group.add_argument("--pfx-cert", metavar="PFXCERT", help="Use certificate authentication from pfx file .pfx")
106+
certificate_group.add_argument("--pfx-base64", metavar="PFXB64", help="Use certificate authentication from pfx file encoded in base64")
107+
certificate_group.add_argument("--pfx-pass", metavar="PFXPASS", help="Password of the pfx certificate")
108+
certificate_group.add_argument("--pem-cert", metavar="PEMCERT", help="Use certificate authentication from PEM file")
109+
certificate_group.add_argument("--pem-key", metavar="PEMKEY", help="Private key for the PEM format")
107110

108111
p_loader = ProtocolLoader()
109112
protocols = p_loader.get_protocols()
@@ -115,15 +118,15 @@ def gen_cli_args():
115118
except Exception as e:
116119
nxc_logger.exception(f"Error loading proto_args from proto_args.py file in protocol folder: {protocol} - {e}")
117120

118-
argcomplete.autocomplete(parser)
121+
argcomplete.autocomplete(parser, always_complete_options=False)
119122
args = parser.parse_args()
120123

121124
if len(sys.argv) == 1:
122125
parser.print_help()
123126
sys.exit(1)
124127

125128
if args.version:
126-
print(f"{VERSION} - {CODENAME} - {COMMIT}")
129+
print(f"{VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
127130
sys.exit(1)
128131

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

nxc/connection.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import random
2+
import sys
3+
import contextlib
4+
25
from os.path import isfile
36
from threading import BoundedSemaphore
47
from functools import wraps
@@ -13,10 +16,9 @@
1316
from nxc.logger import nxc_logger, NXCAdapter
1417
from nxc.context import Context
1518
from nxc.protocols.ldap.laps import laps_search
19+
from nxc.helpers.pfx import pfx_auth
1620

1721
from impacket.dcerpc.v5 import transport
18-
import sys
19-
import contextlib
2022

2123
sem = BoundedSemaphore(1)
2224
global_failed_logins = 0
@@ -229,7 +231,8 @@ def proto_flow(self):
229231
else:
230232
self.logger.debug("Created connection object")
231233
self.enum_host_info()
232-
if self.print_host_info() and (self.login() or (self.username == "" and self.password == "")):
234+
self.print_host_info()
235+
if self.login() or (self.username == "" and self.password == ""):
233236
if hasattr(self.args, "module") and self.args.module:
234237
self.load_modules()
235238
self.logger.debug("Calling modules")
@@ -281,11 +284,6 @@ def call_modules(self):
281284
context = Context(self.db, module_logger, self.args)
282285
context.localip = self.local_ip
283286

284-
if hasattr(module, "on_request") or hasattr(module, "has_response"):
285-
self.logger.debug(f"Module {module.name} has on_request or has_response methods")
286-
self.server.connection = self
287-
self.server.context.localip = self.local_ip
288-
289287
if hasattr(module, "on_login"):
290288
self.logger.debug(f"Module {module.name} has on_login method")
291289
module.on_login(context, self)
@@ -294,10 +292,6 @@ def call_modules(self):
294292
self.logger.debug(f"Module {module.name} has on_admin_login method")
295293
module.on_admin_login(context, self)
296294

297-
if (not hasattr(module, "on_request") and not hasattr(module, "has_response")) and hasattr(module, "on_shutdown"):
298-
self.logger.debug(f"Module {module.name} has on_shutdown method")
299-
module.on_shutdown(context, self)
300-
301295
def inc_failed_login(self, username):
302296
global global_failed_logins
303297
global user_failed_logins
@@ -383,10 +377,10 @@ def parse_credentials(self):
383377
if isfile(user):
384378
with open(user) as user_file:
385379
for line in user_file:
386-
if "\\" in line:
380+
if "\\" in line and len(line.split("\\")) == 2:
387381
domain_single, username_single = line.split("\\")
388382
else:
389-
domain_single = self.args.domain if hasattr(self.args, "domain") and self.args.domain else self.domain
383+
domain_single = self.args.domain if hasattr(self.args, "domain") and self.args.domain is not None else self.domain
390384
username_single = line
391385
domain.append(domain_single)
392386
username.append(username_single.strip())
@@ -395,7 +389,7 @@ def parse_credentials(self):
395389
if "\\" in user:
396390
domain_single, username_single = user.split("\\")
397391
else:
398-
domain_single = self.args.domain if hasattr(self.args, "domain") and self.args.domain else self.domain
392+
domain_single = self.args.domain if hasattr(self.args, "domain") and self.args.domain is not None else self.domain
399393
username_single = user
400394
domain.append(domain_single)
401395
username.append(username_single)
@@ -547,6 +541,14 @@ def login(self):
547541
self.logger.info("Successfully authenticated using Kerberos cache")
548542
return True
549543

544+
if self.args.pfx_cert or self.args.pfx_base64 or self.args.pem_cert:
545+
self.logger.debug("Trying to authenticate using Certificate pfx")
546+
if not self.args.username:
547+
self.logger.fail("You must specify a username when using certificate authentication")
548+
return False
549+
with sem:
550+
return pfx_auth(self)
551+
550552
if hasattr(self.args, "laps") and self.args.laps:
551553
self.logger.debug("Trying to authenticate using LAPS")
552554
username[0], secret[0], domain[0] = laps_search(self, username, secret, cred_type, domain, self.dns_server)

0 commit comments

Comments
 (0)