Profile

머리정리하는곳

c2w2m2

[Protostar] heap2

ㅁ윽 클리어 조건이 헷갈려서 오래걸린 문제 ㅠㅠㅠ 그냥 login 했을때 already logined 뜨면 클리어였습니당..


#include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdio.h> 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(line + 5) < 31) { strcpy(auth->name, line + 5); } } if(strncmp(line, "reset", 5) == 0) { free(auth); } if(strncmp(line, "service", 6) == 0) { service = strdup(line + 7); } if(strncmp(line, "login", 5) == 0) { if(auth->auth) { printf("you have logged in already!\n"); } else { printf("please enter your password\n"); } } } }


그렇게 보니까 그냥 auth 하고 service 로 길이가 17만큼만 입력해주면 쓱-싹 되는 문제였습니다...



쉘따는줄 알고 uaf 까지 고려했었던,,

'Pwnable' 카테고리의 다른 글

[pwnable.kr] syscall  (2) 2017.10.03
[DIMI] scan  (0) 2017.09.26
[CodeGate] BabyMisc  (0) 2017.09.15
[Protostar] heap1  (1) 2017.09.13
<asis ctf> mary_morton  (0) 2017.09.11