Skip to content

Commit dc63dee

Browse files
authored
Add files via upload
1 parent 791f9c2 commit dc63dee

File tree

1 file changed

+73
-59
lines changed

1 file changed

+73
-59
lines changed

eCDPSerialGenerator/eCDPSerialGenerator.c

+73-59
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ 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)
24+
int the_crazy_math_part(unsigned int val1, unsigned int val2, int carry)
2525
{
26-
int c = 0;
27-
26+
int c = carry;
27+
2828
long long r1 = 0xFFFFFFF9;
2929
long long r0 = val1;
3030
long long r3 = val2;
@@ -57,8 +57,7 @@ int the_crazy_math_part(unsigned int val1, unsigned int val2)
5757
}
5858

5959

60-
char* ascii_to_byte(char* enc, char* input)
61-
60+
char* find_pattern(char* enc, char* input)
6261
{
6362
int i;
6463
int ii;
@@ -87,35 +86,25 @@ char* ascii_to_byte(char* enc, char* input)
8786

8887
int find_multiplier(char* system_in, unsigned int maccasId)
8988
{
90-
int system_in_len;
91-
byte* next_var;
92-
byte* this_char;
93-
byte* extraout_r1;
9489
unsigned int total_iterations;
9590
int i = 0;
9691
int ii = 0;
97-
byte* system_in_2;
98-
unsigned int c;
99-
char* starting_inc;
10092

10193
total_iterations = 0;
102-
c = maccasId & 0xffff00ff;
103-
system_in_len = strlen(system_in);
104-
starting_inc = hex_values;
105-
system_in_2 = (byte*)system_in;
94+
unsigned int c = maccasId & 0xffff00ff;
95+
int system_in_len = strlen(system_in);
96+
char* hex_values_ptr = hex_values;
10697
if (0 < system_in_len) {
10798
do {
108-
system_in_2 = system_in_2 + 1;
109-
c = c & 0xffffff00 | (unsigned int)*system_in_2;
110-
next_var = ascii_to_byte((byte*)starting_inc, (byte*)&c);
111-
this_char = next_var + -(int)starting_inc;
112-
if (next_var == (byte*)0x0) {
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) {
113104
this_char = (byte*)0x0;
114105
}
115106
i = i + 1;
116107
total_iterations = (unsigned int)(this_char + total_iterations);
117-
system_in_len = strlen(system_in);
118-
system_in_2 = system_in_2;
119108
} while (i < system_in_len);
120109
}
121110

@@ -124,23 +113,38 @@ int find_multiplier(char* system_in, unsigned int maccasId)
124113
int ret;
125114
unsigned int offset = 7;
126115

127-
if (offset <= total_iterations) {
116+
if (offset <= total_iterations)
117+
{
118+
int c = 0;
128119
i = 0x1c;
129-
ii = total_iterations >> 4;
130-
if ((int)offset <= (int)(total_iterations >> 0x10)) {
131-
i = 0xc;
132-
ii = total_iterations >> 0x14;
120+
unsigned int r3 = total_iterations >> 4;
121+
if (offset <= r3 >> 0xC)
122+
{
123+
i -= 0x10;
124+
r3 <<= 0x10;
133125
}
134-
if ((int)offset <= (int)(ii >> 4)) {
135-
i = i - 8;
136-
ii = ii >> 8;
126+
if (offset <= r3 >> 0x10)
127+
{
128+
i -= 0x8;
129+
r3 <<= 0x8;
137130
}
138-
if ((int)offset <= (int)ii) {
139-
i = i - 4;
140-
ii = ii >> 4;
131+
if (offset <= r3)
132+
{
133+
i -= 0x4;
134+
r3 <<= 0x4;
141135
}
142136

143-
return the_crazy_math_part((total_iterations << (i & 0xff)) * 2, ii);
137+
unsigned int r0 = total_iterations << (i & 0xFF);
138+
139+
i = i + i * 2;
140+
141+
c = ((long long int)r0 * 2) > 0xFFFFFFFF;
142+
r0 = r0 * 2;
143+
144+
printf("Starting Carry: %x\n", c);
145+
146+
147+
return the_crazy_math_part(r0, r3, c);
144148
}
145149
return 0;
146150
}
@@ -162,7 +166,7 @@ unsigned int hex_to_bytes(char* input, int iterator, int multiplier)
162166
memset(curChar, 0x00, 2);
163167
curChar[0] = current_char[0];
164168

165-
iteration = ascii_to_byte(enc, curChar);
169+
iteration = find_pattern(enc, curChar);
166170
final_char = iteration + -(int)enc;
167171
if (iteration == (char*)0x0) {
168172
final_char = (char*)0x0;
@@ -189,69 +193,79 @@ void generate_password(unsigned short* input, char* output)
189193

190194
int main()
191195
{
192-
char maccas_id[7];
193-
char mannager_id[7];
194-
char mac_address[18];
196+
char maccas_id[64];
197+
char mannager_id[64];
198+
char mac_address[64];
195199
char formatted[64];
196200
char encoded[64];
197201
char temp_key[100];
198202
char final_key[100];
199203
char total_output [64];
204+
int iterator = 0;
205+
int i = 0;
206+
int ii = 0;
207+
200208
printf("eCDP Serial Number Generator (By SilicaAndPina)\n");
201209
printf("-- A backdoor on the worlds rarest DS game.\n");
210+
entry:
211+
202212
printf("Enter your NDS's Mac Address (without any seperators): ");
203-
gets_s(mac_address, 18);
213+
gets_s(mac_address, 64);
214+
if (strlen(mac_address) != 12)
215+
goto entry;
216+
217+
204218
printf("Enter McDonalds Store Id (first 6 digit entry): ");
205-
gets_s(maccas_id,7);
206-
printf("Enter McDonalds Manager Id (second 6 digit entry): ");
207-
gets_s(mannager_id, 7);
219+
gets_s(maccas_id,64);
220+
if (strlen(maccas_id) != 6)
221+
goto entry;
208222

209223

224+
printf("Enter McDonalds Manager Id (second 6 digit entry): ");
225+
gets_s(mannager_id, 64);
226+
if (strlen(mannager_id) != 6)
227+
goto entry;
228+
210229
snprintf(formatted, 64, "%s%s%s", mac_address, maccas_id, mannager_id);
211230
printf("Formatted Data: %s\n", formatted);
212-
213231
int multiplier = find_multiplier(formatted, (unsigned int)maccas_id);
214232
printf("Multiplier: %x\n", multiplier);
215233
substitute(formatted, encoded, multiplier);
216234
printf("Encoded Data: %s\n", encoded);
217-
218235
unsigned short password_values[6];
219236
memset(password_values, 0x00, 6 * 2);
220-
int iterator = 0;
221-
int i = 0;
222-
int ii = 0;
237+
223238
do {
224239
int chr = hex_to_bytes(encoded, iterator, multiplier);
225240
i = ii + 1;
226241
password_values[ii] = (unsigned short)chr;
227242
iterator = iterator + 4;
228243
ii = i;
229244
} while (i < 6);
230-
245+
231246
printf("Password Values 1: ");
232247
for (int i = 0; i < 6; i++)
233248
{
234249
printf("%x ", password_values[i]);
235250
}
236251
printf("\n");
237-
int magic_number = 0x3E0F83E1;
238-
252+
i = 0;
239253
ii = 0;
240-
do {
241-
short chr = password_values[ii];
242-
iterator = ii + 1;
243-
password_values[ii] = chr + (short)(int)((long long)magic_number * (long long)(int)(unsigned int)chr >> 0x23) * -0x21 + 1;
244-
ii = iterator;
245-
} while (iterator < 6);
246-
254+
do
255+
{
256+
i = ii;
257+
int chr = password_values[ii++];
258+
password_values[i] = chr % 33 + 1;
259+
} while (ii < 6);
247260
printf("Password Values 2: ");
248261
for (int i = 0; i < 6; i++)
249262
{
250263
printf("%x ", password_values[i]);
251264
}
252265
printf("\n");
253266
generate_password(password_values, final_key);
254-
printf("Ronald McDonald Says your password is %s\n", final_key);
267+
printf("Ronald McDonald Says your password is %s", final_key);
268+
255269

256270
printf("\n\nThou hast been reversed!");
257271
while (1) {};

0 commit comments

Comments
 (0)