mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
nirai: improve data decryption
This commit is contained in:
parent
61b8cc4fd3
commit
723603f5a8
2 changed files with 21 additions and 14 deletions
|
@ -31,14 +31,12 @@ def niraicall_obfuscate(code):
|
||||||
niraimarshal.niraicall_obfuscate = niraicall_obfuscate
|
niraimarshal.niraicall_obfuscate = niraicall_obfuscate
|
||||||
|
|
||||||
class StridePackager(NiraiPackager):
|
class StridePackager(NiraiPackager):
|
||||||
HEADER = 'TTSROCKS'
|
HEADER = 'TTSTRIDE'
|
||||||
BASEDIR = '..' + os.sep
|
BASEDIR = '..' + os.sep
|
||||||
|
|
||||||
def __init__(self, outfile):
|
def __init__(self, outfile):
|
||||||
NiraiPackager.__init__(self, outfile)
|
NiraiPackager.__init__(self, outfile)
|
||||||
self.__manglebase = self.get_mangle_base(self.BASEDIR)
|
self.__manglebase = self.get_mangle_base(self.BASEDIR)
|
||||||
#self.add_panda3d_dirs()
|
|
||||||
#self.add_default_lib()
|
|
||||||
|
|
||||||
def add_source_dir(self, dir):
|
def add_source_dir(self, dir):
|
||||||
self.add_directory(self.BASEDIR + dir, mangler=self.__mangler)
|
self.add_directory(self.BASEDIR + dir, mangler=self.__mangler)
|
||||||
|
@ -95,7 +93,7 @@ class StridePackager(NiraiPackager):
|
||||||
|
|
||||||
# Compile the engine
|
# Compile the engine
|
||||||
if args.compile_cxx:
|
if args.compile_cxx:
|
||||||
compiler = NiraiCompiler('stride.exe', libs=set(glob.glob('C:/repos/libpandadna/libpandadna.dir/Release/*.obj')))
|
compiler = NiraiCompiler('stride.exe', libs=set(glob.glob('libpandadna/libpandadna.dir/Release/*.obj')))
|
||||||
|
|
||||||
compiler.add_nirai_files()
|
compiler.add_nirai_files()
|
||||||
compiler.add_source('src/stride.cxx')
|
compiler.add_source('src/stride.cxx')
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
extern "C" __declspec(dllexport) void initlibpandadna();
|
extern "C" __declspec(dllexport) void initlibpandadna();
|
||||||
void init_libpandadna();
|
void init_libpandadna();
|
||||||
|
|
||||||
const char* header = "TTSROCKS";
|
const char* header = "TTSTRIDE";
|
||||||
const int header_size = 8;
|
const int header_size = 8;
|
||||||
|
|
||||||
const int key_and_iv_size = 16;
|
const int key_and_iv_size = 16;
|
||||||
|
@ -51,9 +51,9 @@ int niraicall_onLoadGameData()
|
||||||
std::string brawdata = ss.str();
|
std::string brawdata = ss.str();
|
||||||
|
|
||||||
// Decrypted the encrypted key and iv
|
// Decrypted the encrypted key and iv
|
||||||
std::string enckeyandiv = brawdata.substr(0, 48);
|
std::string enckeyandiv = brawdata.substr(0, (key_and_iv_size * 2) + key_and_iv_size);
|
||||||
|
|
||||||
unsigned char* deckeyandiv = new unsigned char[32];
|
unsigned char* deckeyandiv = new unsigned char[enckeyandiv.size()];
|
||||||
unsigned char* fixed_key = new unsigned char[key_and_iv_size];
|
unsigned char* fixed_key = new unsigned char[key_and_iv_size];
|
||||||
unsigned char* fixed_iv = new unsigned char[key_and_iv_size];
|
unsigned char* fixed_iv = new unsigned char[key_and_iv_size];
|
||||||
|
|
||||||
|
@ -67,15 +67,24 @@ int niraicall_onLoadGameData()
|
||||||
|
|
||||||
int deckeyandivsize = AES_decrypt((unsigned char*)enckeyandiv.c_str(), enckeyandiv.size(), fixed_key, fixed_iv, deckeyandiv);
|
int deckeyandivsize = AES_decrypt((unsigned char*)enckeyandiv.c_str(), enckeyandiv.size(), fixed_key, fixed_iv, deckeyandiv);
|
||||||
|
|
||||||
std::stringstream sss;
|
delete[] fixed_key;
|
||||||
sss << deckeyandiv;
|
delete[] fixed_iv;
|
||||||
std::string strdeckeyandiv = sss.str();
|
|
||||||
|
unsigned char* key = new unsigned char[key_and_iv_size];
|
||||||
|
unsigned char* iv = new unsigned char[key_and_iv_size];
|
||||||
|
|
||||||
|
// Move the decrypted key and iv into their subsequent char
|
||||||
|
|
||||||
|
for (int i = 0; i < key_and_iv_size; ++i)
|
||||||
|
iv[i] = deckeyandiv[i];
|
||||||
|
|
||||||
|
for (int i = 0; i < key_and_iv_size; ++i)
|
||||||
|
key[i] = deckeyandiv[i + key_and_iv_size];
|
||||||
|
|
||||||
// Decrypt the game data
|
// Decrypt the game data
|
||||||
std::string rawdata = brawdata.substr(48);
|
std::string rawdata = brawdata.substr((key_and_iv_size * 2) + key_and_iv_size);
|
||||||
unsigned char* iv = (unsigned char*)strdeckeyandiv.substr(0, key_and_iv_size).c_str();
|
|
||||||
unsigned char* key = (unsigned char*)strdeckeyandiv.substr(key_and_iv_size).c_str();
|
|
||||||
unsigned char* decrypted_data = new unsigned char[rawdata.size()];
|
unsigned char* decrypted_data = new unsigned char[rawdata.size()];
|
||||||
|
|
||||||
int decsize = AES_decrypt((unsigned char*)rawdata.c_str(), rawdata.size(), key, iv, decrypted_data); // Assumes no error
|
int decsize = AES_decrypt((unsigned char*)rawdata.c_str(), rawdata.size(), key, iv, decrypted_data); // Assumes no error
|
||||||
|
|
||||||
delete[] key;
|
delete[] key;
|
||||||
|
|
Loading…
Reference in a new issue