Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ungraceful error if can't contact proxy #623

Open
digininja opened this issue Aug 30, 2023 · 3 comments
Open

Ungraceful error if can't contact proxy #623

digininja opened this issue Aug 30, 2023 · 3 comments

Comments

@digininja
Copy link
Contributor

OS Used - ALL Information (architecture, linux flavor, etc.)

Kali up to date

Error you are encountering

Set http_proxy to a proxy that doesn't exist:

$ export http_proxy=http://localhost:3140

Run EW:

$ ./EyeWitness.py  --single https://localhost

Get the error:

################################################################################
#                                  EyeWitness                                  #
################################################################################
#           Red Siege Information Security - https://www.redsiege.com           #
################################################################################

HTTPConnectionPool(host='localhost', port=3140): Max retries exceeded with url: http://localhost:44105/session (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f768ed18fd0>: Failed to establish a new connection: [Errno 111] Connection refused')))

Expected behaviour (vs. what you encountered)

Catch the error and handle it nicely.

Any additional information

Only a fool would eat a Marmite/stroopwafel sandwich!

@Relkci
Copy link
Collaborator

Relkci commented May 15, 2024

Reproduced and confirmed.

Occurs in selenium driver initialize and Try: does not catch the stdout despite dropping into except as expected, but not before allowing the driver's error to stdout.

Likely fix is to redirect the thread's std out temporarily while the driver is being initialized, then resetting it back immediately afterwards.

That said, I'm not certain that's the best direction to go- messing with stdout unnecessarily. Having an incorrect/not-available proxy probably deserves an error that tells the problem. Despite the error not looking pretty, it defines the problem somewhat well.

Maybe not handling the error is ok in this case?

Perhaps a preceding stdout if the env var is set that's causing the error would be enough to help the user identify the root cause?

@Relkci
Copy link
Collaborator

Relkci commented May 22, 2024

produced a POC, will create a proper branch and MR (minus the typos)

since the driver is created in a multithreaded process, the try properly drops to exception, but is in a subprocess with an unhandled sdterr. Adding a try to the driver init allows catching of the error and allows the thread to exit gracefully

image

selenium_module: -- push driver init into try

image

eyewitness main

force thread exit if driver failed to init
image

@digininja
Copy link
Contributor Author

I've raised a lot of stuff in here that I've completely forgotten about!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants