Новый алгоритм TPS

Главная - Декабрь 2004 - Новый алгоритм TPS   
Может кому поможет

//--------------

unsigned char tps_xor[0x40] = {0x4F, 0xB4, 0xFC, 0x9B, 0x4A, 0x7F, 0x44, 0xFB,
0x05, 0xFF, 0xBD, 0xBB, 0x16, 0x2D, 0x6C, 0xC8,
0xD8, 0x96, 0xF9, 0xFE, 0x3F, 0xFF, 0x36, 0x24,
0xB6, 0xBF, 0x49, 0xC9, 0x2D, 0x36, 0x5E, 0xD0,
0x1F, 0x09, 0x7E, 0xA9, 0x7F, 0xFF, 0x64, 0xB6,
0x5B, 0x7E, 0xF8, 0xFC, 0x6E, 0x3F, 0x7F, 0xBF,
0xDD, 0x36, 0x12, 0xE9, 0x05, 0xFE, 0xB4, 0x6c,
0x6f, 0xfe, 0x7e, 0xc8, 0x25, 0x90, 0x6d, 0x90};

unsigned char multiv_xor[0x40]={0x7E, 0x6D, 0x7E, 0x12, 0x76, 0xFD, 0x2F, 0xFE,
0x6D, 0xFE, 0xDA, 0x3F, 0xDA, 0x6D, 0xBD, 0x97,
0xD0, 0x6D, 0xD8, 0x9F, 0x69, 0xFD, 0xB6, 0x37,
0xFE, 0x7F, 0x36, 0x92, 0xBD, 0x52, 0x16, 0xDF,
0xFC, 0x96, 0xFF, 0x92, 0xFD, 0x6D, 0x7F, 0xB5,
0xFB, 0x4C, 0xB6, 0xB7, 0x7E, 0xD9, 0xFE, 0x9B,
0xFD, 0xF4, 0x6D, 0x9B, 0xB9, 0x36, 0xBF, 0x7F,
0xD2, 0x2D, 0xDF, 0xB7, 0xD9, 0xFE, 0x69, 0xBF};

unsigned int hash_buff[0x42]={
0xb4e85f52,0xcbfba019,0x6971900d,0x143b6bfa,0xb22da227,0xdcbeae5f,0x75d5ef59,0x78a0fa8a,
0x137b5b9f,0xcfc5f5c0,0xba101a99,0xc2b0e013,0xf973f529,0x36b600e9,0x8ca61a70,0x4e16fa63,
0xd91c92f3,0xefaa921a,0x630c886a,0x2d1a7209,0xa37e77f9,0x4cd4e5e3,0x2fd86d89,0x02c21f80,
0x1ddcfcd8,0x5108193b,0x7ed074b2,0x7c126b32,0x483fb6be,0x1937af85,0x67e7db37,0x1bf5b005,
0x53a57c66,0x4a92d3e3,0x2d7508d4,0x3680b8d1,0xa4c1467d,0xee53959e,0xc3269d4a,0xf5a6259b,
0xd1495860,0x69cdec5e,0x91082e93,0x55e5fb82,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x0000000a,0x00000012
};

