From e51f37f52c4452be1c2cacf5969e6d754eaecc70 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Fri, 30 Aug 2024 19:29:53 -0500 Subject: Put passphrase on main window --- src/VX-GAMBLEGROUND.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/VX-GAMBLEGROUND.c') diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c index e905de4..c01ee5c 100644 --- a/src/VX-GAMBLEGROUND.c +++ b/src/VX-GAMBLEGROUND.c @@ -35,8 +35,6 @@ #include #include -#define PHRASESIZE 32 - const char *argp_program_version = "Alpha-0.1"; const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)"; @@ -87,11 +85,11 @@ static struct argp argp = {options, parse_opt, argdoc, doc, NULL, 0, 0}; int genphrase(char *phrase, size_t phrasesize) { memset(phrase, 0, phrasesize); - for(size_t i = 0; i < phrasesize; i++) { - phrase[i] = randombytes_uniform(('Z' - 'A') + 1) + 'A'; - if(randombytes_random() > (0xffffffff / 2)) - phrase[i] += ('a' - 'A'); - } + for(size_t i = 0; i < phrasesize; i++) + phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A'; + phrase[phrasesize] = '\0'; + + printf("%s\n", phrase); return 0; } @@ -109,7 +107,7 @@ int doslots(struct bullshit *stuff) { getmaxyx(stdscr, stuff->row, stuff->col); stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); - stuff->banner = create_banner(stuff->col, stuff->randphrase); + stuff->banner = create_banner(stuff->col, stuff->randphrase, stuff->passphrase); init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); stuff->menu = new_menu(stuff->items); @@ -154,7 +152,7 @@ int doslots(struct bullshit *stuff) { int doslots_twrapper(void *passed) { return doslots((struct bullshit*)passed); -}; +} int main(int argc, char *argv[]) { @@ -167,12 +165,22 @@ int main(int argc, char *argv[]) { if(args.flags == (SKIPENC | SKIPSLOTS)) error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); + + // C is truly a mystery sometimes. If this is statically defined, shit breaks. But when I allocate it? Just works + char *passphrase = calloc(PHRASESIZE + 1, sizeof(*passphrase)); + if(args.inputpass == NULL) { + genphrase(passphrase, PHRASESIZE); + } else { + passphrase = args.inputpass; + } + + struct bullshit stuff; + strncpy(stuff.passphrase, passphrase, PHRASESIZE); thrd_t slots; int err; - if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) - error(1, 0, "Thread creation failed"); + error(1, 0, "Thread creation failed: %d", err); // if(args.inputpass != NULL) { -- cgit v1.2.3