[CTF Writeup / Rev] LA CTF 2024 - aplet321
[CTF Writeup / Rev] LA CTF 2024 - aplet321
안녕하세요. 이번 글에서는 LA CTF 2024에 출제된 Reversing 문제 aplet321의 writeup을 작성해보도록 하겠습니다.
Unlike Aplet123, Aplet321 might give you the flag if you beg him enough.
문제 설명이고, nc 주소와 파일이 첨부되어 있습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | undefined8 main(void) { int tmp; size_t length; char *text; int a; int b; char input; char acStack567 [519]; setbuf(stdout,(char *)0x0); puts("hi, i\'m aplet321. how can i help?"); fgets(&input,0x200,stdin); length = strlen(&input); if (5 < length) { a = 0; b = 0; text = &input; do { tmp = strncmp(text,"pretty",6); b = b + (uint)(tmp == 0); tmp = strncmp(text,"please",6); a = a + (uint)(tmp == 0); text = text + 1; } while (text != acStack567 + ((int)length - 6)); if (a != 0) { text = strstr(&input,"cat flag.txt"); if (text == (char *)0x0) { puts("sorry, i didn\'t understand what you mean"); return 0; } if ((b + a == 0x36) && (b - a == -0x18)) { puts("cat flag.txt"); system("cat flag.txt"); return 0; } puts("sorry, i\'m not allowed to do that"); return 0; } } puts("so rude"); return 0; } | cs |
첨부된 aplet321 실행파일을 디컴파일한 코드입니다.
do-while 문을 통해 입력값을 체크하는데, flag를 획득하기 위해서는 pretty 단어가 15개, please 단어가 39개 포함되어 있어야 하며, 마지막에 cat flag.txt 문자가 포함되어 있어야 합니다.
>>> "prettyplease"*15 + "aaaaaaplease"*24 + "cat flag.txt"
'prettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseprettypleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleaseaaaaaapleasecat flag.txt'
파이썬으로 해당 조건에 맞는 값을 생성합니다.
nc로 접속하여 위 값을 입력해주면 플래그를 획득할 수 있습니다.


댓글
댓글 쓰기