목록전체 글 (48)
rsp-∞
#include #include void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } void get_shell() { char *cmd = "/bin/sh"; char *args[] = {cmd, NULL}; execve(cmd, args, NULL); } int main() { char buf[0x28]; init(); printf("Input: "); scanf("%s", buf); return 0; } rao.c 코드를 먼저 보자. buf의 크기가 0x28로 설정되어 있고, main 함수의 하단에 scanf를 사용하여 buf의 값을 입력받는다. rao.c의 취약점은 이 scanf 함수이다. 입력받는 값의 길이를 체크하지 않는 함수이..
pwndbg> disassemble phase_3 Dump of assembler code for function phase_3: 0x0000000000400f43 : sub rsp,0x18 0x0000000000400f47 : lea rcx,[rsp+0xc] 0x0000000000400f4c : lea rdx,[rsp+0x8] 0x0000000000400f51 : mov esi,0x4025cf 0x0000000000400f56 : mov eax,0x0 0x0000000000400f5b : call 0x400bf0 0x0000000000400f60 : cmp eax,0x1 0x0000000000400f63 : jg 0x400f6a 0x0000000000400f65 : call 0x40143a 0x0000..
pwndbg> disassemble phase_2 Dump of assembler code for function phase_2: 0x0000000000400efc : push rbp 0x0000000000400efd : push rbx 0x0000000000400efe : sub rsp,0x28 0x0000000000400f02 : mov rsi,rsp 0x0000000000400f05 : call 0x40145c 0x0000000000400f0a : cmp DWORD PTR [rsp],0x1 0x0000000000400f0e : je 0x400f30 0x0000000000400f10 : call 0x40143a 0x0000000000400f15 : jmp 0x400f30 0x0000000000400f..