unsigned char buff_18F9[0x100]={
0x52,0x09,0x6A,0xD5,0x30,0x36,0xA5,0x38,
0xBF,0x40,0xA3,0x9E,0x81,0xF3,0xD7,0xFB,
0x7C,0xE3,0x39,0x82,0x9B,0x2F,0xFF,0x87,
0x34,0x8E,0x43,0x44,0xC4,0xDE,0xE9,0xCB,
0x54,0x7B,0x94,0x32,0xA6,0xC2,0x23,0x3D,
0xEE,0x4C,0x95,0x0B,0x42,0xFA,0xC3,0x4E,
0x08,0x2E,0xA1,0x66,0x28,0xD9,0x24,0xB2,
0x76,0x5B,0xA2,0x49,0x6D,0x8B,0xD1,0x25,
0x72,0xF8,0xF6,0x64,0x86,0x68,0x98,0x16,
0xD4,0xA4,0x5C,0xCC,0x5D,0x65,0xB6,0x92,
0x6C,0x70,0x48,0x50,0xFD,0xED,0xB9,0xDA,
0x5E,0x15,0x46,0x57,0xA7,0x8D,0x9D,0x84,
0x90,0xD8,0xAB,0x00,0x8C,0xBC,0xD3,0x0A,
0xF7,0xE4,0x58,0x05,0xB8,0xB3,0x45,0x06,
0xD0,0x2C,0x1E,0x8F,0xCA,0x3F,0x0F,0x02,
0xC1,0xAF,0xBD,0x03,0x01,0x13,0x8A,0x6B,
0x3A,0x91,0x11,0x41,0x4F,0x67,0xDC,0xEA,
0x97,0xF2,0xCF,0xCE,0xF0,0xB4,0xE6,0x73,
0x96,0xAC,0x74,0x22,0xE7,0xAD,0x35,0x85,
0xE2,0xF9,0x37,0xE8,0x1C,0x75,0xDF,0x6E,
0x47,0xF1,0x1A,0x71,0x1D,0x29,0xC5,0x89,
0x6F,0xB7,0x62,0x0E,0xAA,0x18,0xBE,0x1B,
0xFC,0x56,0x3E,0x4B,0xC6,0xD2,0x79,0x20,
0x9A,0xDB,0xC0,0xFE,0x78,0xCD,0x5A,0xF4,
0x1F,0xDD,0xA8,0x33,0x88,0x07,0xC7,0x31,
0xB1,0x12,0x10,0x59,0x27,0x80,0xEC,0x5F,
0x60,0x51,0x7F,0xA9,0x19,0xB5,0x4A,0x0D,
0x2D,0xE5,0x7A,0x9F,0x93,0xC9,0x9C,0xEF,
0xA0,0xE0,0x3B,0x4D,0xAE,0x2A,0xF5,0xB0,
0xC8,0xEB,0xBB,0x3C,0x83,0x53,0x99,0x61,
0x17,0x2B,0x04,0x7E,0xBA,0x77,0xD6,0x26,
0xE1,0x69,0x14,0x63,0x55,0x21,0x0C,0x7D
};

