Enviado em 31/01/2014 - 05:09h
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
FILE *diarie;
char *options[] = {
":changeFile:\n",
":help:\n",
":end:\n"
};
static void fatal(const char *msg) {
fprintf(stderr, msg);
};
static int configure();
static void help();
static void print_usage();
static void ch_file(const char*);
int main(int argc, char *argv[]) {
char usrtyping[200];
if(!argv[1])
print_usage();
if(configure(argv[1])) {
fatal("Error: cannot open, write or the file does not exist.\n");
return 1;
}
printf("Welcome to the Diarie!\n");
printf("Digit all your shit here, digit :end: to exit.\n"
"Digit :help: to get a simple information.\n");
do {
gets(usrtyping);
strcat(usrtyping, "\n");
fprintf(diarie, usrtyping);
if(!strcmp(usrtyping, options[0])) {
char newFile[200];
printf("Ok, now digit the new file:\n");
gets(newFile);
ch_file(newFile);
} else if(!strcmp(usrtyping, options[1])) {
help();
}
fflush(diarie);
} while(strcmp(usrtyping, options[2]));
return 0;
}
static void print_usage() {
printf("diarie <text-file>\n\n");
help();
exit(1);
}
static int configure(const char *text_file) {
diarie = fopen(text_file, "w");
if(diarie == NULL) {
return 1;
}
return 0;
}
static inline void help() {
printf("Diarie is a simple diarie software for you write\n"
"Your bigger secrets, dirty little secrets, conplainings,\n"
"sexual experiencies and so on. Everything in insecure\n"
"text files whose anyone can see. Including your mother,\n"
"father, sons, girlfriend, aunts, etc...\n\n");
printf("Actions for you perform operations while the diarie is\n"
"running are provided typing a word between \"::\".\n"
"This way the sintax is: :<word>:.\n"
"Available words are:\n"
"changeFile -- for change the text file you write.\n"
"help -- display this help message.\n"
"end -- to end the diarie and flush your all secrets.\n\n"
"Security flaws available for exploit:\n"
"Possible buffer overflow in variable usrtyping.\n\n"
"Limitations:\n"
"For a while, Diarie cannot edit an already written file\n"
"because the developer still know not how to implement this.\n"
"And too de developer don't know how to don't print the commands\n"
"like :help: in the diarie.\n"
"(Laught as most you want.)\n\n");
}
static void ch_file(const char *newFile) {
if(configure(newFile))
fatal("File changing failed.\n");
else
printf("Success! Now continue to digit your bigger secrets.\n");
}
Máquina perereca - até onde é possível o uso de Linux?
Mitigação - O que é e quando é "seguro" desabilitar
Atualizar Debian Online de uma Versão para outra
A arte e a prática da Disciplina a longo prazo
Topgrade - Atualize seu sistema Linux inteiro com um único comando
Site com diversos emojis para seus códigos
Um modo leve de ouvir/ver áudio/vídeo da internet em máquinas pererecas
Instalar Linux e grub em hd ssd externo (3)
O que você está ouvindo agora? [2] (200)