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");
}
Passkeys: A Evolução da Autenticação Digital
Instalação de distro Linux em computadores, netbooks, etc, em rede com o Clonezilla
Título: Descobrindo o IP externo da VPN no Linux
Armazenando a senha de sua carteira Bitcoin de forma segura no Linux
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Como configurar posicionamento e movimento de janelas no Lubuntu (Openbox) com atalhos de teclado
Máquinas Virtuais com IP estático acessando Internet no Virtualbox
Instalar o Microsoft Edge no Slackware 15
Instalando Brave Browser no Linux Mint 22
vídeo pra quem quer saber como funciona Proteção de Memória:
Atualizar para Ubuntu 22.04 nao consigo (0)
Problema com nome composto e organização na tela do yad (2)
Problemas na Atualização do Ubuntu 20.04 para 22.04 (2)
Primeira vez utilizando Linux Ubuntu 22.04 e já tenho problemas… (7)