unsigned int buff_18FD[0x100]={
0x50A7F451,0x5365417E,0xC3A4171A,0x965E273A,0xCB6BAB3B,0xF1459D1F,0xAB58FAAC,0x9303E34B,
0x55FA3020,0xF66D76AD,0x9176CC88,0x254C02F5,0xFCD7E54F,0xD7CB2AC5,0x80443526,0x8FA362B5,
0x495AB1DE,0x671BBA25,0x980EEA45,0xE1C0FE5D,0x02752FC3,0x12F04C81,0xA397468D,0xC6F9D36B,
0xE75F8F03,0x959C9215,0xEB7A6DBF,0xDA595295,0x2D83BED4,0xD3217458,0x2969E049,0x44C8C98E,
0x6A89C275,0x78798EF4,0x6B3E5899,0xDD71B927,0xB64FE1BE,0x17AD88F0,0x66AC20C9,0xB43ACE7D,
0x184ADF63,0x82311AE5,0x60335197,0x457F5362,0xE07764B1,0x84AE6BBB,0x1CA081FE,0x942B08F9,
0x58684870,0x19FD458F,0x876CDE94,0xB7F87B52,0x23D373AB,0xE2024B72,0x578F1FE3,0x2AAB5566,
0x0728EBB2,0x03C2B52F,0x9A7BC586,0xA50837D3,0xF2872830,0xB2A5BF23,0xBA6A0302,0x5C8216ED,
0x2B1CCF8A,0x92B479A7,0xF0F207F3,0xA1E2694E,0xCDF4DA65,0xD5BE0506,0x1F6234D1,0x8AFEA6C4,
0x9D532E34,0xA055F3A2,0x32E18A05,0x75EBF6A4,0x39EC830B,0xAAEF6040,0x069F715E,0x51106EBD,
0xF98A213E,0x3D06DD96,0xAE053EDD,0x46BDE64D,0xB58D5491,0x055DC471,0x6FD40604,0xFF155060,
0x24FB9819,0x97E9BDD6,0xCC434089,0x779ED967,0xBD42E8B0,0x888B8907,0x385B19E7,0xDBEEC879,
0x470A7CA1,0xE90F427C,0xC91E84F8,0x00000000,0x83868009,0x48ED2B32,0xAC70111E,0x4E725A6C,
0xFBFF0EFD,0x5638850F,0x1ED5AE3D,0x27392D36,0x64D90F0A,0x21A65C68,0xD1545B9B,0x3A2E3624,
0xB1670A0C,0x0FE75793,0xD296EEB4,0x9E919B1B,0x4FC5C080,0xA220DC61,0x694B775A,0x161A121C,
0x0ABA93E2,0xE52AA0C0,0x43E0223C,0x1D171B12,0x0B0D090E,0xADC78BF2,0xB9A8B62D,0xC8A91E14,
0x8519F157,0x4C0775AF,0xBBDD99EE,0xFD607FA3,0x9F2601F7,0xBCF5725C,0xC53B6644,0x347EFB5B,
0x7629438B,0xDCC623CB,0x68FCEDB6,0x63F1E4B8,0xCADC31D7,0x10856342,0x40229713,0x2011C684,
0x7D244A85,0xF83DBBD2,0x1132F9AE,0x6DA129C7,0x4B2F9E1D,0xF330B2DC,0xEC52860D,0xD0E3C177,
0x6C16B32B,0x99B970A9,0xFA489411,0x2264E947,0xC48CFCA8,0x1A3FF0A0,0xD82C7D56,0xEF903322,
0xC74E4987,0xC1D138D9,0xFEA2CA8C,0x360BD498,0xCF81F5A6,0x28DE7AA5,0x268EB7DA,0xA4BFAD3F,
0xE49D3A2C,0x0D927850,0x9BCC5F6A,0x62467E54,0xC2138DF6,0xE8B8D890,0x5EF7392E,0xF5AFC382,
0xBE805D9F,0x7C93D069,0xA92DD56F,0xB31225CF,0x3B99ACC8,0xA77D1810,0x6E639CE8,0x7BBB3BDB,
0x097826CD,0xF418596E,0x01B79AEC,0xA89A4F83,0x656E95E6,0x7EE6FFAA,0x08CFBC21,0xE6E815EF,
0xD99BE7BA,0xCE366F4A,0xD4099FEA,0xD67CB029,0xAFB2A431,0x31233F2A,0x3094A5C6,0xC066A235,
0x37BC4E74,0xA6CA82FC,0xB0D090E0,0x15D8A733,0x4A9804F1,0xF7DAEC41,0x0E50CD7F,0x2FF69117,
0x8DD64D76,0x4DB0EF43,0x544DAACC,0xDF0496E4,0xE3B5D19E,0x1B886A4C,0xB81F2CC1,0x7F516546,
0x04EA5E9D,0x5D358C01,0x737487FA,0x2E410BFB,0x5A1D67B3,0x52D2DB92,0x335610E9,0x1347D66D,
0x8C61D79A,0x7A0CA137,0x8E14F859,0x893C13EB,0xEE27A9CE,0x35C961B7,0xEDE51CE1,0x3CB1477A,
0x59DFD29C,0x3F73F255,0x79CE1418,0xBF37C773,0xEACDF753,0x5BAAFD5F,0x146F3DDF,0x86DB4478,
0x81F3AFCA,0x3EC468B9,0x2C342438,0x5F40A3C2,0x72C31D16,0x0C25E2BC,0x8B493C28,0x41950DFF,
0x7101A839,0xDEB30C08,0x9CE4B4D8,0x90C15664,0x6184CB7B,0x70B632D5,0x745C6C48,0x4257B8D0
};


int modif_data(unsigned char *data, unsigned int d3, unsigned int d2, unsigned int d1, unsigned int d0, unsigned int loc4){

return ((data[d3]<<0x18) | (data[d2]<<0x10) | (data[d1]<<0x8) | data[d0]) ^ hash_buff[loc4];
}

int rol(unsigned int Tmp, unsigned char b){

return (Tmp<<b) | (Tmp>>(32-b));
}

int shift_buff_18FD(unsigned int locTmp){

if (locTmp<0x100) return buff_18FD[locTmp];
else
if (locTmp<0x200) return rol(buff_18FD[(locTmp-0x100)&0xFF], 8);
else
if (locTmp<0x300) return rol(buff_18FD[(locTmp-0x200)&0xFF],16);
else
return rol(buff_18FD[(locTmp-0x300)&0xFF],24);
}

int shift_buff_18F9(unsigned int locTmp){
unsigned char locR;

if (locTmp<0x100) {
locR=buff_18F9[locTmp];
return locR & 0x000000FF;
}
else
if (locTmp<0x200) {
locR=buff_18F9[(locTmp-0x100)&0xFF];
return (locR<< 8) & 0x0000FF00;
}
else
if (locTmp<0x300) {
locR=buff_18F9[(locTmp-0x200)&0xFF];
return (locR<<16) & 0x00FF0000;
}
else {
locR=buff_18F9[(locTmp-0x300)&0xFF];
return (locR<<24) & 0xFF000000;
}

}

