
PowerShell-Verschleierer
Sein Ziel ist es, Code zu transformieren, um Analyse und statische Signaturen zu erschweren, nützlich in Laboren und autorisierten Red-Team-/Pentesting-Einsätzen.
Unterstützt 6 Stufen der Verschleierung plus eine Transformations-/Pipeline-Architektur, die das Stapeln von Techniken wie String-Tokenisierung, leichte Literal-Verschlüsselung, Zahlenmaskierung, Identifikator-Morphing, Format "jitter," Kontrollfluss-Kosmetik, Dead-Code-Injektion, Fragmentierungsprofile und deterministische Profile ermöglicht.
⚠️ Verantwortungsvolle Nutzung: Dieses Tool ist nur für Forschung und autorisierte Tests vorgesehen. Nicht für böswillige Zwecke verwenden.```powershell
./psobf -h
██████╗ ███████╗ ██████╗ ██████╗ ███████╗
██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝
██████╔╝███████╗██║ ██║██████╔╝█████╗
██╔═══╝ ╚════██║██║ ██║██╔══██╗██╔══╝
██║ ███████║╚██████╔╝██████╔╝██║
╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝
Omar Salazar
v.2.0.0
Usage: psobf -i -o -level <1|2|3|4|5|6> [options]
Obfuscation Levels: 1 - Char join encoding 2 - Base64 encoding 3 - Base64 encoding (alternate) 4 - GZip + Base64 compression 5 - Script fragmentation 6 - AES-256 CTR encryption (NEW in 2.0.0)
Transform Pipeline Options (use with -pipeline): iden - Identifier morphing (use with -iden obf) strenc - String encryption (use with -strenc xor|rc4) stringdict - String tokenization (use with -stringdict N) numenc - Number encoding fmt - Format jitter (use with -fmt jitter) cf - Control flow obfuscation (use with -cf-opaque, -cf-shuffle) dead - Dead code injection (use with -deadcode N) hexenc - Hex string encoding (NEW) alias - Cmdlet alias substitution (NEW) unicode - Unicode character encoding (NEW) antidebug - Anti-debugging/VM detection (NEW) iexobf - Invoke-Expression obfuscation (NEW)
Examples:
psobf -i script.ps1 -o out.ps1 -level 2
psobf -i script.ps1 -o out.ps1 -level 6 -profile heavy
psobf -i script.ps1 -o out.ps1 -level 4 -pipeline "iden,alias,hexenc,antidebug,iexobf" -iden obf
psobf -i script.ps1 -o out.ps1 -level 4 -pipeline "strenc" -strenc rc4 -strkey 0011223344556677
## Funktionen
<h1 align="center">
<img src="https://assets.kitploit.com/production/public/readmes/6598/11956ab9f65e8dc1b0460652042c601f70d28bb67e9fd6f0a89813ed5369997f.gif" alt="psobf" width="700px"></a>
<br>
</h1>
<h1 align="center">
<img src="https://raw.githubusercontent.com/taurusomar/psobf/HEAD/static/poc2.gif" alt="psobf" width="700px"></a>
<br>
</h1>
---
## Installation```bash
go install github.com/TaurusOmar/psobf/v2/cmd/[email protected]
psobf -i input.ps1 -o out.ps1 -level 1..6 [options] psobf -h # full help
## Funktionen
<h1 align="center">
<img src="https://assets.kitploit.com/production/public/readmes/6598/11956ab9f65e8dc1b0460652042c601f70d28bb67e9fd6f0a89813ed5369997f.gif" alt="psobf" width="700px"></a>
<br>
</h1>
<h1 align="center">
<img src="https://raw.githubusercontent.com/taurusomar/psobf/HEAD/static/poc2.gif" alt="psobf" width="700px"></a>
<br>
</h1>
---
## Installation```bash
go install github.com/TaurusOmar/psobf/cmd/[email protected]
psobf -i input.ps1 -o out.ps1 -level 1..6 [options] psobf -h # full help
---
## Vollständige Referenz der Flags
| Flag | Typ / Werte | Standard | Beschreibung | Beispiel | | |
| ------------- | ----------------- | ---------------: | ------------------------------------------- | ------------------------------------------------------------ | ------------------------------- | ---------------------- |
| `-i` | string | — | Eingabe PS1 (verwende `-stdin` zum Lesen von der Pipe) | `-i script.ps1` | | |
| `-o` | string | `obfuscated.ps1` | Ausgabe (verwende `-stdout` zum Schreiben in STDOUT) | `-o out.ps1` | | |
| `-level` | 1..6 | 1 | Endgültiger Packer (siehe Levels) | `-level 4` | | |
| `-noexec` | bool | false | Nur Payload ausgeben (kein `Invoke-Expression`) | `-noexec` | | |
| `-stdin` | bool | false | PS von STDIN lesen | `-stdin` | | |
| `-stdout` | bool | false | Ergebnis in STDOUT schreiben | `-stdout` | | |
| `-seed` | int64 | zufällig | Reproduzierbarer Zufall | `-seed 42` | | |
| `-q` | bool | false | Ruhig (kein Banner) | `-q` | | |
| `-pipeline` | csv | — | In der Reihenfolge anzuwendende Transformationen | `-pipeline "iden,strenc,stringdict,numenc,fmt,cf,dead,frag"` | | |
| `-iden` | `keep`/`obf` | `keep` | Bezeichner-Morphing (Variablen & Funktionen) | `-iden obf` | | |
| `-strenc` | `off`/`xor`/`rc4` | `off` | Verschlüsselung von Zeichenfolgenliteralen | `-strenc rc4` | | |
| `-strkey` | hex | — | Schlüssel für `-strenc` | `-strkey 0011223344556677` | | |
| `-stringdict` | 0..100 | 0 | Lange Zeichenfolgen tokenisieren; %-Wahrscheinlichkeit pro Literal | `-stringdict 40` | | |
| `-numenc` | bool | false | Zahlen als arithmetische PS-Ausdrücke codieren | `-numenc` | | |
| `-fmt` | `off`/`jitter` | `off` | Leerzeichen/Zeilenumbrüche randomisieren | `-fmt jitter` | | |
| `-cf-opaque` | bool | false | In `if(1 -eq 1){...}` einwickeln | `-cf-opaque` | | |
| `-cf-shuffle` | bool | false | **Funktionsblöcke** neu anordnen | `-cf-shuffle` | | |
| `-deadcode` | 0..100 | 0 | Wahrscheinlichkeit für Dead-Code-Injektion | `-deadcode 20` | | |
| `-frag` | \`profile=tight | medium | loose\` | — | Fragmentierungsprofil (Stufe 5) | `-frag profile=medium` |
| `-minfrag` | int | 10 | Minimale Fragmentgröße (Stufe 5) | `-minfrag 8` | | |
| `-maxfrag` | int | 20 | Maximale Fragmentgröße (Stufe 5) | `-maxfrag 16` | | |
| `-profile` | \`light | balanced | heavy\` | — | Voreinstellungen für Pipeline/Seed/usw. | `-profile heavy` |
| `-fuzz` | int | 0 | N Varianten erzeugen (verschiedene Seeds) | `-fuzz 5` | | |
| `-poly` | int | 0 | Polymorphe Varianten pro Transformation | `-poly 3` | | |
> Die **Pipeline** wird **vor** dem finalen **`-level`**-Packing ausgeführt.
---
## Beispiel-Eingabeskript (sicher)
Um die Beispiele harmlos zu halten, verwenden wir:```powershell
Write-Host "Hello, World!"
$answer = 42
function Greet($name) { Write-Host ("Hi, " + $name) }
Greet "Ada"
Das Folgende zeigt die Form der Ausgaben (Ausschnitte). Tatsächliche Payloads unterscheiden sich.
psobf -i sample.ps1 -o out.ps1 -level 1
**Ausgabe (Auszug):**```powershell
$obfuscated = $([char[]](87,114,105,116,101,45,72,111,115,116,32,34,72,101,108,108,111,44,32,87,111,114,108,100,33,34,10,36,97,110,115,119,101,114,32,61,32,52,50,10,102,117,110,99,116,105,111,110,32,71,114,101,101,116,40,36,110,97,109,101,41,32,123,32,87,114,105,116,101,45,72,111,115,116,32,40,34,72,105,44,32,34,32,43,32,36,110,97,109,101,41,32,125,10,71,114,101,101,116,32,34,65,100,97,34,10) -join ''); Invoke-Expression $obfuscated
psobf -i sample.ps1 -o out.ps1 -level 2
**Ausgabe (Auszug):**```powershell
$obfuscated = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('V3JpdGUtSG9zdCAiSGVsbG8sIFdvcmxkISIKJGFuc3dlciA9IDQyCmZ1bmN0aW9uIEdyZWV0KCRuYW1lKSB7IFdyaXRlLUhvc3QgKCJIaSwgIiArICRuYW1lKSB9CkdyZWV0ICJBZGEiCg==')); Invoke-Expression $obfuscated
psobf -i sample.ps1 -o out.ps1 -level 3
**Ausgabe (Ausschnitt):**```powershell
$e = [Convert]::FromBase64String('V3JpdGUtSG9zdCAiSGVsbG8sIFdvcmxkISIKJGFuc3dlciA9IDQyCmZ1bmN0aW9uIEdyZWV0KCRuYW1lKSB7IFdyaXRlLUhvc3QgKCJIaSwgIiArICRuYW1lKSB9CkdyZWV0ICJBZGEiCg=='); $obfuscated = [Text.Encoding]::UTF8.GetString($e); Invoke-Expression $obfuscated
psobf -i sample.ps1 -o out.ps1 -level 4
**Ausgabe (Auszug):**```powershell
$compressed = 'H4sIAAAAAAAA/wovyixJ1fXILy5RUPJIzcnJ11EIzy/KSVFU4lJJzCsuTy1SsFUwMeJKK81LLsnMz1NwL0pNLdFQyUvMTdVUqFZA0q+h5JGpo6CkoK0Ala3lAitWUHJMSVTiAgQAAP//m+Ey2GoAAAA='; $bytes = [Convert]::FromBase64String($compressed); $ms = New-Object IO.MemoryStream(,$bytes); $gz = New-Object IO.Compression.GzipStream($ms,[IO.Compression.CompressionMode]::Decompress); $sr = New-Object IO.StreamReader($gz); $obfuscated = $sr.ReadToEnd(); Invoke-Expression $obfuscated
Level 5 — Fragmentierung```bash psobf -i sample.ps1 -o out.ps1 -level 5
**Ausgabe (Auszug):**```powershell
$fragments = @('Write-Host "Hello',', World!"
$','answer = 42','
function G','reet($name)',' { Write-Ho','st ("Hi, " ','+ $name) }
','Greet "Ada"','
'); $script = $fragments -join ''; Invoke-Expression $script
psobf -i sample.ps1 -o out.ps1 -level 6
**Output (Auszug):**```powershell
$k=[Convert]::FromBase64String('...base64key...');$iv=[Convert]::FromBase64String('...base64iv...');$e=[Convert]::FromBase64String('...base64ciphertext...');$a=New-Object Security.Cryptography.AesManaged;$a.Key=$k;$a.IV=$iv;$d=$a.CreateDecryptor();$bytes=$d.TransformFinalBlock($e,0,$e.Length);$dec=[Text.Encoding]::UTF8.GetString($bytes);Invoke-Expression $dec
Verwenden Sie
-noexec, um Payloads ohne Ausführung zu inspizieren.
-iden)__$.Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "iden" -iden obf -seed 11
**Ausgabe (Auszug)**```powershell
$WguE = 42
function QhZy($Chx){ Write-Host ("Hi, " + $Chx) }
QhZy "Ada"
-strenc xor|rc4)Verschlüsselt nur String-Literale (keine API-Manipulation). Entschlüsselt just-in-time zur Laufzeit. Flags: -strenc xor|rc4, -strkey .
Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "strenc" -strenc xor -strkey a1b2c3d4 -seed 42
**Ausgabe (Auszug)**```powershell
$b=[Convert]::FromBase64String('EwAB...'); for($i=0;$i -lt $b.Length;$i++){$b[$i]=$b[$i] -bxor 0xA1}; [Text.Encoding]::UTF8.GetString($b)
Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "strenc" -strenc rc4 -strkey 0011223344556677 -seed 7
**Ausgabe (Auszug)**```powershell
function __decGWREVT($k,[byte[]]$d){ $s=0..255; $j=0; for($i=0;$i -lt 256;$i++){ $j=($j+$s[$i]+$k[$i%$k.Length])%256; $t=$s[$i];$s[$i]=$s[$j];$s[$j]=$t } $i=0;$j=0; for($x=0;$x -lt $d.Length;$x++){ $i=($i+1)%256;$j=($j+$s[$i])%256; $t=$s[$i];$s[$i]=$s[$j];$s[$j]=$t; $d[$x]=$d[$x] -bxor $s[($s[$i]+$s[$j])%256] } [Text.Encoding]::UTF8.GetString($d) }
...
( __decGWREVT ([byte[]](0..(8-1)|%{[Convert]::ToByte('0011223344556677'.Substring($_*2,2),16)})) ([Convert]::FromBase64String('m7m7...')) )
-stringdict)Tokenisiert lange Zeichenketten in ein $D-Array und setzt sie zur Laufzeit wieder zusammen. Reduziert sich wiederholende Signaturen.
Flag: -stringdict <0..100>
Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 3 -pipeline "stringdict" -stringdict 40 -seed 1
**Ausgabe (Auszug)**```powershell
$D=@('Hello',', World','!','Hi, ', 'Ada');
Write-Host ($D[0]+$D[1]+$D[2])
function Greet($name){ Write-Host ($D[3] + $name) }
Greet $D[4]
-numenc)Ersetzt einfache Zahlen durch äquivalente arithmetische/bitweise Ausdrücke (außerhalb von Zeichenketten).
Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "numenc" -numenc -seed 1337
**Ausgabe (Ausschnitt)**```powershell
$answer = ((0x2A -bxor 0x00)+0)
Vorsicht: Redirects wie 2>&1 müssen identisch bleiben. Wenn Ihre Quelle unquoted Redirects enthält und Sie Probleme haben, deaktivieren Sie -numenc oder kapseln Sie diese Redirects in Strings in der Quelle.
-fmt)Randomisiert Abstände und Zeilenumbrüche.
Command```bash psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "fmt" -fmt jitter -seed 20
**Ausgabe (Snippet)**```powershell
Write-Host "Hello, World!"
$answer=42
function Greet($name) { Write-Host ("Hi, "+$name) }
Greet "Ada"
-cf-opaque, -cf-shuffle)-cf-opaque: umhüllt das gesamte Skript mit einem niemals-falschen Zweig.-cf-shuffle: ordnet Funktionsblöcke neu an (nicht einzelne Anweisungen). Sie werden Änderungen nur bemerken, wenn Ihr Skript Funktionen definiert.Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "cf" -cf-opaque -cf-shuffle -seed 77
**Ausgabe (Auszug)**```powershell
if(1 -eq 1){
function Greet($name){ Write-Host ("Hi, " + $name) }
Write-Host "Hello, World!"
$answer = 42
Greet "Ada"
}
-deadcode)Fügt No-op-Funktionen, 0-Iterations-Schleifen, harmlose Zeichenketten usw. ein. Gesteuert durch Wahrscheinlichkeit. Flag: -deadcode <0..100> (Wahrscheinlichkeit der Snippet-Einfügung).
Befehl```bash psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "dead" -deadcode 25 -seed 5
**Ausgabe (Auszug)**```powershell
function __dummyzQJxJk { return }
for($i=0;$i -lt 0;$i++){Start-Sleep -Milliseconds 0}
$x='canary';$y=$x+$x|Out-Null
Write-Host "Hello, World!"
...
-frag, -minfrag, -maxfrag)Betrifft nur Stufe 5 (Zeichenkettenfragmente + Runtime Join).
Profile:
profile=tight → kleine Fragmente (≈6–10)profile=medium → mittlere Fragmente (≈10–18)profile=loose → größere Fragmente (≈14–28)Oder anpassen mit -minfrag / -maxfrag.
Befehle```bash
psobf -i sample.ps1 -o out.ps1 -level 5 -frag profile=loose -seed 9
psobf -i sample.ps1 -o out.ps1 -level 5 -minfrag 8 -maxfrag 16 -seed 9
**Ausgabe (Auszug)**```powershell
$fragments=@('Write-Host "Hello,',' World!"',"`n", '$answer = 42',"`n",'function Greet($','name){ Write-Host ("Hi, "+$name)}',"`n",'Greet "Ada"');
$script=$fragments -join ''; Invoke-Expression $script
hexenc)Kodiert Zeichenkettenliterale als Hexadezimal.```bash psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "hexenc" -seed 42
**Ausgabe (Auszug):**```powershell
[Text.Encoding]:https://raw.githubusercontent.com/taurusomar/psobf/main/:UTF8.GetString(%5BConvert%5D::FromHexString(%2748656C6C6F%27))
alias)Ersetzt PowerShell-Cmdlets durch ihre Kurzaliase.```bash psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "alias" -seed 42
**Ausgabe (Auszug):**```powershell
# Write-Host → echo/write/outright
# Get-ChildItem → dir/ls/gci
# ForEach-Object → foreach/%
unicode)Konvertiert Zeichenfolgenzeichen in das [char]0xNNNN-Format.```bash
psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "unicode" -seed 42
**Ausgabe (Auszug):**```powershell
"H[char]0x0065[char]0x006C[char]0x006Co"
antidebug)Injiziert Erkennungsschnipsel für Sandbox/VM/Debugger.```bash psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "antidebug" -seed 42
**Ausgabe (Auszug):**```powershell
if($env:COMPUTERNAME -match '^(SANDBOX|MALWARE|VIRUS)'){ exit }
if((Get-WmiObject Win32_ComputerSystem).Model -match '^(VirtualBox|VMware)'){ exit }
# ... original script ...
iexobf)Ersetzt Invoke-Expression durch alternative Formen.```bash
psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "iexobf" -seed 42
**Ausgabe (Ausschnitt):**```powershell
# Invoke-Expression → IEX or .
. $code # instead of Invoke-Expression $code
Presets sind praktische Ausgangspunkte. Jedes explizite Flag, das Sie übergeben, überschreibt das Preset. Jedes Flag, das Sie explizit übergeben, hat Vorrang vor dem Profil.
-seed N → deterministische Ausgabe für eine gegebene Konfiguration.-seed → kryptografisch gesicherte Zufälligkeit.-fuzz N → erzeugt N Varianten (out.ps1.v1.ps1, out.ps1.v2.ps1, …), ideal für Diversitätstests.Beispiel```bash psobf -i sample.ps1 -o out.ps1 -level 4 -profile heavy -fuzz 3
---
## STDIN/STDOUT und `-noexec`
* **Pipe in / out** ```bash
cat sample.ps1 | psobf -stdin -stdout -level 2 > out.ps1
Ziel ist es, Artefakte zu diversifizieren und stabile Signaturen für die Forschung in autorisierten Umgebungen zu reduzieren.
2. **Maximale Diversität (Format + Fragmentierung + toter Code)**```bash
psobf -i sample.ps1 -o out.ps1 -level 5 \
-pipeline "fmt,frag,dead" -fmt jitter -frag profile=loose -deadcode 15 \
-fuzz 5
4. **Statische IOCs reduzieren (Zahlen + Wörterbuch)**```bash
psobf -i sample.ps1 -o out.ps1 -level 2 -pipeline "numenc,stringdict" -numenc -stringdict 35 -seed 9
---
## Bewährte Methoden und defensive Hinweise
* Rotiere **`-strkey`** und **`-seed`** pro Build.
* Bevorzuge das Kombinieren von Layern: `-strenc` + `-stringdict` + `-fmt jitter` + Fragmentierung.
* Verwende `-fuzz`, um Familien von Varianten für Erkennungstests zu generieren.
* Behalte eine saubere, gutartige Basislinie und überprüfe die funktionale Äquivalenz in der Sandbox vor und nach Transformationen.
* Wenn dein Skript auf empfindliche PS-Syntax angewiesen ist (z.B. Umleitungen), behalte sie in Anführungszeichen oder deaktiviere `-numenc`.
---
## Architekturdiagramm```
┌──────────────┐
│ input.ps1 │
└──────┬───────┘
│ read (-i / -stdin)
▼
┌──────────────┐
│ Pipeline │ order you choose
│ iden │ rename vars/funcs
│ strenc │ XOR/RC4 literals
│ stringdict │ tokenize + rejoin
│ numenc │ numeric masking
│ fmt │ whitespace jitter
│ cf │ opaque/shuffle
│ dead │ harmless noise
└──────┬───────┘
│ mutated script
▼
┌──────────────┐
│ Level 1..5 │ final packing
└──────┬───────┘
│ + Invoke-Expression (unless -noexec)
▼
┌──────────────┐
│ out.ps1 │
└──────────────┘
psobf -i sample.ps1 -o out.ps1 -level 2 -seed 123
psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "strenc" -strenc rc4 -strkey 0011223344556677
psobf -i sample.ps1 -o out.ps1 -level 3 -pipeline "stringdict,numenc" -stringdict 40 -numenc
psobf -i sample.ps1 -o out.ps1 -level 5
-pipeline "iden,strenc,stringdict,numenc,fmt,cf,dead,frag"
-iden obf -strenc xor -strkey a1b2c3d4 -stringdict 35 -numenc
-fmt jitter -cf-opaque -deadcode 15 -frag profile=medium -seed 777
psobf -i sample.ps1 -o out.ps1 -level 6 -profile heavy -seed 999
psobf -i sample.ps1 -o out.ps1 -level 4 -pipeline "antidebug,alias,hexenc" -seed 42
psobf -i sample.ps1 -o out.ps1 -level 6
-pipeline "iden,alias,hexenc,unicode,antidebug,iexobf,strenc"
-iden obf -strenc rc4 -strkey 0011223344556677 -seed 42
psobf -i sample.ps1 -o payload.txt -level 4 -noexec
---
## Rechtliches
Dieses Projekt ist ausschließlich für **bildungsbezogene** und **autorisierte** Tests gedacht. Sie sind allein für Ihre Nutzung verantwortlich. Die Autoren und Mitwirkenden übernehmen keine Haftung für direkte oder indirekte Schäden.