aboutsummaryrefslogtreecommitdiff
path: root/ScriptModification/Out-EncryptedScript.ps1
diff options
context:
space:
mode:
authorPowerShellMafia <PowerShellMafia@users.noreply.github.com>2015-12-18 16:33:59 -0800
committerPowerShellMafia <PowerShellMafia@users.noreply.github.com>2015-12-18 16:33:59 -0800
commit9e771d15bf19ab3c2ac196393c088ecdab6c9a73 (patch)
tree58927893ecb9289ad1de64d3a67eb58d00e4b762 /ScriptModification/Out-EncryptedScript.ps1
parent9f78286ea7b0ec65d2aa09893a076864dd8d14e9 (diff)
parent9f183e36518176c4299eed5c68b7deac7f4e8025 (diff)
downloadPowerSploit-3.0.0.tar.gz
PowerSploit-3.0.0.zip
Merge pull request #102 from PowerShellMafia/devv3.0.0
Merge 3.0 release changes
Diffstat (limited to 'ScriptModification/Out-EncryptedScript.ps1')
-rw-r--r--ScriptModification/Out-EncryptedScript.ps15
1 files changed, 3 insertions, 2 deletions
diff --git a/ScriptModification/Out-EncryptedScript.ps1 b/ScriptModification/Out-EncryptedScript.ps1
index 1764d17..eba48f7 100644
--- a/ScriptModification/Out-EncryptedScript.ps1
+++ b/ScriptModification/Out-EncryptedScript.ps1
@@ -90,7 +90,7 @@ This command can be used to encrypt any text-based file/script
$AsciiEncoder = New-Object System.Text.ASCIIEncoding
$ivBytes = $AsciiEncoder.GetBytes($InitializationVector)
# While this can be used to encrypt any file, it's primarily designed to encrypt itself.
- [Byte[]] $scriptBytes = [Text.Encoding]::ASCII.GetBytes((Get-Content -Encoding Ascii -Path $ScriptPath))
+ [Byte[]] $scriptBytes = Get-Content -Encoding Byte -ReadCount 0 -Path $ScriptPath
$DerivedPass = New-Object System.Security.Cryptography.PasswordDeriveBytes($Password, $AsciiEncoder.GetBytes($Salt), "SHA1", 2)
$Key = New-Object System.Security.Cryptography.TripleDESCryptoServiceProvider
$Key.Mode = [System.Security.Cryptography.CipherMode]::CBC
@@ -126,7 +126,8 @@ function de([String] `$b, [String] `$c)
`$i.Close();
`$j.Close();
`$f.Clear();
-return `$encoding.GetString(`$h,0,`$h.Length);
+if ((`$h.Length -gt 3) -and (`$h[0] -eq 0xEF) -and (`$h[1] -eq 0xBB) -and (`$h[2] -eq 0xBF)) { `$h = `$h[3..(`$h.Length-1)]; }
+return `$encoding.GetString(`$h).TrimEnd([Char] 0);
}
"@