WEBVTT

00:00.000 --> 00:02.980
Hi and welcome to my talk on malicious proxies.

00:03.920 --> 00:05.900
So let me tell you a little bit about myself.

00:05.900 --> 00:09.960
My name is Ed Zebrowski and I've been in security for about 12 years.

00:10.460 --> 00:18.740
Through those 12 years, I've moved back and forth through the various disciplines of malicious logic, incident response, intrusion detection, and pen testing.

00:19.640 --> 00:31.400
During this moving back and forth, I've found that I really enjoy the pen testing the most because it gives me the ability to tackle problems and evolving challenges that I normally wouldn't encounter.

00:32.880 --> 00:40.440
So one thing I want to get out of the way talking about proxies, when I use the term proxy, I'm focusing only on web proxies.

00:41.120 --> 00:48.540
And there's also plenty of reasons why you'd want to deploy a proxy legitimately, but who really cares?

00:48.540 --> 00:51.140
I'm not here to espouse on the benefits of a proxy.

00:53.060 --> 00:55.720
So why would I come up with a malicious proxy anyways?

00:56.120 --> 01:02.900
I wanted to come up with as many ways as I could to screw with a user's web browsing session anytime I could.

01:03.340 --> 01:09.920
And also as a pen tester, it gave me the ability to gather information that I might not have accessibility to.

01:11.860 --> 01:15.220
So a quick simplistic rundown of how proxies work.

01:15.300 --> 01:22.300
You have the client that requests a page through a proxy and that proxy then requests it from the server.

01:22.320 --> 01:28.220
The server passes that page back to the proxy and from the proxy to the client, rendering the page.

01:29.140 --> 01:40.460
A malicious proxy isn't much different because it still sends the request through the proxy to the server and back to the proxy.

01:40.740 --> 01:45.340
The only difference here is the proxy now has a chance to modify this data.

01:45.820 --> 01:52.660
And here's a screenshot of an excerpt of slash dot before and after it modifies it.

01:53.080 --> 02:00.980
Now, what you see here is on the bottom screen, a couple elements being added on to the page there, inserting some JavaScript.

02:05.010 --> 02:14.070
That JavaScript or page as it's been modified by the proxy is then passed right back on to the client where it's now rendered with the modifications you made to it.

02:15.110 --> 02:27.930
So, as I mentioned, a malicious proxy isn't much different from a standard proxy but it can modify and change the HTTP responses and requests and it can also add and remove data.

02:31.970 --> 02:35.910
So there are a couple ways you would want to go about modifying the content.

02:36.230 --> 02:39.870
One way is via modifying the static HTML.

02:40.310 --> 02:50.570
Now, that takes a lot of customization on a per page basis and it's just really kind of difficult to do for every single page that you would possibly want to modify.

02:51.230 --> 02:55.390
Another way to do it is via injecting JavaScript directly into the page.

02:55.530 --> 03:06.550
And that's a lot easier because we only need to find one thing that all pages should have in common like a head tag and add that JavaScript to that element.

03:06.930 --> 03:17.150
This way it allows the client to render the page for us and do it in a consistent way, modifying the DOM.

03:18.990 --> 03:23.870
So there are some potential issues you might encounter when deploying malicious proxy.

03:24.150 --> 03:30.210
One is that inserted JavaScript may be blocked by elements, or excuse me, by extensions like NoScript.

03:30.550 --> 03:43.490
There are ways around this though because if you can inject JavaScript as it's traveling through the proxy, you can just directly inject the JavaScript, making it look like it's from whatever trusted site that the user is going to.

03:44.610 --> 03:51.790
Also, I've encountered that some AJAX heavy sites don't play very well, especially in the area of forms.

03:51.990 --> 03:59.030
If a site sends the form request off in an AJAX request, it might not get picked up.

03:59.030 --> 04:05.690
But if it's sent via a form post to a separate handler, it will get picked up.

04:06.830 --> 04:09.610
Another issue is compressed pages.

04:09.610 --> 04:17.570
Because everything uses the HTTP 1.1 standard these days, excuse me,

04:20.950 --> 04:29.090
because everything uses the HTTP 1.1 standard these days, pages will come by in a binary format making it hard for us to make our changes.

04:29.090 --> 04:30.830
So we have a couple options there.

04:30.830 --> 04:40.010
We can either modify, decompress and modify the page when it comes to the proxy or we can just strip out the header request as it's going out from the client.

04:40.930 --> 04:44.750
Also, modifying the page itself slows down delivery.

