1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 18:53:21 +01:00

[hentainexus] update data decoding procedure (#1125)

This commit is contained in:
Mike Fährmann 2020-11-25 11:26:26 +01:00
parent c57a918f4a
commit f6a684bc37
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -73,11 +73,25 @@ class HentainexusGalleryExtractor(GalleryExtractor):
@staticmethod
def _decode(data):
# https://hentainexus.com/static/js/reader.min.js?r=6
blob = binascii.a2b_base64(data)
return "".join(
chr(blob[i] ^ blob[i-64])
for i in range(64, len(blob))
)
key = blob[0:64]
indices = list(range(256))
result = ""
x = 0
for i in range(256):
x = (x + indices[i] + key[i % len(key)]) % 256
indices[i], indices[x] = indices[x], indices[i]
x = i = 0
for n in range(64, len(blob)):
i = (i + 1) % 256
x = (x + indices[i]) % 256
indices[i], indices[x] = indices[x], indices[i]
result += chr(blob[n] ^ indices[(indices[i] + indices[x]) % 256])
return result
@staticmethod
def _join_title(data):