2

I can successfully run the code below, But failed after obfuscating with javascript-obfuscator.

const puppeteer = require('puppeteer-core');

let params = {
  ignoreHTTPSErrors: true,
  args: [
    '--ignore-certificate-errors',
    '--no-sandbox',
  ],
  executablePath: this.chromePath,
  headless: true,
};
const browser = await puppeteer.launch(params);

var page = await browser.newPage();
await page.goto(this.url, { waitUntil: 'load' });
await page.waitForTimeout(2000);
await page.content();       ----------------------- error in this line
await page.setViewport({ width: 1600, height: 1200 });
await page.waitForTimeout(2000);

Error info:

(node:22648) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: _0xa28d is not defined
    at __puppeteer_evaluation_script__:1:21
    at _0x1ce9f4._evaluateInternal (E:\xx\dist\bundle.js:1:3355462)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async _0x1ce9f4.evaluate (E:\xx\dist\bundle.js:1:3353310)
    at async _0x23b99f.content (E:\xx\dist\bundle.js:1:3400665)
    at async _0x14d154.content (E:\xx\dist\bundle.js:1:3508435)
    at async _0x571581.getContentInaSinglePage (E:\xx\dist\bundle.js:1:4423286)
    at async _0x508402.isInteresting (E:\xx\dist\bundle.js:1:4622902)
    at async _0x508402.startScan (E:\xx\dist\bundle.js:1:4641280)
    at async _0x421a37.scan (E:\xx\dist\bundle.js:1:4643371)
    at async E:\xx\dist\bundle.js:1:4970734

What is the cause of this problem, and how to solve this problem. Any suggestion?

Homer Qing
  • 21
  • 1

1 Answers1

0

You have two solutions for fix this issue:

First one, you can pass variables from outside, like this:

Image

Other one is, you can disable stringArray: true to stringArray: false.

CLI Command:

javascript-obfuscator ./app.js --output ./app-obfuscated.js --string-array false

I think its a bug of javascript-obfuscator library. As a alternative you can use this package:

js-obfuscator

It's working well with puppeteer.