delvelabs/htcap

Failed to launch chrome, error: Gtk-WARNING **: cannot open display:

blackye opened this issue · 2 comments

node /data/project/htcap/core/crawl/probe/index.js -R "B"rtGtf9"=WS-V>,]l1v" -A "ua_test" -r "http://testphp.vulnweb.com/AJAX/" http://testphp.vulnweb.com/
(node:499486) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to launch chrome!

(chrome:499496): Gtk-WARNING **: cannot open display:
[0510/190310.499289:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly

TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

(node:499486) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The important part of the message is: Error: Failed to launch chrome! alongside with cannot open display.

Do you try to run it in a docker container or anything headless?
If it is the case, you have to install xvfb to emulate a display for chrome.

The test to know if your installation is correct (ie. chrome is running), do:

  1. create a test.js file in the project in ./htcap/core/crawl/probe/ (to run it in the same context as the index.js), with the following content:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

I took it from here: https://github.com/GoogleChrome/puppeteer#usage

  1. run it with: node ./test.js

If everything is OK, it will create a example.png in ./htcap/core/crawl/probe/. and the problem is in the probe code.
If you get the same error, there is a problem with your installation.

I made a low level error. From the description you gave and the serious study of Puppeteer, I solved this problem. Thank you for your quick and effective reply.:)