[閒聊] C 語言大師請進

作者: abcd991276 (QQ)   2024-03-14 16:10:23
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FLAGSIZE_MAX 64
int num_allocs;
char *x;
char *input_data;
void win() {
// Print flag
char buf[FLAGSIZE_MAX];
FILE *fd = fopen("flag.txt", "r");
fgets(buf, FLAGSIZE_MAX, fd);
printf("%s\n", buf);
fflush(stdout);
exit(0);
}
void check_win() { ((void (*)())*(int*)x)(); }
void print_menu() {
printf("\n1. Print Heap\n2. Write to buffer\n3. Print x\n4. Print
Flag\n5. "
"Exit\n\nEnter your choice: ");
fflush(stdout);
}
void init() {
printf("\nI have a function, I sometimes like to call it, maybe you
should change it\n");
fflush(stdout);
input_data = malloc(5);
strncpy(input_data, "pico", 5);
x = malloc(5);
strncpy(x, "bico", 5);
}
void write_buffer() {
printf("Data for buffer: ");
fflush(stdout);
scanf("%s", input_data);
}
void print_heap() {
printf("[*] Address -> Value \n");
printf("+
作者: bigbowl ( Gathering Storm。)   2024-03-14 16:11:00
@oin
作者: DJYOSHITAKA (Evans)   2024-03-14 16:11:00
問gpt
作者: wu10200512 (廷廷)   2024-03-14 16:12:00
你找個函數指針指他不就好了
作者: Ceelo (hakkaman)   2024-03-14 16:14:00
這段是做什麼功能的
作者: abcd991276 (QQ)   2024-03-14 16:17:00
要找旗子, 要利用 buffer overflow 來達成 check_win 函數執行 win 函數
作者: argorok (s.green)   2024-03-14 16:20:00
用dbger直接看win位址就好了
作者: MurasakiSion (紫咲シオン)   2024-03-14 16:34:00
在玩ctf喔
作者: abcd991276 (QQ)   2024-03-14 16:37:00
對啊

Links booklink

Contact Us: admin [ a t ] ucptt.com