-
Notifications
You must be signed in to change notification settings - Fork 0
/
103-keygen.c
45 lines (43 loc) · 1.04 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/**
* main - generate a key depending on a username for crackme5
* @argc: number of arguments passed
* @argv: arguments passed to main
*
* Return: 0 on success, 1 on error
*/
int main(int argc, char *argv[])
{
unsigned int i, b;
size_t len, add;
char *l = "A-CHRDw87lNS0E9B2TibgpnMVys5XzvtOGJcYLU+4mjW6fxqZeF3Qa1rPhdKIouk";
char p[7] = " ";
if (argc != 2)
{
printf("Correct usage: ./keygen5 username\n");
return (1);
}
len = strlen(argv[1]);
p[0] = l[(len ^ 59) & 63];
for (i = 0, add = 0; i < len; i++)
add += argv[1][i];
p[1] = l[(add ^ 79) & 63];
for (i = 0, b = 1; i < len; i++)
b *= argv[1][i];
p[2] = l[(b ^ 85) & 63];
for (b = argv[1][0], i = 0; i < len; i++)
if ((char)b <= argv[1][i])
b = argv[1][i];
srand(b ^ 14);
p[3] = l[rand() & 63];
for (b = 0, i = 0; i < len; i++)
b += argv[1][i] * argv[1][i];
p[4] = l[(b ^ 239) & 63];
for (b = 0, i = 0; (char)i < argv[1][0]; i++)
b = rand();
p[5] = l[(b ^ 229) & 63];
printf("%s\n", p);
return (0);
}