Write up (Wargame)

Write up (Wargame)/Pwnable

[pwnable.kr] blackjack 풀이

Analysis 이번 문제는 블랙잭에서 100만 달러 이상을 달성하는 것이다. 일단 nc로 프로그램을 켜보면 꽤 재미있는 블랙잭 화면이 나온다. 실제로 해보면 재미가 있다..! 게임을 플레이하면 포인트를 베팅하고 Hit, Stay를 결정한다. 블랙잭 룰은 일반 블랙잭과 동일하다. 이러한 긴 코드의 프로그램에서 취약점을 찾고 100만달러를 벌라는 것은.. 짐작가는 바가 있다. 너무 짐작이 잘 된다. 코드에서는 이렇게 베팅할 달러를 숫자로 입력하도록 되어있는데 여기가 음수가 되면 패배했을 때, 돈을 벌게 될 것이다. 보통 이런데서 터질거 같으니 넣어봤다. Solution 실제로 된다. 한 줄의 코드도 읽지 않고, 쉽게 플래그를 얻어냈다.

Write up (Wargame)/Pwnable

[pwnable.kr] coin1 풀이

Analysis N과 C값이 주어진다. N은 동전의 갯수이다. C는 선택할 수 있는 횟수이다. N개의 동전 중에서 한 개가 가짜 동전이다. 클라이언트는 0~N-1 개의 인덱스 중에서 입력을 하면 그 인덱스에 해당하는 동전 무게의 합을 알려준다. N값이 너무 커서 사람이 하기에는 무리가 있다. C 횟수도 그렇고 딱 봐도 이진탐색을 써달라고 울부짖는게 보인다. 혹시 몰라 -1 도 넣어보고 했지만 에러는 발생하지 않는다. 이건 알고리즘 문제인듯; Solution 이진탐색 코드를 작성하여 수행 중에, 시간 초과가 난다. 서버가 느리면 여기서 하라고 한다. 아니 ssh로 어디를 접속해야하나 싶었는데 그냥 이전 ssh 아무데나 들어가서 localhost로 하면 된다. 로컬호스트로 하니까 엄청 빨리 나온다.. fro..

Write up (Wargame)/Pwnable

[pwnable.kr] shellshock 풀이, CVE-2014-6271

Analysis bash? 와 관련있다고 하는데 Olday 취약점인가? #include int main(){ setresuid(getegid(), getegid(), getegid()); setresgid(getegid(), getegid(), getegid()); system("/home/shellshock/bash -c 'echo shock_me'"); return 0; } 코드가 매우 짧다. setresuid, setresgid를 통해 set uid가 걸려있던 shellshock 바이너리의 권한을 shellshock_pwn으로 수정한다. 그러고보니 shellshock를 bomb lab에서 했는데. 그 때에는 웹을 통해서 공격했었다. 이 문제에서는 쉘을 그대로 공격하는 것으로 원리를 알아가야겠다. S..

Write up (Wargame)/Pwnable

[pwnable.kr] mistake 풀이

analysis 문제의 내용으로 dhmonkey라는 것과 관련이 있고, 힌트는 연산자 우선 순위이다. dhmonkey를 구글에 검색했을 때 나오는 것이 없으니 사전에 알아두어야 하는 것이 아니라 ssh를 접속하고 나서 지켜보면 될 것 같다. #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); return 0; } char pw_buf2[PW_LEN+1]; printf("input password : "); scanf("%10s", pw_buf2); // xor your input xor(pw_buf2, 10);..

Write up (Wargame)/Pwnable

[pwnable.kr] leg 풀이

analysis 문세 설명을 보니 ARM 문제이다. asm 파일이랑 C언어 파일을 다운로드 하고 분석한다. #include #include int key1(){ asm("mov r3, pc\n"); } int key2(){ asm( "push{r6}\n" "addr6, pc, $1\n" "bxr6\n" ".code 16\n" "movr3, pc\n" "addr3, $0x4\n" "push{r3}\n" "pop{pc}\n" ".code32\n" "pop{r6}\n" ); } int key3(){ asm("mov r3, lr\n"); } int main(){ int key=0; printf("Daddy has very strong arm! : "); scanf("%d", &key); if( (key1()+k..

Write up (Wargame)/Pwnable

[pwnable.kr] input 풀이

Analysis amd64 바이너리임. #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("Just give me correct inputs then you will get the flag :)\n"); // argv if(argc != 100) return 0; if(strcmp(argv['A'],"\x00")) return 0; if(strcmp(argv['B'],"\x20\x0a\x0d")) ret..

Write up (Wargame)/Pwnable

[pwnable.kr] random 풀이

analysis amd 64바이너리고, RELRO, canary, PIE가 없다. #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"); return 0; } printf("Wrong, maybe you should try 2^32 cases.\n"); return 0; } 신기하게도 stdlib를 선언하지 않고 rand 함수를 사용한다. 뭐 gcc가 알아서 넣어줬겠지..? rand 함수에서 seed를 정하지 않았다...

Write up (Wargame)/Pwnable

[pwnable.kr] passcode 풀이

ssh로 서버에 접속해서 문제를 풀어야 한다. 우선 접속해서 살펴본다. analysis 서버가 좀 느리다. flag를 읽어야하고 passcode 프로그램에는 set uid가 걸려있다. C 코드를 분석하고 쉘을 따면 될 것 같다. 프로그램 실행 먼저 해보면 이렇게 뜬다. passcode 코드는 생각보다 짧다. #include #include void login(){ int passcode1; int passcode2; printf("enter passcode1 : "); scanf("%d", passcode1); fflush(stdin); // ha! mommy told me that 32bit is vulnerable to bruteforcing :) printf("enter passcode2 : ");..

그믐​
'Write up (Wargame)' 카테고리의 글 목록