목록리버싱 기초/pwnable.kr (14)
Self-Improvement
풀이 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..
소스코드 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 #include #include unsigned long hashcode = 0x21DD09EC; unsigned long check_password(const char* p){ int* ip = (int*)p; int i; int res=0; for(i=0; i