entry0在radare2中的含义
entry0 meaning in radare2
我是二进制分析的新手。我正在尝试分析我通过 gcc 从 C 代码编译的一个简单程序。
我遵循了以下步骤:
1。 aaa
2。 afl
我得到了这个输出:
0x00000608 3 23 sym._init
0x00000630 1 8 sym.imp.puts
0x00000638 1 8 sym.imp._IO_getc
0x00000640 1 8 sym.imp.__printf_chk
0x00000648 1 8 sym.imp.__cxa_finalize
0x00000650 4 77 sym.main
0x000006a0 1 43 entry0
0x000006d0 4 50 -> 44 sym.deregister_tm_clones
0x00000710 4 66 -> 57 sym.register_tm_clones
0x00000760 5 50 sym.__do_global_dtors_aux
0x000007a0 4 48 -> 42 sym.frame_dummy
0x000007d0 1 24 sym.smth
0x000007f0 4 101 sym.__libc_csu_init
0x00000860 1 2 sym.__libc_csu_fini
0x00000864 1 9 sym._fini
我知道 main 是程序的主要起点,但我担心 entry0 是什么。显然从我所看到的不是一个符号。我尝试了 运行 ag @ entry0
和 ag @ main
,我看到的图表非常不同。通过查看反汇编代码,我看到了 entry0:
我假设这可能是一种 ELF 模板函数,用于加载二进制文件并 运行 它来自 main。 entry0 到底是什么?
抱歉这么久了。提前致谢。
你应该 post 回复关于 https://reverseengineering.stackexchange.com/ 的问题。
entry0
是_start
符号的别名,对应_start
函数。
_start
的内存地址是程序入口点,控制权从加载器传递给程序。
_start
函数源自一个名为 crt1.o
的可重定位 ELF 目标文件,该文件链接到需要 C 运行时环境的二进制文件。
$ objdump -dj .text /usr/lib/x86_64-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_start>:
0: 31 ed xor %ebp,%ebp
2: 49 89 d1 mov %rdx,%r9
5: 5e pop %rsi
6: 48 89 e2 mov %rsp,%rdx
9: 48 83 e4 f0 and [=10=]xfffffffffffffff0,%rsp
d: 50 push %rax
e: 54 push %rsp
f: 49 c7 c0 00 00 00 00 mov [=10=]x0,%r8
16: 48 c7 c1 00 00 00 00 mov [=10=]x0,%rcx
1d: 48 c7 c7 00 00 00 00 mov [=10=]x0,%rdi
24: e8 00 00 00 00 callq 29 <_start+0x29>
29: f4 hlt
以/bin/cat
为例:
$ readelf -h /bin/cat
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x402602 <-----
Start of program headers: 64 (bytes into file)
Start of section headers: 46112 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 28
Section header string table index: 27
入口点的内存地址是0x402602
.
402602: 31 ed xor %ebp,%ebp
402604: 49 89 d1 mov %rdx,%r9
402607: 5e pop %rsi
402608: 48 89 e2 mov %rsp,%rdx
40260b: 48 83 e4 f0 and [=12=]xfffffffffffffff0,%rsp
40260f: 50 push %rax
402610: 54 push %rsp
402611: 49 c7 c0 60 89 40 00 mov [=12=]x408960,%r8
402618: 48 c7 c1 f0 88 40 00 mov [=12=]x4088f0,%rcx
40261f: 48 c7 c7 40 1a 40 00 mov [=12=]x401a40,%rdi
402626: e8 d5 f1 ff ff callq 401800 <__libc_start_main@plt>
40262b: f4 hlt
推荐阅读:
Linux x86 Program Start Up or - How the heck do we get to main()?
我是二进制分析的新手。我正在尝试分析我通过 gcc 从 C 代码编译的一个简单程序。
我遵循了以下步骤:
1。 aaa
2。 afl
我得到了这个输出:
0x00000608 3 23 sym._init
0x00000630 1 8 sym.imp.puts
0x00000638 1 8 sym.imp._IO_getc
0x00000640 1 8 sym.imp.__printf_chk
0x00000648 1 8 sym.imp.__cxa_finalize
0x00000650 4 77 sym.main
0x000006a0 1 43 entry0
0x000006d0 4 50 -> 44 sym.deregister_tm_clones
0x00000710 4 66 -> 57 sym.register_tm_clones
0x00000760 5 50 sym.__do_global_dtors_aux
0x000007a0 4 48 -> 42 sym.frame_dummy
0x000007d0 1 24 sym.smth
0x000007f0 4 101 sym.__libc_csu_init
0x00000860 1 2 sym.__libc_csu_fini
0x00000864 1 9 sym._fini
我知道 main 是程序的主要起点,但我担心 entry0 是什么。显然从我所看到的不是一个符号。我尝试了 运行 ag @ entry0
和 ag @ main
,我看到的图表非常不同。通过查看反汇编代码,我看到了 entry0:
我假设这可能是一种 ELF 模板函数,用于加载二进制文件并 运行 它来自 main。 entry0 到底是什么?
抱歉这么久了。提前致谢。
你应该 post 回复关于 https://reverseengineering.stackexchange.com/ 的问题。
entry0
是_start
符号的别名,对应_start
函数。
_start
的内存地址是程序入口点,控制权从加载器传递给程序。_start
函数源自一个名为crt1.o
的可重定位 ELF 目标文件,该文件链接到需要 C 运行时环境的二进制文件。
$ objdump -dj .text /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crt1.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <_start>: 0: 31 ed xor %ebp,%ebp 2: 49 89 d1 mov %rdx,%r9 5: 5e pop %rsi 6: 48 89 e2 mov %rsp,%rdx 9: 48 83 e4 f0 and [=10=]xfffffffffffffff0,%rsp d: 50 push %rax e: 54 push %rsp f: 49 c7 c0 00 00 00 00 mov [=10=]x0,%r8 16: 48 c7 c1 00 00 00 00 mov [=10=]x0,%rcx 1d: 48 c7 c7 00 00 00 00 mov [=10=]x0,%rdi 24: e8 00 00 00 00 callq 29 <_start+0x29> 29: f4 hlt
以/bin/cat
为例:
$ readelf -h /bin/cat
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x402602 <-----
Start of program headers: 64 (bytes into file)
Start of section headers: 46112 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 28
Section header string table index: 27
入口点的内存地址是0x402602
.
402602: 31 ed xor %ebp,%ebp
402604: 49 89 d1 mov %rdx,%r9
402607: 5e pop %rsi
402608: 48 89 e2 mov %rsp,%rdx
40260b: 48 83 e4 f0 and [=12=]xfffffffffffffff0,%rsp
40260f: 50 push %rax
402610: 54 push %rsp
402611: 49 c7 c0 60 89 40 00 mov [=12=]x408960,%r8
402618: 48 c7 c1 f0 88 40 00 mov [=12=]x4088f0,%rcx
40261f: 48 c7 c7 40 1a 40 00 mov [=12=]x401a40,%rdi
402626: e8 d5 f1 ff ff callq 401800 <__libc_start_main@plt>
40262b: f4 hlt
推荐阅读:
Linux x86 Program Start Up or - How the heck do we get to main()?