本工具将类似 xxd 输出的 16 进制字符串反汇编成某些平台的汇编代码。
下载地址
Git Repository:
WebGit:
使用 git 下载:
$ git-clone ~hellwolf/git/hwdisassembler.git
配置
例子配置文件:
$config{"x86 realmode"} = {
gcc => 'gcc',
objdump => 'objdump',
objdump_Moption => 'i8086',
byteorder => 'le',
};
$config{x86} = {
gcc => 'gcc',
objdump => 'objdump',
byteorder => 'le',
};
$config{powerpc} = {
gcc => "/data/home/hellwolf/dirs/apps/ycross/targets/powerpc-elf_freestanding/bin/powerpc-ycross-elf-gcc",
objdump => "/data/home/hellwolf/dirs/apps/ycross/targets/powerpc-elf_freestanding/bin/powerpc-ycross-elf-objdump",
byteorder => 'be',
};
这个配置文件将支持三个平台,x86,x86 realmode 和 powerpc。 交叉编译器请自行准备。
pipe 模式
命令格式: hwdisassembler 配置文件 pipe 平台
1. 反汇编 powerpc 代码。
$ ./hwdisassembler example.config pipe powerpc <<\EOF
> 02000000: 9421ffe0 7c0802a6 90010024 93e1001c .!..|......$....
> 02000010: 7c3f0b78 4800068d 7c601b78 901f0008 |?.xH...|`.x....
> 02000020: 3d200200 38691e2c 809f0008 4cc63182 = ..8i.,....L.1.
> 02000030: 48001d41 48000a55 81610000 800b0004 H..AH..U.a......
> EOF
/tmp/hwdisasCXPEMMi.o: file format elf32-powerpc
Disassembly of section .text:
00000000 <.text>:
...
2000000: 94 21 ff e0 stwu r1,-32(r1)
2000004: 7c 08 02 a6 mflr r0
2000008: 90 01 00 24 stw r0,36(r1)
200000c: 93 e1 00 1c stw r31,28(r1)
2000010: 7c 3f 0b 78 mr r31,r1
2000014: 48 00 06 8d bl 0x20006a0
2000018: 7c 60 1b 78 mr r0,r3
200001c: 90 1f 00 08 stw r0,8(r31)
2000020: 3d 20 02 00 lis r9,512
2000024: 38 69 1e 2c addi r3,r9,7724
2000028: 80 9f 00 08 lwz r4,8(r31)
200002c: 4c c6 31 82 crclr 4*cr1+eq
2000030: 48 00 1d 41 bl 0x2001d70
2000034: 48 00 0a 55 bl 0x2000a88
2000038: 81 61 00 00 lwz r11,0(r1)
200003c: 80 0b 00 04 lwz r0,4(r11)
2. 反汇编一段来自 debug 程序的 x86 realmode 代码
$ echo BA 0C 01 B4 09 CD 21 B8 00 4C CD 21 | ./hwdisassembler example.config pipe "x86 realmode"
/tmp/hwdisasKMpDD35.o: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: ba 0c 01 mov $0x10c,%dx
3: b4 09 mov $0x9,%ah
5: cd 21 int $0x21
7: b8 00 4c mov $0x4c00,%ax
a: cd 21 int $0x21
cgi 模式
将类似下面的程序拷贝到cgi目录即可:
#!/bin/sh
/data/home/hellwolf/mydoc/prog/hwdisassembler/hwdisassembler /data/home/hellwolf/mydoc/prog/hwdisassembler/config.example cgi
阅读(1528) | 评论(0) | 转发(0) |