Self-Improvement

ARM - plt, got 확인 (got func()) 본문

ARM

ARM - plt, got 확인 (got func())

JoGeun 2021. 1. 25. 16:01

ARM에서의 PLT와 GOT를 확인해보자.

 

1. GDB

strcpy의 plt는 0x10368이다

gef➤  disassemble main
Dump of assembler code for function main:
   0x00010510 <+0>:	push	{r11, lr}
   0x00010514 <+4>:	add	r11, sp, #4
   0x00010518 <+8>:	sub	sp, sp, #40	; 0x28
   0x0001051c <+12>:	str	r0, [r11, #-40]	; 0xffffffd8
   0x00010520 <+16>:	str	r1, [r11, #-44]	; 0xffffffd4
   0x00010524 <+20>:	ldr	r3, [r11, #-44]	; 0xffffffd4
   0x00010528 <+24>:	add	r3, r3, #4
   0x0001052c <+28>:	ldr	r2, [r3]
   0x00010530 <+32>:	sub	r3, r11, #36	; 0x24
   0x00010534 <+36>:	mov	r1, r2
   0x00010538 <+40>:	mov	r0, r3
=> 0x0001053c <+44>:	bl	0x10368 <strcpy@plt>

 

got는 0x21014이다.

add r12, r12, #16, 20의 계산법이 조금 이상하다..

gef➤  x/3i 0x10368
   0x10368 <strcpy@plt>:	add	r12, pc, #0, 12	// r12 = pc(=0x10370)+(0<<12) = 0x10370
   0x1036c <strcpy@plt+4>:	add	r12, r12, #16, 20	; 0x10000	// r12 = r12(0x10370)+(16<<20) = 0x20370
   0x10370 <strcpy@plt+8>:	ldr	pc, [r12, #3236]!	; 0xca4	// 0x20370 + 3236(=0xca4) = 0x21014

 

따로 명령어가 존재하여 쉽게 구할 수 있다.

gef➤  got strcpy

GOT protection: Partial RelRO | GOT functions: 7
 
[0x21014] strcpy@GLIBC_2.4  →  0x1033c

 

2. IDA

plt는 0x10368이다.

 

got는 0x21014이다.