목록시스템 해킹/Exploit Exercises - Protostar (17)
ii4gsp
보호되어 있는 글입니다.

#include #include #include #include #include struct auth { char name[32]; int auth; }; struct auth *auth; char *service; int main(int argc, char **argv) { char line[128]; while(1) { printf("[ auth = %p, service = %p ]\n", auth, service); if(fgets(line, sizeof(line), stdin) == NULL) break; if(strncmp(line, "auth ", 5) == 0) { auth = malloc(sizeof(auth)); memset(auth, 0, sizeof(auth)); if(strlen(l..

include #include #include #include #include struct internet { int priority; char *name; }; void winner() { printf("and we have a winner @ %d\n", time(NULL)); } int main(int argc, char **argv) { struct internet *i1, *i2, *i3; i1 = malloc(sizeof(struct internet)); i1->priority = 1; i1->name = malloc(8); i2 = malloc(sizeof(struct internet)); i2->priority = 2; i2->name = malloc(8); strcpy(i1->name, ..

#include #include #include #include #include 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)..

#include #include #include #include int target; void hello() { printf("code execution redirected! you win\n"); _exit(1); } void vuln() { char buffer[512]; fgets(buffer, sizeof(buffer), stdin); printf(buffer); exit(1); } int main(int argc, char **argv) { vuln(); } exit() 함수를 hello() 함수로 바꿔줘야한다. exit()함수의 주소와 hello()함수의 주소를 구해주자 AAAA를 입력후 포맷 %08x로 값을 확인해보니 4번째 주소에 41414141이 있다. exit()함수의 주소와 hello..

#include #include #include #include int target; void printbuffer(char *string) { printf(string); } void vuln() { char buffer[512]; fgets(buffer, sizeof(buffer), stdin); printbuffer(buffer); if(target == 0x01025544) { printf("you have modified the target :)\n"); } else { printf("target is %08x :(\n", target); } } int main(int argc, char **argv) { vuln(); } target의 값을 0x01025544로 바꿔줘야 한다. 문자 AAAA를..

#include #include #include #include int target; void vuln() { char buffer[512]; fgets(buffer, sizeof(buffer), stdin); printf(buffer); if(target == 64) { printf("you have modified the target :)\n"); } else { printf("target is %d :(\n", target); } } int main(int argc, char **argv) { vuln(); } target의 값을 64로 바꿔줘야한다. AAAA와 %08x 4개를 입력값으로 주니 4번째에서 입력한 AAAA가 보인다. objdump -t 명령으로 target의 주소를 알아냈다. targ..

#include #include #include #include int target; void vuln(char *string) { printf(string); if(target) { printf("you have modified the target :)\n"); } } int main(int argc, char **argv) { vuln(argv[1]); } 이번 문제의 힌트이다. objdump -t 명령으로 target의 주소를 찾아보자 target의 주소는 0x08049638이다. 포맷을 131번 출력하면 \x90 * 4의 90909090이 보인다. 페이로드는 target주소 + .%08x * 129 + .%08n + .%08x target의 값이 변경되어 "you have modified the ..