#include<stdio.h> #include<stdlib.h> int chunk_time =0; int chunk_size[50]; char *chunk_ptr[50]; char magic_addr[1000]; voidbss_write(){ puts("For commissioning only"); char *a[50]; read(0,a,0x50); puts("Input content"); read(0,*a,0x100); } voidgift(){ puts("Convenient debugging"); puts("Please enter the got table of the function"); char a[0x20]; read(0,a,0x20); asm( "pop %rsi\n\t" "mov $1,%rax\n\t" "mov $1,%rdi\n\t" "mov $8,%rdx\n\t" "syscall\n\t" ); puts("Keep this gift"); } voidinit(){ setvbuf(stdout, 0, 2, 0); setvbuf(stdin, 0, 2, 0); } voidmenu(){ puts("Life is fucking movie"); puts("Life is always full of unhappiness, like this question"); puts("Anyway, what's your answer"); puts(">"); } voidadd(){ int index; char size[20]; puts("What do you really want?"); if(chunk_time<=32&&chunk_time>=0){ if(!chunk_ptr[chunk_time]){ printf("This is the %dth choice in your life\n",chunk_time); puts("You can customize the size of chunk, but what about your life"); read(0,size,0x8); chunk_size[chunk_time] = atoi(size); chunk_ptr[chunk_time] = malloc(chunk_size[chunk_time]); printf("chunk_addr is %x\n",&(*chunk_ptr[chunk_time])); puts("Although your life is a piece of shit, you still have the initiative, right?"); read(0,chunk_ptr[chunk_time],chunk_size[chunk_time]); chunk_time++; }else{ puts("error"); exit(0); } }else{ exit(0); puts(""); } } voiddelete(){ char data[100]; int index; puts("I didn't set the pointer to zero, just like some things can't be repeated"); scanf("%d",&index); free(chunk_ptr[index]); } voidedit(){ int index; int chunksize; puts("It's never too late to start again. What do you regret?"); scanf("%d",&index); puts("You all know that there can be overflows here, so why do you set limits on your life?"); scanf("%d",&chunksize); puts("Come back!"); read(0,chunk_ptr[index],chunksize); } voidshow(){ puts("You can't live a perfect life without making any effort"); int index; scanf("%d",&index); puts(chunk_ptr[index]); } intmain(){ int choice; init(); puts("This program is used to debug heap vulnerabilities"); puts("write by chen"); while(1){ menu(); scanf("%d",&choice); switch(choice){ case1: add(); break; case2: delete(); break; case3: edit(); break; case4: show(); break; case5: gift(); break; case6: bss_write(); break; case7: puts("The fog of that morning cleared, not only in the morning, but also in the fog"); puts("You will be stronger next time I see you"); exit(0); break; } } }