1 00:00:00,250 --> 00:00:04,917 >> This is Brady and I guess he's going to talk to you about how I guess Windows likes to 2 00:00:04,917 --> 00:00:10,917 have fun with itself. All right. ? >> [Applause]. ? >> All right, I guess you guys are a little 3 00:00:17,125 --> 00:00:22,417 too excited to watch Windows play with itself. We'll be covering some really interesting 4 00:00:22,417 --> 00:00:28,417 stuff today. First off, I guess a little bit about myself. I started out in the Government 5 00:00:31,000 --> 00:00:35,792 space doing a lot of cool stuff there. Like most of you, I'm passionate about security, been 6 00:00:35,792 --> 00:00:41,708 doing it ever since I was old enough to get into trouble for it. If any of you have heard of 7 00:00:41,708 --> 00:00:47,667 the POS Project, I started that project and currently I'm a founder and principle security 8 00:00:47,667 --> 00:00:52,417 consultant at Simon Briggs Security. So throughout this you will see a lot of the techniques 9 00:00:52,417 --> 00:01:00,000 and tools that we have developed in conducting penetration tests. So before we enter the danger 10 00:01:00,000 --> 00:01:05,833 zone for you Archer fans out there, I wanted to give you a little bit of background as to 11 00:01:05,833 --> 00:01:11,583 what motivated this talk. Ok. So back when I was in the Government space, I remember 12 00:01:11,583 --> 00:01:15,417 talking to some friends in the private sector and they were telling me about some of the 13 00:01:15,417 --> 00:01:22,375 difficulties they had and the differences between what a penetration test was and what an 14 00:01:22,375 --> 00:01:26,125 actual attack was, or what they were actually trying to defend against, right? So, you know, 15 00:01:26,125 --> 00:01:31,875 fast forward, that was about three or four years ago, fast forward from that point a couple 16 00:01:31,875 --> 00:01:36,417 years and that ended up being one of the motivating factors to starting Simon Briggs Security, 17 00:01:36,417 --> 00:01:39,458 was to shorten that gap and to combine what an actual attack is with what a penetration test 18 00:01:39,458 --> 00:01:43,833 should model after. So that's typically, you know, that's typically the methoDLLogy that 19 00:01:43,833 --> 00:01:48,042 we use when conducting penetration tests. So there's still very few covert 20 00:01:48,042 --> 00:01:54,042 persistance tools on the market. Right? A lot of us use Metasploit and I'm a big fan of 21 00:01:58,833 --> 00:02:05,750 Meatsploit. I'm definatley not going to badmouth it because I think it's an awesome project. 22 00:02:05,750 --> 00:02:12,167 But I think it is important to reduce the reliance that we have on Metasploit. And there's other 23 00:02:12,167 --> 00:02:17,083 great projects that do this as well, right. Such as Veil, Veil does it. Cobalt Strike is 24 00:02:17,083 --> 00:02:21,583 another great project that does it as well. So anything that we can do to, you know, customize 25 00:02:21,583 --> 00:02:25,500 and model assesments and penetration tests after what organizations are actually 26 00:02:25,500 --> 00:02:31,250 defending against, I think is a good thing. So throughout my talk, you will see some of the 27 00:02:31,250 --> 00:02:36,708 techniques and the tools that are being released will hopefully help you in doing 28 00:02:36,708 --> 00:02:44,000 that. We have a lot to cover. We're going to first talk a little bit about DLL injection, 29 00:02:44,000 --> 00:02:51,292 a new technique for that. A new, actually a few new techniques for persistence, stealthy 30 00:02:51,292 --> 00:02:55,792 persistence in a Windows environment. We're going to release throwback and I'll give 31 00:02:55,792 --> 00:03:00,292 you some demonstrations with that along with lots of other demos along the way. So I'm 32 00:03:00,292 --> 00:03:06,292 really hoping the demo Gods will be kind to me tonight. So first off, for DLL injection -- ? >> 33 00:03:13,750 --> 00:03:17,750 [Laughter]. ? >> For DLL injection, you know, for those of us who have had to deal with 34 00:03:17,750 --> 00:03:22,417 the Windows API, that's often what it feels like, right? It's kind of a black box. It's 35 00:03:22,417 --> 00:03:28,292 definitely a black box. Three out of the four APIs there are undocumented, right? So a lot of 36 00:03:28,292 --> 00:03:33,083 the options that we have and we that have to deal with, we have to reverse engineer and look at 37 00:03:33,083 --> 00:03:38,500 Microsoft DLLs and try to figure out what Microsoft was thinking when they did things. The only 38 00:03:38,500 --> 00:03:43,625 documented one is create thread, but Microsoft is, you know, implemented quite a few 39 00:03:43,625 --> 00:03:48,208 restrictions around that with integrity level for processes and things like that. I have 40 00:03:48,208 --> 00:03:52,667 never been able to get NE create thread to work very well. My favorite is RTL create user 41 00:03:52,667 --> 00:03:57,792 thread which works really well most of the time. And then you know, at the bottom you have 42 00:03:57,792 --> 00:04:04,083 like NTQAPC thread which can blue screen certain OSs, I think particularly Windows server 43 00:04:04,083 --> 00:04:10,500 2008. And then for the really elite stuff you can do like Code Caving which is also known as 44 00:04:10,500 --> 00:04:16,667 the Nebet Shuttle technique but it is extremely difficult to do on 64 bit windows. So wouldn't 45 00:04:16,667 --> 00:04:21,708 it be nice to have another option, you know, besides one that is documented and three 46 00:04:21,708 --> 00:04:27,667 that have very little support by Microsoft? So the new one that I found, it's called add monitor 47 00:04:27,667 --> 00:04:33,583 and it's actually a port monitor, it's used to install a port monitor for a printer. 48 00:04:33,583 --> 00:04:38,625 There are some advantages and disadvantages of it, but it's still an awesome technique. It 49 00:04:38,625 --> 00:04:43,417 takes three parameters and it injects into it spool SV, you don't have the flexibility of 50 00:04:43,417 --> 00:04:48,042 choosing which process to inject into like you do with some of the other APIs. But on the 51 00:04:48,042 --> 00:04:53,125 positive side it doesn't require masion architecture, you know typically when you want to 52 00:04:53,125 --> 00:04:58,625 inject a 64 DLL you have to be coming from a 64 bit process, otherwise there's a little 53 00:04:58,625 --> 00:05:03,583 trickery involved. So it's super easy to use and in a minute I'll show you the source code and 54 00:05:03,583 --> 00:05:08,708 we'll go through a demo, but it takes literally three parameters. The last one there 55 00:05:08,708 --> 00:05:15,833 is the most important one, which is a monitor info 2 structure. And, again, in a second you'll 56 00:05:15,833 --> 00:05:21,375 see what's contained within that. The biggest disadvantage in my mind is the DLL has to be 57 00:05:21,375 --> 00:05:27,375 on disk and it requires administrative privileges. So with that, let's check out the 58 00:05:30,000 --> 00:05:36,000 DLL injection demo. This one I recorded just because we have a lot of other cool stuff to 59 00:05:41,333 --> 00:05:47,333 cover, so --. Okay, so I can't see very well from here, hopefully you can see better 60 00:05:54,250 --> 00:05:59,000 than me, but you can see that the first, that the command line argument that we're passing is 61 00:05:59,000 --> 00:06:04,042 the name of the DLL we want to inject, right? The part I just highlighted was the monitor info 62 00:06:04,042 --> 00:06:09,208 2 structure which again has 3 parameters. One is generic name, the second one is just the 63 00:06:09,208 --> 00:06:14,542 architecture of the system and then, again, the third one is the DLL name that we are 64 00:06:14,542 --> 00:06:20,583 specifying to the command argument. You need the SE low driver privilege, which is, you 65 00:06:20,583 --> 00:06:25,333 know, you can easily obtain with admin privileges and the last one you know, you just call the 66 00:06:25,333 --> 00:06:32,292 function or the add monitor API with the necessary parameters. So I guess to prove it's being 67 00:06:32,292 --> 00:06:38,583 injected in spool SVI, I wrote it up. Process explorer, there in the background, highlighting 68 00:06:38,583 --> 00:06:45,083 spool SV, so when we actually carry out the demo, you'll see that the DLL gets loaded into 69 00:06:45,083 --> 00:06:50,458 spool SV. In this case, the DLL just a test DLL that I wrote. It will do a hash dump on the local 70 00:06:50,458 --> 00:06:56,458 system and then it will dump it to debug view. So it's a pretty basic demo. But as soon as we 71 00:06:58,625 --> 00:07:04,000 run it, I'm going to drop back into Process Explorer here so you see the DLL, you should see 72 00:07:04,000 --> 00:07:09,458 a gree line up here showing that the DLL got loaded under spool SV. There's the green line so 73 00:07:09,458 --> 00:07:16,500 the DLL is running under spool SV right now, it just got loaded. And now if we check out 74 00:07:16,500 --> 00:07:22,875 the debug view that DLL should have dumped out the local -- done a local hash dump. And you 75 00:07:22,875 --> 00:07:28,875 can see it ran from the spool SV process. So obviously in this case I choose a, you know, the 76 00:07:31,292 --> 00:07:37,292 DLL to do a hash dump. In your case, you know, it can basically do whatever you want it to do, 77 00:07:37,292 --> 00:07:43,292 whatever you design the DLL to do. So that's the DLL injection technique. From there -- okay, 78 00:07:48,708 --> 00:07:54,792 so from there, I want to talk a little about persistence. So first of all, there's lots of 79 00:07:54,792 --> 00:08:00,208 persistence mechanisms in Windows, but which one do you guys typically use? Who uses a 80 00:08:00,208 --> 00:08:07,167 service, first of all? Come on you liars, raise your hand. You all know that you use the 81 00:08:07,167 --> 00:08:10,667 service, right? If you have system privs, that's what you typically use, right, is a 82 00:08:10,667 --> 00:08:16,542 service. That what the ATP report by Manual, isn't that what it said? Like 75% of all 83 00:08:16,542 --> 00:08:22,542 attacks create installer service, according to my good friend Bryce [laughter]. We do 84 00:08:24,625 --> 00:08:30,625 have other options, right. There's run keys, there's SEH tabs, but wouldn't it be nice if 85 00:08:30,625 --> 00:08:34,375 we had another option, especially something as simple as dropping a DLL tab disk and 86 00:08:34,375 --> 00:08:39,083 creating and creating a registry key and have that be loaded on boot through a system level 87 00:08:39,083 --> 00:08:45,792 process. DLL is super stealthy and it, we can design the DLL to do whatever we want. So like I 88 00:08:45,792 --> 00:08:49,542 said, there's lots of techniques. The technique that I used to find this, I'm going to 89 00:08:49,542 --> 00:08:56,333 talk about three, you know, I don't think that the techniques that I use to find these are 90 00:08:56,333 --> 00:09:02,167 new. You know, definitely not, I just used process monitor and in this case, you know, you can see 91 00:09:02,167 --> 00:09:09,000 that on the left, I have process monitor, monitor specifically DM ware tools. And then, you know, 92 00:09:09,000 --> 00:09:13,667 I just went through all the processes, had it monitor that process specifically for DLLs 93 00:09:13,667 --> 00:09:20,125 that were loaded and then start, well first of all, stop and restarted services one by one to 94 00:09:20,125 --> 00:09:26,083 see which DLLs got loaded. You can see then kind of in the middle it says, name not found. 95 00:09:26,083 --> 00:09:31,958 Well it tried loading the NTDSAPI.DLL [indiscernible] from the WBEN directory before it 96 00:09:31,958 --> 00:09:38,542 tried loading it from system 32, so there's a DLL hijacking vulnerability there. So if we 97 00:09:38,542 --> 00:09:44,542 drop a DLL into the WBEN folder named NTDSAPI ours will be loaded as that service on boot. 98 00:09:47,625 --> 00:09:51,750 So it's kind of a cool technique. And that actually is one of the techniques that is 99 00:09:51,750 --> 00:09:55,167 I'm disclosing right now. It's kind of a funny story that goes along with this though. The 100 00:09:55,167 --> 00:10:02,125 second technique that I had listed, actually I found those probably like three years ago, 101 00:10:02,125 --> 00:10:09,542 back when it was ESXI 4.0, 4.1, and I just kind of sat around and didn't do much with them and 102 00:10:09,542 --> 00:10:14,833 finally my DEF CON talk comes around and of course being a good hacker I wait until the 103 00:10:14,833 --> 00:10:20,917 last minute to actually start testing my stuff and I realize that in EXSI 5.5 they're 104 00:10:20,917 --> 00:10:27,875 actually both patched. So I'm pulling a Stewie running around not knowing what the heck to do 105 00:10:27,875 --> 00:10:32,500 because both of them get patched. But fortunately I spent a couple hours and found another 106 00:10:32,500 --> 00:10:39,417 one which is the NTDSAPI.DLL. So literally all you have to do is drop that DLL into the WBEN 107 00:10:39,417 --> 00:10:46,708 folder within system 32 and it will get loaded at boot time by VEM ware tools service. So 108 00:10:46,708 --> 00:10:52,625 obviously the down side is VEM toos has to be installed. So it's more useful on servers or 109 00:10:52,625 --> 00:10:58,625 in a virtual environment. However, we're going to go from good, better, to best. And right 110 00:11:01,125 --> 00:11:07,125 now we're moving on to the best category, okay? The best is this one. And this is to create 111 00:11:11,125 --> 00:11:16,792 persistence in Windows. All you need to do is create a new key at the registry key I specified 112 00:11:16,792 --> 00:11:22,583 and then a value within that key named driver and the value of the driver is just the DLL you 113 00:11:22,583 --> 00:11:28,583 want to get loaded. You drop the DLL into Windows systems 32 and at boot Windows will load that 114 00:11:30,833 --> 00:11:38,250 DLL within the spool SV or the print spooler service. The upside is you can create as many 115 00:11:38,250 --> 00:11:43,458 as you want. You want multiple DLL persistence, you create multiple keys each of them with 116 00:11:43,458 --> 00:11:49,292 the value of driver, each of them specifying the DLL at boot, you know, as many persistence or 117 00:11:49,292 --> 00:11:57,208 DLLs you want to run will be executed by the print spooler. So I think it's time for some 118 00:11:57,208 --> 00:12:03,208 demos. That's enough of me talking. Let's move on to some fun stuff. Oh, wow! That is 119 00:12:10,083 --> 00:12:16,083 really big! I was waiting for that. Okay, all right, I think that's close enough, right? 120 00:12:26,625 --> 00:12:33,375 Hopefully everything fits. I tried to resize the font and everything, so - I cannot even 121 00:12:33,375 --> 00:12:39,375 see that. Is that administrator? Okay. I can see why most people don't extend the desktop. Okay. 122 00:12:44,208 --> 00:12:50,208 So we're going to -- first off, we'll do the first persistence which is the NTDSAPI.DLL. So 123 00:12:55,000 --> 00:13:01,000 that's in demo 2. And - okay, so all we have to do for this one, there's no registry 124 00:13:23,417 --> 00:13:29,417 modifications required. We just have to copy that test DLL to see Windows system 32 WBEN and 125 00:13:35,250 --> 00:13:41,250 then we'll name it NTDSAPI. Did I type that right? Anybody see? NTDSAPI.DLL okay? All right, so 126 00:13:47,042 --> 00:13:53,750 one file is copied. So that's it. There's no registry modifications necessary. What 127 00:13:53,750 --> 00:14:01,625 this DLL does is, it just, it's similar to the first DLL it shows what process loaded it and 128 00:14:01,625 --> 00:14:08,250 then dumps some information out to the debug view. So we're going to reboot. Actually, I'll 129 00:14:08,250 --> 00:14:14,250 just type it because it's a little easier. So what I'm going to do is log in as fast as 130 00:14:18,500 --> 00:14:25,042 possible because, again, it's being loaded in the system so it doesn't wait for me to log in to 131 00:14:25,042 --> 00:14:30,958 execute the back door or the DLL. It's going to execute as soon as the service gets 132 00:14:30,958 --> 00:14:37,167 started. I'm going to log in quick, start up the debug view, and we should see that DLL being 133 00:14:37,167 --> 00:14:43,167 executed. Okay, it should say something about what process or what data it's running from and 134 00:15:26,000 --> 00:15:32,250 where the DLL is located at. Is that what you are seeing, for those of you that can see it? 135 00:15:32,250 --> 00:15:38,292 Ok, so that's the first one, it again requires the VM ware tools are installed. There are some 136 00:15:38,292 --> 00:15:44,292 requirement there, but if it is installed, you have a super stealthy persistence technique 137 00:15:46,708 --> 00:15:52,708 in Windows. So now we'll demo the second one. ? >> Yay! [Applause]. ? >> The second one, 138 00:15:56,458 --> 00:16:01,917 like I said, I think the second one is pretty awesome. It's super stealthy and the best part 139 00:16:01,917 --> 00:16:07,000 about them is when you can find logical vulnerabilities within Windows because those are a lot 140 00:16:07,000 --> 00:16:13,000 harder to patch. So what we have here is we have the - there should just be an error message. 141 00:16:16,333 --> 00:16:22,333 I code named it error message. So if we run that, it just take the DLL, like I said it must be 142 00:16:22,333 --> 00:16:28,333 in system 32, so we'll go ahead and copy test DLL to see Windows system 32 and we'll call it 143 00:16:31,958 --> 00:16:37,958 ErrorMess.DLL. I think I typed that right. So now if we just run Errormess and then just 144 00:16:42,667 --> 00:16:48,667 specify the DLL that is in system 32 and then test app that I wrote just asks if you want to 145 00:16:51,042 --> 00:16:57,750 load it now? And we're just going to say no because we're going to reboot the box anyway. 146 00:16:57,750 --> 00:17:02,625 Then we shut down. This is basically the same test DLL and when we reboot, we should have 147 00:17:02,625 --> 00:17:08,625 two persistence mechanisms on this box now. So the first persistence should be running 148 00:17:21,250 --> 00:17:27,958 out of the VM tools D. The second persistence that we just installed should be running out 149 00:17:27,958 --> 00:17:33,958 spool SV.DXE both of which are system processes. So there's one and it looks like there's the 150 00:18:13,625 --> 00:18:19,625 other. So they are both running as they should. One should be running from VM tools and the 151 00:18:19,625 --> 00:18:25,625 other should be running from spool SV. ? >> [Applause]. ? >> So -- ? >> [Applause]. ? >> So 152 00:18:31,167 --> 00:18:36,333 right there we have two, you know, pretty stealthy persistence techniques. A lot 153 00:18:36,333 --> 00:18:39,750 stealthier anyway than installing a service, right, because a service creats all 154 00:18:39,750 --> 00:18:47,250 kinds of logs. It's kind of a dirty persistence technique, in my opinion, but it does work. 155 00:18:47,250 --> 00:18:53,250 Now let's talk a little bit more about Windows APIs. I guess as a super quick prep course to 156 00:19:01,458 --> 00:19:06,750 throwback, we're going to distinguish between win HTTP and 1 Inet. Those are the two main 157 00:19:06,750 --> 00:19:13,417 libraries within Windows that Windows provides you when you want to write a back door. So 158 00:19:13,417 --> 00:19:18,917 win http is intended primarily for services. Win Inet is for user space. So win Inet will 159 00:19:18,917 --> 00:19:25,625 automatically pull user settings, it will automatically do like the NTLM authentication. 160 00:19:25,625 --> 00:19:29,875 Has anybody ever had problems getting out of a network that does NTLM authentication using 161 00:19:29,875 --> 00:19:35,875 an meterpreter? ? >> Yeah ? >> [Laughter]. ? >> Anybody else? Okay, well, the reason why is 162 00:19:39,042 --> 00:19:43,667 because there's a certain flag that you have to set, it's called the Internet flag keep 163 00:19:43,667 --> 00:19:50,375 connection. And that flag will automatically tell win Inet to do NTLM authentication at the 164 00:19:50,375 --> 00:19:56,375 proxy. So something as complex as NTLM authentication, it can easily be enabled just by 165 00:19:59,375 --> 00:20:05,375 setting a flag within win Inet. ? >> [Indiscernible]. ? >> Oh, great! ? >> [Laughter]. ? >> 166 00:20:10,500 --> 00:20:18,458 [Applause]. ? >> I don't - I actually, I don't drink, but I came prepared with Mountain Dew, 167 00:20:18,458 --> 00:20:24,458 so. ? >> [Off mic] ? >> Oh, okay. ? >> [Laughter]. ? >> You just stand there and look 168 00:20:29,083 --> 00:20:35,083 pretty. We've got it. ? >> That's it? That's all I get? ? >> That's all you get. ? >> 169 00:20:39,708 --> 00:20:45,708 Oh, sorry, I'm not used to drinking. ? >> [Laughter]. ? >> We're not there yet. ? >> On a 170 00:20:50,333 --> 00:20:57,250 special edition of shot the new, we have a new, in addition to our new speaker, 171 00:20:57,250 --> 00:21:03,250 congratulations. ? >> [Applause]. ? >> We also have a new attendee, Nikita. Everybody 172 00:21:08,458 --> 00:21:14,458 say hello to Nikita. It is very tough to get accepted at DEF CON. Congratulations. How about 173 00:21:18,292 --> 00:21:24,292 some love for our new speaker? ? >> [Applause]. ? >> You're done, I've got this. ? >> Okay. 174 00:21:33,125 --> 00:21:39,125 ? >> [Laughter]. ? >> I would have done this very differently. ? >> [Laughter]. ? >> In fact 175 00:21:42,125 --> 00:21:46,833 --. ? >> [Off mic]. ? >> There we go. All right.? >> All right, wait a second, listen this is 176 00:21:46,833 --> 00:21:52,833 all crap. I would have done it differently. You just take it. ? >> [Laughter]. ? >> I can't 177 00:21:55,250 --> 00:22:01,250 even be on stage with this anymore. ? >> [Laughter]. ? >> Who took my alcohol? ? >> I have 178 00:22:07,333 --> 00:22:13,333 it. ? >> Okay. ? >> [Laughter]. ? >> Okay. Thanks, guys. That was fun! ? >> [Laughter]. 179 00:22:19,958 --> 00:22:26,625 [Applause] ? >> Okay, so we'll finish talking about the two different HTTPAPIs within 180 00:22:26,625 --> 00:22:33,000 Windows. As I was saying, the win Inet one is super easy to use. Doing something as complex 181 00:22:33,000 --> 00:22:38,958 is as MT modification is as simple as adding the correct flag within the API column. It's 182 00:22:38,958 --> 00:22:45,750 important to understand the distinction because for throwback, we actually used win 183 00:22:45,750 --> 00:22:52,250 HTTP. You know, based on when doing a penetration test, what's the first thing you want to do? 184 00:22:52,250 --> 00:22:57,708 You get access to a user's work station and from there you want to escalate privileges and run 185 00:22:57,708 --> 00:23:04,750 from a service. So in order to do that, that's why we decided to go the win http route because 186 00:23:04,750 --> 00:23:09,958 it's tailored more for services. So the back door itself is written in C++. The control 187 00:23:09,958 --> 00:23:17,375 panel and the LP portion are written in PHP with MILSQ back. It was designed for stealth. 188 00:23:17,375 --> 00:23:23,250 Like I said, we're trying to converge the penetration test with what an actual attack looks 189 00:23:23,250 --> 00:23:29,583 like, so we want to build tools that support that methoDLLogy. So it has persistence built in, 190 00:23:29,583 --> 00:23:36,292 both as a DLL and as an EXE. Here is a kind of a brief overview of how it works. An 191 00:23:36,292 --> 00:23:40,458 attacker, you know, sends a spear fishing email, or you know, however you use your 192 00:23:40,458 --> 00:23:46,500 imagination to gain access and infect a user's work station with the throwback executable or 193 00:23:46,500 --> 00:23:51,667 the throwback DLL and gets going execution on their box. Throwback then starts leaking 194 00:23:51,667 --> 00:23:57,667 out of their proxy firewall out to their throwback LP, which again is a PHP interface and it 195 00:24:00,500 --> 00:24:06,500 has a control panel that we can then send command and control and we can send commands back to 196 00:24:06,500 --> 00:24:11,833 the throwback door. You'll notice that there's 2 throwback LPs in this scenario, so you can 197 00:24:11,833 --> 00:24:17,958 have it round robin and randomly select one of how ever many LPs you want to configure throwback 198 00:24:17,958 --> 00:24:22,000 to call back to. If you want to set it up to ten, then it will randomly select one of the ten 199 00:24:22,000 --> 00:24:28,333 to call back to however often you tell it to call back. So here are some other features of 200 00:24:28,333 --> 00:24:34,750 throwback. A robust proxy detection. So remember I said that we used win HTTP. So win 201 00:24:34,750 --> 00:24:42,542 HTTP doesn't have the robust user proxy settings that win Inet has. So what we ended up 202 00:24:42,542 --> 00:24:46,583 doing to get around this was, because it does run from a service, you can impersonate 203 00:24:46,583 --> 00:24:53,917 users a lot easier. So what did was we decided was to mount each user's NT user dot dat file, if 204 00:24:53,917 --> 00:24:59,333 it's not able to get out initially, it tries mounting the registry file, looks in their 205 00:24:59,333 --> 00:25:04,250 user settings for proxy settings within Internet Explorer and grabs those proxy settings and 206 00:25:04,250 --> 00:25:10,583 uses those to try to get out. And it does that for all users that have logged into the box 207 00:25:10,583 --> 00:25:15,333 for their proxy settings. Like I said, you can also set it up to use distributed LPs. So instead 208 00:25:15,333 --> 00:25:20,542 of calling back to the same LP every hour or 15 minutes, you can set it up to call 5 or 10 209 00:25:20,542 --> 00:25:26,542 LPs and it decreases the traffic to each domain. It also uses the MSGRPC interface to generate MSF 210 00:25:29,917 --> 00:25:35,250 payloads which we will be demoing in a minute as well. It uses RC4 for encrypted 211 00:25:35,250 --> 00:25:41,333 communications. So you can configure this HTTP or HTTPS. Either way the actual payload 212 00:25:41,333 --> 00:25:47,250 data is encryped using RC4. It also implements reflective DLL injection. We will be demoing 213 00:25:47,250 --> 00:25:51,292 that as well. Reflective DLL injection, you know, from a malware writing perspective is 214 00:25:51,292 --> 00:25:57,917 the coolest thing ever. It just allows you to run other DLLs from memory. So we will be 215 00:25:57,917 --> 00:26:03,667 demoing that as well. Lastly, the string encryption. So if someone does grab the binary and 216 00:26:03,667 --> 00:26:10,833 starts using reverse engineering on it, all of the strings within throwback, before you put, for 217 00:26:10,833 --> 00:26:15,292 example, any of the domains you want to call back to, you have to run it with a, you have to 218 00:26:15,292 --> 00:26:20,500 enter them into a python script that spits out an integer array that you then copy into the C 219 00:26:20,500 --> 00:26:26,833 file so the strings are not stored in clear text within the binary. So a lot of you might 220 00:26:26,833 --> 00:26:32,167 look at this and say what's the difference between this and the meterpreter? I don't think 221 00:26:32,167 --> 00:26:36,208 anybody would say meterpreter, and I again, I really like meterpreter, but it really 222 00:26:36,208 --> 00:26:41,708 doesn't have the best offset, right. So, when you type in meterpreter script it just 223 00:26:41,708 --> 00:26:46,000 randomly generates and executable on target. It randomly generates a service 224 00:26:46,000 --> 00:26:50,875 whereas this is designed more for stealth and it's not an interactive tool either. 225 00:26:50,875 --> 00:26:57,000 meterpreter is for interactive access, interactive shell on a target you have access to. So 226 00:26:57,000 --> 00:26:59,917 with that, it doesn't have as much functionality as meterpreter either. It's just 227 00:26:59,917 --> 00:27:07,125 more of a bare bones, back door that can provide stealthy persistence access within a 228 00:27:07,125 --> 00:27:13,125 network. ? >> [Applause]. ? >> We'll be seeing a demo of it. This is the interface, so 229 00:27:18,833 --> 00:27:24,875 remember I talked about how there's a control panel written in NPHP? This is how you control 230 00:27:24,875 --> 00:27:28,292 all of the different boxes that are calling back. You can see in this case there are four calling 231 00:27:28,292 --> 00:27:32,417 back. The first three are set back to call back every minute. The last one is set to call back 232 00:27:32,417 --> 00:27:36,375 every ten minutes. That's changeable. When a target call back you can say, hey, now I 233 00:27:36,375 --> 00:27:40,500 want you to call back every four hours. If you are not going to be being interactive operations 234 00:27:40,500 --> 00:27:46,167 for a while, you can change that and modify it. So that's the interface. Again we'll be doing 235 00:27:46,167 --> 00:27:53,667 a demo, right now actually, on how to do it. And hopefully I don't feel like doing this to 236 00:27:53,667 --> 00:27:59,667 somebody at the end of it. Okay, so what I wanted to do is just kind of run through, you know, 237 00:28:02,792 --> 00:28:08,792 when doing an assessment the general flow of an assessment, right? So here we have a cally 238 00:28:11,583 --> 00:28:18,875 VM and I'm going to pull this up here. Hopefully that's big enough so you can kind of see 239 00:28:18,875 --> 00:28:24,083 it. I know I can't see it on that little monitor. But we're going to be using the exploit. 240 00:28:24,083 --> 00:28:30,125 It's an old IE 10 exploit, but we have customized it for this particular version of IE 10 241 00:28:30,125 --> 00:28:36,125 we'll be using. And we creatively call it two girls, one sploit. ? >> [Laughter]. 242 00:28:38,875 --> 00:28:42,792 ? >> You know, the rest of the params are pretty basic. Set it on port 80. It's an IE 10 243 00:28:42,792 --> 00:28:48,792 exploit. The payload is a custom DLL inject payload. And I think this payload is one of the most 244 00:28:51,500 --> 00:28:56,708 underrated payloads in Metasploit. It allows you to use a custom DLL as a payload within 245 00:28:56,708 --> 00:29:02,875 Metasploit. So instead of relying on meterpreter and potentially getting flattened by 246 00:29:02,875 --> 00:29:08,833 AV, you can use a custom DLL inject payload and inject whatever DLL, custom DLL you 247 00:29:08,833 --> 00:29:14,042 want. So I suppose I probably should have started that up, but that's just within that resource 248 00:29:14,042 --> 00:29:20,042 file. So I'm going to start up the resource file there. So that's going to start up the 249 00:29:31,500 --> 00:29:37,500 exploit. Okay? I have a lot of things going on here. So this is interface. It is available on 250 00:29:45,625 --> 00:29:51,625 gethubnow. So we'll log in. You can see there's one box calling back. It's just a test box. You 251 00:29:55,500 --> 00:30:02,792 can see the last call back was yesterday when I was testing some stuff. So what we're going 252 00:30:02,792 --> 00:30:08,167 to do, like I said, is come into here. The exploit, yep it started by now. So now, you know 253 00:30:10,542 --> 00:30:15,458 obviously, it doesn't matter how you deliver the payload, that's not what this is about. This is 254 00:30:15,458 --> 00:30:21,458 about, you know, using a custom - using throwback as a custom payload within metasploit. So - 255 00:30:24,167 --> 00:30:30,167 and I think that's that. Just slash into HPEXP so that should - so what that's going to do is 256 00:30:38,292 --> 00:30:44,292 exploit the browser, obviously. It's going to inject the custom DLL into memory. And so now if 257 00:30:46,792 --> 00:30:54,625 we pull this up, we should very shortly see a new box pop up because our DLL was just 258 00:30:54,625 --> 00:31:01,833 injected. ? >> [Applause]. ? >> So from here we have another target, we can install 259 00:31:01,833 --> 00:31:05,958 persistence on it. At this point we're just a DLL running in memory because of the way that 260 00:31:05,958 --> 00:31:11,000 we delivered throwback. If you were to deliver it through macro attack as an executable, then it 261 00:31:11,000 --> 00:31:18,917 would automatically install itself, you know, as persistence. So you can do all 262 00:31:18,917 --> 00:31:24,375 sorts of stuff. You can run - create a process list, which I think is this second one. Nope, 263 00:31:24,375 --> 00:31:30,375 that's not it. Oh, that's actually change call back time, I believe, right? Change call 264 00:31:34,458 --> 00:31:40,458 back time. So that one, actually that one is create task list, I think. I don't know what it is, 265 00:31:45,917 --> 00:31:51,125 but whatever it is, we'll run it. ? >> [Laughter]. ? >> So you can see we just queued it up, 266 00:31:51,125 --> 00:31:56,375 there's now a task waiting for throwback to execute. When it turns pink like that, that means 267 00:31:56,375 --> 00:32:02,500 it is currently executing it. So we can come in her and you can see it's picked up the task and 268 00:32:02,500 --> 00:32:08,500 then it should return the output from that task. Yep, it was a task list. ? >> [Applause]. ? >> 269 00:32:11,875 --> 00:32:17,875 So when we have access to a box, what do we want? Do we want like, you know, do we want this 270 00:32:20,833 --> 00:32:25,583 - I mean, we want shells, right? Isn't that what every wants? We always want a shell. So one 271 00:32:25,583 --> 00:32:31,208 thing we decided to add, you can see it's calling back every minute. So what we're going to 272 00:32:31,208 --> 00:32:37,958 do is, there's a functionality called met creator and what this does is this will generate a 273 00:32:37,958 --> 00:32:43,958 metasploit payload, an meterpreter payload and we're going to create a raw one. And 274 00:32:45,958 --> 00:32:50,000 let's do, I don't know what that is. I think that's the reverse HTTPEX86. ? >> [Off mic]. ? >> 275 00:32:50,000 --> 00:32:56,000 HTTPS. Sure, that works. Okay. And then we're going to go back to our cally box. Let's see what 276 00:33:01,875 --> 00:33:07,875 IP this is. And we'll go ahead and kill this because we don't need that any more. What's the 277 00:33:11,292 --> 00:33:17,292 IP? It's like 20.110? ? >> [Off mic]. ? >> All right. Okay, so we'll come back - oh, not that. 278 00:33:22,875 --> 00:33:28,875 This. So we want the call back to be 22.168.20.1. I think I did that wrong. Is that right? And 279 00:33:35,708 --> 00:33:39,625 port 443. Okay, so now we're going to create the payload and what it's going to do is, it's 280 00:33:39,625 --> 00:33:47,583 going to use the MSG RPC interface within metasploit to create the shell code to execute 281 00:33:47,583 --> 00:33:52,417 this payload in an HTML file. It's going to create a shell code and it's going to look semi 282 00:33:52,417 --> 00:33:58,333 normal. And then what we'll do is we'll queue up throwback to call back to this HTML file and 283 00:33:58,333 --> 00:34:02,458 grab the shell code and it will inject it in the memory so meterpreter will never touch 284 00:34:02,458 --> 00:34:08,917 this, it will be running from memory. So once we click "create payload" here and it creates 285 00:34:08,917 --> 00:34:16,292 this handy little output folder, so we can just copy that to create our handler. So now we'll 286 00:34:16,292 --> 00:34:22,292 come back into here. So one thing that's important to notice is you will notice I changed the 287 00:34:25,708 --> 00:34:31,708 exit function to thread instead of process. That's important because when we inject the shell 288 00:34:34,667 --> 00:34:38,042 code into another process and we come out of our meterpreter shell, we don't want it to kill 289 00:34:38,042 --> 00:34:44,083 the process, we just want it to kill the thread that we created within that process. So we have 290 00:34:44,083 --> 00:34:50,083 our handler listening there. The payload is being generated to that HTML file. So now let's go 291 00:34:56,750 --> 00:35:02,750 ahead and queue up the task. That one. It should say, download and implement shell 292 00:35:08,042 --> 00:35:14,042 code. And then the argument in this case is the process ID or the pin we want to inject into. 293 00:35:18,042 --> 00:35:24,542 In this case, we're just going to cheat and I'm going to just look in the process list and 294 00:35:24,542 --> 00:35:29,667 type one in. We already ran a task list, so, you know, we could just look at the task 295 00:35:29,667 --> 00:35:35,667 list, but it's hard for me to see, so -. Okay, so no notepad ++ so we'll inject in notepad 296 00:35:37,875 --> 00:35:43,875 ++. So it's 1460. And then you have to select the target and then submit it. And we should 297 00:35:58,667 --> 00:36:04,667 only have to wait, at most, a minute for it to execute it. All right, it looks like it executed 298 00:36:19,458 --> 00:36:25,458 it. So if we go back now to our cally box, we have an meterpreter shell in memory. 299 00:36:36,792 --> 00:36:42,792 ? >> [Applause]. ? >> Okay. So that went well. ? >> [Laughter]. ? >> Okay, so going forward like 300 00:36:45,250 --> 00:36:47,458 I said, throwback has been published on gethub. You will see the link in the next slide. 301 00:36:47,458 --> 00:36:49,458 We have used it literally for the last four or five years. So at this point, you know, I feel 302 00:36:49,458 --> 00:36:51,458 it's pretty stable and mature, but, you know, we obviously want to make it a community based 303 00:36:51,458 --> 00:36:53,458 project. We're open to feedback. We're open to other people's ideas on improving it. And we 304 00:36:53,458 --> 00:36:55,458 also like to create modules because it implements the reflective DLL injection. It 305 00:36:55,458 --> 00:37:01,458 would be super easy to add a key logger module, cats module, hashtag module, things like 306 00:37:13,250 --> 00:37:19,250 that. So in the end, the final shameless plug is if you're interested in this type of 307 00:37:24,792 --> 00:37:31,667 writing custom malware, custom back doors, we are actually having or holding a course that 308 00:37:31,667 --> 00:37:37,542 focuses especially on this, on throw backing and creating your own malware in Black Hat Europe 309 00:37:37,542 --> 00:37:42,000 and Black Hat East Coast later this year. I'm also involved with flex grove IO if you're 310 00:37:42,000 --> 00:37:46,708 interested in any spear phishing or things like that. Custom spear phishing attacks, that's 311 00:37:46,708 --> 00:37:50,083 another super awesome project. You should check it out, if nothing else. The counts are 312 00:37:50,083 --> 00:37:56,083 free. Thank you for attending the talk today. I appreciate your time and have fun at DEF 313 00:38:00,083 --> 00:38:02,083 CON. >> [Applause]