Tokyohot N0541 (2024)
void menu(void) puts("\n--- TokyoHot ---"); puts("1) Register"); puts("2) Login"); puts("3) Show secret"); puts("4) Exit"); printf("> ");
int main() setbuf(stdout, NULL); while (1) menu(); int choice = read_int(); switch (choice) case 1: register_user(); break; case 2: login(); break; case 3: show_secret(); break; case 4: exit(0); tokyohot n0541
void login(void) char buf[0x40]; printf("Password: "); read(0, buf, 0x100); // <<< oversized read -> heap overflow strcpy(users[0].pwd, buf); if (strcmp(buf, users[0].pwd) == 0) logged_in = 1; puts("Logged in!"); else puts("Wrong password."); void menu(void) puts("\n--- TokyoHot ---")
def menu(s): recvuntil(s, b'> ')