rosieblue
article thumbnail
Published 2023. 6. 3. 21:25
[Pwnable.kr] fd Linux Exploitation/Wargame
728x90

문제 코드

#include <stdlib.h>
#include <string.h>

char buf[32];

int main(int argc, char* argv[], char* envp[]){
        if(argc<2){
                printf("pass argv[1] a number\n");
                return 0;
        }
        int fd = atoi( argv[1] ) - 0x1234;
        int len = 0;
        len = read(fd, buf, 32);
        if(!strcmp("LETMEWIN\n", buf)){
                printf("good job :)\n");
                system("/bin/cat flag");
                exit(0);
        }
        printf("learn about Linux file IO\n");
        return 0;

}

 

익스플로잇

atoi는 문자열을 정수로 변환하는 애라고 한다.
https://www.ibm.com/docs/ko/i/7.3?topic=functions-atoi-convert-character-string-integer 

atoi() — 문자 스트링을 정수로 변환

형식 #include int atoi(const char *string); 로케일 감지 이 함수의 작동은 현재 로케일의 LC_CTYPE 범주에 영향을 받을 수 있습니다. 자세한 정보는 CCSID 및 로케일 이해의 내용을 참조하십시오. 설명 atoi()

www.ibm.com

 
stdin에서 인자를 받기 위해 argv[1]을 0x1234(10진수로4660)로 맞춰준다

끝.

'Linux Exploitation > Wargame' 카테고리의 다른 글

[드림핵(Dreamhack)] uaf_overwrite  (0) 2023.06.20
[Pwnable.kr] col  (0) 2023.06.03
[Pwnable.kr] bof  (0) 2023.06.03
[ROP 시리즈 (4)] 드림핵(Dreamhack) - rop  (0) 2023.04.21
[드림핵(Dreamhack)] ssp_001  (0) 2023.04.14
profile

rosieblue

@Rosieblue

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!