mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
ペアレンタルコントロール解除用マスターキー生成ツール追加。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@755 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
a1f61d287f
commit
0884e17a8e
95
trunk/MakeMasterKey/src/MakeMasterKeyForCtr.cpp
Normal file
95
trunk/MakeMasterKey/src/MakeMasterKeyForCtr.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CODE_LENGTH 8
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short int u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long int u64;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short int s16;
|
||||
typedef signed long s32;
|
||||
|
||||
u32 table[0x100];
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
void _Crc32Init( void )
|
||||
{
|
||||
u32 poly = 0xedba6320; // DS‚̂Ƃ« 0xedb88320;
|
||||
u32 crc;
|
||||
|
||||
for( u32 i = 0; i < 0x100; i++ )
|
||||
{
|
||||
crc = i;
|
||||
for( u32 j = 8; j > 0; j-- )
|
||||
{
|
||||
if( crc & 1 )
|
||||
{
|
||||
crc = (crc>>1)^poly;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
table[i] = crc;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
u32 _CalcCrc32( const u8 *src, u32 len )
|
||||
{
|
||||
u32 crc = 0xffffffff;
|
||||
|
||||
while( len )
|
||||
{
|
||||
crc = ((crc>>8)&0xffffffff)^table[(crc^(*src))&0xff];
|
||||
src++;
|
||||
len--;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
u32 _CalcMasterkey( const u8 *src )
|
||||
{
|
||||
u32 key;
|
||||
|
||||
_Crc32Init();
|
||||
|
||||
//key = ((_CalcCrc32( src, CODE_LENGTH )^0xaaaa)+5313)%100000;
|
||||
key = ((_CalcCrc32( src, CODE_LENGTH )^0xaaaa)+5719)%100000;
|
||||
return key;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
u32 masterKey;
|
||||
|
||||
if ( ( argc != 2 ) || ( argv[1] == NULL ) )
|
||||
{
|
||||
printf( "usage: MakeMasterKeyForCtr [date+code]\n" );
|
||||
printf( "\n" );
|
||||
printf( "example: date = Sep 8. code = 1234\n" );
|
||||
printf( " MakeMasterKeyForCtr 09081234\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
masterKey = _CalcMasterkey( (const u8*)argv[1] );
|
||||
|
||||
printf( "Master Key = %05d\n", masterKey );
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user