목록2020/06/22 (5)
Self-Improvement
소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #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; } Colored by Color Scripter cs rand() 함수로 랜덤하게 값을 생성해주지만 seed() 없이는 동일한 값이 출력된..
소스 코드 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 #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 : "); scanf("%d", passcode2); printf("checking...\n"..
풀이 pwnable.kr/bin/flag에서 파일을 다운로드하여 실행해 본다. malloc()하고 strcpy 수행만 한다고 되어있다. IDA로 열어서 확인해 보면 제대로 분석이 되어지지가 않는다.. 확인을 해보니 UPX로 패킹이 되어있는 것 같다. UPX 언패킹을 수행한 후에 다시한번 분석을 해본다. upx -d ./flag IDA로 다시한번 확인해 보니 정말로 malloc()와 strcpy() 함수만 수행하고 종료가 되어진다. strcpy() 인자로 넘어가는 레지스터 값을 확인해보면 flag 표시가 되어있으며 확인하면 flag 값을 얻을 수 있다.
소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #include #include #include void func(int key){ char overflowme[32]; printf("overflow me : "); gets(overflowme); // smash me! if(key == 0xcafebabe){ system("/bin/sh"); } else{ printf("Nah..\n"); } } int main(int argc, char* argv[]){ func(0xdeadbeef); return 0; } Colored by Color Scripter cs gets()함수에서 bof가 발생하여 key 값이 저장된 주소까지 덮어씌울 수 있다. * func..