-
Notifications
You must be signed in to change notification settings - Fork 1
/
qcrack_checksum.c
93 lines (69 loc) · 1.92 KB
/
qcrack_checksum.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <string.h>
#include <stdlib.h>
/* returns zero if checksum isn't valid,
positive non-zero if it is valid,
negative non-zero if error (length not 12, challenge string not numbers)
*/
int qcrack_checksum(char *challenge) {
char str1[5];
char str2[8];
unsigned long a, x, y, z, breg, sreg;
if(strlen(challenge) != 12) {
return -1;
}
strncpy(str1, challenge+1, 4);
str1[4] = '\0';
strncpy(str2, challenge+5, 7);
str2[7] = '\0';
sreg = strtoul(str1, NULL, 10);
breg = strtoul(str2, NULL, 10);
x = (sreg*0x3f)^breg;
y = x/0x103;
z = y/0x81;
a = (z/7) + (sreg>>7) + (sreg & 0x7F) + (y%0x81) + (z%7);
return a == x%0x103;
}
int other_stuff(char *challenge) {
char str1[5];
char str2[8];
unsigned long a, x, y, z, breg, sreg, rbp0x17c, rbp0x17cLower7, edx, rbp0x184, ecx, orresult;
if(strlen(challenge) != 12) {
return -1;
}
strncpy(str1, challenge+1, 4);
str1[4] = '\0';
strncpy(str2, challenge+5, 7);
str2[7] = '\0';
sreg = strtoul(str1, NULL, 10);
breg = strtoul(str2, NULL, 10);
x = (sreg*0x3f)^breg;
y = x/0x103;
rbp0x17c = y%0x81; //game number??
printf("%lu\n", rbp0x17c);
z = y/0x81;
a = (z/7) + (sreg>>7) + (sreg & 0x7F) + rbp0x17c + (z%7);
rbp0x17cLower7 = rbp0x17c & 0x7F;
edx = sreg & 0x7F;
rbp0x184 = edx & 0xFF;
rbp0x184 = (rbp0x184 << 3) & 0xFF;
ecx = (z%7) & 0xFF;
orresult = rbp0x184 | ecx;
return orresult & 0xFF00;
}
int game_num(char *challenge) {
char str1[5];
char str2[8];
unsigned long a, x, y, z, breg, sreg;
if(strlen(challenge) != 12) {
return -1;
}
strncpy(str1, challenge+1, 4);
str1[4] = '\0';
strncpy(str2, challenge+5, 7);
str2[7] = '\0';
sreg = strtoul(str1, NULL, 10);
breg = strtoul(str2, NULL, 10);
x = (sreg*0x3f)^breg;
y = x/0x103;
return y%0x81;
}