Skip to content

Commit dca1d08

Browse files
committed
Merge branch 'main' into fix-exec-method
2 parents aa9075e + 0da04dd commit dca1d08

48 files changed

Lines changed: 2689 additions & 2050 deletions

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: 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.11"]
13+
python-version: ["3.12"]
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
@@ -25,13 +25,13 @@ jobs:
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"]
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Python
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: 3.11
22+
python-version: 3.12
2323
cache: poetry
2424
cache-dependency-path: poetry.lock
2525
- name: Install dependencies with dev group

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
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"]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Install poetry

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ a = Analysis(
2525
'impacket.dcerpc.v5.lsad',
2626
'impacket.dcerpc.v5.gkdi',
2727
'impacket.dcerpc.v5.rprn',
28+
'impacket.dcerpc.v5.even',
2829
'impacket.dpapi_ng',
2930
'impacket.tds',
3031
'impacket.version',
@@ -48,6 +49,7 @@ a = Analysis(
4849
'pywerview.cli.helpers',
4950
'pylnk3',
5051
'pypykatz',
52+
'pyNfsClient',
5153
'masky',
5254
'msldap',
5355
'msldap.connection',

nxc/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def gen_cli_args():
2222
except ValueError:
2323
VERSION = importlib.metadata.version("netexec")
2424
COMMIT = ""
25-
CODENAME = "ItsAlwaysDNS"
25+
CODENAME = "NeedForSpeed"
2626
nxc_logger.debug(f"NXC VERSION: {VERSION} - {CODENAME} - {COMMIT}")
2727

2828
generic_parser = argparse.ArgumentParser(add_help=False, formatter_class=DisplayDefaultsNotNone)

nxc/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def proto_flow(self):
229229
else:
230230
self.logger.debug("Created connection object")
231231
self.enum_host_info()
232-
if self.print_host_info() and (self.login() or (self.username == "" and self.password == "")):
232+
self.print_host_info()
233+
if self.login() or (self.username == "" and self.password == ""):
233234
if hasattr(self.args, "module") and self.args.module:
234235
self.load_modules()
235236
self.logger.debug("Calling modules")

nxc/database.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import sys
21
import configparser
32
import shutil
4-
from sqlalchemy import create_engine
5-
from sqlite3 import connect
3+
import sys
64
from os import mkdir
75
from os.path import exists
86
from os.path import join as path_join
7+
from pathlib import Path
8+
from sqlite3 import connect
9+
from threading import Lock
10+
11+
from sqlalchemy import create_engine, MetaData
12+
from sqlalchemy.exc import IllegalStateChangeError
13+
from sqlalchemy.orm import sessionmaker, scoped_session
914

1015
from nxc.loaders.protocolloader import ProtocolLoader
16+
from nxc.logger import nxc_logger
1117
from nxc.paths import WORKSPACE_DIR
1218

1319

@@ -103,3 +109,39 @@ def initialize_db():
103109

104110
# Even if the default workspace exists, we still need to check if every protocol has a database (in case of a new protocol)
105111
init_protocol_dbs("default")
112+
113+
114+
class BaseDB:
115+
def __init__(self, db_engine):
116+
self.db_engine = db_engine
117+
self.db_path = self.db_engine.url.database
118+
self.protocol = Path(self.db_path).stem.upper()
119+
self.metadata = MetaData()
120+
self.reflect_tables()
121+
session_factory = sessionmaker(bind=self.db_engine, expire_on_commit=True)
122+
123+
session = scoped_session(session_factory)
124+
self.sess = session()
125+
self.lock = Lock()
126+
127+
def reflect_tables(self):
128+
raise NotImplementedError("Reflect tables not implemented")
129+
130+
def shutdown_db(self):
131+
try:
132+
self.sess.close()
133+
# due to the async nature of nxc, sometimes session state is a bit messy and this will throw:
134+
# Method 'close()' can't be called here; method '_connection_for_bind()' is already in progress and
135+
# this would cause an unexpected state change to <SessionTransactionState.CLOSED: 5>
136+
except IllegalStateChangeError as e:
137+
nxc_logger.debug(f"Error while closing session db object: {e}")
138+
139+
def clear_database(self):
140+
for table in self.metadata.sorted_tables:
141+
self.db_execute(table.delete())
142+
143+
def db_execute(self, *args):
144+
self.lock.acquire()
145+
res = self.sess.execute(*args)
146+
self.lock.release()
147+
return res

0 commit comments

Comments
 (0)