void z3ResEx::Run( ) { // Check the fileindex exists if( TFileSize( msfName ) == 0 ) { setMessage( "ERROR: Unable to open file (%s)", msfName ); } else { TMemoryStream msf; m_fileindexKey = nullptr; m_fileindexKeyLength = 0; // // Brute-force the key (version 1) // unsigned int keyIndex( 0 ); // For all known keys while( ( keyIndex < keyList1Count ) && ( msf.Size() == 0 ) ) { // Try to read the fileindex if( fsReadMSF( msf, keyList1[ keyIndex ].Data, KeyLength1, 0 ) ) { m_fileindexKey = keyList1[ keyIndex ].Data; m_fileindexKeyLength = KeyLength1; m_fileindexVer = 0; if( m_verboseMessages ) printf("Found key for %s!\n", keyList1[ keyIndex ].Desc ); } ++keyIndex; } // If key has not been found if( m_fileindexKey == nullptr ) { // // Continue to brute-force the key (version 2) // keyIndex = 0; // For all known keys while( ( keyIndex < keyList2Count ) && ( msf.Size() == 0 ) ) { // Try to read the fileindex if( fsReadMSF( msf, keyList2[ keyIndex ].Data, KeyLength2, 1 ) ) { m_fileindexKey = keyList2[ keyIndex ].Data; m_fileindexKeyLength = KeyLength2; m_fileindexVer = 1; if( m_verboseMessages ) printf("Found key for %s!\n", keyList2[ keyIndex ].Desc ); } ++keyIndex; } } // If a valid key has been found and fileindex loaded if( !( ( m_fileindexKey == nullptr ) && ( msf.Size() == 0 ) ) ) { // Attempt to parse it (to extract or list files) msf.Seek( 0, bufo_start ); parseMsf( msf ); } else { // No key found or incompatiable file (not checked) setMessage( "ERROR: This file is using an updated key or unsupported method" ); } msf.Close(); } }
int main( int argc, char **argv ) { printf ( "z3ResEx" \ "\nResearched and coded by x1nixmzeng\n\n" ); // Check arguments if( argc > 1 ) { if( SetCurrentDirectory( argv[1] ) == 0 ) { printf("ERROR: Failed to set the client path (%s)\n", argv[1] ); return 0; } if( argc > 2 ) { // For all other arguments, check against known flags if( argv[2][0] == '-' ) { // -v Verbose // todo // -l List all files if( argv[2][1] == 'l' ) { user_opt_list_files = true; } else // -x No extraction if( argv[2][1] == 'x' ) { user_opt_allow_extraction = false; } // -f Extract only (filter) // todo } } } // Check the fileindex exists if( TFileSize( msfName ) == 0 ) { printf("ERROR: Unable to open file (%s)\n", msfName); } else { unsigned int keyIndex( 0 ); TMemoryStream msf; // Brute-force the key while( ( keyIndex < Z3_KEY_LIST_LENGTH ) && ( msf.Size() == 0 ) ) { if( fsReadMSF( msf, Z3_KEY_LIST[ keyIndex ] ) ) { z3CurrentKey = Z3_KEY_LIST[ keyIndex ]; // todo: verbose? - show key } ++keyIndex; } if( !( z3CurrentKey == nullptr ) ) { // Run main extraction loop if( !( user_opt_allow_extraction ) ) printf("NOTE: Opted NOT to save data\n"); extractionMain( msf ); } else { // No key found or incompatiable file (not checked) printf("ERROR: This file is using an updated key or unsupported method\n"); } msf.Close(); } return 0; }