
PythonとPowerShellに基づくオープンソースの運用前C2サーバー
Octopus は、オープンソースのプレオペレーション C2 サーバーであり、Python ベースで、HTTP/S を介して Octopus PowerShell エージェントを制御できます。
Octopus の主な目的は、実際のレッドチーム作戦を開始する前に使用することです。フル装備の兵器庫とインフラを投入する代わりに、まず Octopus を使用してターゲットを攻撃し、情報を収集してから実際のレッドチーム作戦を開始できます。
Octopus は非常にシンプルな方法で動作し、完全に暗号化されたチャネルを介してコマンドを実行し、C2 と情報を交換します。そのため、ほとんどの AV、エンドポイント保護、ネットワーク監視ソリューションからは目立たず、検出されにくくなっています。
Octopus の優れた機能の 1 つは ESA (Endpoint Situational Awareness) です。これは、ターゲットに関する重要な情報を収集し、作戦中に直面するターゲットネットワークエンドポイントの理解を深めるのに役立ちます。これにより、この情報に基づいて実際の作戦をカスタマイズする機会が得られます。
Octopus は C2 との通信時にステルス性と隠密性を保つように設計されており、PowerShell エージェントと C2 サーバー間の暗号化チャネルにはデフォルトで AES-256 を使用します。また、ドメインの有効な証明書を提供し、Octopus C2 サーバーを設定して SSL/TLS を使用することもできます。
Octopus には、実際に完全な兵器庫やツール、テクニックを展開する前に、今後のエンゲージメントに関する洞察を得ることができるようにするための多くの機能が搭載されています。例:
Octopus のすべての要件は以下でインストールできます:
pip install -r requirements.txt
シェルコード機能とスプーフィング引数エージェントを使用するには、Linux 用の nasm と 'mingw-w64' コンパイラをインストールする必要があります。
Debian ベースのディストリビューションでは、以下を使用して nasm をインストールできます:
apt install nasm
また、Debian ベースのディストリビューションでは、以下を使用して mingw-w64 をインストールできます:
apt install mingw-w64
Octopus は次のオペレーティングシステムでテストされています:
また、C# ソースを問題なくコンパイルできるようにするために、mono をインストールする必要があります。
Octopus は C# ソースをコンパイルするために mono-csc バイナリに依存しており、kali および ubuntu 16.04 でテスト済みの以下のコマンド apt install mono-devel でインストールできます。
mono をインストールしなくても Octopus を使用できますが、
generate_exeコマンドは使用できません。
また、C# のコンパイルは、SHA1 ハッシュ a43ed886b68c6ee913da85df9ad2064f1d81c470 を持つ System.Management.Automation.dll アセンブリに依存することに注意してください。
Octopus の使用中に問題が発生した場合は、バグレポート を送信してください。
まず、以下のコマンドを使用して Octopus の最新バージョンをダウンロードしてください:
git clone https://github.com/mhaskar/Octopus/
次に、以下のコマンドを使用して要件をインストールする必要があります:
pip install -r requirements.txt
その後、以下のコマンドを実行して Octopus サーバーを起動できます:
./octopus.py
実行すると、次のような画面が表示されます:
┌─[askar@hackbook]─[/opt/redteaming/Octopus]
└──╼ $python3 octopus.py
___ ___ ___ ___ ___ ___
/ /\ / /\ ___ / /\ / /\ /__/\ / /\
/ /::\ / /:/ / /\ / /::\ / /::\ \ \:\ / /:/_
/ /:/\:\ / /:/ / /:/ / /:/\:\ / /:/\:\ \ \:\ / /:/ /\
/ /:/ \:\ / /:/ ___ / /:/ / /:/ \:\ / /:/~/:/ ___ \ \:\ / /:/ /::\
/__/:/ \__\:\ /__/:/ / /\ / /::\ /__/:/ \__\:\ /__/:/ /:/ /__/\ \__\:\ /__/:/ /:/\:\
\ \:\ / /:/ \ \:\ / /:/ /__/:/\:\ \ \:\ / /:/ \ \:\/:/ \ \:\ / /:/ \ \:\/:/~/:/
\ \:\ /:/ \ \:\ /:/ \__\/ \:\ \ \:\ /:/ \ \::/ \ \:\ /:/ \ \::/ /:/
\ \:\/:/ \ \:\/:/ \ \:\ \ \:\/:/ \ \:\ \ \:\/:/ \__\/ /:/
\ \::/ \ \::/ \__\/ \ \::/ \ \:\ \ \::/ /__/:/
\__\/ \__\/ \__\/ \__\/ \__\/ \__\/
v1.2 stable !
Octopus C2 | Control your shells
Octopus >>
Octopus は非常に簡単に使用できます。リスナーを起動し、そのリスナーの情報に基づいてエージェントを生成するだけです。
必要な数のリスナーを生成でき、それらに接続するエージェントとの対話を開始できます。
Octopus を使用する前に、URL 処理プロファイルを設定する必要があります。これにより C2 の動作と機能が制御されます。Octopus は HTTP ベースの C2 であるため、URL に依存して接続を処理し、URL が攻撃中のネットワーク内で署名や IoC として機能しないように保証します。URL は必要に応じて簡単にカスタマイズおよび名前変更できます。
現在、プロファイル設定は URL 処理、自動キル値、およびヘッダーのみをサポートしています。
プロファイルの設定
プロファイルの設定を開始するには、profile.py ファイルを編集する必要があります。このファイルには、いくつかの主要な変数が含まれています:
例:
#!/usr/bin/python3
# this is the web listener profile for Octopus C2
# you can customize your profile to handle a specific URLs to communicate with the agent
# TODO : add the ability to customize the request headers
# handling the file downloading
# Ex : /anything
# Ex : /anything.php
file_receiver_url = "/messages"
# handling the report generation
# Ex : /anything
# Ex : /anything.php
report_url = "/calls"
# command sending to agent (store the command will be executed on a host)
# leave <hostname> as it with the same format
# Ex : /profile/<hostname>
# Ex : /messages/<hostname>
# Ex : /bills/<hostname>
command_send_url = "/view/<hostname>"
# handling the executed command
# Ex : /anything
# Ex : /anything.php
command_receiver_url = "/bills"
# handling the first connection from the agent
# Ex : /anything
# Ex : /anything.php
first_ping_url = "/login"
# will return in every response as Server header
server_response_header = "nginx"
# will return white page that includes HTA script
mshta_url = "/hta"
# auto kill value after n tries
auto_kill = 10
エージェントとリスナーはこのプロファイルを使用して相互に通信するように設定されます。次に、リスナーを作成する方法を知る必要があります。
Octopus には 2 つの主要なリスナー、「http リスナー」と「https リスナー」があり、2 つのリスナーのオプションはほぼ同一です。
HTTP リスナー:
listen_http コマンドは、起動時に次の引数を取ります:
listen_http コマンドを実行すると、その例も表示されます:
Octopus >>listen_http
[-] Please check listener arguments !
Syntax : listen_http BindIP BindPort hostname interval URL listener_name
Example (with domain) : listen_http 0.0.0.0 8080 myc2.live 5 comments.php op1_listener
Example (without domain) : listen_http 0.0.0.0 8080 172.0.1.3 5 profile.php op1_listener
##########
Options info :
BindIP IP address that will be used by the listener
BindPort port you want to listen on
Hostname will be used to request the payload from
Interval how may seconds that agent will wait before check for commands
URL page name will hold the payload
Listener_name listener name to use
Octopus >>
次のコマンドを使用してリスナーを起動できます:
listen_http 0.0.0.0 8080 192.168.178.1 5 page.php operation1
次の結果が返されます:
Octopus >>listen_http 0.0.0.0 8080 192.168.178.1 5 page.php operation1
Octopus >> * Serving Flask app "core.weblistener" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
Octopus >>
リスナーが正常に起動されました。listeners コマンドを使用してすべてのリスナーを表示できます:
Octopus >>listeners
Name IP Port Host Interval Path SSL
---------- ------- ------ ------------- ---------- -------- -----
operation1 0.0.0.0 8080 192.168.178.1 5 page.php False
Octopus >>
HTTPS リスナー:
HTTPS リスナーを作成するには、次のように listen_https コマンドを使用できます:
Octopus >>listen_https
[-] Please check listener arguments !
Syntax : listen_https BindIP BindPort hostname interval URL listener_name certficate_path key_path
Example (with domain) : listen_https 0.0.0.0 443 myc2.live 5 login.php op1_listener certs/cert.pem certs/key.pem
Octopus >>listen_https 0.0.0.0 443 myc2.live 5 login.php darkside_operation certs/cert.pem certs/key.pem
SSL listener started !
[+]darkside_operation Listener has been created
Octopus >> * Serving Flask app "core.weblistener" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
Octopus >>