New source: tr.turkanime

This commit is contained in:
jmir1
2023-04-29 01:56:31 +02:00
parent 7804c2f258
commit fe53f7a8c1
14 changed files with 784 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import javax.crypto.spec.SecretKeySpec
/**
* Conforming with CryptoJS AES method
*/
@Suppress("unused", "FunctionName")
@Suppress("unused")
object CryptoAES {
private const val KEY_SIZE = 256
@ -39,19 +39,41 @@ object CryptoAES {
* @param password passphrase
*/
fun decrypt(cipherText: String, password: String): String {
try {
return try {
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
val saltBytes = Arrays.copyOfRange(ctBytes, 8, 16)
val cipherTextBytes = Arrays.copyOfRange(ctBytes, 16, ctBytes.size)
val md5: MessageDigest = MessageDigest.getInstance("MD5")
val keyAndIV = generateKeyAndIV(32, 16, 1, saltBytes, password.toByteArray(Charsets.UTF_8), md5)
return decryptAES(
decryptAES(
cipherTextBytes,
keyAndIV?.get(0) ?: ByteArray(32),
keyAndIV?.get(1) ?: ByteArray(16),
)
} catch (e: Exception) {
return ""
""
}
}
fun decryptWithSalt(cipherText: String, salt: String, password: String): String {
return try {
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
val md5: MessageDigest = MessageDigest.getInstance("MD5")
val keyAndIV = generateKeyAndIV(
32,
16,
1,
salt.decodeHex(),
password.toByteArray(Charsets.UTF_8),
md5
)
decryptAES(
ctBytes,
keyAndIV?.get(0) ?: ByteArray(32),
keyAndIV?.get(1) ?: ByteArray(16),
)
} catch (e: Exception) {
""
}
}

View File

@ -0,0 +1,19 @@
plugins {
id("com.android.library")
kotlin("android")
}
android {
compileSdk = AndroidConfig.compileSdk
namespace = "eu.kanade.tachiyomi.lib.synchrony"
defaultConfig {
minSdk = AndroidConfig.minSdk
targetSdk = AndroidConfig.targetSdk
}
}
dependencies {
compileOnly(libs.kotlin.stdlib)
compileOnly(libs.quickjs)
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,38 @@
package eu.kanade.tachiyomi.lib.synchrony
import app.cash.quickjs.QuickJs
/**
* Helper class to deobfuscate JavaScript strings with synchrony.
*/
object Deobfuscator {
fun deobfuscateScript(source: String): String? {
val engine = QuickJs.create()
val originalScript = javaClass.getResource("/assets/$SCRIPT_NAME")
?.readText() ?: return null
// Sadly needed until QuickJS properly supports module imports:
// Regex for finding one and two in "export{one as Deobfuscator,two as Transformer};"
val regex = """export\{(.*) as Deobfuscator,(.*) as Transformer\};""".toRegex()
val synchronyScript = regex.find(originalScript)!!.let { match ->
val (deob, trans) = match.destructured
val replacement = "const Deobfuscator = $deob, Transformer = $trans;"
originalScript.replace(match.value, replacement)
}
engine.evaluate("globalThis.console = { log: () => {}, warn: () => {}, error: () => {}, trace: () => {} };")
engine.evaluate(synchronyScript)
engine.set("source", TestInterface::class.java, object: TestInterface { override fun getValue() = source })
val result = engine.evaluate("new Deobfuscator().deobfuscateSource(source.getValue())") as? String
engine.close()
return result
}
@Suppress("unused")
private interface TestInterface {
fun getValue(): String
}
}
// Update this when the script is updated!
private const val SCRIPT_NAME = "synchrony-v2.4.2.1.js"