mips调试

0x01 环境搭建

由于我们通常的操作系统指令集都是x86的,所以无法跑MIPS程序。这时候就需要装QEMU来模拟,QEMU通过源码编译较为复杂,我们又没有特殊的需求,所以直接使用ubuntu的APT进行安装即可。

  • sudo apt install qemu

由于MIPS架构有两种——大端MIPS和小端MIPS。所以,我们需要确定这个程序是大端MIPS还是小端MIPS。

  • qemu-mips xxx #大端
  • qemu-mipsel xxx #小端

远程调试MIPS程序,所以要加上-g 端口参数,qemu-mipsel -g 1234 baby_mips,此时用IDA pro就可以通过Remote GDB Server来调试这个MIPS程序。

0x02 反编译

为了方便我们了解key比对函数的功能,我们可以需要对MIPS进行反编译,目前可以反编译MIPS程序的工具有两个。

Retdec
JEB-mips

Retdec有在线反编译网址,retdec.com,也可以通过python api接口使用,比较方便,需要注册获得YOUR-API-KEY,注意retdec-python包需要在python3环境下运行

py 3 -m pip install retdec-python

python用法

from retdec.decompiler import Decompiler

decompiler = Decompiler(api_key='YOUR-API-KEY')
decompilation = decompiler.start_decompilation(input_file='file.exe')
decompilation.wait_until_finished()
decompilation.save_hll_code()

或者命令行执行
$ decompiler -k YOUR-API-KEY file.exe

v23bmYb67R
----------

Waiting for resources (0%)...                    [OK]
Pre-Processing:
  Obtaining file information (5%)...             [OK]
  Unpacking (10%)...                             [OK]
Front-End:
  Initializing (20%)...                          [OK]
[..]
Done (100%)...

Downloading:
 - file.c

这样就会把mips程序反编译成c的代码写成file.c文件了。

猜你喜欢

转载自www.cnblogs.com/P201521440001/p/9753683.html
今日推荐