Wargame & CTF/pwnableKR2023. 11. 27. 12:59Toddler(lotto)

문제 Mommy! I made a lotto program for my homework. do you want to play? ssh lotto@pwnable.kr -p2222 (pw:guest) 풀이 ```c #include #include #include #include unsigned char submit[6]; void play() { int i; printf("Submit your 6 lotto bytes : "); fflush(stdout); int r; r = read(0, submit, 6); printf("Lotto Start!\n"); // sleep(1); // generate lotto numbers int fd = open("/dev/urandom", O_RDONLY); if (f..

Wargame & CTF/pwnableKR2023. 11. 27. 12:51Toddler(blackjack)

문제 Hey! check out this C implementation of blackjack game! I found it online http://cboard.cprogramming.com/c-programming/114023-simple-blackjack-program.html I like to give my flags to millionares. how much money you got? Running at : nc pwnable.kr 9009 풀이 문제에 제시된 링크에서 사용된 C 소스코드를 볼 수 있습니다. 너무 길어서 전체 소스코드는 첨부하지 않았습니다. 우리가 주목해야 할 코드는 다음과 같습니다. int betting() //Asks user amount to bet { printf("\n..

Wargame & CTF/pwnableKR2023. 11. 27. 09:54Toddler(coin1)

문제 Mommy, I wanna play a game! (if your network response time is too slow, try nc 0 9007 inside pwnable.kr server) Running at : nc pwnable.kr 9007 풀이 --------------------------------------------------- - Shall we play a game? - --------------------------------------------------- You have given some gold coins in your hand however, there is one counterfeit coin among them counterfeit coin looks e..

Wargame & CTF/pwnableKR2023. 11. 26. 18:24Toddler(shellshock)

문제 Mommy, there was a shocking news about bash. I bet you already know, but lets just make it sure:) ssh shellshock@pwnable.kr -p2222 (pw:guest) 풀이 #include int main(){ setresuid(getegid(), getegid(), getegid()); setresgid(getegid(), getegid(), getegid()); system("/home/shellshock/bash -c 'echo shock_me'"); return 0; } shellshock 취약점은 bash가 subshell을 실행시키면서 발생합니다. bash의 환경변수에 함수 정의를 이용해서 원격 코드를 ..

Wargame & CTF/pwnableKR2023. 11. 26. 18:13Toddler(mistake)

문제 We all make mistakes, let's move on. (don't take this too seriously, no fancy hacking skill is required at all) This task is based on real event Thanks to dhmonkey hint : operator priority ssh mistake@pwnable.kr -p2222 (pw:guest) 풀이 먼저 mistake.c를 살펴봅시다. #include #include #define PW_LEN 10 #define XORKEY 1 void xor(char* s, int len){ int i; for(i=0; i 0)){ printf("read error\n"); close(fd); re..

Wargame & CTF/pwnableKR2023. 11. 26. 17:18Toddler(leg)

문제 Daddy told me I should study arm. But I prefer to study my leg! Download : http://pwnable.kr/bin/leg.c Download : http://pwnable.kr/bin/leg.asm ssh leg@pwnable.kr -p2222 (pw:guest) 풀이 위의 문제를 해결하기 위해 파이프라인과 ARM Architecture 에 대한 이해가 필요합니다. ARM Architecture는 별도로 따로 정리하도록 하고, 해당 문서에서는 파이프라인만 간단하게 설명합니다. [파이프라인] CPU는 CLOCK 신호에 따라 명령을 처리하도록 설계되어 있습니다. 하지만 파이프라인 매커니즘을 적용하면 주어진 CLOCK 속도보다 더욱 빠르게 처리할..

Wargame & CTF/pwnableKR2023. 11. 26. 16:34Toddler(input)

문제 Mom? how can I pass my input to a computer program? ssh input2@pwnable.kr -p2222 (pw:guest) 풀이 서버에 접속하여 ls 명령을 입력해보면 input, input.c, flag 3개의 파일이 존재하는 것을 알 수 있습니다. cat 명령어를 통해 input.c 파일을 확인합니다. #include #include #include #include #include int main(int argc, char* argv[], char* envp[]){ printf("Welcome to pwnable.kr\n"); printf("Let's see if you know how to give input to program\n"); printf("..

Wargame & CTF/pwnableKR2023. 11. 26. 16:24Toddler(random)

문제 Daddy, teach me how to use random value in programming! ssh random@pwnable.kr -p2222 (pw:guest) 풀이 서버에 접속하여 ls 명령을 입력해보면 random, random.c, flag 3개의 파일이 존재하는 것을 알 수 있습니다. cat 명령어를 사용하여 random.c 파일을 확인합니다. #include int main(){ unsigned int random; random = rand(); // random value! unsigned int key=0; scanf("%d", &key); if( (key ^ random) == 0xdeadbeef ){ printf("Good!\n"); system("/bin/cat flag..

Wargame & CTF/pwnableKR2023. 11. 26. 16:21Toddler(passcode)

문제 Mommy told me to make a passcode based login system. My initial C code was compiled without any error! Well, there was some compiler warning, but who cares about that? ssh passcode@pwnable.kr -p2222 (pw:guest) 풀이 서버에 접속하여 ls 명령을 입력해보면 passcode, passcode.c, flag 3개의 파일이 존재하는 것을 알 수 있습니다. cat 명령어를 통해 passcode.c 파일을 확인합니다. #include #include void login(){ int passcode1; int passcode2; printf("ent..

Wargame & CTF/pwnableKR2023. 11. 26. 16:20Toddler(flag)

문제 Papa brought me a packed present! let's open it. Download : http://pwnable.kr/bin/flag This is reversing task. all you need is binary 풀이 해당 파일을 Hex Editor를 사용하여 확인하면 UPX로 패킹 되어 있다는 것을 알 수 있습니다. UPX 언패킹 툴을 사용하여 언패킹 후 IDA로 열어보면 플래그가 보입니다.

image