param( [Parameter(Mandatory = $false)] [string]$Technique = "All", [Parameter(Mandatory = $false)] [switch]$Help ) try { # Clear the console Clear-Host # Show help if requested if ($Help) { Write-Host "Usage: .\pack.ps1 [-Technique ] [-Help]" Write-Host "" Write-Host "Techniques:" Write-Host " · Chameleon: Substitute strings and concatenate variables" Write-Host " · BetterXencrypt: Compresses and encrypts with random iterations" Write-Host " · PyFuscation: Obfuscate functions, variables and parameters" Write-Host " · ReverseB64: Encode with base64 and reverse it to avoid detections" Write-Host " · PSObfuscation: Convert content to bytes and encode with Gzip" Write-Host " · All: Sequentially executes all techniques described above" Write-Host "" Write-Host "Default: All techniques" exit 0 } # Check if portable.ps1 exists if (-not (Test-Path -Path ".\portable.ps1")) { Write-Error "portable.ps1 not found in current directory." exit 1 } # Check if Invoke-Stealth directory exists if (-not (Test-Path -Path ".\Invoke-Stealth")) { Write-Error "Invoke-Stealth directory not found. Please ensure it's in the current directory." exit 2 } # Check if Invoke-Stealth.ps1 exists if (-not (Test-Path -Path ".\Invoke-Stealth\Invoke-Stealth.ps1")) { Write-Error "Invoke-Stealth.ps1 not found in Invoke-Stealth directory." exit 3 } Write-Host "Copying portable.ps1 to python.ps1..." # Copy portable.ps1 to python.ps1 Copy-Item -Path ".\portable.ps1" -Destination ".\python.ps1" -Force if (-not (Test-Path -Path ".\python.ps1")) { Write-Error "Failed to copy portable.ps1 to python.ps1" exit 4 } Write-Host "Successfully copied portable.ps1 to python.ps1" Write-Host "Starting obfuscation with technique: $Technique" # Run Invoke-Stealth to obfuscate python.ps1 $invokeStealthPath = ".\Invoke-Stealth\Invoke-Stealth.ps1" & $invokeStealthPath ".\python.ps1" -technique $Technique if ($LASTEXITCODE -eq 0) { Write-Host "Obfuscation completed successfully!" Write-Host "Obfuscated script saved as: python.ps1" } else { Write-Error "Obfuscation failed with exit code: $LASTEXITCODE" exit 5 } } catch { Write-Error "Unexpected error: $_" exit 99 }