Skip to content

Commit a562430

Browse files
authored
Merge branch 'main' into neff-patch-1
2 parents 5aca578 + 1bfe964 commit a562430

5 files changed

Lines changed: 562 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ 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
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- name: Install poetry
2121
run: |
22-
pipx install poetry
22+
pipx install poetry==1.8.4
2323
- name: NetExec set up python ${{ matrix.python-version }} on ${{ matrix.os }}
2424
uses: actions/setup-python@v5
2525
with:

nxc/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ def gen_cli_args():
9898
kerberos_group.add_argument("--use-kcache", action="store_true", help="Use Kerberos authentication from ccache file (KRB5CCNAME)")
9999
kerberos_group.add_argument("--aesKey", metavar="AESKEY", nargs="+", help="AES key to use for Kerberos Authentication (128 or 256 bits)")
100100
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+
certificate_group = std_parser.add_argument_group("Certificate", "Options for certificate authentication")
103+
certificate_group.add_argument("--pfx-cert", metavar="PFXCERT", help="Use certificate authentication from pfx file .pfx")
104+
certificate_group.add_argument("--pfx-base64", metavar="PFXB64", help="Use certificate authentication from pfx file encoded in base64")
105+
certificate_group.add_argument("--pfx-pass", metavar="PFXPASS", help="Password of the pfx certificate")
106+
certificate_group.add_argument("--cert-pem", metavar="CERTPEM", help="Use certificate authentication from PEM file")
107+
certificate_group.add_argument("--key-pem", metavar="KEYPEM", help="Private key for the PEM format")
101108

102109
server_group = std_parser.add_argument_group("Servers", "Options for nxc servers")
103110
server_group.add_argument("--server", choices={"http", "https"}, default="https", help="use the selected server")

nxc/connection.py

Lines changed: 12 additions & 2 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
@@ -548,6 +550,14 @@ def login(self):
548550
self.logger.info("Successfully authenticated using Kerberos cache")
549551
return True
550552

553+
if self.args.pfx_cert or self.args.pfx_base64 or self.args.cert_pem:
554+
self.logger.debug("Trying to authenticate using Certificate pfx")
555+
if not self.args.username:
556+
self.logger.fail("You must specify a username when using certificate authentication")
557+
return False
558+
with sem:
559+
return pfx_auth(self)
560+
551561
if hasattr(self.args, "laps") and self.args.laps:
552562
self.logger.debug("Trying to authenticate using LAPS")
553563
username[0], secret[0], domain[0] = laps_search(self, username, secret, cred_type, domain, self.dns_server)

0 commit comments

Comments
 (0)