Intercept DNS request in a Chrome Extension? - google-chrome

If I want to test http://www.domain.com, but I want to test two versions of it by switching the IP out (e.g. one resolves to 127.0.0.1 and the other 192.168.1.200) is it possible to write/use a chrome extension to handle intercepting the DNS query and resolving to my IP of choice?
The current workaround is to utilize the hosts file and flush the DNS cache to switch between them but that's less than optimal and was hoping a browser extension could handle the same thing.

There's no mechanism to manipulate DNS requests/responses natively inside Chrome, not even via the upcoming WebRequest API.
Is there a reason that you need to test with exactly the same domain name? Setting up a dev environment on something like http://dev.example.com/ (or http://example.dev/ if you run your own DNS or have edited your hosts file) is a clean mechanism for producing the effect you want in a way that's functional with the APIs you have access to; writing an extension that gave you a button to toggle between the two domains with the push of a button would be trivial

Related

What is the purpose and code content of Chrome's proxy script?

What is the purpose and the code content of the "Proxy Script" that Chrome attempts to load every time a new page is loaded?
An easy way to trigger this message is to turn on and off Airplane mode:
This happens when your computer's network settings have a HTTP proxy configured. The proxy auto-config (PAC) script file is specified in those settings; Chrome then downloads it and runs it to determine whether and how each request will be proxied. The script is provided by your proxy, not Chrome.
If you are not intentionally using proxies, you should remove the proxy configuration as it might be either unnecessary or malicious. But if this is a machine owned by your employer, it is probably intentional.
I'm not sure if this work the same way on all OSes, but for me on macOS, there's a link from Chrome's settings to the OS network settings:
The reason the message pops up when you enter/exit airplane mode is probably because that counts as a change of network configuration (between "no internet (and no proxy)" to "yes internet and also proxy"), and it's making sure it has the latest PAC script.
If you want to find out what the script contains, copy the PAC URL out of your network settings and download it separately; then you can read the code (which is JavaScript).

Is it possible to use VPN extensions such as Hola in Chrome Apps?

There are several Chrome extensions that acts like a VPN. An (in)famous example is Hola. If I change my IP using one of these, I will globally get a new IP address in Chrome.
However, the new IP is not reflected inside Chrome apps. On the other hands, a proxy like FoxyProxy does indeed also affects Chrome apps.
It is possible somehow to make the extension work inside my app, for example by changing the manifest etc?
It is not possible because the extensions work inside chrome and do not affect the global configuration of the system. You can find more info here

Chrome give "Your connection is not private" when using with a proxy

I'm trying to record a test with Jmeter for https://maps.google.com using JMeter's Test script recorder proxy. However I got "Your connection is not private" error and it doesn't show "proceed to https://maps.google.com" option like usual
Anyone knows how to proceed. Thanks
First of all I would suggest to reconsider the whole test scenario as:
Leave Google Maps load testing to Google engineers
If you attempt to launch a load test against Google Maps - you'll get banned.
Even if your application uses Google Maps in frame for something - you should exclude it from scope as it isn't something you can control even if you won't be happy with the performance.
Just in case if you still need it for any reason you can try the following workarounds:
Under chrome://settings/
Pricacy -> Clear browser data
HTTPS/SSL - > Uninstall JMeter certificate
Try using less "paranoid" browser i.e.Firefox which uses its own certificates and proxy settings
There is an alternative way of recording a JMeter test which doesn't not require setting up proxies and worrying about SSL certificates - JMeter Chrome Extension
Your ip is being changed multiple times due to the proxy so it's making Google think a hacker is ip spoofing a site. Just change the https:// in the url to http://.

Are push notifications possible in html5 without fully https site?

Looks like Push notifications are finally usable for web-apps! Unfortunately, this requires https for ServiceWorker, which not all sites may have.
One thing I noticed in the spec it mentions:
if r's url's scheme is not one of "http" and "https", then:
Throw a TypeError."
So I'm confused - can the site be http, as long as it includes a serviceworker that is from https? For example, mydomain.com could include an https serviceworker from https://anotherdomain.com?
Another standard, web-api simple-push, doesn't mention requiring https (likely an omission in the documentation?), and "The user experience on Firefox Desktop has not been drawn out yet". Is the documentation on this outdated, or is push really only supported in FirefoxOS??
Simple-push, that is the current push solution in Firefox OS doesn't have anything to do with ServiceWorkers.
The next generation of push, implemented by both Google and Mozilla will be done through ServiceWorkers:
Push API spec
In that case yes, your content will need to be served over HTTPS.
Probably you will be interested in the LetsEncrypt initiative:
letsencrypt.org
A new certification authority that will help developers to transition their content over HTTPS.
Also just for development purposes, both Google and Mozilla implementations of ServiceWorkers allow you to bypass the check of the secure content, if you develop against localhost.
In the case of Mozilla you will need to enable the flag:
devtools.serviceWorkers.testing.enabled: true
But again this will be just for development, and AFAIK, Mozilla push landed or is about to land, and will be available in the nightly builds, you can follow the work here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1038811
No, the new generation of push notifications (i.e. Push API) requires HTTPS.
If you need to add push notifications to a website without HTTPS you can use a third-party service like Pushpad (I am the founder) that delivers notifications on your behalf.
The text you cited from the spec is from the Cache.addAll() section (5.4).
Here's the summary of addAll() on MDN:
The addAll() method of the Cache interface takes an array of URLS, retrieves them, and adds the resulting response objects to the given cache. The request objects created during retrieval become keys to the stored response operations.
Service workers can request & cache URLs that are either HTTP or HTTPS, but a Service Worker itself can only work in its registered Scope (which must be HTTPS).
simple-push is not related to Service Workers; it seems comparable to the approaches other platforms have taken:
Apple Push Notifications
Google Cloud Messaging
I found a nice bypass workaround to allow notifications from websites and domains without SSL, hence http:// and not https:// for Firefox.
Firefox holds a file inside the Mozilla directory called permissions.sqlite which is a sqlite database file that holds the permissions for domains. You can add your domain there http://yourdomainname with permissions for notifications and it will work.
I have created a demonstration for Windows here https://gist.github.com/caviv/8df5fa11a98e0e33557f75215f691d54 in golang

How to display web page without getting blocked by the firewall?

I want our app to show the online help page (so it's always up to date) or even a local page. However, it's likely to be blocked by the Firewall (Zone Alarm).
BTW, I tested this with Zone Alarm. It blocked access to a local .html file as well as to an .asp file on the internet. (I.e., tried to display a page in Internet Explorer and got the Zone Alarm dialog asking if I wanted to give permission to display
Is there a way around this?
Perhaps displaying the web page in the Web Browser Control?
It's actually very unlikely that web traffic is blocked at the firewall (unless you mean the file type is blocked?). What you may need to do in such a setting, however, is use the same proxy that IE uses, because direct traffic may be blocked.
The simplest way to do that is to use a high level windows API or IE itself, and HTTP download the latest helpfile if there is a new one - these mechanisms should know about any proxy.
Of course, your users may not be using IE, even if most are. So you might need to allow the user to specify the proxy, or be able to auto configure the proxy in the same way that the browser does it.
edit: I see you mean zonealarm is part of the problem. yes, that is tricky as you will have to either get your application 'blessed' centrally by whoever manages zonealarm in the customer organisation, or (if there is no central management) then the user will have to allow the app to communicate. Perhaps you should bite the bullet and have the online help simply be a website, and spawn the preferred browser via 'executing' the URL as suggested in another answer.
If the web browser isn't blocked the firewall then they probably open port 8080 for any app and thus your app shouldn't be blocked.
If the firewall only allowed port 8080 to IE; you would have to punch a hole in the firewall to use a new browser like firefox or chrome.
To open a web page using the user's preferred browser (with appropriate proxy and authentication settings), use something like ShellExecute with the URL of the document to load. Something like this would do it (where page is the URL to load):
HINSTANCE r = ShellExecute(NULL, "open", page, NULL, NULL, SW_SHOWNORMAL);