Manhuadui - update decryption, refactor pageListParse (#3896)
This commit is contained in:
parent
44ee4ec99c
commit
f0ce48cf7b
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Manhuadui'
|
extName = 'Manhuadui'
|
||||||
pkgNameSuffix = 'zh.manhuadui'
|
pkgNameSuffix = 'zh.manhuadui'
|
||||||
extClass = '.Manhuadui'
|
extClass = '.Manhuadui'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.zh.manhuadui
|
package eu.kanade.tachiyomi.extension.zh.manhuadui
|
||||||
|
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import com.squareup.duktape.Duktape
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
|
@ -9,15 +8,15 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
import javax.crypto.Cipher
|
|
||||||
import javax.crypto.spec.IvParameterSpec
|
|
||||||
import javax.crypto.spec.SecretKeySpec
|
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import javax.crypto.Cipher
|
||||||
|
import javax.crypto.spec.IvParameterSpec
|
||||||
|
import javax.crypto.spec.SecretKeySpec
|
||||||
|
|
||||||
class Manhuadui : ParsedHttpSource() {
|
class Manhuadui : ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -117,8 +116,11 @@ class Manhuadui : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ref: https://jueyue.iteye.com/blog/1830792
|
// ref: https://jueyue.iteye.com/blog/1830792
|
||||||
private fun decryptAES(value: String, key: String, iv: String): String? {
|
private fun decryptAES(value: String): String? {
|
||||||
try {
|
val key = "1231M8H8B8123456"
|
||||||
|
val iv = "A1B2C3D4E5F6G789"
|
||||||
|
|
||||||
|
return try {
|
||||||
val secretKey = SecretKeySpec(key.toByteArray(), "AES")
|
val secretKey = SecretKeySpec(key.toByteArray(), "AES")
|
||||||
val ivParams = IvParameterSpec(iv.toByteArray())
|
val ivParams = IvParameterSpec(iv.toByteArray())
|
||||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||||
|
@ -126,41 +128,35 @@ class Manhuadui : ParsedHttpSource() {
|
||||||
|
|
||||||
val code = Base64.decode(value, Base64.NO_WRAP)
|
val code = Base64.decode(value, Base64.NO_WRAP)
|
||||||
|
|
||||||
return String(cipher.doFinal(code))
|
String(cipher.doFinal(code))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun decrypt(code: String): String? {
|
private val chapterImagesRegex = Regex("""var chapterImages =\s*"(.*?)";""")
|
||||||
val key = "1231994MHB123456"
|
private val imgPathRegex = Regex("""var chapterPath =\s*"(.*?)";""")
|
||||||
val iv = "ABCDEF1G34123412"
|
private val imgCodeCleanupRegex = Regex("""[\[\]"\\]""")
|
||||||
|
|
||||||
return decryptAES(code, key, iv)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val html = document.html()
|
val html = document.html()
|
||||||
val re = Regex("""var chapterImages =\s*"(.*?)";""")
|
val imgCodeStr = chapterImagesRegex.find(html)?.groups?.get(1)?.value ?: throw Exception("imgCodeStr not found")
|
||||||
val imgCodeStr = re.find(html)?.groups?.get(1)?.value
|
val imgCode = decryptAES(imgCodeStr)
|
||||||
val imgCode = decrypt(imgCodeStr!!)
|
?.replace(imgCodeCleanupRegex, "")
|
||||||
val imgPath = Regex("""var chapterPath =\s*"(.*?)";""").find(html)?.groups?.get(1)?.value
|
?.replace("%", "%25")
|
||||||
val imgArrStr = Duktape.create().use {
|
?: throw Exception("Decryption failed")
|
||||||
it.evaluate(imgCode!! + """.join('|')""") as String
|
val imgPath = imgPathRegex.find(document.html())?.groups?.get(1)?.value ?: throw Exception("imgPath not found")
|
||||||
}
|
return imgCode.split(",").mapIndexed { i, imgStr ->
|
||||||
return imgArrStr.split('|').mapIndexed { i, imgStr ->
|
|
||||||
// Log.i("Tachidebug", "img => ${imageServer[0]}/$imgPath$imgStr")
|
|
||||||
if (imgStr.startsWith("http://images.dmzj.com")) {
|
if (imgStr.startsWith("http://images.dmzj.com")) {
|
||||||
Page(i, "", "https://mhcdn.manhuazj.com/showImage.php?url=$imgStr")
|
Page(i, "", "https://img01.eshanyao.com/showImage.php?url=$imgStr")
|
||||||
} else {
|
} else {
|
||||||
Page(i, "", if (imgStr.indexOf("http") == -1) "${imageServer[0]}/$imgPath$imgStr" else imgStr)
|
Page(i, "", if (imgStr.indexOf("http") == -1) "${imageServer[0]}/$imgPath$imgStr" else imgStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = ""
|
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used")
|
||||||
|
|
||||||
override fun getFilterList() = FilterList(
|
override fun getFilterList() = FilterList(
|
||||||
CategoryGroup(),
|
CategoryGroup(),
|
||||||
|
|
Loading…
Reference in New Issue