04:44.750 --> 04:55.810
So if you're doing this on a large scale, you might run into more issues and that's another reason why they use JavaScript to let it do the lifting and the clients do the processing for you.

04:57.830 --> 05:01.630
So backing up now, how would you go about assigning a proxy?

05:01.910 --> 05:06.230
Well, in a pen test statically is not the best way to do it and it's kind of like cheating.

05:07.730 --> 05:12.010
You can also do it dynamically via DNS or DHCP.

05:12.270 --> 05:28.330
DNS has this functionality called a WPAD record and what that does is any browser set up to use autoproxy detection will look for a domain name with a WPAD host appended to it or pre-appended to it.

05:28.890 --> 05:40.710
If it finds it, it will look for a file on a web host at that URL and that file contains the proxy configuration file of where it should proxy through.

05:40.950 --> 05:46.990
The same thing with the DHCP option 252, the only difference is you get more flexible about the URL.

05:47.350 --> 05:51.870
And again, that only works for browsers using autoproxy detection.

05:52.530 --> 05:56.930
And of course, there are the other ways you can do it via like ARP spoofing as well.

05:58.890 --> 06:03.890
So I'm going to start talking about Topple Ganger, the tool I wrote to do this kind of stuff.

06:04.410 --> 06:10.430
When I started writing it, I wrote it as a kind of personal exercise learning Ruby.

06:10.870 --> 06:15.350
So the code isn't pretty and the documentation is sparse but that's a work in progress.

06:15.410 --> 06:25.630
I also wrote it as a proof of concept so some things might not always work but if you find yourself wanting to download it and you do and you find something wrong with it, feel free to let me know about it.

06:25.630 --> 06:27.870
I won't mind you make improvements.

06:29.010 --> 06:34.690
Now for the tool itself, I wanted it to be able to set down on the network and just go immediately.

06:34.990 --> 06:39.970
I didn't want to have to configure it a whole lot and I wanted it to target all sites out of the box.

06:41.750 --> 06:58.830
So Topple Ganger itself can create that WPAD record for us and I found that if you can manage to get on a network, usually the networks trust internal DNS updates so therefore you can become the proxy for the internal networks.

06:59.770 --> 07:05.710
And if any of you are familiar with Grease Monkey, this is kind of like Grease Monkey for an entire network.

07:06.850 --> 07:18.210
Additionally, you can use Google APIs for part of the JavaScript so that way you don't need to have the clients pinging your local machine to get them.

07:18.210 --> 07:21.310
You can go to an already trusted site and let them download from there.

07:24.010 --> 07:26.210
So Doppelganger, as I mentioned, uses Ruby.

07:26.770 --> 07:30.650
And the core and heart and soul of Doppelganger is Webrick.

07:31.010 --> 07:40.290
It uses that as the HTTP server serving up any files like the WPAD file or any other images that might be sent to the client.

07:40.910 --> 07:50.870
It also uses Ruby gems, DNS Ruby for updating the DNS, Packer for packing JavaScript and injecting it directly into the page.

07:51.150 --> 07:55.730
And the bottom two, Windows PR and Win32 process for Windows interoperability.

07:55.830 --> 08:01.310
But I haven't had any success with it binding to a port on Windows yet so I won't count on that working.

08:03.570 --> 08:15.510
So as I mentioned, Doppelganger generically works as a malicious proxy and can operate on both the headers and the content of the page.

08:16.970 --> 08:23.530
Specifically, it has these abilities and these can be customized or added to or what not but this is out of the boxes.

08:23.530 --> 08:24.510
I've written it.

08:24.890 --> 08:29.510
And you only need to create a JavaScript file containing the directives you want it to do.

08:30.450 --> 08:34.950
So I can insert a calling card and calling card is a pretty obvious attack.

08:34.950 --> 08:38.670
Not always useful for a pen test but it has its uses at times.

08:38.990 --> 08:41.070
Also injecting flash applets.

08:41.250 --> 08:49.690
I can also scrape and decode the basic authentication of any users authenticating to a site because that basic auth is only base 64 encoded.

08:50.190 --> 08:54.890
I can use it to steal form data and other header data such as cookies.

09:00.440 --> 09:11.340
So inserting a calling card simply just removes all the children tag and the body tag and it adds new image to display on the page prominently.

09:13.700 --> 09:17.060
Header capturing works just as it sounds.

09:17.080 --> 09:20.320
As a header is coming in or out, you can grab it.

