Pwnable.kr(13)
-
Lotto
더보기 #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(fd==-1){ printf("error. tell admin\n"); exit(-1); } unsigned char lotto[6]; if(read(fd, lotto, 6) != 6){ printf("error..
2022.04.01 -
Blackjack
더보기 // Programmer: Vladislav Shulman // Final Project // Blackjack // Feel free to use any and all parts of this program and claim it as your own work //FINAL DRAFT #include #include #include #include //Used for srand((unsigned) time(NULL)) command #include //Used for system("cls") command #define spade 06 //Used to print spade symbol #define club 05 //Used to print club symbol #define diamond 0..
2022.04.01 -
Coin1
nc로 접속하여 푸는 문제입니다. 맨 처음 화면입니다. 해당 게임은 가짜 코인을 찾는 게임으로 N 개의 코인과 C 번의 기회를 줍니다. 일반 코인은 무게가 10인 반면 가짜 코인은 무게 9입니다. 범위를 입력하면 해당 범위에 대한 무게 합을 출력합니다. 가짜 코인을 100번 찾으면 FLAG를 출력합니다. 여러 숫자들을 입력할 수 있는 규칙과 N에 따라 C가 바뀌는 것을 보고 탐색 문제인 거 같아. 탐색 알고리즘의 시간 복잡도를 검색해보았습니다. 검색 중 이진 탐색 알고리즘의 시간 복잡도가 log2N인 것을 찾고 문제에서 제공하는 N값들을 넣어보니 모두 C보다 같거나 작은 것을 확인할 수 있었습니다. 그래서 이진 탐색을 이용해 문제를 풀 수 있다고 생각하여 진행하였습니다. 코드와 결과는 아래와 같습니다. ..
2022.03.31 -
Shellshock
문제에서 제공하는 소스 코드입니다. #include int main(){ setresuid(getegid(), getegid(), getegid()); setresgid(getegid(), getegid(), getegid()); system("/home/shellshock/bash -c 'echo shock_me'"); return 0; } uid, gid를 shellshock_pwn로 설정한 뒤 system("/home/shellshock/bash -c 'echo shock_me'") 명령어를 실행합니다. 해당 문제를 풀기 위해 먼저 shellshock라는 공격 기법을 찾아보았습니다. 쉘 쇼크 취약점은 특정 bash 버전에서 공격자가 악의적인 시스템 명령을 실행할 수 있는 취약점입니다. 환경 변수 등..
2022.03.31 -
Mistake
#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); if(!strncmp(pw_buf, pw_buf2, PW_LEN)){ printf("Password OK\n"); system("/bin/cat flag\n"); } else{ printf("Wrong Password\n"); } close..
2022.03.31 -
Leg
문제에서 .c, .asm 파일이 주어집니다. #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()+key2()+key3()) == key ){ printf("Con..
2022.03.31