AkashaCorporation/hexcore-elixir
GitHub: AkashaCorporation/hexcore-elixir
一个基于干净室实现的跨平台二进制仿真与动态分析框架,用于替代 GPL 依赖并提供确定性调试与时间旅行能力。
Stars: 1 | Forks: 0
# HexCore Elixir
**Elixir** 是 [HexCore](https://github.com/AkashaCorporation/HikariSystem-HexCore) 背后的高级动态分析、仿真和 instrumentation 框架。它基于 [HexCore-Unicorn](https://github.com/AkashaCorporation/hexcore-unicorn) 构建,提供了一个干净室(clean-room)、Apache-2.0 许可的操作系统仿真层。
Elixir 从底层设计用于取代 GPLv3 框架(如 Qiling),提供全平台操作系统仿真(加载器、系统调用、VFS),并结合了 Frida 开创的强大的可脚本化动态 instrumentation 概念。
## Elixir 的功能
- **CPU 仿真** — 通过 HexCore-Unicorn 驱动执行,附带高级内存错误处理和 JIT 块缓存。
- **干净室操作系统仿真** — 从头实现 PE/ELF/Mach-O 加载器、线程管理和系统调用路由。不含 GPL 代码。
- **Frida 风格的 instrumentation** — 内置 Interceptor API,支持内联 Hook、内存访问跟踪,以及类似 Stalker 的基本块追踪,直接在仿真层实现。
- **虚拟环境模拟** — 完全隔离的虚拟文件系统(VFS)、伪造的 Windows 注册表和模拟网络套接字。
- **快照与恢复** — 用于模糊测试和时间旅行调试的确定性内存与 CPU 上下文快照。
- **跨架构支持** — 开箱即用支持 x86、x86_64、ARM 和 ARM64。
## 架构
Elixir 采用四层架构:
| Tier | 名称 | 描述 |
|------|------|------|
| 1 | **elixir_core** | 执行循环、内存管理器、HexCore-Unicorn 绑定 |
| 2 | **elixir_ldr** | 二进制格式解析器(PE、ELF、Mach-O)、节区映射、导入解析、TLS |
| 3 | **elixir_os** | 操作系统人格 — 系统调用分发、POSIX/Win32 处理器、VFS、注册表 |
| 4 | **elixir_agent** | instrumentation 桥接 — JS/Rust 代理可 Hook 函数、读写内存、操作寄存器 |
```
agents/ (JS/TS) ──► crates/hexcore-elixir (NAPI-RS) ──► crates/elixir-core (Rust FFI) ──► engine/ (C++23)
│
HexCore-Unicorn
```
## 仓库布局
```
HexCore-Elixir/
├── engine/ C++23 core engine, loaders, OS subsystems, CLI
├── crates/ Rust workspace — elixir-core + NAPI bridge
├── agents/ TypeScript/JS agent runtime (Frida-style API)
├── tests/ Integration fixtures, target binaries, and fuzzers
├── ARCHITECTURE.md Architectural overview
├── CHANGELOG.md Release notes
└── roadmap.md Near-term roadmap
```
## 构建前提条件
- **Rust** 稳定版(通过 rustup)
- **Node.js** 22+
- **CMake** 3.20+
- **C++23** 工具链(MSVC 2022 / GCC 13+ / Clang 16+)
- **HexCore-Unicorn**(通过 git 子模块或 Rust 构建脚本自动拉取)
## 构建
### 1. 构建 C++ 引擎
```
cmake -B engine/build -S engine -DCMAKE_BUILD_TYPE=Release
cmake --build engine/build --config Release
```
### 2. 构建 Rust + NAPI 桥接
```
npm install
npm run build
```
### 3. 运行 CLI
```
# 使用脚本对 Linux ELF 进行仿真
./engine/build/Release/elixir_tool run target_bin --os linux --script agent.js
# 在入口点仿真 Windows PE 并进入外壳
./engine/build/Release/elixir_tool run target.exe --os windows --interactive
```
## 代理示例
```
import { Interceptor, Process } from '@hexcore/elixir-agents';
const mod = Process.findModuleByName('libc.so.6');
const malloc = mod?.exports.find(e => e.name === 'malloc');
if (malloc) {
Interceptor.attach(malloc.address, {
onEnter(ctx) {
console.log(`[malloc] size = ${ctx.args[0]}`);
},
onLeave(ctx) {
console.log(`[malloc] => 0x${ctx.returnValue!.toString(16)}`);
}
});
}
```
## 干净室策略
本项目采用 **Apache-2.0** 许可。并未使用任何 GPLv3 源代码(Qiling、Frida-core)。操作系统行为基于公共规范实现(Microsoft PE/COFF 规范、ELF 规范、MSDN、Linux 手册页)。Instrumentation 概念参考了 frida-gum(wxWindows/Permissive 许可)和 DynamoRIO(BSD-3-Clause)。
## 许可
Apache-2.0 — 参见 [许可证](LICENSE)。
由 [Akasha Corporation](https://github.com/AkashaCorporation) 构建
标签:Apache-2.0 许可, ARM64, Clean-room 仿真, DAST, ELF64 加载器, Frida 风格注入, HexCore, HexCore 3.8.0, Interceptor, JIT 块缓存, Linux 系统调用调度, NAPI-RS, PE64 加载器, Ru, Stalker, Unicorn, Win32 API Hook, x86, x86_64, 二进制仿真引擎, 交叉架构, 伪造 Windows 注册表, 内存故障处理, 内存访问追踪, 分析流水线, 可视化界面, 基本块追踪, 快照与时间回溯, 恶意软件分析, 模拟网络套接字, 脱钩 GPL 依赖, 虚拟文件系统, 跨平台仿真