type
status
date
slug
summary
tags
category
icon
password
在复现DownUnderCTF2024发现wp中作者使用的是capstone来解的那道题,觉得是个好用的方法现在来学一下
capstone官网
官方教程(python)
官方教程(C)
官方教程(Java)
基本样本

效果就是上图所示
上述效果图显示的的成员
成员名 | 描述 |
id | 汇编指令的id |
address | 代码地址 |
mnemonic | 汇编指令 |
op_str | 操作对象字符串 |
size | 汇编指令的大小 |
bytes | 返回对应汇编指令的机器码 |
operands | 操作对象(后面介绍) |
更快更简单的基本信息API
从版本 2.1 开始,Python 绑定在 Cs 类中提供了这个新方法 disasm_lite()。与 disasm() 不同,disasm_lite() 仅返回 (address, size, mnemonic, op_str) 的元组。基准测试显示,这种轻量级 API 比同类 API 快 30%。
此示例来自官方文档
下面是 disasm_lite() 的示例

架构与模式


如果需要在运行时动态的更换其解析模式,可以使用如下写法
将额外模式与基本模式结合起来的方法是使用操作数
+
下面的示例仍然来自官方文档

更多与架构无关的反汇编指令数据
Capstone 不会生成反汇编指令的详细信息。如果我们想要隐式寄存器读/写或该指令所属的语义组等信息,我们需要显式打开此选项,如下面的示例代码所示。
operands尝试
下面的示例展示了如何提取 ARM64 代码的指令操作数的详细信息。

- Author:5m10v3
- URL:https://5m10v3.top/article/0f636037-cd26-4d98-812d-77800d3d3144
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!