[kissmanga] update AES key retrieval
This commit is contained in:
0
gallery_dl/extractor/imagehosts.py
Executable file → Normal file
0
gallery_dl/extractor/imagehosts.py
Executable file → Normal file
@@ -10,12 +10,14 @@
|
|||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, cloudflare, aes
|
from .. import text, cloudflare, aes
|
||||||
|
from ..cache import cache
|
||||||
import re
|
import re
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import ast
|
||||||
|
|
||||||
IV = [
|
IV = [
|
||||||
165, 232, 226, 233, 194, 114, 27, 224,
|
0xa5, 0xe8, 0xe2, 0xe9, 0xc2, 0x72, 0x1b, 0xe0,
|
||||||
168, 74, 214, 96, 196, 114, 193, 243,
|
0xa8, 0x4a, 0xd6, 0x60, 0xc4, 0x72, 0xc1, 0xf3
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -102,29 +104,30 @@ class KissmangaChapterExtractor(KissmangaExtractor):
|
|||||||
def get_image_urls(self, page):
|
def get_image_urls(self, page):
|
||||||
"""Extract list of all image-urls for a manga chapter"""
|
"""Extract list of all image-urls for a manga chapter"""
|
||||||
try:
|
try:
|
||||||
key = self.build_aes_key(page)
|
key = self.build_aes_key()
|
||||||
return [
|
return [
|
||||||
aes.aes_cbc_decrypt_text(data, key, IV)
|
aes.aes_cbc_decrypt_text(data, key, IV)
|
||||||
for data in text.extract_iter(
|
for data in text.extract_iter(
|
||||||
page, 'lstImages.push(wrapKA("', '"'
|
page, 'lstImages.push(wrapKA("', '"'
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
except (ValueError, IndexError):
|
||||||
|
self.log.error("Failed to get AES key")
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self.log.error("Failed to decrypt image URls")
|
self.log.error("Failed to decrypt image URls")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def build_aes_key(self, page):
|
@cache(maxage=3600)
|
||||||
|
def build_aes_key(self):
|
||||||
"""Get and parse the AES key"""
|
"""Get and parse the AES key"""
|
||||||
try:
|
script = self.request(self.root + "/Scripts/lo.js").text
|
||||||
pos = page.rindex('; key = ')
|
|
||||||
pos = page.rindex('<script type="text/javascript">', 0, pos)
|
pos = script.index("var chko")
|
||||||
except ValueError:
|
var = text.extract(script, "=", "[", pos)[0].lstrip()
|
||||||
self.log.error("Unable to find AES key")
|
idx = text.extract(script, "[", "]", pos)[0]
|
||||||
return [0] * 32
|
|
||||||
try:
|
pos = script.index(var)
|
||||||
key = text.extract(page, ' = ["', '"]', pos)[0]
|
lst = text.extract(script, "=", ";", pos)[0]
|
||||||
data = bytes(int(i, 16) for i in key[2:].split(r"\x"))
|
key = ast.literal_eval(lst.strip())[int(idx)]
|
||||||
except (ValueError, TypeError):
|
|
||||||
self.log.error("Unable to parse AES key: '%s'", key)
|
return list(hashlib.sha256(key.encode("ascii")).digest())
|
||||||
return [0] * 32
|
|
||||||
return list(hashlib.sha256(data).digest())
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ skip = [
|
|||||||
# dont work on travis-ci
|
# dont work on travis-ci
|
||||||
"exhentai", "kissmanga", "mangafox", "dynastyscans",
|
"exhentai", "kissmanga", "mangafox", "dynastyscans",
|
||||||
# temporary issues
|
# temporary issues
|
||||||
"mangashare", "readcomics", "pawoo",
|
"mangashare", "readcomics",
|
||||||
]
|
]
|
||||||
# enable selective testing for direct calls
|
# enable selective testing for direct calls
|
||||||
if __name__ == '__main__' and len(sys.argv) > 1:
|
if __name__ == '__main__' and len(sys.argv) > 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user