diff --git a/plugins/dbms/mssqlserver/filesystem.py b/plugins/dbms/mssqlserver/filesystem.py index 9a2c6cfd4..0b3be8c67 100644 --- a/plugins/dbms/mssqlserver/filesystem.py +++ b/plugins/dbms/mssqlserver/filesystem.py @@ -175,6 +175,16 @@ class Filesystem(GenericFilesystem): encodedFileContent = base64encode(wFileContent) #psString = "[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String(\"%s\")) | Out-File \"%s\"" % (encodedFileContent, dFile) psString = "[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String(\"%s\")) ^> \"%s\"" % (encodedFileContent, dFile) + #psString = "[System.Text.Encoding]::UTF8.GetBytes([System.Convert]::FromBase64String(\"%s\")) | Out-File \"%s\"" % (encodedFileContent, dFile) + #psString = "[System.Text.Encoding]::UTF8.GetBytes([System.Convert]::FromBase64String(\"%s\")) ^> \"%s\"" % (encodedFileContent, dFile) + #psString = """$Content = Get-Content -Path %s -Encoding Byte + #$Base64 = [System.Convert]::ToBase64String($Content) + psString = """ + $Base64 = [System.Convert]::ToBase64String($Content) + $Content = [System.Convert]::FromBase64String("%s") + Set-Content -Path %s -Value $Content -Encoding Byte + """ % (encodedFileContent, randPSScriptPath) + psString = binToHexQuery.replace(" ", "").replace("\n", ";") logger.debug("uploading the PowerShell script to %s, please wait.." % randPSScriptPath) self.xpCmdshellWriteFile(psString, tmpPath, randPSScript)