This commit is contained in:
enimax-anime
2022-12-03 05:10:43 -08:00
committed by GitHub
parent 2cfadcbdcc
commit 2f331d4d81
3 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Sflix'
pkgNameSuffix = 'en.sflix'
extClass = '.SFlix'
extVersionCode = 13
extVersionCode = 14
libVersion = '13'
}

View File

@ -47,13 +47,18 @@ class SFlixExtractor(private val client: OkHttpClient) {
)
.execute()
.body!!.string()
val key = newClient.newCall(GET("https://raw.githubusercontent.com/consumet/rapidclown/rabbitstream/key.txt"))
.execute()
.body!!.string()
// encrypted data will start with "U2Fsd..." because they put
// "Salted__" at the start of encrypted data, thanks openssl
// if its not encrypted, then return it
if ("\"sources\":\"U2FsdGVk" !in srcRes) return srcRes
if (!srcRes.contains("{\"sources\":")) return null
val encrypted = srcRes.substringAfter("sources\":\"").substringBefore("\"")
val decrypted = Decryptor.decrypt(encrypted, cachedJs) ?: return null
val decrypted = Decryptor.decrypt(encrypted, key) ?: return null
val end = srcRes.replace("\"$encrypted\"", decrypted)
return end
}

View File

@ -9,11 +9,11 @@ import javax.crypto.spec.SecretKeySpec
object Decryptor {
fun decrypt(encodedData: String, js: String): String? {
fun decrypt(encodedData: String, remoteKey: String): String? {
val saltedData = Base64.decode(encodedData, Base64.DEFAULT)
val salt = saltedData.copyOfRange(8, 16)
val ciphertext = saltedData.copyOfRange(16, saltedData.size)
val password = FindPassword.getPassword(js).toByteArray()
val password = remoteKey.toByteArray()
val (key, iv) = GenerateKeyAndIv(password, salt) ?: return null
val keySpec = SecretKeySpec(key, "AES")
val ivSpec = IvParameterSpec(iv)