09:20.740 --> 09:33.280
Like I said, this works for HTTP basic authentication and it can decode it for us on the fly so that way we don't need to bother putting it through our base 64 decoder and we can also grab cookies to steal other people's sessions.

09:34.780 --> 09:46.780
For injecting flash, we can just append that onto the end of the body of the page and this allows us to gather more information about hosts and potentially even exploit flash vulnerabilities.

09:48.820 --> 10:05.500
In capturing form data, the way this works is it binds to the submit event on all forms and when the user clicks on the submit button, it serializes that data, sends it back to the proxy to a non-existent URL where it's then logged by Doppelganger.

10:06.100 --> 10:17.940
And this is pretty useful too, especially for those pages that are HTTP only but then post the data to the form, excuse me, to a secure page.

10:20.630 --> 10:31.610
So, an example of what you might see is here, a tragic event happening on June 23rd, a separation of a couple because that never happens.

10:31.970 --> 10:37.810
But if you're running Doppelganger and you had the calling card functionality, they might see something more like this.

10:41.570 --> 10:58.990
Stealing form data, here's an excerpt from the Slack Flash.login box and I have my username and my password in there and at the bottom in the red is the form data that's serialized and posted back to Doppelganger that contains all the information that the user put into that form.

11:02.880 --> 11:06.380
So, Doppelganger has some other uses potentially.

11:06.380 --> 11:08.120
You could use it in phishing attacks.

11:08.500 --> 11:20.020
You could also use it in Csurf attacks or exploiting other things like Adobe Flash or the Oday Firefox vulnerabilities that just recently came out.

11:22.600 --> 11:31.440
And where I'd like to take it in the future is add more addition or more control over what pages that you can manipulate.

11:31.440 --> 11:34.500
Right now, as I mentioned, it just kind of gets everything out of the box.

11:34.500 --> 11:41.740
You might want to be able to filter out some of those pages and only get the ones that might be of interest to you.

11:42.000 --> 11:55.460
Also, a little more interactivity because there's chances are you might want to add more JavaScript to it via Google APIs, in which case you have to stop Doppelganger, start it back up and run it.

11:55.460 --> 12:05.620
And during that time, you might miss something or if somebody's looking at you as a proxy and you're not running, you could effectively denial of service the network.

12:07.300 --> 12:14.420
And additionally, I'd also like to add some functionality for the SSL strip and SSL sniff that Moxie's been working on.

12:14.540 --> 12:16.240
That's some pretty good work right there.

12:18.140 --> 12:21.860
So now some curious findings about when I was creating this tool.

12:22.580 --> 12:37.480
One of the things I found out when I started with the WPAD was that when I first updated that DNS record, I had about 320 hosts pinging my laptop as their proxy in about an hour's worth of time.

12:38.660 --> 12:52.220
But in our environment, we don't use, our environment uses a GPO to push out proxy as well as baseline image, so we were getting about 320 hosts that were looking at my laptop to be their proxy.

12:53.520 --> 13:01.880
Also, additionally, not on the slides, is I found that big surprise, IE was the biggest offender of using the WPAD, the autoproxy detection.

13:02.300 --> 13:08.060
But there were still some other browsers in there that were using it as well, such as Firefox and Opera, which was a little bit of a surprise to me.

13:10.360 --> 13:14.720
So there are some things you can do about the WPAD attack.

13:15.080 --> 13:27.400
One of the things is you can serve out the DHCP option 252 yourself, or the DNS option, although browsers look at the DHCP option first, so that would be the better way to go.

13:27.740 --> 13:38.080
Also, you could ensure that the browsers aren't set to use autoproxy detection, and as I mentioned, this only protects against the WPAD, not the ARP spoofing type of attacks.

13:39.760 --> 13:57.220
So below is the URL for the code, and it's hosted at Google, and it has the fine seal of works on my machine approval, so you might get a, your mileage may vary, but again, let me know and I'll always look to fixing it.

13:57.220 --> 13:58.220
So, that's it.

13:58.220 --> 13:58.920
Thanks.

14:06.040 --> 14:08.820
I have time for questions if anyone has any questions.

14:12.840 --> 14:13.120
Yes?

14:14.740 --> 14:16.960
No, I'm not decrypting SSL.

14:16.960 --> 14:36.580
I had actually added functionality originally to create self-signed certificates on the fly, and I had that partially working, but then I figured I'd just back off of that and use Moxie's SSL sniff and SSL stripping, which I intend on putting in there to do that kind of functionality.

14:41.280 --> 14:42.420
Okay, well, thank you.

