forked from NewBee119/ctf_vxworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguesshash.c
78 lines (63 loc) · 1.78 KB
/
guesshash.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>
#include <string.h>
void loginDefaultEncrypt
(
char *in, /* input string */
char *out /* encrypted string */
)
{
int ix;
unsigned long magic = 31695317;
unsigned long passwdInt = 0;
if (strlen (in) < 8 || strlen (in) > 40)
{
//errnoSet (S_loginLib_INVALID_PASSWORD);
//return (ERROR);
printf("password is not long enough\n");
}
for (ix = 0; ix < strlen(in); ix++) /* sum the string */
passwdInt += (in[ix]) * (ix+1) ^ (ix+1);
sprintf (out, "%u", (long) (passwdInt * magic)); /* convert interger
to string */
/* make encrypted passwd printable */
for (ix = 0; ix < strlen (out); ix++)
{
if (out[ix] < '3')
out[ix] = out[ix] + '!'; /* arbitrary */
if (out[ix] < '6')
out[ix] = out[ix] + '/'; /* arbitrary */
if (out[ix] < '9')
out[ix] = out[ix] + 'A'; /* arbitrary */
}
return ;
}
int main()
{
char inC[255];
char outC[255];
FILE *fp = fopen("1.txt", "r"); //
if(NULL == fp)
{
printf("failed to open dos.txt\n");
return 1;
}
while(!feof(fp))
{
memset(inC, 0, 255);
memset(outC, 0, 255);
fgets(inC, sizeof(inC) - 1, fp); // 包含了换行符
if(strlen(inC)<8)
continue;
int len = strlen(inC);
len=len-2;
inC[len] = 0; //delete huanhangfu
loginDefaultEncrypt(inC,outC);
if(strcmp(outC, "cQwwddSRxS")==0)
{
printf("password:%s to hash:%s\n",inC, outC);
//return 0;
}
}
fclose(fp);
return 0;
}