Skill站外收录 @skilllib/skill-2117939930272412823
binary-lifting
将机器码转换为 LLVM IR 以实现二进制文件的逆向分析、去混淆和再编译,支持跨架构翻译与静态动态分析,适用于需要对底层代码进行语义还原和优化重构的场景。
效率工具 AI 技能
Skills.MD
# Binary Lifting Skill
This skill covers techniques and tools for lifting binary executables to LLVM IR, enabling advanced analysis, transformation, and recompilation of existing binaries.
## Core Concepts
### What is Binary Lifting?
Binary lifting is the process of translating low-level machine code (x86, ARM, etc.) into a higher-level intermediate representation (LLVM IR), enabling:
- Static and dynamic analysis
- Deobfuscation and vulnerability research
- Code recompilation and optimization
- Cross-architecture translation
### Lifting Pipeline
```
Binary → Disassembly → IR Generation → Optimization → Analysis/Recompilation
```
## Major Lifting Frameworks
### Production-Grade Tools
- **RetDec** (Avast): Full decompiler with C output, multi-architecture support
- **McSema** (Trail of Bits): x86/x64 to LLVM IR, function recovery
- **revng**: Based on QEMU, supports multiple architectures
- **reopt** (Galois): Focus on correctness and formal methods
### Research/Specialized Tools
- **Rellume**: Fast x86-64 to LLVM lifting for JIT scenarios
- **fcd**: Pattern-based decompiler with optimization passes
- **bin2llvm**: QEMU-based binary to LLVM translator
- **llvm-mctoll**: Microsoft's machine code to LLVM lifter
### Language-Specific Lifters
- **llvm2c/IR->C**: Convert LLVM IR back to C code
- **llvm2cranelift**: LLVM IR to Cranelift IR
- **Leaven**: LLVM IR to Go language
- **masxinlingvonta**: JVM bytecode to LLVM IR
## Implementation Techniques
### Instruction Semantics Translation
```cpp
// Example: Translating x86 ADD to LLVM IR
Value* translateADD(IRBuilder<> &builder, Value* op1, Value* op2) {
Value* result = builder.CreateAdd(op1, op2, "add_result");
// Update flags (CF, OF, SF, ZF, etc.)
updateCarryFlag(builder, op1, op2, result);
updateOverflowFlag(builder, op1, op2, result);
updateSignFlag(builder, result);
updateZeroFlag(builder, result);
return result;
}
```
### Control Flow Recovery
1. **Linear Sweep**: Simple but misses code with embedded data
2. **Recursive Descent**: Follow control flow, better coverage
3. **Speculative Disassembly**: Handle indirect jumps/calls
4. **Machine Learning**: Use ML to identify function boundaries
### Handling Indirect Control Flow
- Value Set Analysis (VSA)
- Symbolic execution for jump target resolution
- Type recovery for virtual table reconstruction
## Triton Integration
Triton symbolic execution engine can be used with lifting:
```python
from triton import TritonContext, ARCH, Instruction
ctx = TritonContext(ARCH.X86_64)
# Symbolically execute and extract AST
inst = Instruction(b"\x48\x01\xd8") # add rax, rbx
ctx.processing(inst)
# Convert Triton AST to LLVM IR
ast = ctx.getRegisterAst(ctx.registers.rax)
llvm_ir = triton_ast_to_llvm(ast)
```
## Deobfuscation via Lifting
### Approach
1. Lift obfuscated binary to LLVM IR
2. Apply optimization passes to simplify
3. Use custom passes for specific obfuscation patterns
4. Re-emit cleaned code
### Useful Optimization Passes
- Dead Store Elimination (DSE)
- Global Value Numbering (GVN)
- Constant Propagation
- Instruction Combining
- Loop Simplification
### VMP/VM Handler Recovery
- Identify dispatcher patterns
- Extract VM bytecode semantics
- Convert handlers to native IR
- Example: TicklingVMProtect for VMProtect analysis
## Best Practices
1. **Architecture Support**: Handle endianness, calling conventions, ABI differences
2. **Memory Modeling**: Accurate memory layout for global/stack variables
3. **External Dependencies**: Handle library calls and system calls
4. **Validation**: Compare execution traces of original vs lifted code
5. **Incremental Lifting**: Support partial program analysis
## Dynamic Binary Lifting
### Runtime Translation
- **Instrew**: Fast instrumentation through LLVM
- **QBDI**: QuarkslaB Dynamic Binary Instrumentation
- **binopt**: Runtime optimization of binary code
### JIT Recompilation
Lift frequently executed code paths for runtime optimization:
- Profile-guided lifting
- Hot path detection
- Speculative optimization
## Resources
For a complete list of lifting tools and research papers, refer to the LIFT section in the main README.md.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「binary-lifting」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次