@@ -173,10 +173,10 @@ def _stackedWriteFilePS(self, tmpPath, wFileContent, dFile, fileType):
173173 encodedBase64File = "tmpf%s.txt" % randomStr (lowercase = True )
174174 encodedBase64FilePath = "%s\%s" % (tmpPath , encodedBase64File )
175175
176- randPSScript = "tmpf %s.ps1" % randomStr (lowercase = True )
176+ randPSScript = "tmpps %s.ps1" % randomStr (lowercase = True )
177177 randPSScriptPath = "%s\%s" % (tmpPath , randPSScript )
178178
179- wFileSize = len (wFileContent )
179+ wFileSize = len (encodedFileContent )
180180 chunkMaxSize = 1024
181181
182182 logger .debug ("uploading the base64-encoded file to %s, please wait.." % encodedBase64FilePath )
@@ -186,9 +186,10 @@ def _stackedWriteFilePS(self, tmpPath, wFileContent, dFile, fileType):
186186 self .xpCmdshellWriteFile (wEncodedChunk , tmpPath , encodedBase64File )
187187
188188 #psString = "$Content = [System.Convert]::FromBase64String(\"%s\"); Set-Content -Path \"%s\" -Value $Content -Encoding Byte" % (encodedFileContent, dFile)
189- psString = "$Base64 = Get-Content -Path %s; $Content = " % encodedBase64FilePath
189+ psString = "$Base64 = Get-Content -Path \" %s\" ; " % encodedBase64FilePath
190+ psString += "$Base64 = $Base64 -replace \" `t|`n|`r\" ,\" \" ; $Content = "
190191 psString += "[System.Convert]::FromBase64String($Base64); Set-Content "
191- psString += "-Path %s -Value $Content -Encoding Byte" % dFile
192+ psString += "-Path \" %s \" -Value $Content -Encoding Byte" % dFile
192193
193194 logger .debug ("uploading the PowerShell base64-decoding script to %s, please wait.." % randPSScriptPath )
194195 self .xpCmdshellWriteFile (psString , tmpPath , randPSScript )
0 commit comments