gowitness icon indicating copy to clipboard operation
gowitness copied to clipboard

Chrome window dimensions not obeyed

Open skorokithakis opened this issue 1 year ago • 10 comments

I'm trying the following command on version 3.0.5:

❯ gowitness scan --chrome-window-x 384 --chrome-window-y 640 --screenshot-path . --write-none single --screenshot-format png --url https://sensepost.com
2024/10/22 15:41:12 ERROR: unhandled node event *dom.EventScrollableFlagUpdated
2024/10/22 15:41:15 INFO result 🤖 target=https://sensepost.com status-code=200 title=":: Orange Cyberdefense ::" have-screenshot=true

But the result is 500x501 pixels:

https---sensepost com

What am I doing wrong?

skorokithakis avatar Oct 22 '24 12:10 skorokithakis

Command invocation is fine. We don't have much control over how it's handled from a gowitness perspective. The values are passed to the drivers as is. chromedp and gorod.

Unrelated to this, but this line implies you have an outdated cdproto dependency. Make sure you have the latest gowitness.

2024/10/22 15:41:12 ERROR: unhandled node event *dom.EventScrollableFlagUpdated

leonjza avatar Oct 22 '24 12:10 leonjza

I seem to:

❯ gowitness version
               _ _                   
 ___ ___ _ _ _|_| |_ __ ___ ___ ___ 
| . | . | | | | |  _|  | -_|_ -|_ -|
|_  |___|_____|_|_||_|_|___|___|___|
|___|    v3, with <3 by @leonjza

gowitness: 3.0.5
git hash: 6b0000e
build env: go1.23.2_linux/arm64
build time: 2024-10-21T19:22:14Z

Can I upgrade cdproto somehow? I didn't compile gowitness from source, I'm just using the binary release from GH.

skorokithakis avatar Oct 22 '24 12:10 skorokithakis

Not without a recompilation. I bumped the deps now, will land in a next release in the future.

leonjza avatar Oct 22 '24 13:10 leonjza

I compiled from source but the image is still 500x501:

❯ gowitness version
               _ _                   
 ___ ___ _ _ _|_| |_ __ ___ ___ ___ 
| . | . | | | | |  _|  | -_|_ -|_ -|
|_  |___|_____|_|_||_|_|___|___|___|
|___|    v3, with <3 by @leonjza

gowitness: 3.0.5
git hash: dev
build env: dev
build time: dev

Do you have any tips? I know this might be something with the driver, but I'm stuck.

skorokithakis avatar Oct 22 '24 13:10 skorokithakis

I don't. Like I mentioned, this is passed to the driver. It will require deeper digging into the implementation to debug.

That said, it does seem to honour it somewhat, just not exactly as expected.

leonjza avatar Oct 22 '24 13:10 leonjza

Thank you, I'm looking into this. Is there any way to see which driver executable gowitness is using? Then I'll know where to look.

skorokithakis avatar Oct 22 '24 14:10 skorokithakis

-D flag will surface some debugging info that may help in tracing execution flow. Beyond that you need to start editing source :)

leonjza avatar Oct 22 '24 16:10 leonjza

The error message you’re encountering:

ERROR: unhandled node event *dom.EventScrollableFlagUpdated

occurs because gowitness received an event from the Chrome DevTools Protocol (CDP) that it doesn’t recognize or handle. Specifically, the EventScrollableFlagUpdated is a DOM event that may have been introduced or updated in a newer version of Chrome or Chromium.

Despite this error, it appears that gowitness successfully captured the screenshot:

INFO result 🤖 target=https://sensepost.com status-code=200 title=":: Orange Cyberdefense ::" have-screenshot=true

Why Does This Error Occur?

•	Chrome/Chromium Version: Newer versions of Chrome/Chromium may emit events that older versions of gowitness aren’t programmed to handle.
•	gowitness Version: If you’re using an older version of gowitness, it might not be up-to-date with the latest CDP events.

How to Resolve the Issue

1.	Update gowitness:
•	Ensure you’re using the latest version of gowitness. Update it by running:

go install github.com/sensepost/gowitness@latest

•	This command fetches and installs the latest version directly from the repository.

2.	Check Chrome/Chromium Compatibility:
•	gowitness relies on Chrome or Chromium for rendering pages. Ensure that your browser version is compatible.
•	You can specify a particular Chrome/Chromium binary using the --chrome-path flag:

gowitness scan --chrome-path /path/to/chrome ...

3.	Ignore the Error:
•	If the screenshot is being captured successfully and the error doesn’t impact your workflow, you might choose to ignore it.
•	Alternatively, you can suppress error logs by adjusting the log level:

gowitness scan --log-level warn ...

4.	Report the Issue:
•	If the problem persists, consider opening an issue on the [gowitness GitHub repository](https://github.com/sensepost/gowitness/issues).
•	Provide details about your environment:
•	gowitness version
•	Chrome/Chromium version
•	Operating system

Example Updated Command

Assuming you’ve updated gowitness and want to suppress non-critical errors:

gowitness scan
--chrome-window-x 384
--chrome-window-y 640
--screenshot-path .
--write-none single
--screenshot-format png
--log-level warn
--url https://sensepost.com

Additional Tips

•	Verify Installations:
•	Check your gowitness version:

gowitness --version

•	Check your Chrome/Chromium version:

chrome --version

or

chromium --version

•	Alternative Tools:
•	If the issue continues, you might consider alternative tools like [WebScreenshot](https://github.com/maaaaz/webscreenshot) or [Aquatone](https://github.com/michenriksen/aquatone).

Let me know if you need further assistance! Maybe we can come up with something else!

AiPals avatar Oct 27 '24 09:10 AiPals

@AiPals please don't post LLM generated content here. The relevant dependency has already been updated and will land in a next release.

leonjza avatar Oct 27 '24 09:10 leonjza

I'm not sure if it's relevant of helpful, but I had previously been using the 11ty screenshot capture tool here. I'm generating social cards for link previews, and the dimension and aspect ratio requirements there are quite strict, as well as needing to make sure I capture the full page and avoid any cropping.

I haven't dug into what's happening in the backend there, but the opengraph size has always managed to render the exact size needed. I'm trying gowitness though as caching and timeout issues mean it's just easier to spin up a container and do locally. For now at least I can use --screenshot-fullpage and crop with imagemagick or something, ad the dimensions appear to be okay there.

BenAlanSouthall avatar Nov 18 '24 17:11 BenAlanSouthall