consumet/consumet.ts

ZORO fetchEpisodeSources() throws error

abhishek-exists opened this issue · 2 comments

Describe the bug

fetchEpisodeSources() method is returning following error

Steps to reproduce

Run the zoro test using jest.

Its only failing for fetchEpisodeSources() method

Expected behavior

It should load episode sources.

Actual behavior

Its Breaking while decrypting the contents.

Additional context

Code block responsible from file extractors/megacloud.ts:

decrypt(encrypted: string, keyOrSecret: string, maybe_iv?: string) {
    let key;
    let iv;
    let contents;
    if (maybe_iv) {
      key = keyOrSecret;
      iv = maybe_iv;
      contents = encrypted;
    } else {
      const cypher = Buffer.from(encrypted, "base64");
      const salt = cypher.subarray(8, 16);
      const password = Buffer.concat([
        Buffer.from(keyOrSecret, "binary"),
        salt,
      ]);
      const md5Hashes = [];
      let digest = password;
      for (let i = 0; i < 3; i++) {
        md5Hashes[i] = crypto.createHash("md5").update(digest).digest();
        digest = Buffer.concat([md5Hashes[i], password]);
      }
      key = Buffer.concat([md5Hashes[0], md5Hashes[1]]);
      iv = md5Hashes[2];
      contents = cypher.subarray(16);
    }

    const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
    const decrypted =
      decipher.update(
        contents as any,
        typeof contents === "string" ? "base64" : undefined,
        "utf8"
      ) + decipher.final();

    return decrypted;
  }

Error thrown while processing following line

decipher.final()

Error:

Error: error:1C80006B:Provider routines::wrong final block length
    at Decipheriv.final (node:internal/crypto/cipher:193:29)

Suggestions: I'm not aware of the encryption process but it seems like contents is of size 482 which is not a multiple of 16. Not sure whether this will solve the issue or not.

CC: @riimuru @jasanpreetn9

I can give some insights into this: it seems that the extractVariables method is returning empty string which might be the source of the problem. Maybe the regex needs updating?

Awesome @Kylart , I can verify that Zoro is working

Update: It worked when I made those changes but after few tries, its throwing same error