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 | Bin 255936 -> 0 bytes src/VX-GAMBLEGROUND.c | 30 +++++++++++++++++++----------- src/VX-GAMBLEGROUND.h | 4 ++++ src/screen.c | 9 ++++++++- src/screen.h | 2 +- 5 files changed, 32 insertions(+), 13 deletions(-) delete mode 100755 src/VX-GAMBLEGROUND (limited to 'src') diff --git a/src/VX-GAMBLEGROUND b/src/VX-GAMBLEGROUND deleted file mode 100755 index 0b69d2f..0000000 Binary files a/src/VX-GAMBLEGROUND and /dev/null differ 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) { diff --git a/src/VX-GAMBLEGROUND.h b/src/VX-GAMBLEGROUND.h index 80baacb..182a51f 100644 --- a/src/VX-GAMBLEGROUND.h +++ b/src/VX-GAMBLEGROUND.h @@ -10,9 +10,13 @@ struct arguments { #define SKIPSLOTS 0x1 #define SKIPENC 0x2 +#define PHRASESIZE 32 +int genphrase(char *phrase, size_t phrasesize); + struct bullshit { struct sigaction handler; int row, col, randphrase; + char passphrase[PHRASESIZE + 1]; WINDOW *banner, *menuholder; ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; diff --git a/src/screen.c b/src/screen.c index e70bf21..d5b7f2b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -181,7 +181,7 @@ int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], return 0; } -WINDOW* create_banner(int col, int randomnum) { +WINDOW* create_banner(int col, int randomnum, const char *passphrase) { // Create the banner window WINDOW *phrase = newwin(1, col, 0, 0); if(phrase == NULL) { @@ -191,6 +191,13 @@ WINDOW* create_banner(int col, int randomnum) { wbkgd(phrase, COLOR_PAIR(CCP_BANNER)); mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: "); waddstr(phrase, phrases[randomnum]); + + char *pass = NULL; + if(asprintf(&pass, "Passphrase=%s", passphrase) < 0) + error(1, errno, "[VX-GAMBLEGROUND] asprintf broke"); + mvwaddnstr(phrase, 0, col - strlen(pass) - 2, pass, strlen(pass)); + free(pass); + wnoutrefresh(phrase); return phrase; diff --git a/src/screen.h b/src/screen.h index efe7335..0e5137a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -215,7 +215,7 @@ int init_slotholder(struct slotholder *slots); int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff); // Create the vx-gambleground banner -WINDOW* create_banner(int col, int randomnum); +WINDOW* create_banner(int col, int randomnum, const char *passphrase); // Deal with menu items when a user hits enter int handle_menuitem(MENU *menu, struct params *params); -- cgit v1.2.3