[00:00.000 --> 00:05.740] It is my pleasure now, Césaire Pizzi, on problems. [00:07.400 --> 00:12.020] Hello to everyone. Thank you. Can you hear me? Everyone can hear me? Okay, great. [00:13.100 --> 00:19.320] Okay, let's start immediately. I have to fly a bit on the presentation because it's a bit, [00:19.320 --> 00:26.120] maybe a bit long, but okay, let's say I do my best to do everything. Okay, that's about me, [00:26.120 --> 00:32.680] let's skip it. So just a few information about me. I'm a security researcher. I work on a lot of [00:33.320 --> 00:39.600] open source projects. I developed in the past proof of concept for Arduino code injections, [00:39.600 --> 00:45.680] but that's not important. You can have a look to these things in my GitHub. I will leave you [00:45.680 --> 00:50.400] the reference at the end of the presentation. But let's start with the presentation of this [00:50.400 --> 00:59.660] research. So what I started to think was something about the invisible cloud, as I called it, [01:00.160 --> 01:04.900] of the sandboxes. We have a lot of tools out there, which popped out in the last, [01:04.900 --> 01:12.000] I don't know, five years. Sandboxes available for more or less everyone from our side. From [01:12.000 --> 01:19.240] other side, a lot of vendors that are trying to sell this kind of software to be installed in our [01:19.240 --> 01:25.600] environment. Or maybe another option is to install our own sandbox by using, for example, [01:25.600 --> 01:32.040] well-known tool like Cuckoo, for example, which is a great tool. And so we have a lot of these [01:32.040 --> 01:40.320] systems around. And what I thought is, okay, can we try to use them outside of what is their [01:40.320 --> 01:50.580] maybe intended usage? And so I started to try to make some thoughts about this. [01:50.580 --> 01:56.440] And so, okay, first of all, the sandboxes are usually isolated. So our environments are not [01:56.440 --> 02:04.160] able to go anywhere. But maybe we can try to do something about this. And so what if we can get [02:04.160 --> 02:10.080] access to these systems? For example, we can try to get some internal information that maybe are [02:10.080 --> 02:16.780] not mean to be disclosure. For example, serial numbers. For example, the first thing I thought [02:16.780 --> 02:22.120] was the serial number of the office installation, for example. Or maybe we can try to fingerprint [02:22.120 --> 02:29.120] the system to understand if you are in a sandbox. This we can see, we will see later that it's [02:29.120 --> 02:35.020] maybe done for some funny reasons. Or maybe use them as a bridge to go somewhere else, for [02:35.020 --> 02:43.380] example. And maybe other things as well. And so first thing, I try to do a quick list of sandboxes [02:43.380 --> 02:48.280] out there. These are, I know, this is not a complete list. We have tons of them. I just got [02:48.280 --> 02:54.900] this because they are more or less the most famous or in any case used. For example, for sure, [02:54.900 --> 03:01.560] Virustotal, everyone knows what is it. And also the others probably. But there are quite a lot. [03:01.560 --> 03:08.140] So I decided not to do this test manually, but to write a script to automate the actions. And so [03:08.140 --> 03:15.420] I would like to have, okay, I'd like to build something that allowed me to conduct this research. [03:15.460 --> 03:23.340] And that was done not reinventing anything, actually, sorry. But leveraging well-known tools like, [03:23.340 --> 03:28.920] for example, MSVenom from the Metasploit to create the payloads. Or maybe the 7-Zip self-extractor [03:28.920 --> 03:34.580] to create. What I would like to do is to create a kind of self-extracting executable that will [03:34.580 --> 03:39.360] have a callback function, a way to drop files, because I would like to bring with me some [03:39.360 --> 03:45.460] utilities on the sandbox itself. And maybe a kind of randomization, let's say a simple one, [03:45.460 --> 03:52.460] because we all know that the sandboxes are usually doing a basic check about the hashes. [03:52.560 --> 03:57.640] I would like to avoid this to trigger in any case, every time I upload the sample, a new analysis. So [03:57.640 --> 04:06.260] I created something to address this issue. And so that's not rocket science, just it's a quick [04:06.260 --> 04:12.900] and dirty Python script, nothing really special, but I will release it on GitHub, on my GitHub at [04:12.900 --> 04:18.640] the end of the DevCon. So you can try to use it, okay, you can write your own. It's the same, [04:18.640 --> 04:23.980] probably it's not so difficult to do it, but it allowed me to automate this research. So [04:23.980 --> 04:31.880] how it works, it's in some way the script itself, it's able to leverage the MSVenom capabilities [04:31.880 --> 04:38.740] to create a specific payload with a specific callback IPM port. It has the possibility to [04:38.740 --> 04:47.500] specify a folder where I can put my utilities, and also way to script my actions when I try to [04:47.500 --> 04:52.720] upload this on the sandbox. Okay, for example, here we can see an example of the drop folder. [04:52.720 --> 04:57.180] It's just a folder where I put all my utilities. For example, here you can see that I would like [04:57.180 --> 05:03.920] to upload on the sandbox the qrl.txe and the product-key.txe. Product-key.txe is an utility [05:03.920 --> 05:11.080] for Nimsoft, which is extracting the Microsoft Office product key, for example, from the system. [05:11.420 --> 05:16.700] And I would like to bring this on the sandbox itself. So at the end, when we run the script, [05:16.700 --> 05:22.760] I will have something like that. So a kind of self-extracting executable with [05:23.340 --> 05:29.620] some scrambled name, as you can see here, you see some .txt, .txt files, which are the [05:29.620 --> 05:36.520] qrl.txe we saw before. Scrambled names with scrambled content as well, because I would [05:36.520 --> 05:43.160] like, as I said, to avoid the hash detections. And so that is what will be created. [05:43.160 --> 05:48.760] Together with this, we will see also a setup.bat or setup.sh, which has an underscore [05:49.680 --> 05:56.880] at the beginning with the actions I would like to automate. Okay. The underscore means, [05:56.880 --> 06:02.740] okay, don't touch this file. Tag to my script to not touch the file, but just put it into the [06:02.740 --> 06:08.260] package without scrambling it, because in some case, I don't want to rename it. [06:09.380 --> 06:13.080] And so let's start with the case one. So I would like to try to get a reverse shell [06:13.080 --> 06:19.260] out from the sandboxes. So I run the script with this syntax here, very simple. And I [06:19.260 --> 06:24.780] uploaded it on all these sandboxes mentioned at the beginning. And this is the result. [06:24.780 --> 06:30.560] As you can see here, a lot of them gave me actually a shell. For some of them, it's not [06:30.560 --> 06:34.500] actually surprising. Any run, for example, allow you interactive access. So, okay, it's [06:34.500 --> 06:41.000] not a big issue. But for some other, maybe it's more surprising. And what I would like [06:41.000 --> 06:49.040] to stress is here, the behavior of Palo Alto and VirusTotal. Both of them gave me TCP callback, [06:49.040 --> 06:55.620] but then the connection went down. Like if there is a kind of IPS or something monitoring [06:55.620 --> 07:00.140] the outgoing connection of the system, probably they have something which was recognizing that [07:00.140 --> 07:08.440] I tried to open a reverse shell and they cut off the connection. But let's keep in mind this [07:08.440 --> 07:14.740] because we'll come back on this later on and we'll see something funny. Okay, now I have a [07:14.740 --> 07:20.260] reverse shell on the system, but why this is relevant? Why I should be worried about? Because [07:20.260 --> 07:27.080] I can actually extract information from them. Here, you can see I run the productkey.txt [07:27.080 --> 07:33.000] and I got the office installation product keys. I removed them from privacy here, obviously, [07:33.000 --> 07:39.220] but they were there. And so why this is important? That's really important from my point of view, [07:39.220 --> 07:43.580] from a point of view of a malware researcher, for example. But first of all, consider that [07:44.540 --> 07:49.720] this is a private information that probably someone don't want to disclose. Especially if [07:49.720 --> 07:54.120] you are running your own sandbox, this is something that you have to consider because, [07:54.120 --> 07:59.260] okay, if you are relying on something that is provided by an IT vendor, we don't care. We just [07:59.260 --> 08:07.340] use what our firewall vendor is providing us as a sandbox. But okay, it's their business if [08:07.340 --> 08:14.140] they are losing the office keys. If you are running our own, that's very important. But [08:14.140 --> 08:22.240] what is, in my opinion, the most important thing here is that this allows to leak information from [08:22.240 --> 08:28.880] this. And this allows the fingerprinting of the system. This is already happening. A lot of [08:28.880 --> 08:37.400] malware is doing this. I came across a sample a couple of weeks ago of the Okai keylogger, [08:37.400 --> 08:45.420] which the installer was checking for the username of the system. Username that they will get from [08:45.420 --> 08:52.420] probably VirusTotal or a sandbox like that one. And so that's really important because that means [08:52.980 --> 09:00.940] that if the sample is able to identify it, it can also be the analysis. So it can [09:02.900 --> 09:10.720] make the most undetectable sandboxes useless, let's say. Okay, this is a quick demo of what [09:11.120 --> 09:23.240] I did. So here I tried to upload a sample on the SND box. As you can see on your left side, yes, [09:23.240 --> 09:33.440] there was Metasploit running. As you can see, I got the reversal here. And then I was able to [09:37.140 --> 09:44.020] extract the product key, for example. Here, obviously, I removed. So let's go to the case 2. [09:44.020 --> 09:49.460] So I named it cross sandbox spawning. What it means, we saw that we have external access from [09:49.460 --> 09:54.980] the systems. So that means that also we can try to maybe try to run an attack against someone else. [09:55.640 --> 10:01.300] If I upload something that is doing, let's say, a SQL injection or something like that [10:01.300 --> 10:07.360] to a third-party site, I can do it. Again, this may be not very interesting for us if [10:08.280 --> 10:13.880] we are using third-party sandboxes, but if we are running our own, it's really important because [10:15.200 --> 10:21.300] someone could knock on our door and asking us why you did something wrong on that site. So [10:21.900 --> 10:26.500] this is something we need to keep in mind. Here, this is a simple setup I did on my script. So [10:26.500 --> 10:32.600] I just created this script here. As you can see, there is a qrl.exe running. In this case, [10:32.600 --> 10:37.620] not a real attack. It's just an upload of a file. But it would be interesting for the third case. [10:37.620 --> 10:44.320] So let's keep this in mind. So as you can see, the qrl.exe here is angle bracketed because it [10:44.320 --> 10:53.180] will be replaced automatically by the script with the scrambled name of the file when the file is [10:53.180 --> 10:58.980] renamed. So it will be done automatically by the script. And so this is the result of the test. [10:59.140 --> 11:03.980] As you can see, and I would like to stress, the Palo Alto and Virus Total sandboxes are [11:03.980 --> 11:11.980] allowing me to do this. And that will bring us to the third case. Okay. Why this is relevant? [11:12.080 --> 11:18.100] Because we have to consider a couple of things. One is that, okay, we can use something to proxy [11:18.100 --> 11:23.240] attacks to someone else. This is something that we can take in consideration. Second point, [11:23.860 --> 11:32.040] sometimes these sandboxes are really in our infrastructure. And sometimes we don't even [11:32.040 --> 11:39.100] have a real perception of that. Because, for example, our anti-spam vendor may have his [11:39.960 --> 11:45.060] sandboxes and maybe someone can just run an attack against someone else by sending an email to us, [11:45.060 --> 11:52.900] for example. Because it just executes the payload and so on. Other thing that is interesting is [11:52.900 --> 12:01.280] this example of zero effort exploit as described in Science on the Wire book, which is a great [12:01.280 --> 12:10.440] book if you work in security field. So have a read of it. So let's have a look to the demo as well. [12:13.200 --> 12:23.760] So here I'm uploading the demo on the site and then I'm looking for my on the hybrid analysis, [12:23.760 --> 12:33.880] which is a well-known sandbox. Then I created a fake site, just waiting for an info.php [12:33.880 --> 12:41.540] file to be uploaded. And we can see here that, okay, I got this file uploaded on the sandbox [12:41.540 --> 12:48.460] itself. And this worked for all the sandboxes we saw before. And that is bringing us [12:48.460 --> 12:55.600] to the third case. So let's try to do something creative to combine the two things we did before. [12:55.600 --> 13:03.560] So, okay, we saw that some of the sandboxes looks like preventing us to get access into [13:03.560 --> 13:10.060] leak information. But if we combine the second case, maybe we can do something. So I created [13:10.060 --> 13:16.640] another little script, which has been processed by my Python script, which is just combining the [13:16.640 --> 13:23.240] qrl.exe, so the upload of the file with the product key.exe. So I just, as you can see here, [13:23.240 --> 13:35.860] 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:50.340] So that means that also in this case, I was able to get this, let's say, something that [13:50.340 --> 13:58.380] is not supposed to be disclosed. And so let's have a look here of the, again, a quick demo, [13:58.380 --> 14:06.720] in this case on the Palo Alto wildfire sandbox. So I uploaded the payload. [14:11.860 --> 14:15.560] And then in a while, I will see that I will have the file uploaded [14:17.280 --> 14:25.540] on my site with all the leaked information I will have to get. So here it is. And so we can get [14:25.540 --> 14:33.740] the information out. Okay. Maybe we can also use this system to do some other things because [14:33.740 --> 14:40.400] it's just three cases, very quick. But we can try to do other things like, for example, [14:40.920 --> 14:44.580] test your own sandbox. If you are running your own sandbox in your environment, that's something I [14:44.580 --> 14:51.000] encourage you to do for sure, because maybe someone is not realizing that some kind of [14:51.000 --> 14:58.880] information may be sent out without big effort. So it's something that you need to check. Maybe [14:58.880 --> 15:06.260] try two different fingerprinting techniques because there's really a wall here. You can get [15:06.260 --> 15:10.820] every kind of information out of the sandbox, beginning from the shellbacks, the shim cache [15:10.820 --> 15:17.840] content, and so on. All this information allows someone to do a very, very precise fingerprinting [15:17.840 --> 15:24.500] on the system and maybe understanding also which is the specific sandbox he is running on. So [15:24.500 --> 15:31.240] that's something that you have to take into consideration. Also, I added this build a [15:31.240 --> 15:35.520] database with the result and fingerprinting server sandbox. This is not a good idea. I don't know if [15:35.520 --> 15:46.000] maybe it can be used for nefarious ways. And then, okay, you can try some other things like, [15:46.000 --> 15:53.420] I don't know, I thought mining maybe, no, maybe not because I think the running time is limited [15:53.420 --> 16:02.060] to 15 minutes usually or something like that. So mining is not probably a real thing to do, but [16:02.060 --> 16:11.180] okay, it's something you can try. So this is the summary of what I did. So the results on the [16:11.180 --> 16:16.280] several sandboxes with the specific test I run. [16:18.080 --> 16:25.360] And a sample of collected data. Here I'm focused mainly on the office product key, which were [16:25.360 --> 16:31.460] obviously redacted here for privacy, but you can get everything out from the systems. It's [16:31.460 --> 16:42.260] just a matter of thinking what you want to get. Are offline sandbox safer? You know, [16:42.260 --> 16:47.380] and we saw that there are some vendors not allowing us any kind of external access. [16:47.880 --> 16:54.940] So are they safer? Maybe yes, a little bit, because in case of an APT, for example, let's [16:54.940 --> 17:03.220] think about the terminal attacker. In this case, maybe it can't just get access to your [17:03.220 --> 17:09.740] technology. So if I have FireEye, which is not allowing maybe external access, but they can get [17:09.740 --> 17:19.100] the appliance, I can try to run the fingerprinting on that specific sandbox and so extract this [17:19.100 --> 17:25.360] information anyway, because what these sandboxes are doing are creating very detailed report on [17:25.360 --> 17:32.600] what the sample is doing. So maybe just writing a registry key with the content I would like to [17:32.600 --> 17:40.260] extract, for example, the product key of office or any other information, I can just get the [17:40.260 --> 17:46.240] information out. So they are safer probably, but not completely safe in this point. [17:46.900 --> 17:50.420] Remediations. Okay, which are the remediation is not easy, because I understand that this is [17:50.420 --> 17:56.280] part of the sandbox functionality, so not easy to block this kind of behaviors. [17:57.300 --> 18:01.180] But it's something we have to consider and the vendors have to consider, because [18:01.720 --> 18:09.500] it's really maybe dangerous in some cases. For example, an IPS on the outside connection is a [18:09.500 --> 18:14.000] solution that probably is already in place for some of the vendors, as we saw at the beginning [18:14.000 --> 18:20.700] of the presentation. Also, our web application firewall may be masking information going out. [18:20.700 --> 18:29.620] It's another solution that could be considered. And for, let's say, for internal information, [18:29.620 --> 18:34.480] probably the best solution is randomize as much as possible. But it's not the easy one. [18:35.160 --> 18:42.400] Randomization for sure is the one that could allow to avoid this kind of issues, but it's [18:42.400 --> 18:47.580] for sure not the easy solution, so it's not a quick one. Probably the quick and dirty solution [18:47.580 --> 18:55.700] is running a kind of IPS or something in outgoing connections. Disclosure, I did it, yes, obviously. [18:57.600 --> 19:03.900] The only reply I got was from the guys at VirusTotal. They were very interested in the [19:03.900 --> 19:09.140] thing, so they work and so thumbs up for them, because they took it seriously and they started [19:09.140 --> 19:18.980] to think something about this, so very good. All the others, more or less, didn't give me a reply [19:18.980 --> 19:26.360] about the disclosure. Okay, these are the references of all the tools I used in the [19:28.860 --> 19:37.960] creation of this research. So Metasploit for sure, 7zip, the DVWA site for the creation of [19:39.140 --> 19:49.380] the site and some utilities. And so let's wrap up. Okay, at the end, the sandboxes are useless? No, [19:49.380 --> 19:56.400] I don't think so. I think that we can just understand how they work and how much trust [19:56.400 --> 20:03.000] we can put in them, because, as you can see, it may be easier than what we expect to evade the [20:03.000 --> 20:09.940] analysis. So thinking that we are safe because we have a sandbox in our environment, checking [20:09.940 --> 20:18.480] every file downloaded on the firewall or checking every mail coming in, it's okay. But you have to [20:18.480 --> 20:24.840] understand how these things are working and maybe you can also try to run your own test on that, [20:24.840 --> 20:30.300] because sometimes vendors are just selling these things to us saying, okay, with this you [20:30.300 --> 20:38.680] are 100% safe, the sandbox itself is undetectable. Okay, I trust you, but let's try to run a couple [20:38.680 --> 20:47.460] of tests on them and maybe then ask for a discount for it. 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:58.780] And that's all. So thank you for me. I don't know if you have any questions. [21:01.480 --> 21:08.360] Okay, thank you very much. Thanks for being here and thanks a lot. Enjoy your DEF CON.