-
Notifications
You must be signed in to change notification settings - Fork 0
/
103-keygen.c
52 lines (43 loc) · 1.08 KB
/
103-keygen.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
#include "lists.h"
#include <string.h>
/**
* main - Generates and prints passwords for the crackme5 executable.
* @argc: The number of arguments supplied to the program.
* @argv: An array of pointers to the arguments.
*
* Return: Always 0.
*/
int main(int __attribute__((__unused__)) argc, char *argv[])
{
char password[7], *codex;
int len = strlen(argv[1]), i, tmp;
codex = "A-CHRDw87lNS0E9B2TibgpnMVys5XzvtOGJcYLU+4mjW6fxqZeF3Qa1rPhdKIouk";
tmp = (len ^ 59) & 63;
password[0] = codex[tmp];
tmp = 0;
for (i = 0; i < len; i++)
tmp += argv[1][i];
password[1] = codex[(tmp ^ 79) & 63];
tmp = 1;
for (i = 0; i < len; i++)
tmp *= argv[1][i];
password[2] = codex[(tmp ^ 85) & 63];
tmp = 0;
for (i = 0; i < len; i++)
{
if (argv[1][i] > tmp)
tmp = argv[1][i];
}
srand(tmp ^ 14);
password[3] = codex[rand() & 63];
tmp = 0;
for (i = 0; i < len; i++)
tmp += (argv[1][i] * argv[1][i]);
password[4] = codex[(tmp ^ 239) & 63];
for (i = 0; i < argv[1][0]; i++)
tmp = rand();
password[5] = codex[(tmp ^ 229) & 63];
password[6] = '\0';
printf("%s", password);
return (0);
}