CTF/Solved
LA CTF 2023 - crypto / rolling in the mud
1. intro 2. code 및 분석 2.1. code 2.2. 분석 딱 보자마자 영문 / 기호 대응 문제이다. 맨 마지막 기호가 lactf라고 가정하고 아래와 같이 만들어보았다. 다만 일부는 확인하기 어려웠다. 이를 기준으로 복호화 해보면 아래와 같고, 나머지는 충분히 추측할 수 있다. {emoh_og_?gip_eht_litn?_gnillor_dna_gnillor_dna_gnillor}ftcal 3. exploit lactf{rolling_and_rolling_and_rolling_until_the_pigs_go_home}
LA CTF 2023 - crypto / one-more-time-pad
1. intro 2. code 및 분석 2.1. code from itertools import cycle pt = b"Long ago, the four nations lived together in harmony ..." key = cycle(b"lactf{??????????????}") ct = "" for i in range(len(pt)): b = (pt[i] ^ next(key)) ct += f'{b:02x}' print("ct =", ct) #ct = 200e0d13461a055b4e592b0054543902462d1000042b045f1c407f18581b56194c150c13030f0a5110593606111c3e1f5e305e174571431e 2.2. 분석 xor으로 구성된 단순한 문제..
LA CTF 2023 - pwn/rut-roh-relro
1. intro 2. code 및 분석 2.1. code #include int main(void) { setbuf(stdout, NULL); puts("What would you like to post?"); char buf[512]; fgets(buf, 512, stdin); printf("Here's your latest post:\n"); printf(buf); printf("\nWhat would you like to post?\n"); fgets(buf, 512, stdin); printf(buf); printf("\nYour free trial has expired. Bye!\n"); return 0; } 2.2. 분석 앞선 문제와 유사하지만, 이번에는 두번 입력받고 두번 출력해준다. 3. ..
LA CTF 2023 - pwn / rickroll
1. intro 2. code 및 분석 2.1. code #include int main_called = 0; int main(void) { if (main_called) { puts("nice try"); return 1; } main_called = 1; setbuf(stdout, NULL); printf("Lyrics: "); char buf[256]; fgets(buf, 256, stdin); printf("Never gonna give you up, never gonna let you down\nNever gonna run around and "); printf(buf); printf("Never gonna make you cry, never gonna say goodbye\nNever gonn..
LA CTF 2023 - pwn/bot
1. intro 2. code 및 분석 2.1. code #include #include #include #include int main(void) { setbuf(stdout, NULL); char input[64]; volatile int give_flag = 0; puts("hi, how can i help?"); gets(input); if (strcmp(input, "give me the flag") == 0) { puts("lol no"); } else if (strcmp(input, "please give me the flag") == 0) { puts("no"); } else if (strcmp(input, "help, i have no idea how to solve this") == 0..
LA CTF 2023 - pwn/gatekeep
1. intro 2. code 및 분석 2.1. code #include #include #include #include #include void print_flag() { char flag[256]; FILE* flagfile = fopen("flag.txt", "r"); if (flagfile == NULL) { puts("Cannot read flag.txt."); } else { fgets(flag, 256, flagfile); flag[strcspn(flag, "\n")] = '\0'; puts(flag); } } int check(){ char input[15]; char pass[10]; int access = 0; // If my password is random, I can gatekee..
BB CTF 2023 - Medium pwn
1. intro 2. code 및 분석 2.1. code 2.1.1. main int __cdecl __noreturn main(int argc, const char **argv, const char **envp) { puts("Hi! I am the Stack Oracle.\n"); while ( 1 ) gimme_pointer("Hi! I am the Stack Oracle.\n", argv); } 2.1.2. gimme_pointer unsigned __int64 gimme_pointer() { const void *v1; // [rsp+8h] [rbp-28h] BYREF char buf[24]; // [rsp+10h] [rbp-20h] BYREF unsigned __int64 v3; // [rsp..
BB CTF 2023 - Easy pwn
1. intro 초보를 위한 낮은 난이도의 CTF. DICE CTF에서 내상을 입고 BB CTF에서 약간 회복했다. 2. code 및 분석 2.1. code int __cdecl main(int argc, const char **argv, const char **envp) { char buf[8]; // [rsp+8h] [rbp-28h] BYREF char command[24]; // [rsp+10h] [rbp-20h] BYREF unsigned __int64 v6; // [rsp+28h] [rbp-8h] v6 = __readfsqword(0x28u); strcpy(command, "ls"); puts("Hi! would you like me to ls the current directory?"); re..
DiceCTF 2023 - pwn/bop
1. intro 한 문제 풀고 나머지는 좌절한 CTF... 2. code 및 분석 2.1. code __int64 __fastcall main(int a1, char **a2, char **a3) { char v4[32]; // [rsp+0h] [rbp-20h] BYREF setbuf(stdin, 0LL); setbuf(stdout, 0LL); setbuf(stderr, 0LL); printf("Do you bop? "); return gets(v4); } 2.2. 분석 코드는 참 간결했다. 출력 하나하고 gets로 값을 받아들인다. 3. 취약점 확인 및 공격 준비 3.1. 취약점 buffer overflow 3.2. 공격 준비 ida로 파일을 열었을 때 바로 보이는 함수가 seccomp 였다. 그래서 ..
KnightCTF 2023 - KrackMe 1.0
1. intro 2. code 및 분석 2.1. code int __cdecl main(int argc, const char **argv, const char **envp) { unsigned int i; // [rsp+10h] [rbp-170h] unsigned int j; // [rsp+10h] [rbp-170h] unsigned int k; // [rsp+10h] [rbp-170h] unsigned int m; // [rsp+10h] [rbp-170h] unsigned int n; // [rsp+10h] [rbp-170h] int ii; // [rsp+10h] [rbp-170h] int jj; // [rsp+10h] [rbp-170h] unsigned int kk; // [rsp+10h] [rbp-..