ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • heap0
    Exploit-Exercise 2015. 6. 27. 21:09

    #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> #include <sys/types.h> struct data { char name[64]; }; struct fp { int (*fp)(); }; void winner() { printf("level passed\n"); } void nowinner() { printf("level has not been passed\n"); } int main(int argc, char **argv) { struct data *d; struct fp *f; d = malloc(sizeof(struct data)); f = malloc(sizeof(struct fp)); f->fp = nowinner; printf("data is at %p, fp is at %p\n", d, f); strcpy(d->name, argv[1]); f->fp(); }


    소스코드를 보자.


    일단 data구조체에는 64바이트 크기의 변수가 존재하고, fp에는 4바이트짜리 포인터가 존재한다


    그리고 각각 동적할당을 해준다.


    그럼 동적할당만 68바이트 + sfp + ret 이렇게해주면 정상적으로 변조가될것이다.





    우선 함수주소를 보고, 익스플로잇을하자





    패스

    'Exploit-Exercise' 카테고리의 다른 글

    stack6  (0) 2015.12.08
    Fusion Level 0  (0) 2015.09.09
    stack4  (0) 2015.06.27
    stack3  (0) 2015.04.21
    stack2  (0) 2015.04.21

    댓글

Designed by Tistory.