Skip to content

Error: Proxy Required #21

Description

@Hexboi

Hi, I wondered if you ever encountered the scenario where the "victim" network had a network proxy in place, which forces the client connections to pass through it.

Here is the error code for context:

>>> exec(decoded_script)
Traceback (most recent call last):
  File "urllib\request.py", line 1348, in do_open
  File "http\client.py", line 1283, in request
  File "http\client.py", line 1329, in _send_request
  File "http\client.py", line 1278, in endheaders
  File "http\client.py", line 1038, in _send_output
  File "http\client.py", line 976, in send
  File "http\client.py", line 1448, in connect
  File "http\client.py", line 952, in connect
  File "http\client.py", line 925, in _tunnel
OSError: Tunnel connection failed: 407 Proxy Authorization Required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 149, in <module>
  File "urllib\request.py", line 216, in urlopen
  File "urllib\request.py", line 519, in open
  File "urllib\request.py", line 536, in _open
  File "urllib\request.py", line 496, in _call_chain
  File "urllib\request.py", line 1391, in https_open
  File "urllib\request.py", line 1351, in do_open
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 Proxy Authorization Required>

I tried setting variables both via Terminal, before launching Python and in the Python console itself using the "urllib.request" library, without success in both cases, code below for context:

PS C:\Users\testuser> set HTTP_PROXY=http://user:password@proxy.domain.local:8080
PS C:\Users\testuser> set HTTPS_PROXY=http://user:password@proxy.domain.local:8080
PS C:\Users\testuser> C:\Users\testuser\Downloads\python-3.10.11-embed-amd64\python.exe
import os
import urllib.request

# Set your proxy credentials
proxy_url = "proxyaddress:port"
proxy_user = "username"
proxy_pass = "password"

# Create proxy handler
proxy_handler = urllib.request.ProxyHandler({
    'http': f'http://{proxy_user}:{proxy_pass}@{proxy_url}',
    'https': f'https://{proxy_user}:{proxy_pass}@{proxy_url}'
})

# Install the opener
opener = urllib.request.build_opener(proxy_handler)
urllib.request.install_opener(opener)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions