Skip to content

Commit 46a97cc

Browse files
authored
Merge branch 'main' into neff-fix-modules
2 parents 0641534 + d19b524 commit 46a97cc

13 files changed

Lines changed: 25 additions & 34 deletions

File tree

nxc/modules/add-computer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from impacket.dcerpc.v5 import samr, epm, transport
44
import sys
55

6-
76
class NXCModule:
87
"""
98
Module by CyberCelt: @Cyb3rC3lt
@@ -41,6 +40,7 @@ def options(self, context, module_options):
4140

4241
if "CHANGEPW" in module_options and ("NAME" not in module_options or "PASSWORD" not in module_options):
4342
context.log.error("NAME and PASSWORD options are required!")
43+
sys.exit(1)
4444
elif "CHANGEPW" in module_options:
4545
self.__noAdd = True
4646

@@ -87,8 +87,7 @@ def on_login(self, context, connection):
8787
# If SAMR fails now try over LDAPS
8888
if not self.noLDAPRequired:
8989
self.do_ldaps_add(connection, context)
90-
else:
91-
sys.exit(1)
90+
9291

9392
def do_samr_add(self, context):
9493
"""
@@ -178,7 +177,6 @@ def do_samr_add(self, context):
178177
samr.hSamrLookupNamesInDomain(dce, domain_handle, [self.__computerName])
179178
self.noLDAPRequired = True
180179
context.log.highlight("{}".format('Computer account already exists with the name: "' + self.__computerName + '"'))
181-
sys.exit(1)
182180
except samr.DCERPCSessionError as e:
183181
if e.error_code != 0xC0000073:
184182
raise

nxc/modules/nanodump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def on_admin_login(self, context, connection):
174174
self.context.log.fail(f"Error deleting lsass.dmp file on share {self.share}: {e}")
175175
else:
176176
try:
177-
exec_method = MSSQLEXEC(self.connection.conn)
177+
exec_method = MSSQLEXEC(self.connection.conn, self.context.log)
178178
exec_method.get_file(self.remote_tmp_dir + nano_log_name, filename)
179179
self.context.log.success(f"Dumpfile of lsass.exe was transferred to {filename}")
180180
except Exception as e:

nxc/protocols/ftp/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def reflect_tables(self):
7474
print(
7575
f"""
7676
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
77-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
77+
[-] This is probably because a newer version of nxc is being run on an old DB schema
7878
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
7979
[-] Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
8080
)

nxc/protocols/ldap/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def reflect_tables(self):
5454
print(
5555
f"""
5656
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
57-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
57+
[-] This is probably because a newer version of nxc is being run on an old DB schema
5858
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
5959
[-] Then remove the nxc {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
6060
)

nxc/protocols/mssql/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def reflect_tables(self):
7777
print(
7878
f"""
7979
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
80-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
80+
[-] This is probably because a newer version of nxc is being run on an old DB schema
8181
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
8282
[-] Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
8383
)

nxc/protocols/rdp/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def reflect_tables(self):
5757
print(
5858
f"""
5959
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
60-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
60+
[-] This is probably because a newer version of nxc is being run on an old DB schema
6161
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
6262
[-] Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
6363
)

nxc/protocols/smb.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ def enum_host_info(self):
257257
except Exception as e:
258258
self.logger.debug(f"Error logging off system: {e}")
259259

260-
261260
def print_host_info(self):
262261
signing = colored(f"signing:{self.signing}", host_info_colors[0], attrs=["bold"]) if self.signing else colored(f"signing:{self.signing}", host_info_colors[1], attrs=["bold"])
263262
smbv1 = colored(f"SMBv1:{self.smbv1}", host_info_colors[2], attrs=["bold"]) if self.smbv1 else colored(f"SMBv1:{self.smbv1}", host_info_colors[3], attrs=["bold"])
@@ -1010,7 +1009,6 @@ def groups(self):
10101009
def users(self):
10111010
if len(self.args.users) > 0:
10121011
self.logger.debug(f"Dumping users: {', '.join(self.args.users)}")
1013-
10141012
return UserSamrDump(self).dump(self.args.users)
10151013

10161014
def hosts(self):
@@ -1491,12 +1489,14 @@ def dpapi(self):
14911489
credential.url,
14921490
)
14931491

1494-
if dump_cookies:
1492+
if dump_cookies and cookies:
14951493
self.logger.display("Start Dumping Cookies")
14961494
for cookie in cookies:
14971495
if cookie.cookie_value != "":
14981496
self.logger.highlight(f"[{credential.winuser}][{cookie.browser.upper()}] {cookie.host}{cookie.path} - {cookie.cookie_name}:{cookie.cookie_value}")
14991497
self.logger.display("End Dumping Cookies")
1498+
elif dump_cookies:
1499+
self.logger.fail("No cookies found")
15001500

15011501
vaults = []
15021502
try:
@@ -1537,6 +1537,9 @@ def dpapi(self):
15371537
credential.url,
15381538
)
15391539

1540+
if not (credentials and system_credentials and browser_credentials and cookies and vaults and firefox_credentials):
1541+
self.logger.fail("No secrets found")
1542+
15401543
@requires_admin
15411544
def lsa(self):
15421545
try:

nxc/protocols/smb/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def reflect_tables(self):
193193
print(
194194
f"""
195195
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
196-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
196+
[-] This is probably because a newer version of nxc is being run on an old DB schema
197197
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
198198
[-] Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
199199
)

nxc/protocols/ssh.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import time
66

7-
from io import StringIO
87
from nxc.config import process_secret
98
from nxc.connection import connection, highlight
109
from nxc.logger import NXCAdapter
@@ -182,26 +181,20 @@ def check_if_admin_sudo(self):
182181
self.logger.error("Command: 'mkfifo' unavailable, running command with 'sudo' failed")
183182
return
184183

185-
def plaintext_login(self, username, password, private_key=None):
184+
def plaintext_login(self, username, password, private_key=""):
186185
self.username = username
187186
self.password = password
188-
private_key = ""
189187
stdout = None
190188
try:
191189
if self.args.key_file or private_key:
192-
self.logger.debug("Logging in with key")
190+
self.logger.debug(f"Logging {self.host} with username: {username}, keyfile: {self.args.key_file}")
193191

194-
if self.args.key_file:
195-
with open(self.args.key_file) as f:
196-
private_key = f.read()
197-
198-
pkey = paramiko.RSAKey.from_private_key(StringIO(private_key))
199192
self.conn.connect(
200193
self.host,
201194
port=self.port,
202195
username=username,
203196
passphrase=password if password != "" else None,
204-
pkey=pkey,
197+
key_filename=private_key if private_key else self.args.key_file,
205198
look_for_keys=False,
206199
allow_agent=False,
207200
)
@@ -228,13 +221,10 @@ def plaintext_login(self, username, password, private_key=None):
228221
# Some IOT devices will not raise exception in self.conn._transport.auth_password / self.conn._transport.auth_publickey
229222
_, stdout, _ = self.conn.exec_command("id")
230223
stdout = stdout.read().decode(self.args.codec, errors="ignore")
224+
except SSHException as e:
225+
self.logger.fail(f"{username}:{process_secret(password)} Could not decrypt private key, error: {e}")
231226
except Exception as e:
232-
if self.args.key_file:
233-
password = f"{process_secret(password)} (keyfile: {self.args.key_file})"
234-
if "OpenSSH private key file checkints do not match" in str(e):
235-
self.logger.fail(f"{username}:{password} - Could not decrypt key file, wrong password")
236-
else:
237-
self.logger.fail(f"{username}:{password} {e}")
227+
self.logger.fail(f"{username}:{process_secret(password)} {e}")
238228
self.conn.close()
239229
return False
240230
else:
@@ -287,7 +277,7 @@ def plaintext_login(self, username, password, private_key=None):
287277
self.server_os_platform,
288278
"- Shell access!" if shell_access else ""
289279
)
290-
self.logger.success(f"{username}:{password} {self.mark_pwned()} {highlight(display_shell_access)}")
280+
self.logger.success(f"{username}:{process_secret(password)} {self.mark_pwned()} {highlight(display_shell_access)}")
291281

292282
return True
293283

nxc/protocols/ssh/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def reflect_tables(self):
9999
print(
100100
f"""
101101
[-] Error reflecting tables for the {self.protocol} protocol - this means there is a DB schema mismatch
102-
[-] This is probably because a newer version of nxc is being ran on an old DB schema
102+
[-] This is probably because a newer version of nxc is being run on an old DB schema
103103
[-] Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)
104104
[-] Then remove the nxc {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB"""
105105
)

0 commit comments

Comments
 (0)