1 00:00:00,000 --> 00:00:03,200 Well, welcome to the hacking malware talk that we're going to give here today. 2 00:00:04,220 --> 00:00:09,280 All right, I'm Val Smith. Some of you might know me. I'm a malware analyst. I do penetration 3 00:00:09,280 --> 00:00:14,440 testing, exploit development. I'm affiliated with offensive computing, which is part of 4 00:00:14,440 --> 00:00:18,500 what this talk's about. I also do some work with the Metasploit team and Cult of the Dead 5 00:00:18,500 --> 00:00:18,600 Cow. 6 00:00:21,640 --> 00:00:27,040 And I'm Danny Quist, security researcher, software developer, exploit developer, and 7 00:00:27,040 --> 00:00:29,960 reverse engineer, and I'm affiliated with offensive computing. 8 00:00:32,340 --> 00:00:36,680 All right, just real briefly, I want to give thanks to a couple of other team members, 9 00:00:36,960 --> 00:00:42,320 Patrick Stock, H.D. Moore, Ty Bodell, Scott Miller, who's giving a talk here later, so 10 00:00:42,320 --> 00:00:46,700 if you get a chance, go see that, and tons of other people. So thanks to everybody. 11 00:00:48,380 --> 00:00:52,600 Okay, what we're going to talk about today, we're going to cover a few things. The first 12 00:00:52,600 --> 00:00:56,060 thing that we're going to talk about is malware and malware protections. 13 00:00:57,040 --> 00:01:00,780 We're going to lay some basic found work for you guys, then we're going to talk about 14 00:01:00,780 --> 00:01:05,080 virtual machine detection. You may have heard of tools like Red Pill. We're going to expand 15 00:01:05,080 --> 00:01:05,880 upon that a little bit. 16 00:01:06,640 --> 00:01:10,440 Then we're going to go into exploiting some malware and we use Metasploit to do that. 17 00:01:10,840 --> 00:01:15,820 Hopefully that will be interesting. And finally, we're going to finish up with explaining our 18 00:01:15,820 --> 00:01:18,380 offensive computing project and what that's all about. 19 00:01:19,980 --> 00:01:25,120 All right, so I'm going to jump right in. Basically, we look at malware like any other 20 00:01:25,120 --> 00:01:25,520 system. 21 00:01:25,520 --> 00:01:29,960 You know, an application operating system, it's got its own protections, its own security, 22 00:01:30,120 --> 00:01:31,960 and so its own vulnerabilities as well. 23 00:01:32,560 --> 00:01:37,860 You know, malware does lots of things to protect itself from analysis and from being removed. 24 00:01:38,260 --> 00:01:42,940 So we spent some time focusing on how to bypass these protections, and we're going to talk 25 00:01:42,940 --> 00:01:43,280 about that. 26 00:01:45,100 --> 00:01:45,540 Okay. 27 00:01:45,860 --> 00:01:50,940 So the main areas that we're going to cover in this talk, just to get the basics out of 28 00:01:50,940 --> 00:01:53,520 the way, are anti-virtual machine detection. 29 00:01:53,520 --> 00:01:58,520 Malware, often, like if you've seen the Dasher worm, it'll detect that you're running in 30 00:01:58,520 --> 00:02:03,700 a virtual machine, destroy itself, and destroy the virtual machine, at least temporarily. 31 00:02:04,700 --> 00:02:09,960 Malware also uses things like binary compression, make itself smaller, encoding to make it harder 32 00:02:09,960 --> 00:02:13,220 to disassemble, and anti-debugger technologies. 33 00:02:14,340 --> 00:02:17,020 We're going to touch on each of these areas to lay a groundwork. 34 00:02:18,140 --> 00:02:18,580 Okay. 35 00:02:18,680 --> 00:02:22,440 So we like evil things, so we're going to use evil to fight evil. 36 00:02:22,440 --> 00:02:28,660 All the same sorts of methods that you might use in exploit development, you know, software 37 00:02:28,660 --> 00:02:32,440 cracking especially, old school stuff, that's the kind of things that we use against malware. 38 00:02:33,080 --> 00:02:39,180 You know, disassemblers, packer detectors, debuggers, Metasploit, of course, other cracking 39 00:02:39,180 --> 00:02:39,460 tools. 40 00:02:39,940 --> 00:02:41,480 So we're going to cover some of these areas. 41 00:02:42,960 --> 00:02:44,300 All right, you're up. 42 00:02:47,020 --> 00:02:52,360 Okay, so one of the first things that a piece of malware can do is look 43 00:02:52,440 --> 00:02:53,660 to see if it's in a virtual machine. 44 00:02:54,200 --> 00:02:57,680 This is actual disassembly from the Dasher variant. 45 00:02:58,220 --> 00:03:03,360 And those of you that don't speak assembly, the pseudocode is if you detect malware, destroy 46 00:03:03,360 --> 00:03:06,020 yourself, otherwise continue with the hilarity. 47 00:03:06,700 --> 00:03:09,060 And Dasher isn't all that wonderful. 48 00:03:09,380 --> 00:03:13,100 It does this elite net start and then grips for the VMware string. 49 00:03:13,840 --> 00:03:17,180 So all you have to do on this one, it's pretty easy to start. 50 00:03:17,280 --> 00:03:19,680 So it's just looking for the VMware services inside of here. 51 00:03:19,860 --> 00:03:20,060 Okay. 52 00:03:21,940 --> 00:03:22,420 All right. 53 00:03:23,960 --> 00:03:25,000 We've got a quick demo. 54 00:03:25,140 --> 00:03:28,160 Actually, we have several movies to sort of demonstrate how this stuff works. 55 00:03:28,380 --> 00:03:29,220 So we're going to play them. 56 00:03:29,240 --> 00:03:30,740 Hopefully they don't look too bad on the big screen. 57 00:03:34,680 --> 00:03:39,280 So this first movie is going to demonstrate how this anti-virtual machine stuff works. 58 00:03:40,600 --> 00:03:42,020 And let me get that started for you. 59 00:03:44,720 --> 00:03:45,120 Okay. 60 00:03:45,520 --> 00:03:50,680 So we're going to open up the Dasher worm here in a tool called Bintex. 61 00:03:50,820 --> 00:03:52,120 It's just a string viewer. 62 00:03:52,420 --> 00:03:55,360 And we're going to look through here for strings that might help us figure out what this malware 63 00:03:55,360 --> 00:03:55,700 is doing. 64 00:03:56,040 --> 00:03:59,080 And basically there's a little bit, but a lot of it is pretty much garbage. 65 00:03:59,700 --> 00:04:00,680 So that's not so good. 66 00:04:00,800 --> 00:04:01,960 We can't really tell what's going on. 67 00:04:03,100 --> 00:04:07,620 So the next thing to do, of course, is pop it up in IDA Pro, the reverse engineer's 68 00:04:07,620 --> 00:04:11,780 tool of choice, and see if there's any more information we can get from this malware. 69 00:04:13,320 --> 00:04:15,620 First thing that's going to happen, we're going to get some errors in IDA Pro. 70 00:04:15,880 --> 00:04:19,720 This is a hint that it's been protected in some way, packed, compressed, whatever. 71 00:04:19,960 --> 00:04:20,320 Okay. 72 00:04:22,040 --> 00:04:22,400 All right. 73 00:04:22,420 --> 00:04:26,300 So when it loads up, you'll see here, like, in the names window up at the top right, typically 74 00:04:26,300 --> 00:04:29,320 there's functions and other stuff, and down at the bottom, strings. 75 00:04:29,740 --> 00:04:30,760 There's pretty much nothing. 76 00:04:31,880 --> 00:04:36,080 So we're going to run this malware, we're in a VMware machine right now, and see if 77 00:04:36,080 --> 00:04:37,080 we can tell what's going on. 78 00:04:37,660 --> 00:04:40,680 And you see the malware detected us, and it's destroying itself. 79 00:04:41,380 --> 00:04:44,240 It'll just keep running command line windows until the virtual machine dies. 80 00:04:45,360 --> 00:04:46,680 So that's kind of rough for analysis. 81 00:04:55,220 --> 00:04:55,940 All right. 82 00:04:55,980 --> 00:05:01,580 So the more sophisticated methods for detecting virtual machine start using some of the proprietary 83 00:05:02,240 --> 00:05:05,460 protocols inside of the VMware driver interface. 84 00:05:05,960 --> 00:05:13,280 So from a user level program at ring three, you can actually set up the entire transaction 85 00:05:13,280 --> 00:05:14,180 as you would to do that. 86 00:05:14,300 --> 00:05:20,620 So in this assembly code here, we're setting up a VMXH operation, which is a special code 87 00:05:20,620 --> 00:05:21,480 to send to VMware. 88 00:05:22,420 --> 00:05:25,500 And some other values, and we're actually using the get VMware version. 89 00:05:26,040 --> 00:05:30,980 We set it to the VX port, and then we do an in operation to read from that port. 90 00:05:31,520 --> 00:05:35,540 And basically, if something comes back there, then that's a VMware port. 91 00:05:35,820 --> 00:05:37,840 If something doesn't, then that triggers an exception. 92 00:05:38,340 --> 00:05:42,600 And so you'll see this a lot in samples of malware if you do analysis on them. 93 00:05:44,400 --> 00:05:44,840 Okay. 94 00:05:44,900 --> 00:05:47,060 Again, this is the virtual PC interface. 95 00:05:47,520 --> 00:05:50,820 This uses the emit series of calls, but it's basically the same thing. 96 00:05:51,320 --> 00:05:51,760 Okay. 97 00:05:51,760 --> 00:05:54,780 If these fail in any way, you're going to trigger an exception and go off to it. 98 00:05:57,980 --> 00:06:02,560 So virtual machines are important for the malware analysts because it's important to 99 00:06:02,560 --> 00:06:03,540 have some level of safety. 100 00:06:03,800 --> 00:06:05,740 You don't want to infect your root machine. 101 00:06:06,260 --> 00:06:10,540 Not that it doesn't happen, but there's a couple different or a few different types 102 00:06:10,540 --> 00:06:11,340 of virtual machines. 103 00:06:11,640 --> 00:06:15,300 The first one is a fully emulated instruction set. 104 00:06:15,560 --> 00:06:20,300 And this is where the instructions are translated dynamically on the fly from the host OS. 105 00:06:21,760 --> 00:06:25,520 These have a, you know, 100% it's being emulated. 106 00:06:25,680 --> 00:06:27,680 Things like box, it's really slow. 107 00:06:27,840 --> 00:06:29,780 That's because it's doing this one-to-one emulation. 108 00:06:30,720 --> 00:06:34,060 The next advanced in virtual machines is a somewhat emulated. 109 00:06:34,260 --> 00:06:36,680 And this is VMware's acceleration mode. 110 00:06:37,040 --> 00:06:43,360 So this is where some of the critical instructions are emulated by the VMware, but otherwise 111 00:06:43,720 --> 00:06:48,760 the entire operation of it is carried off on the raw hardware. 112 00:06:49,200 --> 00:06:49,340 Okay. 113 00:06:51,020 --> 00:06:51,140 Okay. 114 00:06:51,760 --> 00:06:51,880 So this is the virtualization. 115 00:06:52,740 --> 00:06:58,060 Joanna Rutkowska gave a great talk about ideas about how malware could use that. 116 00:06:58,220 --> 00:07:02,640 And this is the Intel Vanderpool instruction set and AMD Pacific instruction set. 117 00:07:02,840 --> 00:07:08,820 And what these do is they actually have chip support inside of the CPU to handle the virtualization 118 00:07:08,820 --> 00:07:09,180 functions. 119 00:07:11,600 --> 00:07:12,240 Okay. 120 00:07:12,280 --> 00:07:14,960 So generic VM detection. 121 00:07:15,360 --> 00:07:19,760 There was an excellent paper outlining the problems implementing virtual machines on 122 00:07:19,760 --> 00:07:21,160 IA32 architectures. 123 00:07:21,220 --> 00:07:21,740 Okay. 124 00:07:24,740 --> 00:07:26,000 And they actually had a paper outlining the problems implementing virtual machines on 125 00:07:26,000 --> 00:07:31,380 And basically what they said is that there are some registers that have system-wide applicability. 126 00:07:31,960 --> 00:07:39,660 So you have the LDT, the local descriptor table, the GDT, global descriptor table, IDT, 127 00:07:39,820 --> 00:07:41,360 which is the interrupt descriptor table. 128 00:07:41,520 --> 00:07:44,500 And this is the technique used by Joanna's Red Pill. 129 00:07:44,780 --> 00:07:46,600 And also the machine status word. 130 00:07:46,820 --> 00:07:49,680 So anytime a program is executing inside of VMware. 131 00:07:49,680 --> 00:07:53,540 These instructions and these register reads have to be emulated. 132 00:07:53,800 --> 00:07:58,780 And that's where we get our, that's where we make our tool useful. 133 00:08:00,060 --> 00:08:04,400 So the thing about it is the Intel CPU was not originally designed for virtualization. 134 00:08:05,280 --> 00:08:09,000 It either must be emulated, these instructions, or it must be translated. 135 00:08:09,580 --> 00:08:14,740 And so this is all ring three or user level code, or signature generation. 136 00:08:15,220 --> 00:08:15,320 Okay. 137 00:08:17,460 --> 00:08:17,980 Okay. 138 00:08:19,680 --> 00:08:20,220 So some of the techniques. 139 00:08:21,220 --> 00:08:22,680 See the evil theme in here? 140 00:08:23,380 --> 00:08:23,440 Okay. 141 00:08:23,920 --> 00:08:24,620 Cheap shot. 142 00:08:24,720 --> 00:08:24,900 I'm sorry. 143 00:08:25,420 --> 00:08:26,920 So the IDT technique. 144 00:08:27,060 --> 00:08:33,420 This is done by the Red Pill by Joanna Rakowska and the Scoopy Doo by Tobias Klein. 145 00:08:33,940 --> 00:08:37,600 This is just a simple signature match on the IDT register value. 146 00:08:38,220 --> 00:08:43,860 But the problem with the IDT is that being the interrupt descriptor table, each CPU has 147 00:08:43,860 --> 00:08:45,140 its own copy of the IDT. 148 00:08:45,420 --> 00:08:49,100 So if you're on a multiprocessor machine, the signature is not going to match. 149 00:08:49,680 --> 00:08:56,240 And so the question becomes how does the ingenious malware developer come up with a way to understand 150 00:08:56,240 --> 00:08:58,860 all of the IDTs across all number of processors. 151 00:08:59,520 --> 00:09:04,760 And so the quick thing that you can discern from this is that if you are using the IDT 152 00:09:04,760 --> 00:09:08,060 method, you're going to fail one over n times for however many processors you have. 153 00:09:09,160 --> 00:09:11,640 The global descriptor table had similar results. 154 00:09:12,020 --> 00:09:14,260 It was effective in discovering this. 155 00:09:14,420 --> 00:09:17,400 The only thing that was useful was the LDT. 156 00:09:17,540 --> 00:09:19,260 You could see it across a parallel. 157 00:09:19,320 --> 00:09:19,660 Okay. 158 00:09:20,200 --> 00:09:23,580 It was a parallel system, and it always had the same idea. 159 00:09:23,820 --> 00:09:27,380 And this is, you know, since it's used for accessing local data, it's all operating 160 00:09:27,380 --> 00:09:31,620 system dependent, but for our case in Windows, it worked quite nicely. 161 00:09:33,400 --> 00:09:36,280 So memory is addressed similarly on the context switch. 162 00:09:37,120 --> 00:09:42,900 The problem with the LDT method, as was pointed out when we made a rootkit.com post, is that 163 00:09:42,900 --> 00:09:43,960 it fails on full emulation. 164 00:09:44,780 --> 00:09:47,020 So the trick to get around this. 165 00:09:47,820 --> 00:09:48,960 If you want to. 166 00:09:49,760 --> 00:09:53,080 Analyze a piece of malware that's only looking at the LDT is to disable emulation. 167 00:09:53,840 --> 00:09:58,900 But it turns out that there's another bug in the machine status word is what we'll use 168 00:09:58,900 --> 00:10:00,020 to give the full idea. 169 00:10:00,600 --> 00:10:07,440 So here's our grand unified VMware fingering our VM fingering out our fingerprinting algorithm. 170 00:10:08,120 --> 00:10:13,320 So the first thing we do is we look at the easy LDT value and see if this matches our 171 00:10:13,320 --> 00:10:13,660 signature. 172 00:10:14,200 --> 00:10:16,740 If it does, and we say, fine, we're in a virtual machine. 173 00:10:17,300 --> 00:10:17,880 Do you miss? 174 00:10:17,920 --> 00:10:18,360 The machine? 175 00:10:18,360 --> 00:10:21,500 The machine status word, or if we fail on that, we look at the machine status word. 176 00:10:22,200 --> 00:10:26,760 The high order bytes in the Intel specification says that this is undefined. 177 00:10:27,940 --> 00:10:33,180 And so inside of the Intel machine, it sets it, our Intel, actual Intel hardware, it sets 178 00:10:33,180 --> 00:10:34,540 it to a predefined value. 179 00:10:34,860 --> 00:10:39,540 But on VMware, there's a bug or at least an oversight that says that it, or it doesn't 180 00:10:39,540 --> 00:10:41,360 clear that out, possibly for speed. 181 00:10:41,800 --> 00:10:44,460 So that's where we build up our signature detection. 182 00:10:46,440 --> 00:10:46,920 Okay. 183 00:10:47,020 --> 00:10:48,340 So we'll do a demo. 184 00:10:48,360 --> 00:10:48,720 We'll do a demo here. 185 00:10:56,860 --> 00:10:58,480 Make this bigger so people can see it. 186 00:11:07,840 --> 00:11:08,220 Okay. 187 00:11:10,240 --> 00:11:12,140 So I'm just going to run this VM detect tool. 188 00:11:13,500 --> 00:11:14,760 This looks at the LDT. 189 00:11:15,280 --> 00:11:17,580 It's set to all zeros, which is indicative of this. 190 00:11:17,580 --> 00:11:21,360 The machine status word, again, the high order bits are 8001. 191 00:11:21,560 --> 00:11:25,680 So we can mostly conclude that this is a native machine here. 192 00:11:27,420 --> 00:11:29,720 Over on a VMware system. 193 00:11:44,500 --> 00:11:45,960 We'll run the VM detect tool. 194 00:11:47,300 --> 00:11:52,280 And we'll see that we're detecting a fully emulated virtual machine here. 195 00:11:52,580 --> 00:11:55,660 And so we're also running some of the other systems to look at it. 196 00:11:55,760 --> 00:11:59,340 So for the emulation method, if you're in VMware. 197 00:11:59,340 --> 00:12:01,340 And you go to options and it's advanced here. 198 00:12:02,040 --> 00:12:06,360 This disable acceleration is the critical flag to look at. 199 00:12:06,940 --> 00:12:11,720 And so again, this is a bit opposite from the actual demo. 200 00:12:11,880 --> 00:12:17,240 But if you run a VM detect on this, too, we can see that the LDT has this 6040 value. 201 00:12:17,560 --> 00:12:23,640 And the machine status word is set to the normal Intel thing. 202 00:12:23,780 --> 00:12:26,520 And that's because the root CPU is actually running that. 203 00:12:26,700 --> 00:12:29,160 So this is a virtual machine without emulation. 204 00:12:35,660 --> 00:12:36,140 Okay. 205 00:12:37,100 --> 00:12:39,780 So how do you defeat these VM techniques? 206 00:12:40,200 --> 00:12:42,560 The first one are in the case of the Dasher variant. 207 00:12:42,880 --> 00:12:47,900 It's just looking for that string in the list of running services which says I'm running 208 00:12:47,900 --> 00:12:49,100 the VMware tools. 209 00:12:49,460 --> 00:12:53,220 So all you have to do is, you know, net stop VMware tools and then you're done. 210 00:12:54,200 --> 00:12:57,180 The next method that you can use is to binary patch the malware. 211 00:12:57,180 --> 00:13:01,400 Basically, just to nop over the VMware detection routines. 212 00:13:01,720 --> 00:13:09,820 So inside of here, we're actually finding the call and patching it over with the 0x90. 213 00:13:10,060 --> 00:13:17,120 The other thing that you can do, if you like to roll that way, is that you can run natively 214 00:13:17,120 --> 00:13:19,160 or use some obscure VM. 215 00:13:21,660 --> 00:13:22,160 Okay. 216 00:13:24,160 --> 00:13:27,060 So as you can see, Danny is the brains behind operation. 217 00:13:27,180 --> 00:13:28,340 I'm just the eye candy. 218 00:13:31,360 --> 00:13:32,220 We're working on that. 219 00:13:38,580 --> 00:13:39,120 All right. 220 00:13:40,220 --> 00:13:41,220 We're movie happy. 221 00:13:42,240 --> 00:13:46,900 So basically, we're going to pop this thing open in OLLI debug and look at it and try 222 00:13:46,900 --> 00:13:50,340 to get an idea of what's going on, how it's, you know, screwing over our VM. 223 00:13:53,280 --> 00:13:56,140 Again, this is the Dasher worm that we were looking at earlier. 224 00:13:58,100 --> 00:14:00,960 So this isn't like an advanced OLLI demo or anything. 225 00:14:01,180 --> 00:14:04,660 We basically, you know, consider OLLI to be sort of like a machine TiVo. 226 00:14:04,780 --> 00:14:07,800 We like to be able to go forward and pause things and see what's going on. 227 00:14:09,100 --> 00:14:11,060 So what we did here is we opened Dasher. 228 00:14:11,400 --> 00:14:12,340 We advance it. 229 00:14:12,440 --> 00:14:15,780 You know, we step through it a few times until we get to a point where we think something's 230 00:14:15,780 --> 00:14:16,160 going on. 231 00:14:16,440 --> 00:14:20,380 And then we're searching down here in this window for potentially useful strings that 232 00:14:20,380 --> 00:14:22,420 could give us hints as to what to do about this. 233 00:14:22,660 --> 00:14:23,800 It's kind of hard to see in there. 234 00:14:24,820 --> 00:14:26,840 So I'm going to cut and paste it into Notepad. 235 00:14:27,920 --> 00:14:30,920 And then we'll search through there and you can see what's going on. 236 00:14:33,960 --> 00:14:34,320 Okay. 237 00:14:34,360 --> 00:14:36,120 Basically, there's tons of information in here. 238 00:14:36,320 --> 00:14:40,420 But we're looking for something that really triggers us off on the VMware self-destruct 239 00:14:40,420 --> 00:14:42,020 mechanism and how that works. 240 00:14:43,860 --> 00:14:45,440 So I'm going to fast forward just a little bit. 241 00:14:47,360 --> 00:14:47,720 Okay. 242 00:14:47,780 --> 00:14:51,160 You can see there there's a batch file called virtual.bat. 243 00:14:51,540 --> 00:14:52,980 That's not native to the system. 244 00:14:53,060 --> 00:14:55,180 That's something that's there since the malware started running. 245 00:14:55,400 --> 00:14:57,160 So we're going to go take a look at that and see what it does. 246 00:15:00,440 --> 00:15:00,880 Okay. 247 00:15:01,740 --> 00:15:02,920 So we found that file. 248 00:15:03,100 --> 00:15:03,640 It's indeed there. 249 00:15:04,180 --> 00:15:05,280 And you can look in here. 250 00:15:05,520 --> 00:15:10,040 It's just a batch file that says look at the net start services output, run find string, 251 00:15:10,240 --> 00:15:11,020 and find VMware. 252 00:15:11,420 --> 00:15:13,720 This is a really lame way of doing this. 253 00:15:13,820 --> 00:15:16,800 That's why we're releasing the VMware detect that Danny was talking about. 254 00:15:17,220 --> 00:15:20,840 But you can see that's basically what malware people are doing. 255 00:15:21,060 --> 00:15:24,600 Most of the malware that's out there running around the wild uses these really simple techniques. 256 00:15:26,200 --> 00:15:26,640 Okay. 257 00:15:26,640 --> 00:15:31,780 So now that we know how it's detecting VMware, let's see if we can find what it does next. 258 00:15:32,080 --> 00:15:33,160 So we're going to do the same thing. 259 00:15:33,260 --> 00:15:34,400 We advance the stack a little bit. 260 00:15:34,860 --> 00:15:38,080 We're going to pop this open in Notepad and look for some more useful strings that can 261 00:15:38,080 --> 00:15:38,580 help us out. 262 00:15:40,200 --> 00:15:41,600 And more fast forwarding. 263 00:15:52,040 --> 00:15:53,480 Other malware is more advanced. 264 00:15:54,220 --> 00:15:55,520 You might not be able to do this. 265 00:15:55,520 --> 00:15:57,200 Like, we'll get into it a little bit more later. 266 00:15:57,320 --> 00:16:00,320 But it might detect all the debug and prevent you from doing this kind of thing. 267 00:16:07,920 --> 00:16:08,280 Okay. 268 00:16:08,300 --> 00:16:08,840 Almost there. 269 00:16:09,480 --> 00:16:09,920 All right. 270 00:16:10,040 --> 00:16:14,300 So you can see there's a really friendly batch file on the system now called f-off.bat. 271 00:16:15,660 --> 00:16:17,780 Definitely not something that we put there originally. 272 00:16:18,120 --> 00:16:19,560 So the malware had to create this. 273 00:16:19,680 --> 00:16:21,500 We're going to pop this open and see what this is going to do. 274 00:16:21,560 --> 00:16:22,700 Probably not something friendly. 275 00:16:31,020 --> 00:16:31,400 Okay. 276 00:16:33,860 --> 00:16:35,860 So it's basically just a go-to loop. 277 00:16:36,300 --> 00:16:41,240 Spawn a command shell over and over and over again until you fill up the memory. 278 00:16:42,020 --> 00:16:42,400 Okay. 279 00:16:44,360 --> 00:16:48,940 So the next thing we've got to do if we want to do some real analysis on this malware is 280 00:16:48,940 --> 00:16:50,580 get around its protection mechanism. 281 00:16:51,980 --> 00:16:53,220 The simplest way... 282 00:16:53,220 --> 00:16:55,500 I mean, you can do some of the old-school cracker stuff that Danny was talking about. 283 00:16:55,520 --> 00:16:56,800 And knock it out or whatever. 284 00:16:57,060 --> 00:17:00,920 But if you don't really know what's going on, do the same thing it does. 285 00:17:01,100 --> 00:17:05,880 Look in the services strings for the VMware tool service and stop it. 286 00:17:09,920 --> 00:17:11,140 So we're going to stop that service. 287 00:17:11,300 --> 00:17:15,360 Now if you do a net start and look in the services list, it's not going to be there 288 00:17:15,360 --> 00:17:15,600 anymore. 289 00:17:16,160 --> 00:17:18,440 So when the malware looks for it, it's not going to find it either. 290 00:17:20,740 --> 00:17:24,700 Then the next thing to do is to instrument your system with things like sysinternals, 291 00:17:24,700 --> 00:17:28,600 regmon, filemon, whatever, so you can see what the malware's doing to your system when 292 00:17:28,600 --> 00:17:29,000 you run it. 293 00:17:31,680 --> 00:17:35,700 You want to look at things like network ports, run a sniffer, all that sort of stuff. 294 00:17:37,580 --> 00:17:39,160 I'm going to fast-forward just a little bit more. 295 00:17:42,860 --> 00:17:43,220 Okay. 296 00:17:43,600 --> 00:17:47,060 What we're doing here is filtering out known things in regmon. 297 00:17:47,260 --> 00:17:47,940 We're going to run it. 298 00:17:48,120 --> 00:17:50,440 And you can see in the background, all that stuff got populated. 299 00:17:50,820 --> 00:17:52,820 That's everything the worm does to our system now. 300 00:17:52,980 --> 00:17:53,920 So we're inside of VMware. 301 00:17:54,220 --> 00:17:54,680 We're able to run it. 302 00:17:54,680 --> 00:17:59,520 We're able to analyze this malware that we weren't before and build up a model or a signature 303 00:17:59,520 --> 00:18:02,820 for what it's going to do and run a sniffer and take a look at that. 304 00:18:08,480 --> 00:18:08,960 Okay. 305 00:18:09,140 --> 00:18:13,140 So a couple of the other things besides VMware detection that malware does is binary compression. 306 00:18:13,940 --> 00:18:15,860 You know, there's a lot of reasons for doing this. 307 00:18:16,020 --> 00:18:16,920 Smaller binaries. 308 00:18:17,140 --> 00:18:18,240 Takes less bandwidth. 309 00:18:18,540 --> 00:18:20,960 This is really important in worms so that they can propagate really quickly. 310 00:18:21,480 --> 00:18:23,320 Leave a smaller footprint on your system. 311 00:18:23,320 --> 00:18:27,040 Makes it harder to disassemble and analyze, figure out what's going on. 312 00:18:27,140 --> 00:18:30,120 There's tons of packers out there off the shelf that you can get. 313 00:18:30,560 --> 00:18:32,540 Lots of people write custom packers for their malware. 314 00:18:34,360 --> 00:18:37,180 The next thing is encryption, which is very much related. 315 00:18:37,780 --> 00:18:41,620 Basically these things load a small decoder stub at the beginning of the binary or something 316 00:18:41,620 --> 00:18:42,060 like that. 317 00:18:42,240 --> 00:18:45,880 And they either uncompress or decrypt themselves before they execute. 318 00:18:47,140 --> 00:18:48,020 This has... 319 00:18:48,020 --> 00:18:50,020 This doesn't give you a smaller footprint. 320 00:18:50,520 --> 00:18:52,880 But it makes it harder to reverse engineer. 321 00:18:53,320 --> 00:18:54,220 To analyze what the binary is doing. 322 00:18:54,620 --> 00:18:56,500 There are some legitimate uses for this stuff. 323 00:18:57,120 --> 00:18:58,820 Like intellectual property protection. 324 00:18:59,260 --> 00:19:01,120 But I don't think anyone really takes that seriously. 325 00:19:01,300 --> 00:19:02,480 Because all of it can be broken. 326 00:19:05,700 --> 00:19:06,100 Okay. 327 00:19:08,940 --> 00:19:11,160 Just going to show a quick example of what that looks like. 328 00:19:16,460 --> 00:19:17,280 We love movies. 329 00:19:20,000 --> 00:19:20,520 All right. 330 00:19:20,580 --> 00:19:23,120 We're going to take some botnet thing that we found out. 331 00:19:23,320 --> 00:19:24,640 And take a look at it. 332 00:19:24,700 --> 00:19:26,280 This one hasn't been protected with anything. 333 00:19:26,580 --> 00:19:27,980 So you can see here there's a bunch of strings. 334 00:19:28,200 --> 00:19:29,860 It's got denial of service stuff going on. 335 00:19:30,180 --> 00:19:31,760 It's got IRC commands. 336 00:19:32,420 --> 00:19:34,320 So it's pretty easy to tell what's happening here. 337 00:19:34,660 --> 00:19:39,140 If you pop it open in IDA Pro, you're going to see quite a bit of information that you 338 00:19:39,140 --> 00:19:41,060 can fully reverse engineer this bot. 339 00:19:41,720 --> 00:19:43,820 You look up there, there's functions in the top right. 340 00:19:43,980 --> 00:19:44,880 There's strings in the bottom. 341 00:19:45,140 --> 00:19:46,380 The assembly looks pretty good. 342 00:19:47,020 --> 00:19:49,460 It's easy to figure out what this is doing. 343 00:19:50,620 --> 00:19:52,020 And if you look at a call graph. 344 00:19:52,020 --> 00:19:53,340 It makes a lot of sense. 345 00:19:53,480 --> 00:19:53,960 It's really clear. 346 00:19:54,560 --> 00:19:57,180 So we're going to protect this with one of the common packers called UPEX. 347 00:19:58,860 --> 00:20:00,240 This is a compressor. 348 00:20:01,720 --> 00:20:03,040 And we're going to compress the bot. 349 00:20:05,280 --> 00:20:08,500 And then we're going to do all these same steps again to see what changed and how it 350 00:20:08,500 --> 00:20:08,940 looks different. 351 00:20:10,760 --> 00:20:13,500 So you can see in here, most of the strings have disappeared. 352 00:20:13,700 --> 00:20:14,480 There's still a few here. 353 00:20:15,240 --> 00:20:17,880 But it's actually improved the protection of this piece of malware. 354 00:20:19,200 --> 00:20:22,000 When you look at it on IDA, you're going to see a bunch of changes. 355 00:20:22,020 --> 00:20:26,940 The first being, you're probably going to have some errors, like trying to find the 356 00:20:26,940 --> 00:20:29,240 import address table, for example. 357 00:20:33,880 --> 00:20:36,000 And you can see there, there's a lot less functions. 358 00:20:36,200 --> 00:20:37,520 The strings are pretty much mangled. 359 00:20:37,720 --> 00:20:39,200 The call graph looks really interesting. 360 00:20:41,520 --> 00:20:43,240 Little less clear than the previous one. 361 00:20:44,480 --> 00:20:45,100 There you go. 362 00:20:45,240 --> 00:20:46,080 For comparison. 363 00:20:47,140 --> 00:20:48,660 But still, it's not too bad. 364 00:20:48,780 --> 00:20:50,240 You can glean some information from this. 365 00:20:50,540 --> 00:20:51,000 All right. 366 00:20:51,000 --> 00:20:52,580 We're going to get all hardcore and use Morphine. 367 00:20:52,740 --> 00:20:54,160 It's written by a guy named Holy Father. 368 00:20:54,560 --> 00:20:55,900 And this is an encryptor. 369 00:20:55,960 --> 00:20:57,220 So we're encrypting on top of this. 370 00:20:58,740 --> 00:21:03,480 And now when we pop it open and take a look at it, you know, there's even less strings. 371 00:21:03,620 --> 00:21:06,360 Pretty much none, except for get proc address and load library. 372 00:21:06,600 --> 00:21:07,960 Those are really common in malware. 373 00:21:08,140 --> 00:21:08,940 You'll see those all the time. 374 00:21:11,980 --> 00:21:14,440 And IDA's going to look really bizarre once we open this one up. 375 00:21:19,980 --> 00:21:20,300 Okay. 376 00:21:21,000 --> 00:21:21,120 Strings. 377 00:21:21,640 --> 00:21:23,180 Basically nothing in the names window. 378 00:21:23,640 --> 00:21:25,320 And a really confusing call graph. 379 00:21:25,780 --> 00:21:31,380 So that loop right there is probably indicative of the stub that unpacks or decompresses this 380 00:21:31,380 --> 00:21:31,760 whole thing. 381 00:21:39,100 --> 00:21:39,540 Okay. 382 00:21:39,700 --> 00:21:42,220 So a little Faustian picture there. 383 00:21:42,400 --> 00:21:43,840 How are we going to defeat this stuff? 384 00:21:44,300 --> 00:21:45,480 Well, there's a lot of different ways. 385 00:21:45,580 --> 00:21:46,260 There's some basic ways. 386 00:21:46,360 --> 00:21:47,380 Like you scan it with a detector. 387 00:21:47,640 --> 00:21:50,080 And if you can detect what it's packed or compressed with. 388 00:21:50,080 --> 00:21:54,200 Go out there and search around for an unpacker or unencrypter. 389 00:21:54,620 --> 00:21:55,480 If it's available. 390 00:21:55,740 --> 00:21:56,720 A lot of times they're not. 391 00:21:56,980 --> 00:21:59,220 So you need to unpack it yourself. 392 00:21:59,920 --> 00:22:02,880 There's a great tool called x86emu by Chris Eagle. 393 00:22:04,040 --> 00:22:05,880 Highly recommend for doing this kind of thing. 394 00:22:06,060 --> 00:22:07,360 Of course, IDA, Oli debug. 395 00:22:08,200 --> 00:22:12,860 The best way for getting around these malware protections is to actually partially execute 396 00:22:12,860 --> 00:22:16,680 the malware and dump the region of memory where this process resides. 397 00:22:17,880 --> 00:22:19,880 Some processes don't stay memory resident. 398 00:22:20,080 --> 00:22:21,680 So this could be a little bit harder. 399 00:22:21,860 --> 00:22:25,160 You need to run like a debugger so you can pause it right before it exits or whatever. 400 00:22:29,360 --> 00:22:29,720 Okay. 401 00:22:30,240 --> 00:22:31,260 There's another video here. 402 00:22:34,260 --> 00:22:35,620 We'll just take a quick look at this. 403 00:22:46,200 --> 00:22:46,740 All right. 404 00:22:46,760 --> 00:22:49,740 So you can see we have some professional tools developed for this. 405 00:22:52,200 --> 00:22:57,620 These are three of sort of the top packer detectors, PID and PSCAN and protection ID. 406 00:22:58,280 --> 00:23:02,480 So we're going to stick this thing in there and basically they're not going to detect 407 00:23:02,480 --> 00:23:02,940 anything. 408 00:23:03,200 --> 00:23:05,080 They have no idea what this is protected with. 409 00:23:06,260 --> 00:23:13,100 These tools based on like opcode sequence signature matching, which is okay, but a lot 410 00:23:13,100 --> 00:23:15,740 of these new packers and encryptors coming out are polymorphic. 411 00:23:15,780 --> 00:23:16,940 So it's different all the time. 412 00:23:17,740 --> 00:23:18,220 Okay. 413 00:23:21,660 --> 00:23:25,020 A lot of these demos are with real live malware that we get through our site. 414 00:23:25,280 --> 00:23:26,760 So you know, these aren't contrived. 415 00:23:26,840 --> 00:23:28,600 These are actually, we're reverse engineering real malware. 416 00:23:33,360 --> 00:23:33,680 Okay. 417 00:23:33,760 --> 00:23:38,840 So what we're going to do here is pop this open in Oli debug and we're going to advance 418 00:23:38,840 --> 00:23:39,300 it through. 419 00:23:39,380 --> 00:23:42,020 We're going to step through several instructions to try to get it to a certain point. 420 00:23:42,760 --> 00:23:46,120 There's way more complex techniques than this, but we just want to get the basics out of 421 00:23:46,120 --> 00:23:46,320 the way. 422 00:23:51,300 --> 00:23:53,460 There's a tool called Lord PE, which I like a lot. 423 00:23:53,640 --> 00:23:55,460 It's good for editing binaries. 424 00:23:55,520 --> 00:23:56,940 It's also good for dumping them. 425 00:23:57,180 --> 00:23:58,840 You can dump them in Oli debug with a plugin. 426 00:23:59,460 --> 00:24:04,000 So what we're going to do here is we load it up in Oli debug, which paused the malware 427 00:24:04,000 --> 00:24:04,860 process for us. 428 00:24:05,200 --> 00:24:07,780 We found it in Lord PE and then we're going to dump it. 429 00:24:11,340 --> 00:24:15,220 And then Lord PE has a little tool to help fix up the binary and hopefully get some more 430 00:24:15,220 --> 00:24:15,980 import table information. 431 00:24:17,000 --> 00:24:17,360 Okay. 432 00:24:17,840 --> 00:24:18,200 Okay. 433 00:24:20,240 --> 00:24:20,800 All right. 434 00:24:20,860 --> 00:24:22,040 So previously we had this thing. 435 00:24:22,120 --> 00:24:23,300 The packers couldn't detect it. 436 00:24:23,380 --> 00:24:24,400 We couldn't find any strings. 437 00:24:24,800 --> 00:24:26,780 It pretty much was hard to figure out what was going on. 438 00:24:27,300 --> 00:24:33,940 Now that we've dumped it from memory, we can open it up in IDA and hopefully you'll 439 00:24:33,940 --> 00:24:35,700 see here, yeah, all the functions are available. 440 00:24:36,780 --> 00:24:37,440 Strings are available. 441 00:24:37,540 --> 00:24:41,460 So you can start to see here, you know, okay, there's some registry key access going on. 442 00:24:42,060 --> 00:24:44,720 We're going to pop it up in the strings window because it's a little bit easier to see. 443 00:24:46,020 --> 00:24:46,400 Okay. 444 00:24:47,820 --> 00:24:48,200 All right. 445 00:24:49,320 --> 00:24:52,520 I mean, the main point of reverse engineering malware is to find out what it is and what 446 00:24:52,520 --> 00:24:52,860 it's doing. 447 00:24:55,220 --> 00:24:56,800 And a lot of times you can figure that out. 448 00:24:56,900 --> 00:25:00,180 For example, these strings here, it's obviously a porn bot of some sort. 449 00:25:00,660 --> 00:25:03,100 If you want some anime, install this, it'll hook you up. 450 00:25:11,040 --> 00:25:11,400 Okay. 451 00:25:13,120 --> 00:25:17,700 So the final kind of protection that we're going to go over here is anti-debugger technology. 452 00:25:17,820 --> 00:25:18,180 Okay. 453 00:25:18,960 --> 00:25:20,700 People are getting really crazy with this. 454 00:25:20,840 --> 00:25:23,800 They're like checksumming their binary image and memory. 455 00:25:24,100 --> 00:25:25,540 But this is one of the simple methods. 456 00:25:25,820 --> 00:25:30,600 Windows actually provides an API call, which is useful to developers to detect if a debugger 457 00:25:30,600 --> 00:25:31,540 is attached to their process. 458 00:25:32,220 --> 00:25:34,160 This is just some basic code to show how this works. 459 00:25:34,940 --> 00:25:36,680 There's a lot of different ways to get around this. 460 00:25:36,940 --> 00:25:41,260 We actually did some cracker stuff and found this in a binary and jumped over it. 461 00:25:41,780 --> 00:25:45,640 Oli debug has a really helpful is debugger present hiding plugin now. 462 00:25:45,820 --> 00:25:47,920 So that's one of the best ways to get around this. 463 00:25:49,120 --> 00:25:51,920 I don't think I'm going to go into this video because this is pretty simple. 464 00:25:52,040 --> 00:25:57,500 You basically run Oli debug if you have the plugin installed and click hide from is debugger 465 00:25:57,500 --> 00:25:57,680 present. 466 00:25:59,560 --> 00:25:59,920 Okay. 467 00:25:59,980 --> 00:26:02,360 One of the other things that we did here is we disassembled the binary. 468 00:26:03,200 --> 00:26:08,220 We found the is debugger present call in there and basically changed the jump so that we 469 00:26:08,220 --> 00:26:08,900 could get past it. 470 00:26:09,760 --> 00:26:15,840 You can see in there basically if the debugger's present, it sends you to a you die now call. 471 00:26:16,040 --> 00:26:17,180 So a lot of malware will do that. 472 00:26:17,220 --> 00:26:17,840 It'll delete itself. 473 00:26:18,180 --> 00:26:20,100 Or similar to the VMware protection stuff. 474 00:26:22,040 --> 00:26:22,480 Okay. 475 00:26:23,000 --> 00:26:24,580 Now we're going to get to the cool stuff, hopefully. 476 00:26:25,060 --> 00:26:26,200 Exploiting malware vulnerabilities. 477 00:26:27,360 --> 00:26:31,640 Often malware writers don't care about quality or, you know, stability. 478 00:26:31,900 --> 00:26:35,840 They just want to get it out to get famous or if they're trying to make money from identity 479 00:26:35,840 --> 00:26:36,200 theft. 480 00:26:36,500 --> 00:26:39,040 So they don't really write great code all the time. 481 00:26:39,200 --> 00:26:41,180 Which means that often the malware has vulnerabilities. 482 00:26:41,780 --> 00:26:45,240 A classic example of this is this thing called AV serve FTP server. 483 00:26:45,460 --> 00:26:46,900 It's used in a lot of worms. 484 00:26:47,240 --> 00:26:48,160 Like, I think the... 485 00:26:48,180 --> 00:26:49,440 Sasser worm probably used it. 486 00:26:51,340 --> 00:26:52,800 So we took a look at this thing. 487 00:26:53,500 --> 00:26:56,480 Somebody out there wrote an exploit for it, which was kind of hard to use. 488 00:26:56,660 --> 00:26:59,540 So we decided to use the awesome Metasploit and make it better. 489 00:27:00,640 --> 00:27:03,600 We unpacked this binary using the unpack methods we mentioned earlier. 490 00:27:03,860 --> 00:27:05,980 And we started analyzing the disassembly. 491 00:27:06,560 --> 00:27:11,080 Inside here is a real basic buffer overflow in the port command of the FTP server. 492 00:27:11,500 --> 00:27:14,920 If you look up there, basically, it takes the port command from the user. 493 00:27:15,360 --> 00:27:17,440 And whatever port the user feeds it. 494 00:27:17,440 --> 00:27:18,900 It sends it right to a stir copy. 495 00:27:19,160 --> 00:27:19,780 With no checking. 496 00:27:20,240 --> 00:27:22,580 So you can send a port command of 500 days. 497 00:27:24,920 --> 00:27:25,280 Okay. 498 00:27:25,880 --> 00:27:28,880 Metasploit is great because you can write, like, one line exploits. 499 00:27:28,940 --> 00:27:30,980 Because the whole framework is there to handle everything for you. 500 00:27:31,600 --> 00:27:32,700 So that's basically what we did. 501 00:27:33,220 --> 00:27:37,280 Sometimes writing a denial of service attack for a piece of malware could be really helpful 502 00:27:37,280 --> 00:27:38,220 if you own your network. 503 00:27:40,000 --> 00:27:44,640 You know, for example, if a network gets compromised by one of these worms and you can't make it 504 00:27:44,640 --> 00:27:45,900 to all the machines to go clean them up. 505 00:27:45,900 --> 00:27:50,420 You could do, like, a broadcast denial of service attack which will kill the worm on 506 00:27:50,420 --> 00:27:53,360 everybody's machine but leave the host intact so people can keep working. 507 00:27:53,680 --> 00:27:55,880 So that's kind of the idea behind this, what we're doing here. 508 00:27:57,060 --> 00:28:02,120 At the bottom in red, you can see we developed a really simple request through the Metasploit 509 00:28:02,120 --> 00:28:04,840 framework to send a port command of 295 A's. 510 00:28:06,880 --> 00:28:07,280 Okay. 511 00:28:07,640 --> 00:28:08,560 Well, that's pretty cool. 512 00:28:08,680 --> 00:28:11,300 But, you know, just for bling's sake, we're going to kick it up a notch. 513 00:28:11,600 --> 00:28:13,600 And see if we can get a shell on this piece of malware. 514 00:28:14,180 --> 00:28:15,880 We used a classic SEH overlay. 515 00:28:17,020 --> 00:28:26,020 Metasploit has a cool tool called MSFP scan which can find return addresses and DLLs 516 00:28:26,020 --> 00:28:26,560 and things like that. 517 00:28:26,720 --> 00:28:27,200 So we used that. 518 00:28:27,400 --> 00:28:29,340 There will be a movie for this in just a second. 519 00:28:30,080 --> 00:28:33,880 But I want to cover the exploit line real quickly because it's a little bit complicated. 520 00:28:34,840 --> 00:28:40,180 Basically we're going to send the FTP command, a bunch of padding, a jump to jump forward 521 00:28:40,180 --> 00:28:44,360 six bytes to our address, which we found in kernel32.dll. 522 00:28:44,360 --> 00:28:47,800 And then a jump back about a thousand bytes to our shell code. 523 00:28:48,080 --> 00:28:52,360 The reason for this is because on this particular one, memory gets corrupted and two copies 524 00:28:52,360 --> 00:28:53,540 of our shell code get created. 525 00:28:53,760 --> 00:28:56,160 The bottom one is destroyed and the top one is actually good. 526 00:28:56,280 --> 00:28:57,240 So that's why we're jumping back. 527 00:28:57,440 --> 00:28:58,380 And then some padding. 528 00:28:59,880 --> 00:29:01,740 So let's show the fancy video. 529 00:29:12,300 --> 00:29:12,900 All right. 530 00:29:12,960 --> 00:29:14,140 So the two black windows. 531 00:29:14,360 --> 00:29:16,660 Our SSH into a system running Metasploit. 532 00:29:17,420 --> 00:29:22,960 We're going to open up this piece of malware in Windabug so that we can watch what happens 533 00:29:22,960 --> 00:29:23,780 when we send our exploit. 534 00:29:25,580 --> 00:29:29,860 You can see up there it dumps what DLLs are being imported into this malware FTP server. 535 00:29:30,640 --> 00:29:34,360 So we were able to look at that to decide which one to pick to find an address. 536 00:29:34,960 --> 00:29:36,720 So we hit G. The malware is running. 537 00:29:37,440 --> 00:29:39,420 We're going to go ahead and write our exploit real quick. 538 00:29:41,480 --> 00:29:42,680 This is the first version. 539 00:29:42,800 --> 00:29:43,620 The denial service. 540 00:29:43,620 --> 00:29:45,600 To get a feel for what's going on. 541 00:29:48,320 --> 00:29:51,480 So just for the heck of it, we're going to send it 500 A's and see what happens. 542 00:29:55,940 --> 00:29:57,040 So we send our exploit. 543 00:29:57,260 --> 00:29:57,960 Sends a port command. 544 00:29:58,220 --> 00:29:59,960 You can see in Windabug the worm crashed. 545 00:30:00,880 --> 00:30:01,900 And we own EIP. 546 00:30:04,560 --> 00:30:05,080 All right. 547 00:30:05,120 --> 00:30:07,440 So looking through memory just to get an idea of what's going on. 548 00:30:07,540 --> 00:30:08,860 We can see all our A's are in there. 549 00:30:09,020 --> 00:30:10,040 The port command is in there. 550 00:30:10,700 --> 00:30:12,600 We've basically taken over this piece of malware. 551 00:30:13,620 --> 00:30:17,000 So if this guy is running on your network spewing a bunch of crap and you can't physically 552 00:30:17,000 --> 00:30:20,300 get to it for some reason, you could send a denial service and turn it off and the system 553 00:30:20,300 --> 00:30:20,800 would still run. 554 00:30:22,160 --> 00:30:25,440 But we're going to get a little more complex and write a real exploit for it. 555 00:30:30,740 --> 00:30:31,100 Okay. 556 00:30:31,200 --> 00:30:36,080 So like I said before, the port command, some padding, you know, we're going to do 557 00:30:36,080 --> 00:30:36,580 all that stuff. 558 00:30:38,600 --> 00:30:38,960 . 559 00:30:41,880 --> 00:30:43,600 We actually just guessed completely on this one. 560 00:30:43,600 --> 00:30:44,640 We got it in the first try and got it all right. 561 00:30:52,160 --> 00:30:52,560 Okay. 562 00:30:53,020 --> 00:30:58,040 We need to use the MSFP scan to find a suitable address to jump to. 563 00:30:58,740 --> 00:30:59,740 And it's pretty easy. 564 00:30:59,900 --> 00:31:02,980 You just give it a dash F and the DLL you want to look at. 565 00:31:04,240 --> 00:31:06,520 And it will give you a bunch of addresses to choose from. 566 00:31:07,420 --> 00:31:09,900 This is a little endian, so we've got to flip all the bits around. 567 00:31:13,180 --> 00:31:13,580 All right. 568 00:31:16,880 --> 00:31:17,960 Punchline is coming, I promise. 569 00:31:33,760 --> 00:31:34,120 Okay. 570 00:31:34,220 --> 00:31:36,780 So this is the part where we're going to put our shell code. 571 00:31:37,000 --> 00:31:38,560 We're going to jump back 1,005 bytes. 572 00:31:39,720 --> 00:31:40,080 . 573 00:31:40,080 --> 00:31:40,160 . 574 00:31:48,380 --> 00:31:49,820 And some padding at the end. 575 00:31:51,460 --> 00:31:54,260 But this shows really, you know, some of the power of Metasploit. 576 00:31:54,340 --> 00:31:57,160 I mean, you can write a pretty complex exploit in one line. 577 00:32:02,220 --> 00:32:02,540 Okay. 578 00:32:02,580 --> 00:32:05,120 So we're going to load up our exploit, if I can type it correctly. 579 00:32:06,860 --> 00:32:07,180 . 580 00:32:12,000 --> 00:32:12,320 . 581 00:32:12,320 --> 00:32:13,580 And then we need to go ahead and set up our exploit. 582 00:32:13,580 --> 00:32:15,760 We're going to start up the worm so that it has something to attack. 583 00:32:16,120 --> 00:32:17,040 Close our debugger. 584 00:32:19,160 --> 00:32:22,700 And sometimes you want to make sure the worm is actually fully gone from your task list 585 00:32:22,700 --> 00:32:24,900 because things can hang around and cause problems. 586 00:32:25,680 --> 00:32:26,060 Okay. 587 00:32:26,140 --> 00:32:27,180 So the worm is running in the background. 588 00:32:27,440 --> 00:32:28,060 We're going to type exploit. 589 00:32:28,680 --> 00:32:30,060 It's going to send the FTP command. 590 00:32:30,960 --> 00:32:31,800 And we've got a shell. 591 00:32:37,400 --> 00:32:37,800 Okay. 592 00:32:39,160 --> 00:32:43,240 So it's just a different kind of concept, you know, fighting evil with evil. 593 00:32:43,240 --> 00:32:47,300 Using all the same techniques that exploit developers use against malware, worms, trojans, 594 00:32:47,380 --> 00:32:47,580 whatever. 595 00:32:50,000 --> 00:32:50,440 Okay. 596 00:32:50,560 --> 00:32:52,160 So now we're going to introduce our website. 597 00:32:53,580 --> 00:32:54,020 . 598 00:32:55,480 --> 00:32:57,660 I guess two of us can't stand here at the same time. 599 00:32:58,460 --> 00:32:58,900 Okay. 600 00:32:59,020 --> 00:33:00,500 So we can hack the malware. 601 00:33:00,740 --> 00:33:01,500 Now what? 602 00:33:01,680 --> 00:33:03,020 What do we do with this? 603 00:33:04,600 --> 00:33:06,620 Basically, we want access to more malware. 604 00:33:06,780 --> 00:33:07,920 We want to make it more open. 605 00:33:08,520 --> 00:33:13,220 Right now, the antivirus companies use the previous methods and others to, you know, 606 00:33:13,240 --> 00:33:14,340 to build commercial products. 607 00:33:14,740 --> 00:33:16,200 But there are well-known deficiencies. 608 00:33:16,540 --> 00:33:21,500 There's the signature performance, amount of processing required on the computer, and 609 00:33:21,500 --> 00:33:26,940 they're intrusive, not very effective, and the performance isn't all that great. 610 00:33:27,160 --> 00:33:32,080 So, you know, personally, I don't run AV protection because it gets in the way of other stuff 611 00:33:32,080 --> 00:33:32,480 I want to do. 612 00:33:33,040 --> 00:33:34,820 So how is the AV market doing? 613 00:33:35,160 --> 00:33:41,100 There was a recent article that came out from Ossert saying that there's a 20% detection rate. 614 00:33:41,100 --> 00:33:46,560 And looking at our database, we roughly confirmed this using very unscientific methods. 615 00:33:47,200 --> 00:33:51,100 But this is, profit is their primary goal. 616 00:33:51,300 --> 00:33:52,480 And that's fine. 617 00:33:52,580 --> 00:33:53,360 We're not against that. 618 00:33:54,000 --> 00:33:58,280 But what we would like to do is have a lot of the AV companies collaborate with each other. 619 00:34:00,120 --> 00:34:06,960 So this 20% detection rate wasn't 20% of all the malware that was detected. 620 00:34:07,080 --> 00:34:10,460 It was each AV company detected a different 20%. 621 00:34:10,460 --> 00:34:11,080 So if they collaborate. 622 00:34:11,100 --> 00:34:14,080 Then they would get more, you know, 60, 80%. 623 00:34:15,160 --> 00:34:17,940 And, again, the behavior-based models are the new hotness. 624 00:34:18,120 --> 00:34:21,360 But if you start doing that, then you get into more performance problems. 625 00:34:22,100 --> 00:34:27,440 So what we say is that open analysis of malware and open sharing can only help the situation. 626 00:34:29,380 --> 00:34:31,100 So what's wrong with the current situation? 627 00:34:31,340 --> 00:34:34,080 Again, the field is very elitist. 628 00:34:34,340 --> 00:34:36,720 There are lots of vetted private mailing lists. 629 00:34:37,600 --> 00:34:40,140 If Paul Vixie is in the audience, he can tell you all. 630 00:34:40,140 --> 00:34:43,640 He's got some ideas for a private exchange system. 631 00:34:44,180 --> 00:34:45,700 But generally, these are hoarded. 632 00:34:45,820 --> 00:34:50,340 And the idea of these collections becomes a commodity for all the AV companies. 633 00:34:50,880 --> 00:34:59,540 And so what also happens is that AV companies come up with a situation like the Nixom worm or LoveSan. 634 00:34:59,700 --> 00:35:03,060 Or I think every single AV vendor had a different name for it. 635 00:35:03,160 --> 00:35:04,840 So how do you come up with this? 636 00:35:05,020 --> 00:35:07,580 And MITRE's done some work on naming that. 637 00:35:07,640 --> 00:35:09,580 But it hasn't been well adopted. 638 00:35:10,200 --> 00:35:12,500 The other problem is that there's casts of researchers. 639 00:35:12,900 --> 00:35:14,920 You have to prove yourself to get into the field. 640 00:35:15,740 --> 00:35:17,600 And it prevents outside analysis. 641 00:35:17,940 --> 00:35:23,960 So if you've got a, hey, I've got an idea and I need, you know, four gigs of malware, that doesn't really fit here. 642 00:35:24,760 --> 00:35:25,940 Or in the current situation. 643 00:35:27,200 --> 00:35:30,480 So academic analysis is limited without effort. 644 00:35:30,680 --> 00:35:36,140 And it's not attractive if you're sitting with something on your network and you need to know something about it. 645 00:35:36,200 --> 00:35:38,680 The information provided by these outside vendors 646 00:35:38,680 --> 00:35:40,380 isn't always complete. 647 00:35:40,660 --> 00:35:43,420 And it's hard to validate these results. 648 00:35:43,980 --> 00:35:46,780 So you want to ask the questions, what can I do to stop this? 649 00:35:46,960 --> 00:35:48,060 And what is this thing doing? 650 00:35:48,420 --> 00:35:52,520 You know, if it's targeted specifically for my company, I need to know right away. 651 00:35:54,280 --> 00:35:55,700 So what's our solution? 652 00:35:56,220 --> 00:35:58,760 Everyone gets the same access to malware. 653 00:35:59,200 --> 00:36:00,300 We do not vet. 654 00:36:00,660 --> 00:36:04,920 The only vetting we do is we check to see if your email skills are there. 655 00:36:05,080 --> 00:36:05,920 And you can click a link. 656 00:36:07,160 --> 00:36:08,660 And so all the analysis is done. 657 00:36:08,680 --> 00:36:09,740 And this is done in an open manner. 658 00:36:10,260 --> 00:36:12,340 You know, other than requiring you to log in. 659 00:36:13,560 --> 00:36:16,140 Everything is shared and available to you. 660 00:36:17,040 --> 00:36:19,500 We've got an online web forum. 661 00:36:20,240 --> 00:36:21,420 Bulletin board type environment. 662 00:36:21,720 --> 00:36:25,180 And soon we're going to have an auto decompiling wiki styled environment. 663 00:36:25,480 --> 00:36:27,960 So our end goal is IDA for the web. 664 00:36:28,120 --> 00:36:29,320 But we'll see how that works out. 665 00:36:30,620 --> 00:36:34,000 The other thing that we're doing is auto scanning with a set of AV products. 666 00:36:34,320 --> 00:36:37,460 We've got a pretty good sampling of the Unix scanners that are available. 667 00:36:39,440 --> 00:36:41,620 And there's a lot of these available already. 668 00:36:41,820 --> 00:36:47,320 But in this case, and there's the theme with those is that you upload your malware. 669 00:36:47,840 --> 00:36:49,820 But you can't get what other people have uploaded. 670 00:36:50,020 --> 00:36:51,500 So we'd like to change that. 671 00:36:53,420 --> 00:36:55,600 Next thing is unpacking and decryption. 672 00:36:55,720 --> 00:36:57,600 This is an ongoing method. 673 00:36:57,760 --> 00:36:58,800 Right now it's pretty manual. 674 00:36:58,880 --> 00:37:03,900 So if somebody unpacks a malware, then we can go ahead and include that. 675 00:37:04,140 --> 00:37:06,420 So we're working on some automated methods. 676 00:37:06,520 --> 00:37:08,520 And we'll, of course, be sharing those as they come available. 677 00:37:10,180 --> 00:37:13,820 So we've got a little bit of criticism from this. 678 00:37:14,500 --> 00:37:18,280 If any of you read FunSec, you witnessed this firsthand. 679 00:37:19,300 --> 00:37:23,580 So the first comment we got was lack of a vetting process helps the bad guys. 680 00:37:24,660 --> 00:37:30,340 Well, what we're saying is that it helps the well-intentioned analysis or it hurts them much more. 681 00:37:31,880 --> 00:37:34,640 So writing effective malware is hard, thankfully. 682 00:37:35,020 --> 00:37:36,740 But defending against it is harder. 683 00:37:36,940 --> 00:37:38,660 It's a lot of work to get into the reverse engine. 684 00:37:38,680 --> 00:37:40,800 It's an engineering field and that sort of thing. 685 00:37:40,960 --> 00:37:43,380 And if we come to it, AV is failing. 686 00:37:43,540 --> 00:37:44,680 It detects the known stuff. 687 00:37:44,920 --> 00:37:47,280 But the unknown stuff is what we're worried about. 688 00:37:48,500 --> 00:37:51,680 But there's other people that say, I don't care if you distribute your samples. 689 00:37:51,880 --> 00:37:53,380 Open analysis is a bad thing. 690 00:37:53,840 --> 00:37:59,860 But open analysis is already available from Symantec, McAfee, and the good guys at F-Secure. 691 00:38:01,100 --> 00:38:03,340 So we say that this doesn't matter too much. 692 00:38:03,460 --> 00:38:06,640 So what we're looking for is a synergy between the access to the malware 693 00:38:06,640 --> 00:38:08,820 and getting that. 694 00:38:08,980 --> 00:38:13,400 So the other thing we'd like to see more of is that peer-reviewed publications 695 00:38:13,400 --> 00:38:16,780 tend to focus on malware performance rather than mitigation. 696 00:38:17,040 --> 00:38:20,100 People are starting to work on some automated methods to discover this. 697 00:38:20,260 --> 00:38:23,420 But for the most part, it's not there yet. 698 00:38:25,440 --> 00:38:26,880 So malware is poorly written. 699 00:38:27,060 --> 00:38:28,560 It's difficult to make it reliable. 700 00:38:28,880 --> 00:38:30,460 And it's difficult to make it portable. 701 00:38:30,680 --> 00:38:35,680 But as soon as whoever is writing all this figures out test-driven development 702 00:38:35,680 --> 00:38:37,800 and that sort of thing, then they're going to go crazy. 703 00:38:38,020 --> 00:38:39,100 The field will go crazy. 704 00:38:42,960 --> 00:38:43,540 All right. 705 00:38:43,580 --> 00:38:45,820 So this is how we're ruining the inner tubes. 706 00:38:48,900 --> 00:38:49,300 Tubes. 707 00:38:49,880 --> 00:38:50,280 OK. 708 00:38:50,460 --> 00:38:54,220 So we're going to talk about our automated malware analyzer. 709 00:38:54,660 --> 00:38:57,340 Basically what we've done is we've put online a searchable web database. 710 00:38:58,860 --> 00:39:03,460 We run a number of checks on the malware, like file typing, multiple checksums, 711 00:39:03,540 --> 00:39:04,640 because as we all know, 712 00:39:04,640 --> 00:39:05,840 MD5 sum has been broken. 713 00:39:07,320 --> 00:39:09,900 Packer detection with MSFP scan. 714 00:39:10,540 --> 00:39:14,600 Actually, H.D. Moore did a few modifications to this tool so that we can feed it a Packer database 715 00:39:14,600 --> 00:39:17,600 and then it can scan a file for those opcode sequences. 716 00:39:18,220 --> 00:39:19,160 So thanks to him. 717 00:39:20,520 --> 00:39:23,700 We do multiple antivirus scan like he talked about, kind of like VirusTotal. 718 00:39:24,920 --> 00:39:30,380 We gather portable executable information like the sections and headers and all that kind of stuff 719 00:39:30,860 --> 00:39:32,420 with a tool called the Pelt Project. 720 00:39:32,420 --> 00:39:35,780 We have a rudimentary auto disassembler. 721 00:39:35,960 --> 00:39:39,400 And actually we've been talking to some people about how we can improve that. 722 00:39:39,560 --> 00:39:41,000 So there'll be some cool stuff there soon. 723 00:39:41,340 --> 00:39:43,860 And then we have this massive binary archive of malware. 724 00:39:44,560 --> 00:39:46,960 We get strings disassembly to a wiki. 725 00:39:48,480 --> 00:39:52,020 This is just sort of a screenshot of our site so you can get an idea of what it looks like. 726 00:39:53,280 --> 00:39:54,860 We've got uploads. 727 00:39:55,040 --> 00:39:57,120 You can go up there if you have an executable or DLL. 728 00:39:57,300 --> 00:39:58,360 You can upload it to our site. 729 00:39:58,560 --> 00:40:01,660 It'll auto analyze it, you know, about 30 seconds to a minute. 730 00:40:01,660 --> 00:40:03,980 And then it'll give you some results back. 731 00:40:04,140 --> 00:40:05,620 All those results get put into our database. 732 00:40:05,880 --> 00:40:08,780 So if you find something on your system, you can search our database 733 00:40:08,780 --> 00:40:13,640 and get not only analysis but a copy of it in case, you know, you're looking for some specific worm. 734 00:40:14,280 --> 00:40:18,480 And then we also have this blog system where we can post really in-depth analysis. 735 00:40:19,660 --> 00:40:21,980 We tend to get a lot of the new stuff really quick. 736 00:40:22,180 --> 00:40:24,880 So check there frequently for in-depth analysis. 737 00:40:25,700 --> 00:40:27,600 This is what the database output looks like. 738 00:40:27,680 --> 00:40:31,120 So if you search for an MD5 sum or a particular malware name, 739 00:40:31,120 --> 00:40:33,180 you're going to see something that looks a little bit like this. 740 00:40:34,020 --> 00:40:38,000 Basically, you know, your check sums are at the top, what type of file, what type of packer, 741 00:40:38,460 --> 00:40:40,240 if any of the antivirus detect it. 742 00:40:40,300 --> 00:40:42,000 And you can see here they didn't do so well. 743 00:40:42,580 --> 00:40:47,800 We're constantly adding new antivirus tools as we get licenses for them. 744 00:40:48,100 --> 00:40:50,640 And then over on the right, you can actually download a sample. 745 00:40:50,760 --> 00:40:53,180 It's compressed and password protected, but the password's right there. 746 00:40:53,540 --> 00:40:57,460 You can get a text report with some of the more executable information in it, 747 00:40:58,160 --> 00:40:59,040 disassembly and some strings. 748 00:41:02,380 --> 00:41:02,780 Okay. 749 00:41:02,900 --> 00:41:08,900 So this is sort of the proof of concept idea here where, you know, 750 00:41:08,920 --> 00:41:11,820 the automated analysis is going to go through and attempt to disassemble this. 751 00:41:11,960 --> 00:41:14,300 And if it's successful, it's going to put it into a wiki. 752 00:41:14,400 --> 00:41:18,260 So multiple people can log into the site and work on a piece of malware, 753 00:41:18,480 --> 00:41:19,600 add comments, et cetera. 754 00:41:21,280 --> 00:41:22,440 Just another view of this. 755 00:41:22,520 --> 00:41:25,640 You can see here, you know, a little piece of disassembly there. 756 00:41:25,720 --> 00:41:26,980 Someone went in and added a comment. 757 00:41:27,480 --> 00:41:30,600 This isn't that cool yet, but I think eventually as we work on it, 758 00:41:30,600 --> 00:41:31,540 it'll be pretty useful. 759 00:41:34,860 --> 00:41:35,440 All right. 760 00:41:35,520 --> 00:41:39,840 So I think we're going to have some time for questions and answers here in a second. 761 00:41:39,940 --> 00:41:44,400 But just to wrap up real quick, what you just saw was an improved method of virtual machine detection, 762 00:41:45,400 --> 00:41:48,340 some of the typical things that malware does to protect itself, 763 00:41:49,300 --> 00:41:51,440 some kind of nifty exploits against malware, 764 00:41:51,660 --> 00:41:56,300 and then our offensive computing project, which we hope we can get more participation in. 765 00:41:58,100 --> 00:41:58,660 All right. 766 00:41:58,660 --> 00:41:59,660 Anybody got any questions? 767 00:42:04,820 --> 00:42:05,300 Yes. 768 00:42:05,940 --> 00:42:08,660 We have rootkits, trojans, viruses, worms. 769 00:42:09,300 --> 00:42:13,220 We have about 32,000 pieces of malware in our database currently 770 00:42:13,220 --> 00:42:16,220 and tens more thousands waiting to be put in. 771 00:42:22,340 --> 00:42:22,980 Hold on. 772 00:42:23,220 --> 00:42:23,580 One more time. 773 00:42:30,960 --> 00:42:34,700 Well, it's different in the sense that it's pretty well organized. 774 00:42:35,080 --> 00:42:36,160 It's easy to find. 775 00:42:36,340 --> 00:42:39,040 We're getting a lot of support from the community to add new tools. 776 00:42:39,400 --> 00:42:43,280 Pretty soon, our autoanalysis will be really in-depth and intensive. 777 00:42:47,180 --> 00:42:51,000 The question was, how is this different from other virus bulletins? 778 00:42:51,580 --> 00:42:55,000 You know, and basically the thing is just a lot of those are just collections of malware, 779 00:42:55,120 --> 00:42:56,320 not so much analysis. 780 00:42:56,580 --> 00:42:57,740 And it's not vetted. 781 00:42:57,740 --> 00:42:58,560 Anybody can join. 782 00:43:03,940 --> 00:43:05,080 Can you hear me? 783 00:43:05,380 --> 00:43:05,500 Yeah. 784 00:43:05,740 --> 00:43:10,500 A lot of these AV vendors are claiming they're not using signatures as much. 785 00:43:10,540 --> 00:43:13,640 They're using heuristics and stuff, and they can detect zero a day. 786 00:43:13,880 --> 00:43:19,260 Have you analyzed any of these vendors and seen if it really works? 787 00:43:20,860 --> 00:43:22,460 We haven't seen much success with that. 788 00:43:22,500 --> 00:43:23,880 I'll let Danny talk about it a little bit. 789 00:43:24,340 --> 00:43:28,880 Well, I mean, you can take a look at the 20 percent detection rate that they're getting 790 00:43:28,880 --> 00:43:30,920 and make your own conclusions from that. 791 00:43:31,100 --> 00:43:31,240 So. 792 00:43:32,020 --> 00:43:32,460 Okay. 793 00:43:32,660 --> 00:43:33,220 Thank you. 794 00:43:33,440 --> 00:43:33,700 Sure. 795 00:43:38,000 --> 00:43:38,440 Yeah. 796 00:43:38,560 --> 00:43:38,900 One second. 797 00:43:43,560 --> 00:43:44,720 Any other questions? 798 00:43:51,200 --> 00:43:52,000 It must die. 799 00:43:52,100 --> 00:43:52,540 Yeah. 800 00:43:53,420 --> 00:43:53,860 Yeah. 801 00:43:55,120 --> 00:43:55,400 Okay. 802 00:43:55,440 --> 00:43:55,820 There you go. 803 00:43:56,040 --> 00:43:56,940 Thank you very much.