- Return address 영역에 Shellcode가 저장된 주소로 변경해, Shellcode를 호출하는 방식이다.
- Return to Shellcode를 이해하기 위해 CALL,RET 명령어에 대한 이해가 필요하다.
Instruction | Processing |
Call <Operation> |
PUSH Return Address JMP <Operation> |
ret |
POP RIP JMP RIP |
- Return to Shellcode를 이해하기 위해 Memory 권한에 대한 이해가 필요하다.
Permissions in memory(DEP enabled)
Permissions in memory(DEP disabled)
- DEP를 해제하기 위해 GCC 옵션으로 "-z execstack" 를 추가해야 한다.
- 0x5555555546d1 = vuln() 함수 종료 후 복귀할 주소.
- 0x55555555468a = vuln() 함수 시작 주소. 해당 위치에 bp를 걸고 continue.
- 다음과 같이 Return address를 확인 할 수 있다.
rsp 레지스터가 가리키고 있는 최상위 Stack 메모리는 0x7fffffffe3e8이다.
- 0x5555555546bb = read()함수 호출 주소에 bp 걸고 continue
- 다음과 같이 Return address 값이 변경된 것을 확인 할 수 있다.
- x86_64 Shellcode
"\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05"
REF: https://www.lazenca.net/display/TEC/02.Return+to+Shellcode
02.Return to Shellcode - TechNote - Lazenca.0x0
Excuse the ads! We need some help to keep our site up. List Return to Shellcode Return to Shellcode란 Return address 영역에 Shellcode가 저장된 주소로 변경해, Shellcode를 호출하는 방식입니다. CALL & RET instruction Return to Shellco
www.lazenca.net
댓글 영역