BayGC/03


Top / BayGC / 03

逆アセンブル

g++ -S したコードは gas 形式というものになっていて、非常に読みにくいので、逆アセンブルをしてみます。ここでは、逆アセンブルの方法について知りました。

ソースコード

void test()
{
}

void test(int a, int b)
{
}

int test(int c)
{
}

int main() {
	return 0;
}

オブジェクトファイルの生成

g++ -c 1.cpp
ndisasm -u 1.o
00000000  4C                dec esp
00000001  0103              add [ebx],eax
00000003  0000              add [eax],al
00000005  0000              add [eax],al
00000007  00E0              add al,ah
00000009  0000              add [eax],al
0000000B  000C00            add [eax+eax],cl
0000000E  0000              add [eax],al
00000010  0000              add [eax],al
00000012  0401              add al,0x1
00000014  2E7465            cs jz 0x7c
00000017  7874              js 0x8d
00000019  0000              add [eax],al
0000001B  0000              add [eax],al
0000001D  0000              add [eax],al
0000001F  0000              add [eax],al
00000021  0000              add [eax],al
00000023  004000            add [eax+0x0],al
00000026  0000              add [eax],al
00000028  8C00              mov [eax],es
0000002A  0000              add [eax],al
0000002C  CC                int3
0000002D  0000              add [eax],al
0000002F  0000              add [eax],al
00000031  0000              add [eax],al
00000033  0002              add [edx],al
00000035  0000              add [eax],al
00000037  0020              add [eax],ah
00000039  0000              add [eax],al
0000003B  60                pusha
0000003C  2E6461            fs popa
0000003F  7461              jz 0xa2
00000041  0000              add [eax],al
00000043  0000              add [eax],al
00000045  0000              add [eax],al
00000047  0000              add [eax],al
00000049  0000              add [eax],al
0000004B  0000              add [eax],al
0000004D  0000              add [eax],al
0000004F  0000              add [eax],al
00000051  0000              add [eax],al
00000053  0000              add [eax],al
00000055  0000              add [eax],al
00000057  0000              add [eax],al
00000059  0000              add [eax],al
0000005B  0000              add [eax],al
0000005D  0000              add [eax],al
0000005F  004000            add [eax+0x0],al
00000062  00C0              add al,al
00000064  2E627373          bound esi,[cs:ebx+0x73]
00000068  0000              add [eax],al
0000006A  0000              add [eax],al
0000006C  0000              add [eax],al
0000006E  0000              add [eax],al
00000070  0000              add [eax],al
00000072  0000              add [eax],al
00000074  0000              add [eax],al
00000076  0000              add [eax],al
00000078  0000              add [eax],al
0000007A  0000              add [eax],al
0000007C  0000              add [eax],al
0000007E  0000              add [eax],al
00000080  0000              add [eax],al
00000082  0000              add [eax],al
00000084  0000              add [eax],al
00000086  0000              add [eax],al
00000088  800000            add byte [eax],0x0
0000008B  C05589E5          rcl byte [ebp-0x77],0xe5
0000008F  83EC08            sub esp,byte +0x8
00000092  83E4F0            and esp,byte -0x10
00000095  B800000000        mov eax,0x0
0000009A  83C00F            add eax,byte +0xf
0000009D  83C00F            add eax,byte +0xf
000000A0  C1E804            shr eax,0x4
000000A3  C1E004            shl eax,0x4
000000A6  8945F8            mov [ebp-0x8],eax
000000A9  8B45F8            mov eax,[ebp-0x8]
000000AC  E800000000        call 0xb1
000000B1  E800000000        call 0xb6
000000B6  C745FC01000000    mov dword [ebp-0x4],0x1
000000BD  B800000000        mov eax,0x0
000000C2  C9                leave
000000C3  C3                ret
000000C4  90                nop
000000C5  90                nop
000000C6  90                nop
000000C7  90                nop
000000C8  90                nop
000000C9  90                nop
000000CA  90                nop
000000CB  90                nop
000000CC  2100              and [eax],eax
000000CE  0000              add [eax],al
000000D0  0B00              or eax,[eax]
000000D2  0000              add [eax],al
000000D4  1400              adc al,0x0
000000D6  260000            add [es:eax],al
000000D9  0009              add [ecx],cl
000000DB  0000              add [eax],al
000000DD  001400            add [eax+eax],dl
000000E0  2E66696C65000000  imul bp,[cs:ebp+0x0],word 0x0
000000E8  0000              add [eax],al
000000EA  0000              add [eax],al
000000EC  FE                db 0xFE
000000ED  FF00              inc dword [eax]
000000EF  006701            add [edi+0x1],ah
000000F2  302E              xor [esi],ch
000000F4  637070            arpl [eax+0x70],si
000000F7  0000              add [eax],al
000000F9  0000              add [eax],al
000000FB  0000              add [eax],al
000000FD  0000              add [eax],al
000000FF  0000              add [eax],al
00000101  0000              add [eax],al
00000103  005F6D            add [edi+0x6d],bl
00000106  61                popa
00000107  696E0000000000    imul ebp,[esi+0x0],dword 0x0
0000010E  0000              add [eax],al
00000110  0100              add [eax],eax
00000112  2000              and [eax],al
00000114  0200              add al,[eax]
00000116  2E7465            cs jz 0x17e
00000119  7874              js 0x18f
0000011B  0000              add [eax],al
0000011D  0000              add [eax],al
0000011F  0000              add [eax],al
00000121  0001              add [ecx],al
00000123  0000              add [eax],al
00000125  0003              add [ebx],al
00000127  0138              add [eax],edi
00000129  0000              add [eax],al
0000012B  0002              add [edx],al
0000012D  0000              add [eax],al
0000012F  0000              add [eax],al
00000131  0000              add [eax],al
00000133  0000              add [eax],al
00000135  0000              add [eax],al
00000137  0000              add [eax],al
00000139  002E              add [esi],ch
0000013B  6461              fs popa
0000013D  7461              jz 0x1a0
0000013F  0000              add [eax],al
00000141  0000              add [eax],al
00000143  0000              add [eax],al
00000145  0002              add [edx],al
00000147  0000              add [eax],al
00000149  0003              add [ebx],al
0000014B  0100              add [eax],eax
0000014D  0000              add [eax],al
0000014F  0000              add [eax],al
00000151  0000              add [eax],al
00000153  0000              add [eax],al
00000155  0000              add [eax],al
00000157  0000              add [eax],al
00000159  0000              add [eax],al
0000015B  0000              add [eax],al
0000015D  002E              add [esi],ch
0000015F  627373            bound esi,[ebx+0x73]
00000162  0000              add [eax],al
00000164  0000              add [eax],al
00000166  0000              add [eax],al
00000168  0000              add [eax],al
0000016A  0300              add eax,[eax]
0000016C  0000              add [eax],al
0000016E  0301              add eax,[ecx]
00000170  0000              add [eax],al
00000172  0000              add [eax],al
00000174  0000              add [eax],al
00000176  0000              add [eax],al
00000178  0000              add [eax],al
0000017A  0000              add [eax],al
0000017C  0000              add [eax],al
0000017E  0000              add [eax],al
00000180  0000              add [eax],al
00000182  5F                pop edi
00000183  5F                pop edi
00000184  5F                pop edi
00000185  6D                insd
00000186  61                popa
00000187  696E0000000000    imul ebp,[esi+0x0],dword 0x0
0000018E  0000              add [eax],al
00000190  2000              and [eax],al
00000192  0201              add al,[ecx]
00000194  0000              add [eax],al
00000196  0000              add [eax],al
00000198  0000              add [eax],al
0000019A  0000              add [eax],al
0000019C  0000              add [eax],al
0000019E  0000              add [eax],al
000001A0  0000              add [eax],al
000001A2  0000              add [eax],al
000001A4  0000              add [eax],al
000001A6  5F                pop edi
000001A7  5F                pop edi
000001A8  61                popa
000001A9  6C                insb
000001AA  6C                insb
000001AB  6F                outsd
000001AC  636100            arpl [ecx+0x0],sp
000001AF  0000              add [eax],al
000001B1  0000              add [eax],al
000001B3  0000              add [eax],al
000001B5  0002              add [edx],al
000001B7  000400            add [eax+eax],al
000001BA  0000              add [eax],al

少しは見やすくなりました。

MENU

now: 1

リンク


最新の20件
2018-05-03 2017-09-29 2017-04-25 2017-01-10 2016-12-11 2016-10-04 2016-08-14 2016-06-05 2016-05-29 2016-04-15 2015-12-28 2013-02-25 2013-02-21 2013-02-20 2013-02-12 2013-02-11 2013-02-10
最新の20件
2010-02-01 2010-01-31 2010-01-30 2010-01-29 2010-01-16

Counter: 2732, today: 1, yesterday: 1

リロード   新規 編集 凍結 差分 添付 複製 改名   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Last-modified: 2008-03-28 (金) 15:47:54 (3740d);  Modified by mona
PukiWiki 1.4.6 Copyright © 2001-2005 PukiWiki Developers Team. License is GPL.
Based on "PukiWiki" 1.3 by yu-ji
Powered by PHP 5.2.17
HTML convert time to 0.031 sec.