fix(en/nineanime): Fix keys and encryption algorithm (#3156)
This commit is contained in:
parent
36b7d06ec7
commit
23784f52c2
@ -77,7 +77,7 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
|
|||||||
}
|
}
|
||||||
val vidId = embedLink.substringAfterLast("/").substringBefore("?")
|
val vidId = embedLink.substringAfterLast("/").substringBefore("?")
|
||||||
val encodedID = encodeID(vidId, keyList)
|
val encodedID = encodeID(vidId, keyList)
|
||||||
val apiSlug = callFromFuToken(host, encodedID)
|
val apiSlug = callFromFuToken(host, encodedID, embedLink)
|
||||||
|
|
||||||
return buildString {
|
return buildString {
|
||||||
append("https://")
|
append("https://")
|
||||||
@ -110,9 +110,13 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
|
|||||||
return encoded.toString(Charsets.UTF_8).replace("/", "_").trim()
|
return encoded.toString(Charsets.UTF_8).replace("/", "_").trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callFromFuToken(host: String, data: String): String {
|
private fun callFromFuToken(host: String, data: String, embedLink: String): String {
|
||||||
|
val refererHeaders = headers.newBuilder().apply {
|
||||||
|
add("Referer", embedLink)
|
||||||
|
}.build()
|
||||||
|
|
||||||
val fuTokenScript = client.newCall(
|
val fuTokenScript = client.newCall(
|
||||||
GET("https://$host/futoken"),
|
GET("https://$host/futoken", headers = refererHeaders),
|
||||||
).execute().body.string()
|
).execute().body.string()
|
||||||
|
|
||||||
val js = buildString {
|
val js = buildString {
|
||||||
|
@ -8,7 +8,7 @@ import javax.crypto.spec.SecretKeySpec
|
|||||||
class AniwaveUtils {
|
class AniwaveUtils {
|
||||||
|
|
||||||
fun vrfEncrypt(input: String): String {
|
fun vrfEncrypt(input: String): String {
|
||||||
val rc4Key = SecretKeySpec("ysJhV6U27FVIjjuk".toByteArray(), "RC4")
|
val rc4Key = SecretKeySpec("tGn6kIpVXBEUmqjD".toByteArray(), "RC4")
|
||||||
val cipher = Cipher.getInstance("RC4")
|
val cipher = Cipher.getInstance("RC4")
|
||||||
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters)
|
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters)
|
||||||
|
|
||||||
@ -16,8 +16,9 @@ class AniwaveUtils {
|
|||||||
vrf = Base64.encode(vrf, Base64.URL_SAFE or Base64.NO_WRAP)
|
vrf = Base64.encode(vrf, Base64.URL_SAFE or Base64.NO_WRAP)
|
||||||
vrf = Base64.encode(vrf, Base64.DEFAULT or Base64.NO_WRAP)
|
vrf = Base64.encode(vrf, Base64.DEFAULT or Base64.NO_WRAP)
|
||||||
vrf = vrfShift(vrf)
|
vrf = vrfShift(vrf)
|
||||||
vrf = Base64.encode(vrf, Base64.DEFAULT)
|
vrf = vrf.reversed().toByteArray()
|
||||||
vrf = rot13(vrf)
|
vrf = Base64.encode(vrf, Base64.URL_SAFE or Base64.NO_WRAP)
|
||||||
|
// vrf = rot13(vrf)
|
||||||
val stringVrf = vrf.toString(Charsets.UTF_8)
|
val stringVrf = vrf.toString(Charsets.UTF_8)
|
||||||
return "vrf=${java.net.URLEncoder.encode(stringVrf, "utf-8")}"
|
return "vrf=${java.net.URLEncoder.encode(stringVrf, "utf-8")}"
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ class AniwaveUtils {
|
|||||||
var vrf = input.toByteArray()
|
var vrf = input.toByteArray()
|
||||||
vrf = Base64.decode(vrf, Base64.URL_SAFE)
|
vrf = Base64.decode(vrf, Base64.URL_SAFE)
|
||||||
|
|
||||||
val rc4Key = SecretKeySpec("hlPeNwkncH0fq9so".toByteArray(), "RC4")
|
val rc4Key = SecretKeySpec("LUyDrL4qIxtIxOGs".toByteArray(), "RC4")
|
||||||
val cipher = Cipher.getInstance("RC4")
|
val cipher = Cipher.getInstance("RC4")
|
||||||
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters)
|
cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters)
|
||||||
vrf = cipher.doFinal(vrf)
|
vrf = cipher.doFinal(vrf)
|
||||||
@ -48,7 +49,7 @@ class AniwaveUtils {
|
|||||||
|
|
||||||
private fun vrfShift(vrf: ByteArray): ByteArray {
|
private fun vrfShift(vrf: ByteArray): ByteArray {
|
||||||
for (i in vrf.indices) {
|
for (i in vrf.indices) {
|
||||||
val shift = arrayOf(-3, 3, -4, 2, -2, 5, 4, 5)[i % 8]
|
val shift = arrayOf(-2, -4, -5, 6, 2, -3, 3, 6)[i % 8]
|
||||||
vrf[i] = vrf[i].plus(shift).toByte()
|
vrf[i] = vrf[i].plus(shift).toByte()
|
||||||
}
|
}
|
||||||
return vrf
|
return vrf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user