summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rwxr-xr-xsrc/VX-GAMBLEGROUNDbin255936 -> 0 bytes
-rw-r--r--src/VX-GAMBLEGROUND.c30
-rw-r--r--src/VX-GAMBLEGROUND.h4
-rw-r--r--src/screen.c9
-rw-r--r--src/screen.h2
6 files changed, 34 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 8fd19f6..d60216b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ screen
6search 6search
7main 7main
8*.o 8*.o
9a.out \ No newline at end of file 9a.out
10VX-GAMBLEGROUND \ No newline at end of file
diff --git a/src/VX-GAMBLEGROUND b/src/VX-GAMBLEGROUND
deleted file mode 100755
index 0b69d2f..0000000
--- a/src/VX-GAMBLEGROUND
+++ /dev/null
Binary files 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 @@
35#include <stdio.h> 35#include <stdio.h>
36#include <threads.h> 36#include <threads.h>
37 37
38#define PHRASESIZE 32
39
40const char *argp_program_version = "Alpha-0.1"; 38const char *argp_program_version = "Alpha-0.1";
41const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)"; 39const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)";
42 40
@@ -87,11 +85,11 @@ static struct argp argp = {options, parse_opt, argdoc, doc, NULL, 0, 0};
87 85
88int genphrase(char *phrase, size_t phrasesize) { 86int genphrase(char *phrase, size_t phrasesize) {
89 memset(phrase, 0, phrasesize); 87 memset(phrase, 0, phrasesize);
90 for(size_t i = 0; i < phrasesize; i++) { 88 for(size_t i = 0; i < phrasesize; i++)
91 phrase[i] = randombytes_uniform(('Z' - 'A') + 1) + 'A'; 89 phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A';
92 if(randombytes_random() > (0xffffffff / 2)) 90 phrase[phrasesize] = '\0';
93 phrase[i] += ('a' - 'A'); 91
94 } 92 printf("%s\n", phrase);
95 93
96 return 0; 94 return 0;
97} 95}
@@ -109,7 +107,7 @@ int doslots(struct bullshit *stuff) {
109 107
110 getmaxyx(stdscr, stuff->row, stuff->col); 108 getmaxyx(stdscr, stuff->row, stuff->col);
111 stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); 109 stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1);
112 stuff->banner = create_banner(stuff->col, stuff->randphrase); 110 stuff->banner = create_banner(stuff->col, stuff->randphrase, stuff->passphrase);
113 111
114 init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); 112 init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs);
115 stuff->menu = new_menu(stuff->items); 113 stuff->menu = new_menu(stuff->items);
@@ -154,7 +152,7 @@ int doslots(struct bullshit *stuff) {
154 152
155int doslots_twrapper(void *passed) { 153int doslots_twrapper(void *passed) {
156 return doslots((struct bullshit*)passed); 154 return doslots((struct bullshit*)passed);
157}; 155}
158 156
159 157
160int main(int argc, char *argv[]) { 158int main(int argc, char *argv[]) {
@@ -167,12 +165,22 @@ int main(int argc, char *argv[]) {
167 if(args.flags == (SKIPENC | SKIPSLOTS)) 165 if(args.flags == (SKIPENC | SKIPSLOTS))
168 error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); 166 error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure");
169 167
168
169 // C is truly a mystery sometimes. If this is statically defined, shit breaks. But when I allocate it? Just works
170 char *passphrase = calloc(PHRASESIZE + 1, sizeof(*passphrase));
171 if(args.inputpass == NULL) {
172 genphrase(passphrase, PHRASESIZE);
173 } else {
174 passphrase = args.inputpass;
175 }
176
177
170 struct bullshit stuff; 178 struct bullshit stuff;
179 strncpy(stuff.passphrase, passphrase, PHRASESIZE);
171 thrd_t slots; 180 thrd_t slots;
172 int err; 181 int err;
173
174 if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) 182 if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success)
175 error(1, 0, "Thread creation failed"); 183 error(1, 0, "Thread creation failed: %d", err);
176 184
177 185
178 // if(args.inputpass != NULL) { 186 // 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 {
10#define SKIPSLOTS 0x1 10#define SKIPSLOTS 0x1
11#define SKIPENC 0x2 11#define SKIPENC 0x2
12 12
13#define PHRASESIZE 32
14int genphrase(char *phrase, size_t phrasesize);
15
13struct bullshit { 16struct bullshit {
14 struct sigaction handler; 17 struct sigaction handler;
15 int row, col, randphrase; 18 int row, col, randphrase;
19 char passphrase[PHRASESIZE + 1];
16 20
17 WINDOW *banner, *menuholder; 21 WINDOW *banner, *menuholder;
18 ITEM *items[STATIC_ARRSIZE(menu_choices) + 1]; 22 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],
181 return 0; 181 return 0;
182} 182}
183 183
184WINDOW* create_banner(int col, int randomnum) { 184WINDOW* create_banner(int col, int randomnum, const char *passphrase) {
185 // Create the banner window 185 // Create the banner window
186 WINDOW *phrase = newwin(1, col, 0, 0); 186 WINDOW *phrase = newwin(1, col, 0, 0);
187 if(phrase == NULL) { 187 if(phrase == NULL) {
@@ -191,6 +191,13 @@ WINDOW* create_banner(int col, int randomnum) {
191 wbkgd(phrase, COLOR_PAIR(CCP_BANNER)); 191 wbkgd(phrase, COLOR_PAIR(CCP_BANNER));
192 mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: "); 192 mvwaddstr(phrase, 0, 1, "VX-GAMBLEGROUND: ");
193 waddstr(phrase, phrases[randomnum]); 193 waddstr(phrase, phrases[randomnum]);
194
195 char *pass = NULL;
196 if(asprintf(&pass, "Passphrase=%s", passphrase) < 0)
197 error(1, errno, "[VX-GAMBLEGROUND] asprintf broke");
198 mvwaddnstr(phrase, 0, col - strlen(pass) - 2, pass, strlen(pass));
199 free(pass);
200
194 wnoutrefresh(phrase); 201 wnoutrefresh(phrase);
195 202
196 return phrase; 203 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);
215int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff); 215int init_custom_menu_format(WINDOW *menuholder, MENU *menu, const int fmtdim[2], Menu_Options toggleon, Menu_Options toggleoff);
216 216
217// Create the vx-gambleground banner 217// Create the vx-gambleground banner
218WINDOW* create_banner(int col, int randomnum); 218WINDOW* create_banner(int col, int randomnum, const char *passphrase);
219 219
220// Deal with menu items when a user hits enter 220// Deal with menu items when a user hits enter
221int handle_menuitem(MENU *menu, struct params *params); 221int handle_menuitem(MENU *menu, struct params *params);