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
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 |