int modif_with_buff_18FD(unsigned int loc00, unsigned int loc03, unsigned int loc01, unsigned int loc02, unsigned int locBuff){

return shift_buff_18FD( (loc00&0xFF) )
^shift_buff_18FD( 0x100+((loc03>>8)&0xFF) )
^shift_buff_18FD( 0x200+((loc01>>0x10)&0xFF) )
^shift_buff_18FD( 0x300+((loc02>>0x18)&0xFF) )
^hash_buff[locBuff];
}

int modif_with_buff_18F9(unsigned int loc01, unsigned int loc0B, unsigned int loc0D, unsigned int loc0F, unsigned int locBuff){

return shift_buff_18F9( (loc01&0xFF) )
^shift_buff_18F9( 0x100+((loc0B>>8)&0xFF) )
^shift_buff_18F9( 0x200+((loc0D>>0x10)&0xFF) )
^shift_buff_18F9( 0x300+((loc0F>>0x18)&0xFF) )
^hash_buff[locBuff];
}


int TPSCrypt2_decrypt(unsigned char *data){
unsigned int loc0, loc2, loc4, loc5, loc6, loc7, loc8, locA, locB, locC, locD, locE;

loc8=modif_data(data, 3, 2, 1, 0,0x28);
loc7=modif_data(data, 7, 6, 5, 4,0x29);
loc6=modif_data(data,0xB,0xA, 9, 8,0x2A);
loc5=modif_data(data,0xF,0xE,0xD,0xC,0x2B);

loc4=0x28;
locD=0;

loc_40011E04:
loc4=loc4-8;

locA=modif_with_buff_18FD(loc8,loc5,loc6,loc7,loc4+4);
locC=modif_with_buff_18FD(loc5,loc6,loc7,loc8,loc4+7);
locB=modif_with_buff_18FD(loc6,loc7,loc8,loc5,loc4+6);
loc5=modif_with_buff_18FD(loc7,loc8,loc5,loc6,loc4+5);

loc8=modif_with_buff_18FD(locA,locC,locB,loc5,loc4);
loc7=modif_with_buff_18FD(loc5,locA,locC,locB,loc4+1);
loc6=modif_with_buff_18FD(locB,loc5,locA,locC,loc4+2);
loc5=modif_with_buff_18FD(locC,locB,loc5,locA,loc4+3);

locD++;
if (4>locD) goto loc_40011E04;


loc0=loc4-4;
loc4=modif_with_buff_18FD(loc8,loc5,loc6,loc7,loc0);
locC=modif_with_buff_18FD(loc5,loc6,loc7,loc8,loc0+3);
locE=modif_with_buff_18FD(loc6,loc7,loc8,loc5,loc0+2);
loc2=modif_with_buff_18FD(loc7,loc8,loc5,loc6,loc0+1);


locA=modif_with_buff_18F9(loc4,locC,locE,loc2,loc0-4);
data[0]=locA&0xFF;
data[1]=(locA>>8)&0xFF;
data[2]=(locA>>0x10)&0xFF;
data[3]=(locA>>0x18)&0xFF;

locA=modif_with_buff_18F9(loc2,loc4,locC,locE,loc0-3);
data[4]=locA&0xFF;
data[5]=(locA>>8)&0xFF;
data[6]=(locA>>0x10)&0xFF;
data[7]=(locA>>0x18)&0xFF;

locA=modif_with_buff_18F9(locE,loc2,loc4,locC,loc0-2);
data[8]=locA&0xFF;
data[9]=(locA>>8)&0xFF;
data[0xA]=(locA>>0x10)&0xFF;
data[0xB]=(locA>>0x18)&0xFF;

locA=modif_with_buff_18F9(locC,locE,loc2,loc4,loc0-1);
data[0xC]=locA&0xFF;
data[0xD]=(locA>>8)&0xFF;
data[0xE]=(locA>>0x10)&0xFF;
data[0xF]=(locA>>0x18)&0xFF;

//return 1;

}

Помогло Дальше не...куда?

Да ну дайте же ссылку для gw на Humax без эмуляторов......

   

 
  䀀