728x90
#include <stdio.h>

int main(void) {
    
    FILE *fp;
    char buf[0x80] = {};
    size_t flag_len = 0;

    printf("Welcome To DreamHack Wargame!\n");

    fp = fopen("/flag", "r");  // /flag 파일 오픈
    fseek(fp, 0, SEEK_END);  //파일 끝으로 이동
    flag_len = ftell(fp);  //파일 내용 길이 저장
    fseek(fp, 0, SEEK_SET); //파일 시작 위치로 이동
    fread(buf, 1, flag_len, fp);  //파일 내용 끝까지 읽음
    fclose(fp);  //읽기 종료

    printf("FLAG : ");

    fwrite(buf, 1, flag_len, stdout);  //파일 내용 화면에 출력
}

linux에서 문제에 주어진 nc 명령을 그대로 입력한다.

nc host3.dreamhack.games 9048

nc는 netcat의 약자로 통신할 때 사용한다. 연결하자마자 FLAG가 출력된다.

728x90

'dreamhack > System Hacking' 카테고리의 다른 글

basic_exploitation_001  (0) 2023.02.14
basic_exploitation_000  (0) 2023.02.14

+ Recent posts