more on issue #742

This commit is contained in:
Bernardo Damele 2014-06-30 20:39:21 +01:00
parent ce67156d80
commit 0c1b3f2dbc

View File

@ -173,18 +173,7 @@ class Filesystem(GenericFilesystem):
randPSScriptPath = "%s\%s" % (tmpPath, randPSScript) randPSScriptPath = "%s\%s" % (tmpPath, randPSScript)
encodedFileContent = base64encode(wFileContent) encodedFileContent = base64encode(wFileContent)
#psString = "[System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String(\"%s\")) | Out-File \"%s\"" % (encodedFileContent, dFile) psString = "$Content = [System.Convert]::FromBase64String(\"%s\"); Set-Content -Path \"%s\" -Value $Content -Encoding Byte" % (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 = """
$Content = [System.Convert]::FromBase64String("%s")
Set-Content -Path %s -Value $Content -Encoding Byte
""" % (encodedFileContent, randPSScriptPath)
psString = psString.replace(" ", "").replace("\n", ";")
logger.debug("uploading the PowerShell script to %s, please wait.." % randPSScriptPath) logger.debug("uploading the PowerShell script to %s, please wait.." % randPSScriptPath)
self.xpCmdshellWriteFile(psString, tmpPath, randPSScript) self.xpCmdshellWriteFile(psString, tmpPath, randPSScript)