WEBVTT

00:00.000 --> 00:05.740
It is my pleasure now, Césaire Pizzi, on problems.

00:07.400 --> 00:08.840
Hello to everyone.

00:08.840 --> 00:09.620
Thank you.

00:09.620 --> 00:10.400
Can you hear me?

00:10.400 --> 00:11.160
Everyone can hear me?

00:11.160 --> 00:12.020
Okay, great.

00:13.100 --> 00:16.040
Okay, let's start immediately.

00:16.040 --> 00:23.640
I have to fly a bit on the presentation because it's a bit, maybe a bit long, but okay, let's say I do my best to do everything.

00:23.960 --> 00:27.160
Okay, that's about me, let's skip it.

00:27.160 --> 00:29.360
So just a few information about me.

00:29.360 --> 00:31.380
I'm a security researcher.

00:31.380 --> 00:34.780
I work on a lot of open source projects.

00:34.780 --> 00:41.060
I developed in the past proof of concept for Arduino code injections, but that's not important.

00:41.060 --> 00:44.460
You can have a look to these things in my GitHub.

00:44.560 --> 00:47.240
I will leave you the reference at the end of the presentation.

00:47.240 --> 00:51.220
But let's start with the presentation of this research.

00:51.220 --> 01:01.480
So what I started to think was something about the invisible cloud, as I called it, of the sandboxes.

01:01.480 --> 01:06.840
We have a lot of tools out there, which popped out in the last, I don't know, five years.

01:07.580 --> 01:11.820
Sandboxes available for more or less everyone from our side.

01:11.820 --> 01:19.840
From other side, a lot of vendors that are trying to sell this kind of software to be installed in our environment.

01:19.840 --> 01:30.060
Or maybe another option is to install our own sandbox by using, for example, well-known tool like Cuckoo, for example, which is a great tool.

01:30.460 --> 01:33.580
And so we have a lot of these systems around.

01:33.800 --> 01:43.420
And what I thought is, okay, can we try to use them outside of what is their maybe intended usage?

01:44.420 --> 01:50.580
And so I started to try to make some thoughts about this.

01:50.580 --> 01:54.900
And so, okay, first of all, the sandboxes are usually isolated.

01:54.900 --> 01:58.400
So our environments are not able to go anywhere.

01:58.660 --> 02:02.120
But maybe we can try to do something about this.

02:02.120 --> 02:05.640
And so what if we can get access to these systems?

02:05.720 --> 02:13.640
For example, we can try to get some internal information that maybe are not mean to be disclosure.

02:13.640 --> 02:14.960
For example, serial numbers.

02:14.960 --> 02:20.180
For example, the first thing I thought was the serial number of the office installation, for example.

02:20.180 --> 02:26.560
Or maybe we can try to fingerprint the system to understand if you are in a sandbox.

02:26.560 --> 02:31.640
This we can see, we will see later that it's maybe done for some funny reasons.

02:31.640 --> 02:35.780
Or maybe use them as a bridge to go somewhere else, for example.

02:35.940 --> 02:38.140
And maybe other things as well.

02:38.480 --> 02:44.220
And so first thing, I try to do a quick list of sandboxes out there.

02:44.240 --> 02:46.820
These are, I know, this is not a complete list.

02:46.820 --> 02:47.740
We have tons of them.

02:47.740 --> 02:53.800
I just got this because they are more or less the most famous or in any case used.

02:53.800 --> 02:56.860
For example, for sure, Virustotal, everyone knows what is it.

02:56.860 --> 02:58.920
And also the others probably.

02:58.980 --> 03:01.560
But there are quite a lot.

03:01.560 --> 03:07.600
So I decided not to do this test manually, but to write a script to automate the actions.

03:07.800 --> 03:15.420
And so I would like to have, okay, I'd like to build something that allowed me to conduct this research.

03:15.460 --> 03:20.300
And that was done not reinventing anything, actually, sorry.

03:20.320 --> 03:26.720
But leveraging well-known tools like, for example, MSVenom from the Metasploit to create the payloads.

03:26.720 --> 03:29.800
Or maybe the 7-Zip self-extractor to create.

03:29.800 --> 03:41.900
What I would like to do is to create a kind of self-extracting executable that will have a callback function, a way to drop files, because I would like to bring with me some utilities on the sandbox itself.

