(12-10-2022, 09:42 PM)rufaswan Wrote: Actually @bihaiorg already posted the solution, the code from 52pojie.cn looks very complex, but it can be simplified to
Code:if ( v10 == *(_QWORD *)"VEGATOPJOY000000VEGATOPJOY000000N7cocos2d5ImageE" )
{
v33 = v10;
v34 = v9;
v35 = v11;
v3 -= 16;
v12 = v4[23];
v4 += 16;
*v4 ^= 0x51u;
v4[1] = v4[1] ^ 0x49;
v4[2] = v4[2] ^ 0x51;
v4[3] = v4[3] ^ 0x49;
v4[4] = v4[4] ^ 0x41;
v4[5] = v4[5] ^ 0x4E;
v4[6] = v4[6] ^ 0x52;
v4[7] = v12 ^ 0x41;
v4[8] = v4[8] ^ 0x4E;
v4[9] = v4[9] ^ 0x58;
v4[10] = v4[10] ^ 0x49;
v4[11] = v4[11] ^ 0x41;
v4[12] = v4[12] ^ 0x4F;
v4[13] = v4[13] ^ 0x42;
v4[14] = v4[14] ^ 0x45;
v4[15] ^= 0x49u;
}
What the code basically means - check the first 16 bytes for "VEGATOPJOY000000", then XOR the next 16 bytes with "51 49 51 49 41 4e 52 41 4e 58 49 41 4f 42 45 49". That is the ASTC image header. The rest are ASTC image data, and they are unencrypted..
Re-save the ASTC image part as *.ASTC file, and you can use this tool to convert them
https://github.com/ARM-software/astc-encoder/releases
Run in command line like this
Code:astcenc-sse2.exe -dl IN.ASTC OUT.PNG
The tool can also encode the edited PNG back. Just XOR the ASTC header, and then prepend "VEGATOPJOY000000" back to the file. It's very easy.
Thanks for @bihaiorg for figured the whole thing out and sharing the code!
- Rufas
"Re-save the ASTC image part as *.ASTC file"
Pardon me, how exactly do I accomplish this? Is there an option for this in the hex editor?