Skip to content

Commit

Permalink
Merge branch 'main' into remove-git-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
NeffIsBack authored Apr 1, 2024
2 parents cb40697 + 0eeddfb commit e14bbaf
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Lint Python code with ruff
# Caching source: https://gist.github.com/gh640/233a6daf68e9e937115371c0ecd39c61?permalink_comment_id=4529233#gistcomment-4529233

on: [push, pull_request]
on:
push:

jobs:
lint:
name: Lint Python code with ruff
runs-on: ubuntu-latest
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
Expand Down
52 changes: 34 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
name: NetExec Tests

on:
workflow_dispatch:
pull_request_review:
types: [submitted]

jobs:
build:
name: NetExec Tests for Py${{ matrix.python-version }}
name: Test for Py${{ matrix.python-version }}
if: github.event.review.state == 'APPROVED'
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 5
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: NetExec set up python on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: |
pipx install poetry --python python${{ matrix.python-version }}
poetry --version
poetry env info
- name: Install libraries with dev group
run: |
poetry install --with dev
- name: Run the e2e test
run: |
poetry run pytest tests
- uses: actions/checkout@v3
- name: Install poetry
run: |
pipx install poetry
- name: NetExec set up python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: poetry.lock
- name: Install poetry
run: |
pipx install poetry --python python${{ matrix.python-version }}
poetry --version
poetry env info
- name: Install libraries with dev group
run: |
poetry install --with dev
- name: Load every protocol and module
run: |
poetry run netexec winrm 127.0.0.1
poetry run netexec vnc 127.0.0.1
poetry run netexec smb 127.0.0.1
poetry run netexec ldap 127.0.0.1
poetry run netexec wmi 127.0.0.1
poetry run netexec rdp 127.0.0.1
poetry run netexec mssql 127.0.0.1
poetry run netexec ssh 127.0.0.1
poetry run netexec ftp 127.0.0.1
poetry run netexec smb 127.0.0.1 -M veeam
4 changes: 3 additions & 1 deletion nxc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ def hash_login(self, domain, username, ntlm_hash):
def proto_flow(self):
self.logger.debug("Kicking off proto_flow")
self.proto_logger()
if self.create_conn_obj():
if not self.create_conn_obj():
self.logger.info(f"Failed to create connection object for target {self.host}, exiting...")
else:
self.logger.debug("Created connection object")
self.enum_host_info()
if self.print_host_info() and (self.login() or (self.username == "" and self.password == "")):
Expand Down
2 changes: 1 addition & 1 deletion nxc/loaders/moduleloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_module_info(self, module_path):
module_spec = spec.loader.load_module().NXCModule

module = {
f"{module_spec.name.lower()}": {
f"{module_spec.name}": {
"path": module_path,
"description": module_spec.description,
"options": module_spec.options.__doc__,
Expand Down
2 changes: 1 addition & 1 deletion nxc/modules/MAQ.py → nxc/modules/maq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NXCModule:
def options(self, context, module_options):
pass

name = "MAQ"
name = "maq"
description = "Retrieves the MachineAccountQuota domain-level attribute"
supported_protocols = ["ldap"]
opsec_safe = True
Expand Down
2 changes: 1 addition & 1 deletion nxc/netexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def main():
exit(0)
elif args.module:
nxc_logger.debug(f"Modules to be Loaded: {args.module}, {type(args.module)}")
for m in map(str.lower, args.module):
for m in args.module:
if m not in modules:
nxc_logger.error(f"Module not found: {m}")
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Run `pytest` (or `poetry run pytest`)

### End to End Tests
* Install nxc (either in venv or via Poetry)
* Install nxc (either in venv or via Poetry): `poetry install --with dev`
* Run `python tests/e2e_tests.py -t $IP -u $USER -p $PASS`, with optional `-k` parameter
* Poetry: `poetry run python tests/e2e_tests.py -t $IP -u $USER -p $PASS`
* To see full errors (that might show real errors not caught by checking the exit code), run with the `--errors` flag
File renamed without changes.

0 comments on commit e14bbaf

Please sign in to comment.