1 00:00:00,000 --> 00:00:05,740 It is my pleasure now, Césaire Pizzi, on problems. 2 00:00:07,400 --> 00:00:08,840 Hello to everyone. 3 00:00:08,840 --> 00:00:09,620 Thank you. 4 00:00:09,620 --> 00:00:10,400 Can you hear me? 5 00:00:10,400 --> 00:00:11,160 Everyone can hear me? 6 00:00:11,160 --> 00:00:12,020 Okay, great. 7 00:00:13,100 --> 00:00:16,040 Okay, let's start immediately. 8 00:00:16,040 --> 00: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. 9 00:00:23,960 --> 00:00:27,160 Okay, that's about me, let's skip it. 10 00:00:27,160 --> 00:00:29,360 So just a few information about me. 11 00:00:29,360 --> 00:00:31,380 I'm a security researcher. 12 00:00:31,380 --> 00:00:34,780 I work on a lot of open source projects. 13 00:00:34,780 --> 00:00:41,060 I developed in the past proof of concept for Arduino code injections, but that's not important. 14 00:00:41,060 --> 00:00:44,460 You can have a look to these things in my GitHub. 15 00:00:44,560 --> 00:00:47,240 I will leave you the reference at the end of the presentation. 16 00:00:47,240 --> 00:00:51,220 But let's start with the presentation of this research. 17 00:00:51,220 --> 00:01:01,480 So what I started to think was something about the invisible cloud, as I called it, of the sandboxes. 18 00:01:01,480 --> 00:01:06,840 We have a lot of tools out there, which popped out in the last, I don't know, five years. 19 00:01:07,580 --> 00:01:11,820 Sandboxes available for more or less everyone from our side. 20 00:01:11,820 --> 00: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. 21 00:01:19,840 --> 00: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. 22 00:01:30,460 --> 00:01:33,580 And so we have a lot of these systems around. 23 00:01:33,800 --> 00:01:43,420 And what I thought is, okay, can we try to use them outside of what is their maybe intended usage? 24 00:01:44,420 --> 00:01:50,580 And so I started to try to make some thoughts about this. 25 00:01:50,580 --> 00:01:54,900 And so, okay, first of all, the sandboxes are usually isolated. 26 00:01:54,900 --> 00:01:58,400 So our environments are not able to go anywhere. 27 00:01:58,660 --> 00:02:02,120 But maybe we can try to do something about this. 28 00:02:02,120 --> 00:02:05,640 And so what if we can get access to these systems? 29 00:02:05,720 --> 00:02:13,640 For example, we can try to get some internal information that maybe are not mean to be disclosure. 30 00:02:13,640 --> 00:02:14,960 For example, serial numbers. 31 00:02:14,960 --> 00:02:20,180 For example, the first thing I thought was the serial number of the office installation, for example. 32 00:02:20,180 --> 00:02:26,560 Or maybe we can try to fingerprint the system to understand if you are in a sandbox. 33 00:02:26,560 --> 00:02:31,640 This we can see, we will see later that it's maybe done for some funny reasons. 34 00:02:31,640 --> 00:02:35,780 Or maybe use them as a bridge to go somewhere else, for example. 35 00:02:35,940 --> 00:02:38,140 And maybe other things as well. 36 00:02:38,480 --> 00:02:44,220 And so first thing, I try to do a quick list of sandboxes out there. 37 00:02:44,240 --> 00:02:46,820 These are, I know, this is not a complete list. 38 00:02:46,820 --> 00:02:47,740 We have tons of them. 39 00:02:47,740 --> 00:02:53,800 I just got this because they are more or less the most famous or in any case used. 40 00:02:53,800 --> 00:02:56,860 For example, for sure, Virustotal, everyone knows what is it. 41 00:02:56,860 --> 00:02:58,920 And also the others probably. 42 00:02:58,980 --> 00:03:01,560 But there are quite a lot. 43 00:03:01,560 --> 00:03:07,600 So I decided not to do this test manually, but to write a script to automate the actions. 44 00:03:07,800 --> 00:03:15,420 And so I would like to have, okay, I'd like to build something that allowed me to conduct this research. 45 00:03:15,460 --> 00:03:20,300 And that was done not reinventing anything, actually, sorry. 46 00:03:20,320 --> 00:03:26,720 But leveraging well-known tools like, for example, MSVenom from the Metasploit to create the payloads. 47 00:03:26,720 --> 00:03:29,800 Or maybe the 7-Zip self-extractor to create. 48 00:03:29,800 --> 00: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. 49 00:03:41,980 --> 00: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. 50 00:03:52,560 --> 00:03:57,520 I would like to avoid this to trigger in any case, every time I upload the sample, a new analysis. 51 00:03:57,520 --> 00:04:01,780 So I created something to address this issue. 52 00:04:02,280 --> 00: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. 53 00:04:14,200 --> 00:04:17,860 So you can try to use it, okay, you can write your own. 54 00:04:17,860 --> 00:04:23,980 It's the same, probably it's not so difficult to do it, but it allowed me to automate this research. 55 00:04:23,980 --> 00: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. 56 00:04:37,320 --> 00: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. 57 00:04:49,780 --> 00:04:52,720 Okay, for example, here we can see an example of the drop folder. 58 00:04:52,720 --> 00:04:55,260 It's just a folder where I put all my utilities. 59 00:04:55,260 --> 00: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. 60 00:05:01,400 --> 00:05:11,080 Product-key.txe is an utility for Nimsoft, which is extracting the Microsoft Office product key, for example, from the system. 61 00:05:11,420 --> 00:05:14,560 And I would like to bring this on the sandbox itself. 62 00:05:14,720 --> 00:05:18,880 So at the end, when we run the script, I will have something like that. 63 00:05:18,880 --> 00: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. 64 00:05:32,680 --> 00:05:39,080 Scrambled names with scrambled content as well, because I would like, as I said, to avoid the hash detections. 65 00:05:39,080 --> 00:05:43,160 And so that is what will be created. 66 00:05:43,160 --> 00: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. 67 00:05:54,060 --> 00:05:54,700 Okay. 68 00:05:54,880 --> 00:05:58,600 The underscore means, okay, don't touch this file. 69 00:05:58,920 --> 00: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. 70 00:06:09,380 --> 00:06:10,900 And so let's start with the case one. 71 00:06:10,900 --> 00:06:14,700 So I would like to try to get a reverse shell out from the sandboxes. 72 00:06:14,700 --> 00:06:17,780 So I run the script with this syntax here, very simple. 73 00:06:18,000 --> 00:06:23,480 And I uploaded it on all these sandboxes mentioned at the beginning. 74 00:06:23,480 --> 00:06:24,780 And this is the result. 75 00:06:24,780 --> 00:06:29,400 As you can see here, a lot of them gave me actually a shell. 76 00:06:29,400 --> 00:06:31,340 For some of them, it's not actually surprising. 77 00:06:31,340 --> 00:06:33,820 Any run, for example, allow you interactive access. 78 00:06:33,820 --> 00:06:35,640 So, okay, it's not a big issue. 79 00:06:35,920 --> 00:06:40,080 But for some other, maybe it's more surprising. 80 00:06:40,080 --> 00:06:45,960 And what I would like to stress is here, the behavior of Palo Alto and VirusTotal. 81 00:06:46,040 --> 00:06:52,340 Both of them gave me TCP callback, but then the connection went down. 82 00:06:52,340 --> 00: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. 83 00:07:06,020 --> 00: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. 84 00:07:13,220 --> 00:07:16,840 Okay, now I have a reverse shell on the system, but why this is relevant? 85 00:07:16,840 --> 00:07:18,900 Why I should be worried about? 86 00:07:19,000 --> 00:07:22,700 Because I can actually extract information from them. 87 00:07:22,860 --> 00:07:30,560 Here, you can see I run the productkey.txt and I got the office installation product keys. 88 00:07:30,560 --> 00:07:34,460 I removed them from privacy here, obviously, but they were there. 89 00:07:35,000 --> 00:07:36,640 And so why this is important? 90 00:07:36,940 --> 00:07:41,740 That's really important from my point of view, from a point of view of a malware researcher, for example. 91 00:07:41,800 --> 00:07:49,080 But first of all, consider that this is a private information that probably someone don't want to disclose. 92 00:07:49,080 --> 00: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. 93 00:07:58,920 --> 00:08:05,820 We just use what our firewall vendor is providing us as a sandbox. 94 00:08:05,820 --> 00:08:09,720 But okay, it's their business if they are losing the office keys. 95 00:08:09,920 --> 00:08:13,800 If you are running our own, that's very important. 96 00:08:13,960 --> 00:08:22,900 But what is, in my opinion, the most important thing here is that this allows to leak information from this. 97 00:08:22,900 --> 00:08:26,900 And this allows the fingerprinting of the system. 98 00:08:26,940 --> 00:08:28,240 This is already happening. 99 00:08:28,240 --> 00:08:30,500 A lot of malware is doing this. 100 00:08:30,520 --> 00: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. 101 00:08:44,160 --> 00:08:49,800 Username that they will get from probably VirusTotal or a sandbox like that one. 102 00:08:49,800 --> 00: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. 103 00:08:59,900 --> 00:09:08,680 So it can make the most undetectable sandboxes useless, let's say. 104 00:09:09,060 --> 00:09:11,700 Okay, this is a quick demo of what I did. 105 00:09:11,700 --> 00:09:18,300 So here I tried to upload a sample on the SND box. 106 00:09:19,020 --> 00:09:26,580 As you can see on your left side, yes, there was Metasploit running. 107 00:09:26,580 --> 00:09:31,560 As you can see, I got the reversal here. 108 00:09:31,600 --> 00:09:33,440 And then I was able to 109 00:09:37,140 --> 00:09:40,040 extract the product key, for example. 110 00:09:40,040 --> 00:09:41,560 Here, obviously, I removed. 111 00:09:42,260 --> 00:09:44,020 So let's go to the case 2. 112 00:09:44,020 --> 00:09:46,620 So I named it cross sandbox spawning. 113 00:09:46,680 --> 00:09:50,320 What it means, we saw that we have external access from the systems. 114 00:09:50,400 --> 00:09:54,980 So that means that also we can try to maybe try to run an attack against someone else. 115 00:09:55,640 --> 00: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. 116 00:10:04,220 --> 00: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. 117 00:10:21,300 --> 00:10:23,680 So this is something we need to keep in mind. 118 00:10:23,680 --> 00:10:26,380 Here, this is a simple setup I did on my script. 119 00:10:26,380 --> 00:10:28,980 So I just created this script here. 120 00:10:28,980 --> 00:10:31,860 As you can see, there is a qrl.exe running. 121 00:10:32,020 --> 00:10:33,440 In this case, not a real attack. 122 00:10:33,440 --> 00:10:35,140 It's just an upload of a file. 123 00:10:35,200 --> 00:10:37,620 But it would be interesting for the third case. 124 00:10:37,620 --> 00:10:40,240 So let's keep this in mind. 125 00:10:40,240 --> 00: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. 126 00:10:53,660 --> 00:10:56,020 So it will be done automatically by the script. 127 00:10:56,540 --> 00:10:58,980 And so this is the result of the test. 128 00:10:59,140 --> 00: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. 129 00:11:06,580 --> 00:11:09,280 And that will bring us to the third case. 130 00:11:09,540 --> 00:11:10,140 Okay. 131 00:11:10,480 --> 00:11:11,980 Why this is relevant? 132 00:11:12,080 --> 00:11:13,900 Because we have to consider a couple of things. 133 00:11:13,900 --> 00:11:19,320 One is that, okay, we can use something to proxy attacks to someone else. 134 00:11:19,320 --> 00:11:22,360 This is something that we can take in consideration. 135 00:11:22,600 --> 00:11:30,560 Second point, sometimes these sandboxes are really in our infrastructure. 136 00:11:30,560 --> 00:11:35,180 And sometimes we don't even have a real perception of that. 137 00:11:35,180 --> 00: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. 138 00:11:45,860 --> 00:11:51,340 Because it just executes the payload and so on. 139 00:11:51,360 --> 00: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. 140 00:12:03,980 --> 00:12:06,560 So have a read of it. 141 00:12:07,220 --> 00:12:10,440 So let's have a look to the demo as well. 142 00:12:13,200 --> 00: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. 143 00:12:27,240 --> 00:12:35,420 Then I created a fake site, just waiting for an info.php file to be uploaded. 144 00:12:36,400 --> 00:12:42,240 And we can see here that, okay, I got this file uploaded on the sandbox itself. 145 00:12:42,240 --> 00:12:46,020 And this worked for all the sandboxes we saw before. 146 00:12:46,720 --> 00:12:50,620 And that is bringing us to the third case. 147 00:12:50,620 --> 00:12:55,600 So let's try to do something creative to combine the two things we did before. 148 00:12:55,600 --> 00:13:04,480 So , okay, we saw that some of the sandboxes looks like preventing us to get access into leak information. 149 00:13:04,480 --> 00:13:08,920 But if we combine the second case, maybe we can do something. 150 00:13:08,920 --> 00: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. 151 00:13:21,000 --> 00: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. 152 00:13:36,540 --> 00:13:42,640 And actually, I was able in this way to extract information from both Palo Alto and VirusTotal. 153 00:13:42,640 --> 00: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. 154 00:13:53,320 --> 00: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. 155 00:14:02,620 --> 00:14:06,720 So I uploaded the payload. 156 00:14:11,860 --> 00: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. 157 00:14:23,040 --> 00:14:24,320 So here it is. 158 00:14:24,320 --> 00:14:27,080 And so we can get the information out. 159 00:14:29,000 --> 00:14:29,960 Okay. 160 00:14:30,420 --> 00:14:35,760 Maybe we can also use this system to do some other things because it's just three cases, very quick. 161 00:14:36,740 --> 00:14:41,800 But we can try to do other things like, for example, test your own sandbox. 162 00:14:41,800 --> 00: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. 163 00:14:55,960 --> 00:14:58,620 So it's something that you need to check. 164 00:14:58,680 --> 00:15:05,540 Maybe try two different fingerprinting techniques because there's really a wall here. 165 00:15:05,540 --> 00: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. 166 00:15:12,100 --> 00: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. 167 00:15:24,420 --> 00:15:28,460 So that's something that you have to take into consideration. 168 00:15:29,280 --> 00:15:33,220 Also, I added this build a database with the result and fingerprinting server sandbox. 169 00:15:33,220 --> 00:15:34,620 This is not a good idea. 170 00:15:34,620 --> 00:15:42,460 I don't know if maybe it can be used for nefarious ways. 171 00:15:42,540 --> 00: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. 172 00:15:55,920 --> 00:16:05,300 So mining is not probably a real thing to do, but okay, it's something you can try. 173 00:16:05,300 --> 00:16:08,580 So this is the summary of what I did. 174 00:16:08,580 --> 00:16:16,280 So the results on the several sandboxes with the specific test I run. 175 00:16:18,080 --> 00:16:20,760 And a sample of collected data. 176 00:16:20,760 --> 00: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. 177 00:16:31,300 --> 00:16:36,700 It's just a matter of thinking what you want to get. 178 00:16:38,060 --> 00:16:40,180 Are offline sandbox safer? 179 00:16:40,960 --> 00:16:47,380 You know, and we saw that there are some vendors not allowing us any kind of external access. 180 00:16:47,880 --> 00:16:49,060 So are they safer? 181 00:16:49,060 --> 00:16:57,040 Maybe yes, a little bit, because in case of an APT, for example, let's think about the terminal attacker. 182 00:16:58,360 --> 00:17:04,060 In this case, maybe it can't just get access to your technology. 183 00:17:04,060 --> 00: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. 184 00:17:27,960 --> 00: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. 185 00:17:41,080 --> 00:17:46,240 So they are safer probably, but not completely safe in this point. 186 00:17:46,900 --> 00:17:47,480 Remediations. 187 00:17:47,480 --> 00: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. 188 00:17:57,300 --> 00: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. 189 00:18:06,420 --> 00: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. 190 00:18:15,700 --> 00:18:20,700 Also, our web application firewall may be masking information going out. 191 00:18:20,700 --> 00:18:24,220 It's another solution that could be considered. 192 00:18:24,520 --> 00:18:32,300 And for, let's say, for internal information, probably the best solution is randomize as much as possible. 193 00:18:32,300 --> 00:18:34,480 But it's not the easy one. 194 00:18:35,160 --> 00: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. 195 00:18:45,220 --> 00:18:51,780 Probably the quick and dirty solution is running a kind of IPS or something in outgoing connections. 196 00:18:53,100 --> 00:18:55,700 Disclosure, I did it, yes, obviously. 197 00:18:57,600 --> 00:19:01,220 The only reply I got was from the guys at VirusTotal. 198 00:19:02,200 --> 00: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. 199 00:19:14,340 --> 00:19:20,760 All the others, more or less, didn't give me a reply about the disclosure. 200 00:19:21,640 --> 00:19:30,660 Okay, these are the references of all the tools I used in the creation of this research. 201 00:19:30,660 --> 00:19:42,560 So Metasploit for sure, 7zip, the DVWA site for the creation of the site and some utilities. 202 00:19:43,460 --> 00:19:44,800 And so let's wrap up. 203 00:19:45,500 --> 00:19:49,240 Okay, at the end, the sandboxes are useless? 204 00:19:49,240 --> 00:19:50,420 No, I don't think so. 205 00:19:50,420 --> 00: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. 206 00:20:03,500 --> 00: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. 207 00:20:15,860 --> 00: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. 208 00:20:35,140 --> 00: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. 209 00:20:44,020 --> 00:20:47,460 Okay, this is my GitHub. 210 00:20:47,980 --> 00:20:52,040 So if you want to have a look at the presentation, the script, I will publish everything there. 211 00:20:52,520 --> 00:20:55,120 And that's all. 212 00:20:55,180 --> 00:20:57,520 So thank you for me. 213 00:20:57,520 --> 00:20:58,780 I don't know if you have any questions. 214 00:21:01,480 --> 00:21:03,700 Okay, thank you very much. 215 00:21:03,700 --> 00:21:07,000 Thanks for being here and thanks a lot. 216 00:21:07,200 --> 00:21:08,360 Enjoy your DEF CON.