From 75190da24a9a223fc6e76d9f7411ea0a4f7566ec Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sat, 11 Nov 2023 17:13:41 -0500 Subject: [PATCH 1/2] Adding error handling for unexpected powershell output, see issue #93 --- nxc/modules/veeam_dump.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/nxc/modules/veeam_dump.py b/nxc/modules/veeam_dump.py index 305e4b5d9..84ffbbf76 100644 --- a/nxc/modules/veeam_dump.py +++ b/nxc/modules/veeam_dump.py @@ -149,12 +149,18 @@ def printCreds(self, context, output): context.log.fail(output_stripped[0]) return - for account in output_stripped: - user, password = account.split(" ", 1) - password = password.replace("WHITESPACE_ERROR", " ") - context.log.highlight(user + ":" + f"{password}") - if " " in password: - context.log.fail(f'Password contains whitespaces! The password for user "{user}" is: "{password}"') + # When powershell returns something else than the usernames and passwords account.split() will throw a ValueError. + # This is likely an error thrown by powershell, so we print the error and the output for debugging purposes. + try: + for account in output_stripped: + user, password = account.split(" ", 1) + password = password.replace("WHITESPACE_ERROR", " ") + context.log.highlight(user + ":" + f"{password}") + if " " in password: + context.log.fail(f'Password contains whitespaces! The password for user "{user}" is: "{password}"') + except ValueError: + context.log.fail(f"Powershell returned unexpected output: {output_stripped}") + context.log.fail("Please report this issue on GitHub!") def on_admin_login(self, context, connection): self.checkVeeamInstalled(context, connection) From 862aef7ec60ecb7c7f1092112802a86c7880d007 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Sun, 12 Nov 2023 23:14:04 +0100 Subject: [PATCH 2/2] Properly use f-string --- nxc/modules/veeam_dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/modules/veeam_dump.py b/nxc/modules/veeam_dump.py index 84ffbbf76..a44fa2e55 100644 --- a/nxc/modules/veeam_dump.py +++ b/nxc/modules/veeam_dump.py @@ -155,7 +155,7 @@ def printCreds(self, context, output): for account in output_stripped: user, password = account.split(" ", 1) password = password.replace("WHITESPACE_ERROR", " ") - context.log.highlight(user + ":" + f"{password}") + context.log.highlight(f"{user}:{password}") if " " in password: context.log.fail(f'Password contains whitespaces! The password for user "{user}" is: "{password}"') except ValueError: