Skip to content

Commit 1e7ed07

Browse files
authored
Create Payload-Encrypt.ps1
1 parent 6b780f8 commit 1e7ed07

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Payload-Encrypt.ps1

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function Invoke-PsPayCrypt {
2+
param (
3+
[string]$Path = $null
4+
)
5+
6+
PROCESS {
7+
if (-not $Path) {
8+
$Path = Read-Host "Enter the path to the PowerShell script:"
9+
if (-not (Test-Path -Path $Path -PathType Leaf)) {
10+
Write-Host "Invalid path or file does not exist. Exiting."
11+
return
12+
}
13+
}
14+
15+
$scrcont = Get-Content $Path -Raw
16+
$encscr = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($scrcont))
17+
18+
$Seed = Get-Random
19+
$MixedBase64 = [Text.Encoding]::ASCII.GetString(([Text.Encoding]::ASCII.GetBytes($encscr) | Sort-Object { Get-Random -SetSeed $Seed }))
20+
21+
$Var1 = -Join ((65..90) + (97..122) | Get-Random -Count ((1..12) | Get-Random) | % { [char]$_ })
22+
$Var2 = -Join ((65..90) + (97..122) | Get-Random -Count ((1..12) | Get-Random) | % { [char]$_ })
23+
24+
$obfedscr = "# Obfuscated by: https://github.com/EvilBytecode`n`n" +
25+
"`$$($Var1) = [Text.Encoding]::ASCII.GetString(([Text.Encoding]::ASCII.GetBytes(`'$($MixedBase64)') | Sort-Object { Get-Random -SetSeed $($Seed) })); `$$($Var2) = [Text.Encoding]::ASCII.GetString([Convert]::FromBase64String(`$$($Var1))); IEX `$$($Var2)"
26+
27+
$putfile = "Obfuscated-" + ([System.IO.Path]::GetRandomFileName() -replace '\.', '') + ".ps1"
28+
$obfedscr | Out-File -FilePath $putfile
29+
30+
Write-Host "[+] Obfuscated script saved as $putfile" -ForegroundColor Green
31+
Start-Sleep 5
32+
}
33+
}
34+
Invoke-PsPayCrypt

0 commit comments

Comments
 (0)