03:41.980 --> 03:52.460
And maybe a kind of randomization, let's say a simple one, because we all know that the sandboxes are usually doing a basic check about the hashes.

03:52.560 --> 03:57.520
I would like to avoid this to trigger in any case, every time I upload the sample, a new analysis.

03:57.520 --> 04:01.780
So I created something to address this issue.

04:02.280 --> 04:14.200
And so that's not rocket science, just it's a quick and dirty Python script, nothing really special, but I will release it on GitHub, on my GitHub at the end of the DevCon.

04:14.200 --> 04:17.860
So you can try to use it, okay, you can write your own.

04:17.860 --> 04:23.980
It's the same, probably it's not so difficult to do it, but it allowed me to automate this research.

04:23.980 --> 04:36.880
So how it works, it's in some way the script itself, it's able to leverage the MSVenom capabilities to create a specific payload with a specific callback IPM port.

04:37.320 --> 04:49.080
It has the possibility to specify a folder where I can put my utilities, and also way to script my actions when I try to upload this on the sandbox.

04:49.780 --> 04:52.720
Okay, for example, here we can see an example of the drop folder.

04:52.720 --> 04:55.260
It's just a folder where I put all my utilities.

04:55.260 --> 05:01.400
For example, here you can see that I would like to upload on the sandbox the qrl.txe and the product-key.txe.

05:01.400 --> 05:11.080
Product-key.txe is an utility for Nimsoft, which is extracting the Microsoft Office product key, for example, from the system.

05:11.420 --> 05:14.560
And I would like to bring this on the sandbox itself.

05:14.720 --> 05:18.880
So at the end, when we run the script, I will have something like that.

05:18.880 --> 05:32.560
So a kind of self-extracting executable with some scrambled name, as you can see here, you see some .txt, .txt files, which are the qrl.txe we saw before.

05:32.680 --> 05:39.080
Scrambled names with scrambled content as well, because I would like, as I said, to avoid the hash detections.

05:39.080 --> 05:43.160
And so that is what will be created.

05:43.160 --> 05:53.820
Together with this, we will see also a setup.bat or setup.sh, which has an underscore at the beginning with the actions I would like to automate.

05:54.060 --> 05:54.700
Okay.

05:54.880 --> 05:58.600
The underscore means, okay, don't touch this file.

05:58.920 --> 06:08.260
Tag to my script to not touch the file, but just put it into the package without scrambling it, because in some case, I don't want to rename it.

06:09.380 --> 06:10.900
And so let's start with the case one.

06:10.900 --> 06:14.700
So I would like to try to get a reverse shell out from the sandboxes.

06:14.700 --> 06:17.780
So I run the script with this syntax here, very simple.

06:18.000 --> 06:23.480
And I uploaded it on all these sandboxes mentioned at the beginning.

06:23.480 --> 06:24.780
And this is the result.

06:24.780 --> 06:29.400
As you can see here, a lot of them gave me actually a shell.

06:29.400 --> 06:31.340
For some of them, it's not actually surprising.

06:31.340 --> 06:33.820
Any run, for example, allow you interactive access.

06:33.820 --> 06:35.640
So, okay, it's not a big issue.

06:35.920 --> 06:40.080
But for some other, maybe it's more surprising.

06:40.080 --> 06:45.960
And what I would like to stress is here, the behavior of Palo Alto and VirusTotal.

06:46.040 --> 06:52.340
Both of them gave me TCP callback, but then the connection went down.

06:52.340 --> 07:06.020
Like if there is a kind of IPS or something monitoring the outgoing connection of the system, probably they have something which was recognizing that I tried to open a reverse shell and they cut off the connection.

07:06.020 --> 07:12.540
But let's keep in mind this because we'll come back on this later on and we'll see something funny.

07:13.220 --> 07:16.840
Okay, now I have a reverse shell on the system, but why this is relevant?

07:16.840 --> 07:18.900
Why I should be worried about?

07:19.000 --> 07:22.700
Because I can actually extract information from them.

07:22.860 --> 07:30.560
Here, you can see I run the productkey.txt and I got the office installation product keys.

07:30.560 --> 07:34.460
I removed them from privacy here, obviously, but they were there.

07:35.000 --> 07:36.640
And so why this is important?

07:36.940 --> 07:41.740
That's really important from my point of view, from a point of view of a malware researcher, for example.

07:41.800 --> 07:49.080
But first of all, consider that this is a private information that probably someone don't want to disclose.

07:49.080 --> 07:58.920
Especially if you are running your own sandbox, this is something that you have to consider because, okay, if you are relying on something that is provided by an IT vendor, we don't care.

07:58.920 --> 08:05.820
We just use what our firewall vendor is providing us as a sandbox.

08:05.820 --> 08:09.720
But okay, it's their business if they are losing the office keys.

08:09.920 --> 08:13.800
If you are running our own, that's very important.

08:13.960 --> 08:22.900
But what is, in my opinion, the most important thing here is that this allows to leak information from this.

08:22.900 --> 08:26.900
And this allows the fingerprinting of the system.

08:26.940 --> 08:28.240
This is already happening.

08:28.240 --> 08:30.500
A lot of malware is doing this.

08:30.520 --> 08:44.160
I came across a sample a couple of weeks ago of the Okai keylogger, which the installer was checking for the username of the system.

08:44.160 --> 08:49.800
Username that they will get from probably VirusTotal or a sandbox like that one.

08:49.800 --> 08:59.900
And so that's really important because that means that if the sample is able to identify it, it can also be the analysis.

08:59.900 --> 09:08.680
So it can make the most undetectable sandboxes useless, let's say.

09:09.060 --> 09:11.700
Okay, this is a quick demo of what I did.

09:11.700 --> 09:18.300
So here I tried to upload a sample on the SND box.

09:19.020 --> 09:26.580
As you can see on your left side, yes, there was Metasploit running.

09:26.580 --> 09:31.560
As you can see, I got the reversal here.

09:31.600 --> 09:33.440
And then I was able to

09:37.140 --> 09:40.040
extract the product key, for example.

09:40.040 --> 09:41.560
Here, obviously, I removed.

09:42.260 --> 09:44.020
So let's go to the case 2.

09:44.020 --> 09:46.620
So I named it cross sandbox spawning.

09:46.680 --> 09:50.320
What it means, we saw that we have external access from the systems.

09:50.400 --> 09:54.980
So that means that also we can try to maybe try to run an attack against someone else.

09:55.640 --> 10:04.220
If I upload something that is doing, let's say, a SQL injection or something like that to a third-party site, I can do it.

10:04.220 --> 10:21.300
Again, this may be not very interesting for us if we are using third-party sandboxes, but if we are running our own, it's really important because someone could knock on our door and asking us why you did something wrong on that site.

10:21.300 --> 10:23.680
So this is something we need to keep in mind.

10:23.680 --> 10:26.380
Here, this is a simple setup I did on my script.

10:26.380 --> 10:28.980
So I just created this script here.

10:28.980 --> 10:31.860
As you can see, there is a qrl.exe running.

10:32.020 --> 10:33.440
In this case, not a real attack.

10:33.440 --> 10:35.140
It's just an upload of a file.

10:35.200 --> 10:37.620
But it would be interesting for the third case.

10:37.620 --> 10:40.240
So let's keep this in mind.

10:40.240 --> 10:53.660
So as you can see, the qrl.exe here is angle bracketed because it will be replaced automatically by the script with the scrambled name of the file when the file is renamed.

10:53.660 --> 10:56.020
So it will be done automatically by the script.

10:56.540 --> 10:58.980
And so this is the result of the test.

10:59.140 --> 11:05.660
As you can see, and I would like to stress, the Palo Alto and Virus Total sandboxes are allowing me to do this.

11:06.580 --> 11:09.280
And that will bring us to the third case.

11:09.540 --> 11:10.140
Okay.

11:10.480 --> 11:11.980
Why this is relevant?

11:12.080 --> 11:13.900
Because we have to consider a couple of things.

11:13.900 --> 11:19.320
One is that, okay, we can use something to proxy attacks to someone else.

11:19.320 --> 11:22.360
This is something that we can take in consideration.

11:22.600 --> 11:30.560
Second point, sometimes these sandboxes are really in our infrastructure.

