Chrome-remote-interface: Is it possible to set the proxy information on a running chrome via the remote interface?

Created on 7 Jun 2017  路  7Comments  路  Source: cyrus-and/chrome-remote-interface

More of a question than an issue. Is this possible? I can set the proxy when i launch the chrome instance via command line args, but is it possible to change these dynamically? I can't see it documented on the Chrome DevTools Protocol, but was wondering if there are any undocumented ways of doing this.

I also found this on the extensions api https://developer.chrome.com/extensions/proxy but i can't find a way to exploit it remotely.

question

Most helpful comment

@cyrus-and yea looks like I assumed it by default, sorry. Anyways just wanted to highlight it for anyone who tries to change proxy in headless mode

All 7 comments

AFAIK the protocol does not provide such facility.

I also found this on the extensions api https://developer.chrome.com/extensions/proxy but i can't find a way to exploit it remotely.

You can write an extension that uses and this API and that can be activated via [message passing]. Then using the CDP you can inject the JavaScript code that triggers the action using [Runtime.evaluate]. Something like:

Runtime.evaluate({
    expression: `postMessage('{proxySettings: {...}}', '*')`
});

Then from the extension:

window.addEventListener('message', function (event) {
    if (...) {
        chrome.proxy.settings.set(...);
    }
});

It's a bit involved, and I've never tried to to that, but it should work.

I haven't tried this yet, but you might want to check out the new enableRequestInterception-related APIs.

This just landed on Canary -
https://chromium.googlesource.com/chromium/src/+/6f5b3053ff11488b985c18e8d03472356e049fd5

Thanks both for your input.
@cyrus-and That does look a bit tricky. I may be better off just launching a new chrome instance to change the proxy.
@paambaati The request intercept looks promising but i don't see aware in there to modify the proxy.

The request intercept looks promising but i don't see aware in there to modify the proxy.

@FergusNelson I think the point is to manually implementing one, something like:

  1. intercept the request;
  2. manually perform the above request against a proxy;
  3. continue the intercepted request passing in the raw proxy response.

A bit tricky too...

I think you now have some useful ideas, feel free to close this issue if you're done.

@cyrus-and the thing is in headless chrome extensions don't work, so it's not possible so set proxy on fly by all means. https://bugs.chromium.org/p/chromium/issues/detail?id=706008#c5

@route do you read "headless" anywhere in this thread besides your comment?

@cyrus-and yea looks like I assumed it by default, sorry. Anyways just wanted to highlight it for anyone who tries to change proxy in headless mode

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilanc picture ilanc  路  9Comments

akleiner2 picture akleiner2  路  4Comments

hbakhtiyor picture hbakhtiyor  路  7Comments

paambaati picture paambaati  路  7Comments

westy92 picture westy92  路  3Comments