Skip to content

Commit bcb3734

Browse files
committed
Added master key generator tool for parental lock
1 parent 24c7446 commit bcb3734

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

parentool/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OBJS = main.o
2+
LIBS =
3+
CXXFLAGS = -I.
4+
CFLAGS = -Wall -I.
5+
OUTPUT = parentool
6+
CC = gcc
7+
8+
main: $(OBJS)
9+
g++ -o $(OUTPUT) $(LIBS) $(OBJS)
10+
11+
12+
clean:
13+
rm -rf $(OUTPUT) $(OBJS)

parentool/main.c

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
#include <stdint.h>
5+
6+
unsigned int calculate_master_key(unsigned char* generator)
7+
{
8+
uint32_t table[0x100];
9+
uint32_t data;
10+
uint32_t i, j;
11+
uint32_t y;
12+
uint8_t x;
13+
uint64_t yll;
14+
uint32_t yhi;
15+
16+
for(i=0; i<0x100; i++)
17+
{
18+
data = i;
19+
for(j=0; j<4; j++)
20+
{
21+
if (data & 1)
22+
data = 0xEDBA6320 ^ (data>>1);
23+
else
24+
data = data>>1;
25+
26+
if (data & 1)
27+
data = 0xEDBA6320 ^ (data>>1);
28+
else
29+
data = data>>1;
30+
}
31+
32+
table[i] = data;
33+
}
34+
35+
y = 0xFFFFFFFF;
36+
x = generator[0];
37+
for(i=0; i<4; i++)
38+
{
39+
x ^= y;
40+
y = table[x] ^ (y>>8);
41+
x = generator[1+i*2] ^ y;
42+
y = table[x] ^ (y>>8);
43+
x = generator[2+i*2];
44+
}
45+
46+
y ^= 0xAAAA;
47+
y += 0x1657;
48+
49+
yll = y;
50+
yll = (yll+1) * 0xA7C5AC47ULL;
51+
yhi = (yll>>48);
52+
yhi *= 0xFFFFF3CB;
53+
y += (yhi<<5);
54+
55+
return y;
56+
}
57+
58+
int main(int argc, const char* argv[])
59+
{
60+
unsigned char generator[9] = {0};
61+
unsigned int servicecode, month, day, masterkey;
62+
63+
if (argc != 4)
64+
{
65+
printf("usage: <servicecode> <month> <day>\n");
66+
exit(1);
67+
}
68+
69+
servicecode = strtoul(argv[1], 0, 10);
70+
month = strtoul(argv[2], 0, 10);
71+
day = strtoul(argv[3], 0, 10);
72+
73+
servicecode %= 10000;
74+
month %= 100;
75+
day %= 100;
76+
sprintf((char*)generator, "%02d%02d%04d", month, day, servicecode);
77+
78+
masterkey = calculate_master_key(generator);
79+
80+
printf("Master key is %05d\n", masterkey);
81+
return 0;
82+
}

0 commit comments

Comments
 (0)