| | |
| | | 0x8E, 0x93, 0xB5, 0x44, 0x8D, 0x42, 0x22, 0x84, 0x95, 0x33, 0x22, 0x93, |
| | | 0x42, 0x82, 0xA3, 0x35, 0x91, 0x33, 0x13, 0x93, 0x71, 0x21, 0x01, 0x71, |
| | | 0x37, 0x9F, 0xA6, 0x68, 0x92, 0x86, 0x46, 0x72, 0x43, 0x62, 0x12, 0x52, |
| | | 0x5D, 0x85, 0x93, 0x86, 0x82, 0x46, 0x31, 0x86, 0x57, 0x48, 0x16, 0x88, |
| | | // 扇区14密码 (基于扇区13的XOR密钥重新计算为27562CCFE9F7) |
| | | 0x5D, 0xE5, 0x93, 0x86, 0x82, 0x46, 0x31, 0x86, 0x57, 0x48, 0x16, 0x88, |
| | | 0x97, 0x73, 0xB5, 0x47, 0x95, 0x55, 0x36, 0x69, 0x49, 0x58, 0x18, 0x6A, |
| | | 0xEA, 0x46, 0x84, 0x93, 0x82, 0x19, 0x29, 0x91, 0x31, 0x1C, 0x0C, 0x7D |
| | | }; |
| | |
| | | jobject packageInfoObject = env->CallObjectMethod(packageManagerObject, getPackageInfoId, |
| | | packNameString, 64); |
| | | if (!packageInfoObject) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get PackageInfo"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get PackageInfo"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | |
| | | jfieldID signaturefieldID = env->GetFieldID(packageInfoClass, "signatures", |
| | | "[Landroid/content/pm/Signature;"); |
| | | if (!signaturefieldID) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature field ID"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature field ID"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | |
| | | jobjectArray signatureArray = (jobjectArray) env->GetObjectField(packageInfoObject, |
| | | signaturefieldID); |
| | | if (!signatureArray || env->GetArrayLength(signatureArray) == 0) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "No signatures found"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "No signatures found"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | | // 获取第一个签名对象 |
| | | jobject signatureObject = env->GetObjectArrayElement(signatureArray, 0); |
| | | if (!signatureObject) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature object"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature object"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | | // 获取签名字符串 |
| | | jstring signatureString = (jstring) env->CallObjectMethod(signatureObject, signToStringId); |
| | | if (!signatureString) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature string"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature string"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | | // 获取签名字符串的UTF-8字符 |
| | | const char *signStrng = env->GetStringUTFChars(signatureString, 0); |
| | | if (!signStrng) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature UTF chars"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to get signature UTF chars"); |
| | | return env->NewStringUTF(""); |
| | | } |
| | | |
| | |
| | | |
| | | // 解密并转换每个扇区密钥 |
| | | for (size_t i = 0; i < numKeys; i++) { |
| | | // __android_log_print(ANDROID_LOG_DEBUG, "M1Card", "处理扇区 %zu 的密钥", i); |
| | | // __android_log_print(ANDROID_LOG_DEBUG, "M1Card", "处理扇区 %zu 的密钥", i); |
| | | |
| | | // 确保不会越界访问 |
| | | if (i * 12 + 6 > sizeof(ENCRYPTED_SECTOR_KEYS)) { |
| | | __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Index out of bounds"); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Index out of bounds"); |
| | | break; |
| | | } |
| | | |
| | |
| | | jstring decrypted_str = decrypt_key(env, ENCRYPTED_SECTOR_KEYS + (i * 12), 6); |
| | | |
| | | if (!decrypted_str) { |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to decrypt key for sector %zu", i); |
| | | // __android_log_print(ANDROID_LOG_ERROR, "M1Card", "Failed to decrypt key for sector %zu", i); |
| | | continue; |
| | | } |
| | | |