Open cyber opened 4 years ago
Also, adding something like socks5:// to the beginning of the SOCKS field causes the proxy to not work at all, and chromedriver connects directly to the internet.
Looks like this is just a limitation of chrome-driver itself? Had to switch to python & use the temporary extension trick to get this working.
@cyber What's the temporary extension trick?
@Manouchehri can't find the exact stackoverflow thread that I copied it from, but this worked a couple months ago:
manifest_json = """
{
"version": "1.0.0",
"manifest_version": 2,
"name": "Chrome Proxy",
"permissions": [
"proxy",
"tabs",
"unlimitedStorage",
"storage",
"<all_urls>",
"webRequest",
"webRequestBlocking"
],
"background": {
"scripts": ["background.js"]
},
"minimum_chrome_version":"22.0.0"
}
"""
background_js = """
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "http",
host: "%s",
port: parseInt(%s)
},
bypassList: ["localhost"]
}
};
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
function callbackFn(details) {
return {
authCredentials: {
username: "%s",
password: "%s"
}
};
}
chrome.webRequest.onAuthRequired.addListener(
callbackFn,
{urls: ["<all_urls>"]},
['blocking']
);
""" % (PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASS)
def get_chromedriver(use_proxy=False, user_agent=None):
chrome_options = webdriver.ChromeOptions()
if use_proxy:
pluginfile = 'proxy_auth_plugin.zip'
with zipfile.ZipFile(pluginfile, 'w') as zp:
zp.writestr("manifest.json", manifest_json)
zp.writestr("background.js", background_js)
chrome_options.add_extension(pluginfile)
if user_agent:
chrome_options.add_argument('--user-agent=%s' % user_agent)
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(
CHROMEDRIVER_PATH,
options=chrome_options)
return driver
note that this'll create the .zip file in the directory, so you might want to remove it after oh and another limitation is that you can't use extensions in headless mode
Same issue here after updating to newest version of the chrome-standalone docker image. I was able to have my proxies accept IP authentication, which appears to fix the issue, but basic auth in socks5 proxies are not working.
I have the same issue
Did anyone find a solution?
https://github.com/SeleniumHQ/selenium/issues/9176#issuecomment-779208791
Chrome doesn't support SOCKS authentication
this "should" work by proxy-chaining with gost or redsocks (via)
gost -L=socks5://127.0.0.1:8005 -F=socks5://$username:$password@$ipaddr:$port &
chromium \
--proxy-server=socks5://127.0.0.1:8005 \
"--proxy-bypass-list=<-loopback>" \
"--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1"
for host-resolver-rules
see also
https://www.chromium.org/developers/design-documents/network-stack/socks-proxy/
Here is my setup:
This will open chrome, but trying to visit any website will yield this error:
ERR_SOCKS_CONNECTION_FAILED
The same proxy will work in python requests (in this format:
socks5://username:password@proxy.com:777
)Any thoughts?