Skip to content

Commit 0ffa19d

Browse files
Merge pull request Pennyw0rth#272 from Pennyw0rth/neff-fix-ssh
Fix ssh auth message
2 parents 1f8a0ef + 71f9fda commit 0ffa19d

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

nxc/protocols/ssh.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, args, db, host):
1919
self.protocol = "SSH"
2020
self.remote_version = "Unknown SSH Version"
2121
self.server_os_platform = "Linux"
22-
self.user_principal = "root"
22+
self.uac = ""
2323
super().__init__(args, db, host)
2424

2525
def proto_flow(self):
@@ -221,10 +221,15 @@ def plaintext_login(self, username, password, private_key=""):
221221
# Some IOT devices will not raise exception in self.conn._transport.auth_password / self.conn._transport.auth_publickey
222222
_, stdout, _ = self.conn.exec_command("id")
223223
stdout = stdout.read().decode(self.args.codec, errors="ignore")
224+
except AuthenticationException:
225+
self.logger.fail(f"{username}:{process_secret(password)}")
224226
except SSHException as e:
225-
self.logger.fail(f"{username}:{process_secret(password)} Could not decrypt private key, error: {e}")
227+
if "Invalid key" in str(e):
228+
self.logger.fail(f"{username}:{process_secret(password)} Could not decrypt private key, error: {e}")
229+
else:
230+
self.logger.exception(e)
226231
except Exception as e:
227-
self.logger.fail(f"{username}:{process_secret(password)} {e}")
232+
self.logger.exception(e)
228233
self.conn.close()
229234
return False
230235
else:
@@ -235,15 +240,11 @@ def plaintext_login(self, username, password, private_key=""):
235240
_, stdout, _ = self.conn.exec_command("whoami /priv")
236241
stdout = stdout.read().decode(self.args.codec, errors="ignore")
237242
self.server_os_platform = "Windows"
238-
self.user_principal = "admin"
239243
if "SeDebugPrivilege" in stdout:
240244
self.admin_privs = True
241245
elif "SeUndockPrivilege" in stdout:
242246
self.admin_privs = True
243-
self.user_principal = "admin (UAC)"
244-
else:
245-
# non admin (low priv)
246-
self.user_principal = "admin (low priv)"
247+
self.uac = "with UAC - "
247248

248249
if not stdout:
249250
self.logger.debug(f"User: {self.username} can't get a basic shell")
@@ -261,22 +262,12 @@ def plaintext_login(self, username, password, private_key=""):
261262
if self.args.key_file:
262263
self.db.add_admin_user("key", username, password, host_id=host_id, cred_id=cred_id)
263264
else:
264-
self.db.add_admin_user(
265-
"plaintext",
266-
username,
267-
password,
268-
host_id=host_id,
269-
cred_id=cred_id,
270-
)
265+
self.db.add_admin_user("plaintext", username, password, host_id=host_id, cred_id=cred_id)
271266

272267
if self.args.key_file:
273268
password = f"{process_secret(password)} (keyfile: {self.args.key_file})"
274269

275-
display_shell_access = "{} {} {}".format(
276-
f"({self.user_principal})" if self.admin_privs else f"(non {self.user_principal})",
277-
self.server_os_platform,
278-
"- Shell access!" if shell_access else ""
279-
)
270+
display_shell_access = f"{self.uac}{self.server_os_platform}{' - Shell access!' if shell_access else ''}"
280271
self.logger.success(f"{username}:{process_secret(password)} {self.mark_pwned()} {highlight(display_shell_access)}")
281272

282273
return True

0 commit comments

Comments
 (0)