write

    [pwnable.kr][Toddler] lotto 문제풀이

    [pwnable.kr][Toddler] lotto 문제풀이

    lotto #include #include #include #include unsigned char submit[6]; void play(){ int i; printf("Submit your 6 lotto bytes : "); fflush(stdout); int r; r = read(0, submit, 6); printf("Lotto Start!\n"); //sleep(1); // generate lotto numbers int fd = open("/dev/urandom", O_RDONLY); if(fd==-1){ printf("error. tell admin\n"); exit(-1); } unsigned char lotto[6]; if(read(fd, lotto, 6) != 6){ printf("err..

    [pwnable.kr][Toddler] coin1 문제풀이

    [pwnable.kr][Toddler] coin1 문제풀이

    coin1 문제를 요약하면 동전이 있는데 진짜 동전은 무게가 10이고, 가짜는 9이다.한번 실행되면 랜덤한 동전 개수(N)와 서버에게 물어볼 수 있는 카운트 수(C)가 설정되어 출력된다.만약 '0 1' 이라고 해서 보내면 서버는 첫번째 코인과 두번째 코인의 무게를 합한 값을 대답해준다.하나의 세트에는 1개의 가짜 동전이 존재하고, 동전을 찾으면 다시 새로운 세트가 만들어 지고 또 다시 가짜 동전 1개를 찾아야 한다.이런식으로 총 100개의 가짜 동전을 찾으면 되는데, 문제는 주어진 시간은 60초이다.따라서 자동화코드를 만들어서 찾는 방법 밖에없다. 가짜 동전을 최소한의 질의로 찾는 알고리즘부터 만들어야 한다.예를들어 서버로부터 N=400, C=10이라는 값을 받았다고 가정했을 때,코인을 0~200, 20..

    [LOB] Level20: xavius → death_knight [完]

    [LOB] Level20: xavius → death_knight [完]

    death_knight /* The Lord of the BOF : The Fellowship of the BOF - dark knight - remote BOF */ #include #include #include #include #include #include #include #include #include main() { char buffer[40]; int server_fd, client_fd; struct sockaddr_in server_addr; struct sockaddr_in client_addr; int sin_size; if((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1){ perror("socket"); exit(1); } server_..

    [LOB] Level19: nightmare → xavius

    [LOB] Level19: nightmare → xavius

    xavius /* The Lord of the BOF : The Fellowship of the BOF - xavius - arg */ #include #include #include main() { char buffer[40]; char *ret_addr; // overflow! fgets(buffer, 256, stdin); printf("%s\n", buffer); if(*(buffer+47) == '\xbf') { printf("stack retbayed you!\n"); exit(0); } if(*(buffer+47) == '\x08') { printf("binary image retbayed you, too!!\n"); exit(0); } // check if the ret_addr is li..

    [LOB] Level18: succubus → nightmare

    [LOB] Level18: succubus → nightmare

    nightmare /* The Lord of the BOF : The Fellowship of the BOF - nightmare - PLT */ #include #include #include #include main(int argc, char *argv[]) { char buffer[40]; char *addr; if(argc < 2){ printf("argv error\n"); exit(0); } // check address addr = (char *)&strcpy; if(memcmp(argv[1]+44, &addr, 4) != 0){ printf("You must fall in love with strcpy()\n"); exit(0); } // overflow! strcpy(buffer, arg..

    [LOB] Level17: zombie_assassin → succubus

    [LOB] Level17: zombie_assassin → succubus

    succubus keyword : RTL /* The Lord of the BOF : The Fellowship of the BOF - succubus - calling functions continuously */ #include #include #include // the inspector int check = 0; void MO(char *cmd) { if(check != 4) exit(0); printf("welcome to the MO!\n"); // olleh! system(cmd); } void YUT(void) { if(check != 3) exit(0); printf("welcome to the YUT!\n"); check = 4; } void GUL(void) { if(check != ..

    [LOB] Level16: assassin → zombie_assassin

    [LOB] Level16: assassin → zombie_assassin

    zombie_assassin Keyword : RTL /* The Lord of the BOF : The Fellowship of the BOF - zombie_assassin - FEBP */ #include #include main(int argc, char *argv[]) { char buffer[40]; if(argc < 2){ printf("argv error\n"); exit(0); } if(argv[1][47] == '\xbf') { printf("stack retbayed you!\n"); exit(0); } if(argv[1][47] == '\x40') { printf("library retbayed you, too!!\n"); exit(0); } // strncpy instead of ..

    [LOB] Level15: gaint → assassin

    [LOB] Level15: gaint → assassin

    assassin /* The Lord of the BOF : The Fellowship of the BOF - assassin - no stack, no RTL */ #include #include main(int argc, char *argv[]) { char buffer[40]; if(argc < 2){ printf("argv error\n"); exit(0); } if(argv[1][47] == '\xbf') { printf("stack retbayed you!\n"); exit(0); } if(argv[1][47] == '\x40') { printf("library retbayed you, too!!\n"); exit(0); } strcpy(buffer, argv[1]); printf("%s\n"..