Skip to content

Commit 01a7930

Browse files
authoredNov 25, 2020
Add files via upload
1 parent dc63dee commit 01a7930

File tree

1 file changed

+45
-50
lines changed

1 file changed

+45
-50
lines changed
 

‎eCDPSerialGenerator/eCDPSerialGenerator.c

+45-50
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void substitute(char* input, char* output, int multiply_by)
2121
output[0x18] = 0;
2222
}
2323

24-
int the_crazy_math_part(unsigned int val1, unsigned int val2, int carry)
24+
int the_crazy_math_part(unsigned int val1, unsigned int val2, int carry, int start_at)
2525
{
2626
int c = carry;
2727

@@ -32,7 +32,7 @@ int the_crazy_math_part(unsigned int val1, unsigned int val2, int carry)
3232

3333
// yes this is just the asm implemented in C, dont @ me
3434

35-
for (int i = 0; i < 4; i++)
35+
for (int i = start_at; i < 0x20; i++)
3636
{
3737
// adcs r3,r1,r3,lsl 1h
3838
r3 = (r1 + (r3 << 1)) + c; //same as r3 = (r3+(r1 * 2)) + c;
@@ -62,94 +62,89 @@ char* find_pattern(char* enc, char* input)
6262
int i;
6363
int ii;
6464
char* iii;
65-
char c;
6665

67-
c = *enc;
6866
i = 0;
69-
while (1) {
70-
if (c == '\0') {
71-
return (char*)0x0;
72-
}
67+
if (!*enc)
68+
return 0;
69+
while (1)
70+
{
7371
ii = 0;
74-
iii = enc + i;
75-
while (c = input[ii], c != '\0' && (*iii == c)) {
76-
iii = iii + 1;
77-
ii = ii + 1;
72+
iii = &enc[i];
73+
while (input[ii] && *iii == input[ii])
74+
{
75+
++iii;
76+
++ii;
7877
}
79-
if (c == '\0') break;
80-
i = i + 1;
81-
c = enc[i];
78+
if (!input[ii])
79+
break;
80+
if (!enc[++i])
81+
return 0;
8282
}
83-
return enc + i;
83+
return &enc[i];
8484
}
8585

8686

87-
int find_multiplier(char* system_in, unsigned int maccasId)
87+
int find_multiplier(char* system_in)
8888
{
89-
unsigned int total_iterations;
90-
int i = 0;
89+
int total_iterations = 0;
9190
int ii = 0;
92-
93-
total_iterations = 0;
94-
unsigned int c = maccasId & 0xffff00ff;
95-
int system_in_len = strlen(system_in);
91+
int next_var = 0;
92+
93+
char* system_in_base_ptr = system_in;
9694
char* hex_values_ptr = hex_values;
97-
if (0 < system_in_len) {
98-
do {
99-
system_in++;
100-
c = c & 0xffffff00 | (unsigned int)*system_in;
101-
byte* next_ptr = next_ptr = find_pattern(hex_values_ptr, (char*)&c);
102-
byte* this_char = next_ptr + -(int)hex_values_ptr;
103-
if (next_ptr == (byte*)0x0) {
104-
this_char = (byte*)0x0;
105-
}
106-
i = i + 1;
107-
total_iterations = (unsigned int)(this_char + total_iterations);
108-
} while (i < system_in_len);
95+
for (int i = 0; i < strlen(system_in_base_ptr); i++)
96+
{
97+
char c = *system_in++;
98+
char characters[2];
99+
memset(characters, 0, 2);
100+
characters[0] = c;
101+
102+
char* a2b = find_pattern(hex_values_ptr, characters);
103+
next_var = a2b - (uintptr_t)hex_values_ptr;
104+
if (!a2b)
105+
next_var = 0;
106+
total_iterations += next_var;
109107
}
110-
111108
// step 2
112109

113-
int ret;
114110
unsigned int offset = 7;
115111

116112
if (offset <= total_iterations)
117113
{
118114
int c = 0;
119-
i = 0x1c;
115+
int start_at = 0x1c;
120116
unsigned int r3 = total_iterations >> 4;
121117
if (offset <= r3 >> 0xC)
122118
{
123-
i -= 0x10;
124-
r3 <<= 0x10;
119+
start_at -= 0x10;
120+
r3 >>= 0x10;
125121
}
126122
if (offset <= r3 >> 0x10)
127123
{
128-
i -= 0x8;
129-
r3 <<= 0x8;
124+
start_at -= 0x8;
125+
r3 >>= 0x8;
130126
}
131127
if (offset <= r3)
132128
{
133-
i -= 0x4;
134-
r3 <<= 0x4;
129+
start_at -= 0x4;
130+
r3 >>= 0x4;
135131
}
136132

137-
unsigned int r0 = total_iterations << (i & 0xFF);
133+
unsigned int r0 = total_iterations << (start_at & 0xFF);
138134

139-
i = i + i * 2;
140135

141136
c = ((long long int)r0 * 2) > 0xFFFFFFFF;
142137
r0 = r0 * 2;
143138

144139
printf("Starting Carry: %x\n", c);
145140

146141

147-
return the_crazy_math_part(r0, r3, c);
142+
return the_crazy_math_part(r0, r3, c, start_at);
148143
}
149144
return 0;
150145
}
151146

152-
unsigned int hex_to_bytes(char* input, int iterator, int multiplier)
147+
unsigned int hex_to_bytes(char* input, int iterator)
153148
{
154149
byte* iteration;
155150
byte* final_char;
@@ -228,15 +223,15 @@ int main()
228223

229224
snprintf(formatted, 64, "%s%s%s", mac_address, maccas_id, mannager_id);
230225
printf("Formatted Data: %s\n", formatted);
231-
int multiplier = find_multiplier(formatted, (unsigned int)maccas_id);
226+
int multiplier = find_multiplier(formatted);
232227
printf("Multiplier: %x\n", multiplier);
233228
substitute(formatted, encoded, multiplier);
234229
printf("Encoded Data: %s\n", encoded);
235230
unsigned short password_values[6];
236231
memset(password_values, 0x00, 6 * 2);
237232

238233
do {
239-
int chr = hex_to_bytes(encoded, iterator, multiplier);
234+
int chr = hex_to_bytes(encoded, iterator);
240235
i = ii + 1;
241236
password_values[ii] = (unsigned short)chr;
242237
iterator = iterator + 4;

0 commit comments

Comments
 (0)
Please sign in to comment.