forked from rw-r-r-0644/wiiu-aprilfool-boot0hax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crypt_string.c
57 lines (48 loc) · 1.51 KB
/
crypt_string.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
// Bad, quick, encryption code, don't use it for anything else than april fools!
int main(int argc, char *argv[])
{
char * text = argv[1];
int text_len = strlen(text);
char key[] = "wait a Minute"; // The time needed for the real boot0 hax xP (don't use [tm], that breaks the code)
int key_len = strlen(key);
// Do initial text obfuscation
for (int i = 0; i < text_len; i++)
text[i]++;
// If the key is smaller than the text, copy the key over until it covers the whole text (yeah, it's a bad solution...)
char * key_fixed;
if (key_len < text_len)
{
key_fixed = malloc(text_len + 1);
int i;
for (i = 0; i < (text_len / key_len); i++)
memcpy(&key_fixed[i * key_len], key, key_len);
memcpy(&key_fixed[i * key_len], key, text_len - (i * key_len));
}
else
{
key_fixed = key;
}
//Add the key
uint16_t * encrypted = malloc(sizeof(uint16_t) * text_len);
for (int i = 0; i < text_len; i++)
encrypted[i] = text[i] + key_fixed[i];
// Print the encrypted text + null termination
printf("{{");
for (int i = 0; i < text_len; i++)
printf("0x%X, ", encrypted[i]);
printf("0x00}, %s},\n\n", (argv[2] == NULL) ? "0" : argv[2]);
// Obfuscate the key
for (int i = 0; i < key_len; i++)
key[i]++;
// Print the obfuscated key
//printf("const char * key = {");
//for (int i = 0; i < key_len; i++)
// printf("0x%02X, ", key[i]);
//
//printf("\b\b};\n");
return 0;
}