11:30.560 --> 11:35.180
And sometimes we don't even have a real perception of that.

11:35.180 --> 11:45.860
Because, for example, our anti-spam vendor may have his sandboxes and maybe someone can just run an attack against someone else by sending an email to us, for example.

11:45.860 --> 11:51.340
Because it just executes the payload and so on.

11:51.360 --> 12:03.980
Other thing that is interesting is this example of zero effort exploit as described in Science on the Wire book, which is a great book if you work in security field.

12:03.980 --> 12:06.560
So have a read of it.

12:07.220 --> 12:10.440
So let's have a look to the demo as well.

12:13.200 --> 12:25.520
So here I'm uploading the demo on the site and then I'm looking for my on the hybrid analysis, which is a well-known sandbox.

12:27.240 --> 12:35.420
Then I created a fake site, just waiting for an info.php file to be uploaded.

12:36.400 --> 12:42.240
And we can see here that, okay, I got this file uploaded on the sandbox itself.

12:42.240 --> 12:46.020
And this worked for all the sandboxes we saw before.

12:46.720 --> 12:50.620
And that is bringing us to the third case.

12:50.620 --> 12:55.600
So let's try to do something creative to combine the two things we did before.

12:55.600 --> 13:04.480
So , okay, we saw that some of the sandboxes looks like preventing us to get access into leak information.

13:04.480 --> 13:08.920
But if we combine the second case, maybe we can do something.

13:08.920 --> 13:21.000
So I created another little script, which has been processed by my Python script, which is just combining the qrl.exe, so the upload of the file with the product key.exe.

13:21.000 --> 13:35.860
So I just, as you can see here, redirected the output of the product key.exe in a file and then try to upload it on my site.

13:36.540 --> 13:42.640
And actually, I was able in this way to extract information from both Palo Alto and VirusTotal.

13:42.640 --> 13:52.820
So that means that also in this case, I was able to get this, let's say, something that is not supposed to be disclosed.

13:53.320 --> 14:02.500
And so let's have a look here of the, again, a quick demo, in this case on the Palo Alto wildfire sandbox.

14:02.620 --> 14:06.720
So I uploaded the payload.

14:11.860 --> 14:23.040
And then in a while, I will see that I will have the file uploaded on my site with all the leaked information I will have to get.

14:23.040 --> 14:24.320
So here it is.

14:24.320 --> 14:27.080
And so we can get the information out.

14:29.000 --> 14:29.960
Okay.

14:30.420 --> 14:35.760
Maybe we can also use this system to do some other things because it's just three cases, very quick.

14:36.740 --> 14:41.800
But we can try to do other things like, for example, test your own sandbox.

14:41.800 --> 14:55.960
If you are running your own sandbox in your environment, that's something I encourage you to do for sure, because maybe someone is not realizing that some kind of information may be sent out without big effort.

14:55.960 --> 14:58.620
So it's something that you need to check.

14:58.680 --> 15:05.540
Maybe try two different fingerprinting techniques because there's really a wall here.

15:05.540 --> 15:12.100
You can get every kind of information out of the sandbox, beginning from the shellbacks, the shim cache content, and so on.

15:12.100 --> 15:24.420
All this information allows someone to do a very, very precise fingerprinting on the system and maybe understanding also which is the specific sandbox he is running on.

15:24.420 --> 15:28.460
So that's something that you have to take into consideration.

15:29.280 --> 15:33.220
Also, I added this build a database with the result and fingerprinting server sandbox.

15:33.220 --> 15:34.620
This is not a good idea.

15:34.620 --> 15:42.460
I don't know if maybe it can be used for nefarious ways.

15:42.540 --> 15:55.920
And then, okay, you can try some other things like, I don't know, I thought mining maybe, no, maybe not because I think the running time is limited to 15 minutes usually or something like that.

15:55.920 --> 16:05.300
So mining is not probably a real thing to do, but okay, it's something you can try.

16:05.300 --> 16:08.580
So this is the summary of what I did.

16:08.580 --> 16:16.280
So the results on the several sandboxes with the specific test I run.

16:18.080 --> 16:20.760
And a sample of collected data.

16:20.760 --> 16:31.300
Here I'm focused mainly on the office product key, which were obviously redacted here for privacy, but you can get everything out from the systems.

16:31.300 --> 16:36.700
It's just a matter of thinking what you want to get.

16:38.060 --> 16:40.180
Are offline sandbox safer?

16:40.960 --> 16:47.380
You know, and we saw that there are some vendors not allowing us any kind of external access.

16:47.880 --> 16:49.060
So are they safer?

16:49.060 --> 16:57.040
Maybe yes, a little bit, because in case of an APT, for example, let's think about the terminal attacker.

16:58.360 --> 17:04.060
In this case, maybe it can't just get access to your technology.

17:04.060 --> 17:27.960
So if I have FireEye, which is not allowing maybe external access, but they can get the appliance, I can try to run the fingerprinting on that specific sandbox and so extract this information anyway, because what these sandboxes are doing are creating very detailed report on what the sample is doing.

17:27.960 --> 17:41.080
So maybe just writing a registry key with the content I would like to extract, for example, the product key of office or any other information, I can just get the information out.

17:41.080 --> 17:46.240
So they are safer probably, but not completely safe in this point.

17:46.900 --> 17:47.480
Remediations.

17:47.480 --> 17:56.280
Okay, which are the remediation is not easy, because I understand that this is part of the sandbox functionality, so not easy to block this kind of behaviors.

17:57.300 --> 18:05.240
But it's something we have to consider and the vendors have to consider, because it's really maybe dangerous in some cases.

18:06.420 --> 18:15.420
For example, an IPS on the outside connection is a solution that probably is already in place for some of the vendors, as we saw at the beginning of the presentation.

18:15.700 --> 18:20.700
Also, our web application firewall may be masking information going out.

18:20.700 --> 18:24.220
It's another solution that could be considered.

18:24.520 --> 18:32.300
And for, let's say, for internal information, probably the best solution is randomize as much as possible.

18:32.300 --> 18:34.480
But it's not the easy one.

18:35.160 --> 18:45.220
Randomization for sure is the one that could allow to avoid this kind of issues, but it's for sure not the easy solution, so it's not a quick one.

18:45.220 --> 18:51.780
Probably the quick and dirty solution is running a kind of IPS or something in outgoing connections.

18:53.100 --> 18:55.700
Disclosure, I did it, yes, obviously.

18:57.600 --> 19:01.220
The only reply I got was from the guys at VirusTotal.

19:02.200 --> 19:14.300
They were very interested in the thing, so they work and so thumbs up for them, because they took it seriously and they started to think something about this, so very good.

19:14.340 --> 19:20.760
All the others, more or less, didn't give me a reply about the disclosure.

19:21.640 --> 19:30.660
Okay, these are the references of all the tools I used in the creation of this research.

19:30.660 --> 19:42.560
So Metasploit for sure, 7zip, the DVWA site for the creation of the site and some utilities.

19:43.460 --> 19:44.800
And so let's wrap up.

19:45.500 --> 19:49.240
Okay, at the end, the sandboxes are useless?

19:49.240 --> 19:50.420
No, I don't think so.

19:50.420 --> 20:03.500
I think that we can just understand how they work and how much trust we can put in them, because, as you can see, it may be easier than what we expect to evade the analysis.

20:03.500 --> 20:15.840
So thinking that we are safe because we have a sandbox in our environment, checking every file downloaded on the firewall or checking every mail coming in, it's okay.

20:15.860 --> 20:35.040
But you have to understand how these things are working and maybe you can also try to run your own test on that, because sometimes vendors are just selling these things to us saying, okay, with this you are 100% safe, the sandbox itself is undetectable.

20:35.140 --> 20:42.480
Okay, I trust you, but let's try to run a couple of tests on them and maybe then ask for a discount for it.

20:44.020 --> 20:47.460
Okay, this is my GitHub.

20:47.980 --> 20:52.040
So if you want to have a look at the presentation, the script, I will publish everything there.

20:52.520 --> 20:55.120
And that's all.

20:55.180 --> 20:57.520
So thank you for me.

20:57.520 --> 20:58.780
I don't know if you have any questions.

21:01.480 --> 21:03.700
Okay, thank you very much.

21:03.700 --> 21:07.000
Thanks for being here and thanks a lot.

21:07.200 --> 21:08.360
Enjoy your DEF CON.

