1 00:00:00,000 --> 00:00:01,020 Okay. 2 00:00:01,020 --> 00:00:02,580 How's everybody doing? 3 00:00:03,800 --> 00:00:05,200 All right. 4 00:00:05,220 --> 00:00:07,560 Let's give a big hand and welcome our presenters here. 5 00:00:07,560 --> 00:00:10,200 Danny Quist and Laurie LeBrock. 6 00:00:15,850 --> 00:00:17,630 Thank you very much. 7 00:00:17,790 --> 00:00:20,610 So this is Reverse Engineering by Crayon. 8 00:00:20,610 --> 00:00:27,390 I'm going to talk a little bit about some hypervisor-based malware analysis and visualization tools that I've developed here. 9 00:00:27,650 --> 00:00:29,310 So my name is Danny Quist. 10 00:00:29,310 --> 00:00:31,450 I founded Offensive Computing. 11 00:00:31,450 --> 00:00:34,210 Also a PhD candidate at New Mexico Tech. 12 00:00:34,210 --> 00:00:37,430 I do reverse engineering and I teach reverse engineering. 13 00:00:38,490 --> 00:00:40,530 And I'm Laurie LeBrock. 14 00:00:40,650 --> 00:00:42,350 I guess I need a mic. 15 00:00:42,370 --> 00:00:43,650 I'm Laurie LeBrock. 16 00:00:43,650 --> 00:00:50,090 I'm an associate professor and fortunately get to work with Danny, run the scholarship for service program at New Mexico Tech. 17 00:00:50,370 --> 00:00:55,110 And Danny's going to present essentially all of this because it's really his work. 18 00:00:57,590 --> 00:00:58,630 Okay. 19 00:00:58,630 --> 00:00:59,790 Wow. 20 00:01:00,030 --> 00:01:02,150 30 seconds into the talk and there's already booing. 21 00:01:02,150 --> 00:01:03,010 Thanks guys. 22 00:01:03,650 --> 00:01:06,430 I do have a fire extinguisher here I was told not to use. 23 00:01:06,430 --> 00:01:07,790 That makes me want to use it. 24 00:01:09,530 --> 00:01:10,410 Okay. 25 00:01:11,110 --> 00:01:16,390 So what we're going to talk about is get started talking about the reverse engineering process. 26 00:01:16,390 --> 00:01:18,690 Then I'll talk a little bit about hypervisors. 27 00:01:18,790 --> 00:01:23,150 And then specifically Xen and Ether, which are pretty awesome. 28 00:01:23,390 --> 00:01:27,590 And how we modify the reverse engineering process to work with these. 29 00:01:27,630 --> 00:01:29,930 And then I'll show my visualization tool Vera. 30 00:01:30,270 --> 00:01:33,650 And then I'll show you some real reversing that I did with this. 31 00:01:33,790 --> 00:01:36,310 And then some results of this process. 32 00:01:37,210 --> 00:01:37,690 Okay. 33 00:01:37,690 --> 00:01:40,590 So let's get started by looking at the reverse engineering process. 34 00:01:40,990 --> 00:01:48,370 The first step with this is and this is just my process and the one that I teach and the one that I've had a lot of good luck with. 35 00:01:48,470 --> 00:01:50,710 It's by no means everybody's one. 36 00:01:50,710 --> 00:01:52,710 But this is just what I use when I'm doing it. 37 00:01:52,710 --> 00:01:54,690 So that's the big caveat there. 38 00:01:54,690 --> 00:01:57,890 So the first thing that I do is I set up an isolated environment. 39 00:01:57,890 --> 00:02:00,850 This is something like VM wearers and virtual PCs. 40 00:02:00,850 --> 00:02:02,470 Some sort of dedicated hardware. 41 00:02:02,710 --> 00:02:04,790 Then we get into the initial analysis. 42 00:02:04,790 --> 00:02:12,390 And this is using the real high level tools like Sysinternals to look for system calls and monitoring any sort of operating system state change. 43 00:02:12,510 --> 00:02:16,710 The next one is removing deobfuscation and dearmoring a program. 44 00:02:16,990 --> 00:02:20,590 So this is unpacking using debuggers, Saffron or Ether. 45 00:02:20,930 --> 00:02:23,610 Then we get into disassembly. 46 00:02:23,610 --> 00:02:27,990 So this is with Idapro or Olidebug or Dumpbin if you're so inclined. 47 00:02:28,530 --> 00:02:32,850 And then the next part is identifying relevant and interesting features. 48 00:02:32,850 --> 00:02:39,330 And so this is where a lot of newbies have trouble with the process and something that I wanted to address. 49 00:02:39,770 --> 00:02:46,970 So the two things that we're going to talk about here are specifically going to be addressed is that we're going to look at dearmoring or deobfuscation. 50 00:02:47,170 --> 00:02:51,470 And this is using a tool called Ether, which is completely cool. 51 00:02:51,570 --> 00:02:54,290 And are Paul and Artem here? 52 00:02:55,010 --> 00:02:56,410 Oh, okay. 53 00:02:56,410 --> 00:02:56,810 All right. 54 00:02:56,810 --> 00:02:57,410 So good. 55 00:02:57,410 --> 00:02:58,810 I know Artem embarrasses you. 56 00:02:59,150 --> 00:03:03,770 And then identifying the interesting features is the thing that the visualization tool is going to do. 57 00:03:04,530 --> 00:03:05,370 Okay. 58 00:03:05,370 --> 00:03:08,210 So setting up an isolated runtime environment. 59 00:03:08,210 --> 00:03:11,290 The point of this is just to protect yourself from the code. 60 00:03:11,670 --> 00:03:16,810 And this is, you know, assuming that it's pretty difficult to actually break out of the VM. 61 00:03:16,930 --> 00:03:22,910 It also makes a known good baseline environment to allow you to do backtracking if something bad happens. 62 00:03:24,010 --> 00:03:26,090 So execution initial analysis. 63 00:03:26,090 --> 00:03:30,810 This is just to get the extremely high-level overview of what code's doing without looking at assembly. 64 00:03:30,930 --> 00:03:37,310 And so this is looking for changes on the file system, changes in the behavior of the system, network traffic, and overall performance. 65 00:03:38,710 --> 00:03:39,830 Okay. 66 00:03:39,830 --> 00:03:42,450 So now removing software armoring. 67 00:03:42,450 --> 00:03:49,010 Software armoring are just protections to prevent reverse engineering or make the program smaller or protect it in some manner. 68 00:03:49,110 --> 00:03:52,170 And this is done via packers, which are just self-modifying code. 69 00:03:52,170 --> 00:03:54,330 And there's a whole lot of research out there on this. 70 00:03:54,390 --> 00:03:58,150 Alibone, Saffron, Polyunpack, Renovo, Ether, and Azure. 71 00:03:58,250 --> 00:04:00,310 So this research is going to use Ether. 72 00:04:01,750 --> 00:04:02,190 Okay. 73 00:04:02,190 --> 00:04:04,670 So let's talk a little bit about the packing problem. 74 00:04:04,670 --> 00:04:08,210 All a packer is is it's a self -modifying portion of code. 75 00:04:08,210 --> 00:04:15,010 It has a small decoder stub that decompresses the main executables and then restores the imports and then allows the program to execute normally. 76 00:04:15,510 --> 00:04:18,810 And this just plays tricks with the executable. 77 00:04:18,970 --> 00:04:25,430 It does the bare minimum amount of work to get things loaded up and hides imports and that sort of stuff. 78 00:04:25,430 --> 00:04:27,670 And it's basically just to trip up any of the tools. 79 00:04:28,450 --> 00:04:41,350 So the way this looks is that we'll have a PE file right here and you'll have a normal unpacked file and you apply a packer to it and what happens is that you get the compressed or obfuscated code with a small decoder stub on the right. 80 00:04:42,110 --> 00:04:43,150 Okay. 81 00:04:43,450 --> 00:04:45,470 There's some other troublesome protections. 82 00:04:45,470 --> 00:04:47,750 The first one is virtual machine detection. 83 00:04:48,010 --> 00:04:50,990 You can get some of these things that are put out. 84 00:04:53,510 --> 00:04:57,030 Also we developed a tool called OCVM detect. 85 00:04:57,610 --> 00:05:01,590 But generally detecting that you're inside of a VM is very, very easy. 86 00:05:01,590 --> 00:05:05,650 And so there was an excellent paper that if you haven't read it yet, you should. 87 00:05:05,650 --> 00:05:09,110 It's called Attacks on Virtual Machine Emulators by Peter Ferry. 88 00:05:09,110 --> 00:05:19,670 What this does is it goes through every single VM that was available at the time and he gives roughly 10 assembly instructions about how to detect all of them. 89 00:05:19,870 --> 00:05:25,850 It's all for 16-bit mode of a DOS program, but it's pretty easy to translate into the 32-bit equivalent. 90 00:05:26,450 --> 00:05:27,650 Debugger detection. 91 00:05:27,990 --> 00:05:34,590 This is just looking at the process execution block and checking to see if the is being debugged flag is set. 92 00:05:34,590 --> 00:05:37,710 And also the eflags trap flag is going to be set there. 93 00:05:38,370 --> 00:05:41,730 Timing attacks deal with the time step counter. 94 00:05:41,730 --> 00:05:49,710 And the time step counter, you just take a, you pull it before and then run some instructions and pull it after and then see if things are inordinately large. 95 00:05:49,870 --> 00:05:52,130 And so this turns out to be a very effective tool. 96 00:05:53,710 --> 00:05:59,330 Okay, so all this is very annoying for the reverser and there's basically two methods for circumvention. 97 00:05:59,330 --> 00:06:07,330 The first one is that you can know about all the possible protections and get into the cat and mouse game of trying to remove those or you can make yourself invisible. 98 00:06:07,490 --> 00:06:10,310 So the second one is a lot less work. 99 00:06:10,310 --> 00:06:12,890 So being a good grad student, I chose the lazy way. 100 00:06:14,830 --> 00:06:17,290 So there's been a couple... 101 00:06:17,290 --> 00:06:18,050 Sorry? 102 00:06:18,670 --> 00:06:21,490 I just have water here, so... 103 00:06:21,490 --> 00:06:22,550 Can we get security here? 104 00:06:22,550 --> 00:06:24,950 This guy's causing problems. 105 00:06:26,330 --> 00:06:27,470 Thanks, honey. 106 00:06:31,790 --> 00:06:36,810 Okay, so software-based VMs... I always wanted to be that guy at DEF CON, too. 107 00:06:36,850 --> 00:06:40,990 All right, so software-based virtual machines. 108 00:06:41,050 --> 00:06:45,150 These are things like Renovo and PolyUnpack and the Dynamics Box Unpacker. 109 00:06:45,850 --> 00:06:50,470 The problems with these is that they get into issues where detecting these is actually pretty easy. 110 00:06:50,470 --> 00:06:57,370 So the Intel CPU is never really meant to support virtualization and they don't emulate these bug for bug. 111 00:06:58,850 --> 00:07:01,070 Okay, so OS integrated debugging. 112 00:07:01,070 --> 00:07:03,490 This is Saffron and Olibone. 113 00:07:03,490 --> 00:07:14,390 Both of these systems abuse the page fault handler and sets a supervisor bit on running pages so that you can actually get some sort of idea of the execution inside of there. 114 00:07:14,550 --> 00:07:19,370 The problems with these and one of the problems I had with Saffron is it destabilized the system. 115 00:07:19,650 --> 00:07:28,310 It was very good at unpacking something once, but if you wanted to run the system or do anything else with it, you basically had to reboot and do the process again. 116 00:07:28,330 --> 00:07:32,690 So it wasn't very flexible for implementing an automated unpacking system. 117 00:07:33,470 --> 00:07:38,570 The other problem with that is that you couldn't actually do any sort of fine grain monitoring. 118 00:07:38,570 --> 00:07:41,030 You basically got things on the page boundaries. 119 00:07:43,110 --> 00:07:46,130 Okay, so now we get into the awesome. 120 00:07:46,470 --> 00:07:50,430 So there's a fully hardware virtualization monitoring system called Ether. 121 00:07:50,670 --> 00:07:55,670 It was built by Artem Dynaburg and Paul Royal from Georgia Tech. 122 00:07:55,670 --> 00:07:58,130 This is a Zen based hypervisor system. 123 00:07:59,530 --> 00:08:12,810 Ether has a couple of things that monitor for system calls, instruction traces, memory writes, and basically all the interaction with the OS is done via the shadow page table inside of the Zen hypervisor. 124 00:08:13,790 --> 00:08:23,730 So the problem is, which isn't really a problem, is that it requires dedicated hardware, but what it buys you is that you get an actual VM environment that you can use to restore a lot of this too. 125 00:08:23,730 --> 00:08:25,210 So it's actually very flexible. 126 00:08:26,390 --> 00:08:29,590 Okay, so back to the reverse engineering process. 127 00:08:29,930 --> 00:08:34,450 Disassembly and code analysis, this is one of the most nebulous portions of the process. 128 00:08:34,770 --> 00:08:41,390 And when I'm teaching this, this is the one that the students get a little bit frustrated at because this is something that you only get after you've done a lot of reversing. 129 00:08:41,390 --> 00:08:42,970 So how do you get a lot of reversing experience? 130 00:08:42,970 --> 00:08:43,950 By reversing. 131 00:08:44,570 --> 00:08:47,530 And it largely depends on intuition. 132 00:08:47,910 --> 00:08:54,970 And you get into this issue where a lot of times you focus too much on the actual assembly code and not the overall view of the program. 133 00:08:55,010 --> 00:08:59,010 So fighting analyst fatigue is something I like to address. 134 00:08:59,010 --> 00:09:03,890 Get to the meat of the problem before it's so you can avoid the issues. 135 00:09:04,690 --> 00:09:08,270 Okay, and finding interesting and relevant portions of the program. 136 00:09:08,270 --> 00:09:11,770 So just like the disassembly portion, this requires a lot of experience. 137 00:09:12,010 --> 00:09:20,750 Some typical starting points is looking for interesting strings, looking for API calls, and looking at any sort of interaction with the operating system. 138 00:09:20,870 --> 00:09:30,650 And so this is a fundamentally imprecise process and beginners typically have problems with this because until you get to where you understand this a little bit, it's hard to know where to start. 139 00:09:32,410 --> 00:09:36,030 Okay, so let's talk about hypervisors for a little bit. 140 00:09:41,640 --> 00:09:50,180 There's been a lot of hype about this over the last few years and I'm not trying to propel this anymore even though the talk title probably suggests it. 141 00:09:51,800 --> 00:10:00,560 But one of the things is that a lot of the new hypervisor-based root kits, like BluePill and that sort of thing, have led a lot of the defensive tools. 142 00:10:00,560 --> 00:10:12,980 And just like always, the offensive need to hide yourself from a running process or from any sort of introspection from a piece of code inside the operating system works well in this environment. 143 00:10:12,980 --> 00:10:15,960 So that's what we're going to utilize here. 144 00:10:16,700 --> 00:10:23,700 And one big feature that we're trying to take advantage of is the detection of hardware-based virtualization is not widely implemented. 145 00:10:24,080 --> 00:10:28,960 That's not to say it's impossible, it's just that I don't see too much of that out in the wild. 146 00:10:31,040 --> 00:10:34,900 Okay, so there are a couple of hypervisor implementations. 147 00:10:34,940 --> 00:10:37,700 VMware ESX server, I've had some good luck running. 148 00:10:38,260 --> 00:10:44,360 This is a commercial solution from VMware and it mostly avoids a lot of the VM detection issues. 149 00:10:44,980 --> 00:10:52,380 Linux kernel virtual machines, this is what I use as my base environment when I'm basically reverse engineering. 150 00:10:52,640 --> 00:10:56,260 And that's just to prevent me from running malware on my home system. 151 00:10:56,300 --> 00:10:58,040 Which, not to say that never happens. 152 00:10:58,620 --> 00:11:00,140 Or my base system. 153 00:11:00,440 --> 00:11:01,680 And then Xen. 154 00:11:01,680 --> 00:11:06,200 Xen is really nice because it's got an excellent set of tools for introspection. 155 00:11:06,420 --> 00:11:10,720 And a lot of this has really been led by Georgia Tech, so hats off to you guys there. 156 00:11:11,440 --> 00:11:16,960 But what's nice about Xen is it uses a standard QEMU image format that's been set up a long time before. 157 00:11:16,960 --> 00:11:20,640 And it's an API that's fully controlled via Python. 158 00:11:20,660 --> 00:11:22,540 So you can integrate into tools. 159 00:11:27,160 --> 00:11:29,940 Okay, so let's talk about Xen and Ether. 160 00:11:30,640 --> 00:11:37,080 So Ether is a set of patches to the Xen hypervisor that's used to instrument a Windows system. 161 00:11:37,300 --> 00:11:43,200 And so it has a bunch of base modules that allow you to do instruction tracing, API tracing, and unpacking. 162 00:11:43,420 --> 00:11:50,720 And so one of the best papers I've read in a couple years is this Ether malware extensions via hardware virtualization extensions. 163 00:11:51,020 --> 00:11:56,760 And this was, again, written by Artem and Paul and a couple other people at the ACM CCS conference. 164 00:11:56,760 --> 00:12:00,740 So if you haven't read this, it's extremely high quality and very useful. 165 00:12:00,820 --> 00:12:03,400 Especially compared to other academic research. 166 00:12:03,400 --> 00:12:06,760 So you should definitely check this out. 167 00:12:08,000 --> 00:12:10,220 So Ether's event tracing. 168 00:12:10,220 --> 00:12:12,920 This is what it's using to detect events on the system. 169 00:12:12,920 --> 00:12:18,980 So we talked about system call execution, instruction execution, memory writes, and context switching. 170 00:12:19,180 --> 00:12:22,100 But what's nice about it is it also gives you covert monitoring. 171 00:12:22,100 --> 00:12:27,200 So there's no modifications to the base system, which means that it's very hard to detect. 172 00:12:28,120 --> 00:12:33,940 So instruction tracing inside of Ether is implemented by setting the trap flag inside of the E flags register. 173 00:12:34,140 --> 00:12:38,320 And then modifications to that is handled via the push F and pop F instructions. 174 00:12:38,320 --> 00:12:43,520 So these are intercepted by the hypervisor and used for watching that. 175 00:12:43,520 --> 00:12:49,540 So modifications to the single stepping process to look and see if it's being single stepped is effectively hidden. 176 00:12:50,820 --> 00:12:51,580 Okay. 177 00:12:51,580 --> 00:12:53,180 Memory and system calls. 178 00:12:53,180 --> 00:12:56,800 Memory writes are tracked by manipulating a shadow page table. 179 00:12:56,880 --> 00:12:59,960 So this gives you access to all the read to and written memory. 180 00:13:00,320 --> 00:13:01,720 System calls. 181 00:13:01,720 --> 00:13:06,300 This modifies the sys enter EIP register to point to a non -page address. 182 00:13:06,420 --> 00:13:09,200 And when any sort of access is hit to that, Ether logs that. 183 00:13:09,200 --> 00:13:14,660 And also logs the instruction to catch the older system calls. 184 00:13:16,000 --> 00:13:16,340 Okay. 185 00:13:16,340 --> 00:13:21,320 So the this architecture, you start out with a Linux DOM zero management system. 186 00:13:21,320 --> 00:13:24,700 This is basically a Linux system that you run all your tools on. 187 00:13:24,700 --> 00:13:28,240 This is going to have the VM disk image and Ether management tools. 188 00:13:28,240 --> 00:13:31,780 And then it's going to work with the Zen hypervisor, which will have the Ether patches. 189 00:13:31,840 --> 00:13:35,820 And then work with an instrumented Windows XP service pack 2. 190 00:13:36,620 --> 00:13:37,360 Okay. 191 00:13:37,640 --> 00:13:40,700 So I made a couple of extensions to Ether. 192 00:13:40,980 --> 00:13:45,600 The first thing is I moved some of the unpacking code from the hypervisor into user space. 193 00:13:45,900 --> 00:13:49,900 I put a little bit more user mode analysis in this. 194 00:13:49,900 --> 00:13:53,980 And I also repaired the portable executable rebuilding system. 195 00:13:53,980 --> 00:13:57,740 And this is just to allow you to actually disassemble it inside of IDA. 196 00:13:58,440 --> 00:14:03,880 And then there's a lot of other monitoring for executables that will be released a little bit later. 197 00:14:06,420 --> 00:14:15,040 So the user mode unpacking, what this is, is all we're trying to do is watch for and monitor all the memory writes and executions. 198 00:14:15,080 --> 00:14:18,320 And so we keep all the memory writes inside of a hash table. 199 00:14:18,320 --> 00:14:27,200 Whenever we see a execution inside of one of those memory writes, we assume that it's a candidate original entry point and then take a dump of the image. 200 00:14:27,240 --> 00:14:30,020 This isn't perfect, but it's a decent solution. 201 00:14:30,040 --> 00:14:33,140 And it certainly helps you to get some unpacked code. 202 00:14:33,500 --> 00:14:39,620 The other nice thing about moving this out of the hypervisor was that there's a little bit of scaffolding for future modifications. 203 00:14:41,300 --> 00:14:45,660 PE repairs, to implement this, this is, there were a couple issues. 204 00:14:45,660 --> 00:14:47,520 First of all, the sections weren't aligned. 205 00:14:47,700 --> 00:14:50,000 The address of the entry point was invalid. 206 00:14:50,180 --> 00:14:52,040 And it wouldn't load inside of IDA correctly. 207 00:14:52,040 --> 00:15:00,480 So basically all I did is I took the code from ollie dump and used that to fix the section offsets and repair the resources as much as possible. 208 00:15:00,480 --> 00:15:06,780 And then setting the address of the original entry point to the correct place allowed it to be loaded inside of IDA. 209 00:15:07,440 --> 00:15:08,180 Okay? 210 00:15:08,200 --> 00:15:13,120 So the results from this is that you get it close to a truly covert analysis system. 211 00:15:13,460 --> 00:15:15,140 Ether is nearly invisible. 212 00:15:15,160 --> 00:15:17,500 It's still subject to blue pill detection. 213 00:15:17,500 --> 00:15:19,960 So we can start playing that game. 214 00:15:19,960 --> 00:15:21,840 But I think it's a game that's worth playing. 215 00:15:21,840 --> 00:15:23,780 So get started with that. 216 00:15:24,040 --> 00:15:27,900 The next thing that we get is fine grain resolution of program execution. 217 00:15:28,060 --> 00:15:32,780 And since you get memory monitoring, we can start doing some cool stuff with it. 218 00:15:32,780 --> 00:15:37,280 So we can start looking at these files inside of IDA and a lot of other tools. 219 00:15:38,060 --> 00:15:38,460 Okay. 220 00:15:38,460 --> 00:15:42,020 So I want to give a quick demo of how ether works. 221 00:15:43,360 --> 00:15:45,320 Or at least the unpacking portion. 222 00:15:55,820 --> 00:15:56,320 Okay. 223 00:15:56,320 --> 00:15:59,240 So we're going to start by loading the file up inside of IDA. 224 00:16:00,620 --> 00:16:08,460 And just to verify that this is actually a packed executable, we can see that the, we get the standard warning about the import segments being destroyed. 225 00:16:09,260 --> 00:16:15,940 And if we allow IDA to continue executing, we can see that it's generally not finding anything. 226 00:16:15,940 --> 00:16:17,880 The start function is pretty miserable. 227 00:16:17,880 --> 00:16:19,580 It's missing strings. 228 00:16:19,760 --> 00:16:22,380 So there's not actually stuff inside of here. 229 00:16:23,700 --> 00:16:27,000 And the functions are pretty much nonexistent. 230 00:16:27,020 --> 00:16:32,520 And the import address, it just has the suspicious get proc address and load library. 231 00:16:32,520 --> 00:16:34,680 So in this case, things are pretty bad. 232 00:16:34,680 --> 00:16:38,700 Also, this top visualization bar inside of IDA doesn't have a lot of blue codes. 233 00:16:38,700 --> 00:16:41,520 That's a good indication that things are all hosed. 234 00:16:44,470 --> 00:16:45,150 Okay. 235 00:16:45,250 --> 00:16:49,410 So what we're going to do is actually start running this inside of ether. 236 00:16:50,210 --> 00:16:53,750 To do that, this is just going to be a Linux box here. 237 00:16:54,150 --> 00:16:55,970 So this is my ether system. 238 00:16:56,130 --> 00:16:59,490 And I'm just going to mount the QEMU image. 239 00:16:59,610 --> 00:17:05,350 This handy command and the 3G driver for NTFS you can use to copy the file over. 240 00:17:05,510 --> 00:17:07,730 So this is pretty straightforward. 241 00:17:08,970 --> 00:17:10,890 So we get that copied in. 242 00:17:11,570 --> 00:17:15,730 And even though this is a video, you can see how slow I type. 243 00:17:18,610 --> 00:17:19,190 Okay. 244 00:17:19,190 --> 00:17:21,070 So we're copying this over. 245 00:17:23,130 --> 00:17:29,190 Once we get the file copied over, what we want to do is we actually want to start the virtual machine up. 246 00:17:29,190 --> 00:17:33,550 So what I'm going to do is use the standard Zen commands to get this started. 247 00:17:33,750 --> 00:17:38,490 So this is going to be XM create and then you give it the config file of what you're looking for. 248 00:17:41,830 --> 00:17:42,430 Okay. 249 00:17:42,430 --> 00:17:46,650 So once I get started, you get this message. 250 00:17:46,770 --> 00:17:54,270 And once you've got that, you should be able to open up a VNC image and we can see here that our Windows machine has actually started. 251 00:17:55,710 --> 00:17:56,670 Yeah. 252 00:17:57,830 --> 00:17:58,870 All right. 253 00:17:58,870 --> 00:17:59,970 So Windows. 254 00:18:01,390 --> 00:18:03,030 Wait for it. 255 00:18:03,510 --> 00:18:03,990 Okay. 256 00:18:03,990 --> 00:18:08,670 So once we have that, we actually get the screen and everything's happy and we've got our virus right here. 257 00:18:08,950 --> 00:18:10,390 So everything's ready to go. 258 00:18:10,610 --> 00:18:20,890 So one thing when you're using Ether that you want to be careful of is you want to be able to load the task manager so that you can actually kill execution of the program when it's running. 259 00:18:20,890 --> 00:18:26,070 So this turns out to be a pretty important thing to do unless you like your box rebooting. 260 00:18:26,870 --> 00:18:27,170 Okay. 261 00:18:27,170 --> 00:18:30,350 So what we're going to do is do an XM list to get the ID out of here. 262 00:18:30,530 --> 00:18:32,050 So in this case, it's nine. 263 00:18:34,110 --> 00:18:37,310 And then we're going to actually start running the Ether tool. 264 00:18:37,310 --> 00:18:39,210 So this will be Ether. 265 00:18:39,710 --> 00:18:41,490 Give it the ID that you want. 266 00:18:41,530 --> 00:18:43,570 The user mode unpack code. 267 00:18:45,110 --> 00:18:48,110 The executable that you want to watch for. 268 00:18:48,110 --> 00:18:50,290 And then a local copy of that executable. 269 00:18:50,970 --> 00:18:58,050 And so once you've got that up and running, we can see that this is a good sign that Ether's happy. 270 00:18:58,050 --> 00:19:00,290 It's at the filter name to be mu under bar net bowl. 271 00:19:00,290 --> 00:19:03,530 So whenever it sees a context switch into this process, it's going to pull it out. 272 00:19:07,180 --> 00:19:12,900 And at this point, what we're going to go over and do is over on this system, we're going to run the virus. 273 00:19:12,900 --> 00:19:14,140 So we're running net bowl. 274 00:19:15,700 --> 00:19:21,760 And we can see that net bowl's going to start taking about 100% of the CPU and it gets a little bouncy. 275 00:19:22,060 --> 00:19:24,440 Or like it gets a little sluggish inside of there. 276 00:19:24,720 --> 00:19:31,240 So in this case, we fixed the dump image to have an RVA of this 421340. 277 00:19:32,120 --> 00:19:34,060 So this is a good candidate dump. 278 00:19:35,020 --> 00:19:40,700 And we'll allow this to execute a little bit longer until we see the actual icon for the program pop up. 279 00:19:40,700 --> 00:19:44,460 So one of the reasons I use net bowl so often is it's pretty benign. 280 00:19:44,460 --> 00:19:48,880 But it's still got the malicious component to it so you can watch and see that things are executing. 281 00:19:49,340 --> 00:19:51,180 So this actually takes a little bit of time. 282 00:19:51,180 --> 00:19:54,100 So I am a little bit of time dilation to go on. 283 00:19:54,940 --> 00:19:55,420 All right. 284 00:19:55,420 --> 00:20:03,520 So the next thing we get is a fixed dump image to have an OEP of RVA BBO8 or 40BBO8. 285 00:20:03,800 --> 00:20:10,800 And so this is actually the original entry point for the program that I verified by manually reversing this. 286 00:20:11,120 --> 00:20:11,520 Okay. 287 00:20:11,520 --> 00:20:15,640 So it's very important to kill the process inside of Windows before you stop Ether. 288 00:20:16,860 --> 00:20:18,860 Otherwise, hilarity ensues. 289 00:20:19,140 --> 00:20:20,760 So we've got that going. 290 00:20:22,140 --> 00:20:24,060 Then we stop Ether. 291 00:20:25,420 --> 00:20:28,980 And then inside of this, we should have a listing of directories. 292 00:20:28,980 --> 00:20:32,060 And then for each one of these files, there's the original address. 293 00:20:32,060 --> 00:20:35,500 So we've got new net bowl image and then the address that it stopped. 294 00:20:35,500 --> 00:20:39,180 And then this dash fixed is the corrected image inside of here. 295 00:20:40,400 --> 00:20:40,960 Okay. 296 00:20:40,960 --> 00:20:48,660 So now what we can do is we can take this image and load it up inside of IDA pro and we should start seeing some good things here. 297 00:20:48,660 --> 00:20:50,960 So what we're going to do is pull the fixed image up. 298 00:20:53,080 --> 00:20:54,040 Fixed. 299 00:20:55,240 --> 00:20:56,980 Load that up inside of IDA. 300 00:20:56,980 --> 00:21:01,080 And then once we start loading it, we can see that things are a little bit happier. 301 00:21:01,380 --> 00:21:06,680 So IDA is making noises like it's found the right compiler signatures that it's used to. 302 00:21:06,700 --> 00:21:10,540 It's found a lot of the unpacking code and that sort of stuff. 303 00:21:10,540 --> 00:21:12,780 So we get actual visualization. 304 00:21:12,920 --> 00:21:14,880 The functions exist inside of here. 305 00:21:14,880 --> 00:21:19,440 We get our references and everything that we come to expect from this. 306 00:21:20,280 --> 00:21:22,320 So we get these functions. 307 00:21:22,620 --> 00:21:26,520 Strings, this is a good indication that we've got net bowl unpacked. 308 00:21:26,520 --> 00:21:34,420 So in this case, we've got the HRH's net bowl, which I presume is what the AV companies named the virus after and all this other stuff. 309 00:21:35,560 --> 00:21:36,060 Okay. 310 00:21:37,740 --> 00:21:40,360 So again, we can follow links and that sort of stuff. 311 00:21:40,360 --> 00:21:43,080 All of that works and we're all set to go there. 312 00:21:45,780 --> 00:21:46,400 Okay. 313 00:21:46,560 --> 00:21:49,480 So this is an example of Mew's net bowl. 314 00:21:49,840 --> 00:21:53,640 And one person brought up a point like, so what? 315 00:21:53,640 --> 00:21:54,180 It's Mew. 316 00:21:54,180 --> 00:21:55,400 It's easy to do. 317 00:21:55,500 --> 00:21:58,320 But this unpacker is really awesome. 318 00:21:58,320 --> 00:21:59,840 It works on pretty much everything. 319 00:21:59,840 --> 00:22:03,340 So I ran the media through this and it does a great job. 320 00:22:03,360 --> 00:22:06,540 So if we could just like clap for Artem right now. 321 00:22:06,540 --> 00:22:07,420 It's pretty cool. 322 00:22:13,700 --> 00:22:14,740 Thank you. 323 00:22:15,480 --> 00:22:16,380 All right. 324 00:22:16,500 --> 00:22:23,340 So with that said, we'll talk a little bit more about what's going on. 325 00:22:23,680 --> 00:22:25,640 So there are a couple of open problems. 326 00:22:25,840 --> 00:22:29,100 The unpacking process produces a lot of candidate dump files. 327 00:22:29,100 --> 00:22:32,520 So this algorithm that we have is a little bit imprecise. 328 00:22:32,640 --> 00:22:37,140 So what we want to do is we want a better way to find the original entry point. 329 00:22:37,400 --> 00:22:40,160 The other thing is that import rebuilding is still an issue. 330 00:22:40,460 --> 00:22:44,180 That's something I'm working on at this point, but I haven't had a chance to integrate it in yet. 331 00:22:44,840 --> 00:22:47,800 And so the other thing I'd like to do is do some analysis. 332 00:22:47,800 --> 00:22:49,800 So this is going to be the next thing here. 333 00:22:50,600 --> 00:22:57,240 So we can integrate this into our process by allowing somebody to figure out to know what to look for inside of here. 334 00:22:57,240 --> 00:23:00,080 Because this is the thing that people have trouble with most of the time. 335 00:23:00,460 --> 00:23:05,640 So once you have an idea of the execution flow of a program, it's really nice to be able to look at this. 336 00:23:05,680 --> 00:23:11,200 So software armoring is pretty much made to be a trivial process and is extremely easy. 337 00:23:12,500 --> 00:23:13,000 Okay. 338 00:23:13,000 --> 00:23:15,320 So let's get to the visualization portion. 339 00:23:17,420 --> 00:23:24,100 One of the goals I set out with when I was doing this visualization is to be able to quickly subvert the software armoring process. 340 00:23:24,260 --> 00:23:30,460 So in the case of Netbull, we only had two images that we were trying to detect there, our two candidate dump files. 341 00:23:30,560 --> 00:23:37,460 But what I'd like to do are in other samples, especially with more complex packers, you end up getting thousands of them. 342 00:23:37,460 --> 00:23:39,500 So we want to make that process a little easier. 343 00:23:40,040 --> 00:23:49,500 The other thing is for various portions and phases of the program, I wanted to identify initialization, main loops, and the end of the unpacking code. 344 00:23:49,500 --> 00:23:59,440 So figure out where the self-modifying code ends, which is the OEP detection, and figure out some of the dynamic runtime behavior of the program, and also integrate it with some of the tools that we're used to, like IDA. 345 00:24:00,960 --> 00:24:08,020 So I made this program called Vero, which is visualization of executables for reversing an analysis. 346 00:24:08,440 --> 00:24:16,580 But really it was just a contrived name to name something after Jane's gun in Firefly, and so I was finally glad to have a program that I could do that. 347 00:24:17,740 --> 00:24:23,120 So when you're looking at this, it's... the code's pretty simple. 348 00:24:23,120 --> 00:24:27,060 It's kind of a Fisher-Price, my first MFC and OpenGL application. 349 00:24:27,280 --> 00:24:34,940 But generally, it uses a lot of the OpenGL rendering and integrates with IDA Pro, and it's fast, small, and has a low memory footprint. 350 00:24:36,280 --> 00:24:36,980 Okay. 351 00:24:36,980 --> 00:24:39,200 So with that, I'll turn it over to Lori. 352 00:24:40,320 --> 00:24:47,880 So this is just a graph preview, which on... you know, the fortunate part is there's now a graph in here at the beginning instead of without one. 353 00:24:47,880 --> 00:24:52,300 The bad news is it's zoomed out so far you can't see nodes versus edges. 354 00:24:52,400 --> 00:25:03,520 But the idea here is that we're going to use a graphical representation so that you can see what the different phases of computation are and where your time is being spent. 355 00:25:03,860 --> 00:25:08,520 So the vertices here actually represent addresses. 356 00:25:09,040 --> 00:25:17,820 It could be the address of a specific instruction, or it could be, as you see at the bottom, the address of the beginning instruction in a basic block, either one of the two. 357 00:25:18,140 --> 00:25:23,560 And the edges represent a... an execution on a path. 358 00:25:23,620 --> 00:25:25,760 So you're going from one instruction to the next. 359 00:25:25,760 --> 00:25:26,920 What path did you take? 360 00:25:26,920 --> 00:25:28,200 That's an execution. 361 00:25:28,320 --> 00:25:33,880 The more time some... a transition happens, the heavier the weight on the edge. 362 00:25:33,880 --> 00:25:38,120 So that gives you an idea of how... where you're spending your time in the execution. 363 00:25:38,940 --> 00:25:46,960 The basic blocks, for any of you who have done the low-level compiler stuff and that sort of thing, you see those are just... it's straight line code. 364 00:25:46,960 --> 00:25:51,280 So no transfer of control except from one instruction to the next in the stream. 365 00:25:51,360 --> 00:25:54,620 There's no conditionals, none of that stuff. 366 00:25:54,620 --> 00:26:02,460 So basic blocks give you a real simple way of getting a hold on a little bit more code at a time than a single instruction. 367 00:26:02,840 --> 00:26:06,940 That makes this potentially useful for commercial codes. 368 00:26:06,940 --> 00:26:23,160 But as you're going to see, some of the next steps in this will be looking at doing functions and handling function-level sorts of things because you, again, you still get... you saw that... that graph is actually a very small graph compared to what graph theorists look at, 369 00:26:23,160 --> 00:26:25,480 but they get kind of big and complex. 370 00:26:25,760 --> 00:26:29,580 So the basic blocks give you a way of compressing some of this. 371 00:26:29,580 --> 00:26:35,180 The instruction view , where you're looking at every single instruction becomes a node in the graph. 372 00:26:35,180 --> 00:26:36,780 Gives real pretty graphs. 373 00:26:36,780 --> 00:26:39,940 Danny likes those nice big swoopy graphs, as he calls them. 374 00:26:40,500 --> 00:26:50,140 So they may have some aesthetic value because they're pretty to look at, but again, any kind of commercial code and they're just too big to be able to figure out what's going on. 375 00:26:52,420 --> 00:27:01,120 So again, those transitions between addresses, they're going to give us more information about where we're spending time in the graph. 376 00:27:01,500 --> 00:27:16,780 But there's an assumption here that I just need to point out, and that is the assumption is that during this single execution, so this is for a single execution of the code, during that single execution of the code, the thing you're looking for happened. 377 00:27:17,220 --> 00:27:27,000 So if you get something that every 50th time it's executed, it does something, you're not likely to find that using this approach. 378 00:27:27,100 --> 00:27:35,220 And so some future work can look at doing more statistical base, where are executions different when you don't change the input file sort of thing. 379 00:27:35,220 --> 00:27:41,420 But at the moment, you run it once, you get these graphs, they tell you where things are executed more. 380 00:27:41,460 --> 00:27:53,600 So looking at these edges, wherever you see from one node coming out multiple lines, that means there was a decision point there and there are multiple paths you can go to the next instruction. 381 00:27:55,100 --> 00:28:02,760 The thing that's really interesting, although somewhat arbitrary, is how the colors are assigned and what they mean. 382 00:28:02,760 --> 00:28:11,520 So I'm going to have Danny step back up here and talk about what these different colors in the graph mean when you're trying to find information. 383 00:28:14,130 --> 00:28:18,010 Okay, so again, these colors were chosen sort of arbitrarily. 384 00:28:18,270 --> 00:28:28,890 And what these represent are the relation of the file that has been dumped from Ether to what's actually on disk. 385 00:28:28,890 --> 00:28:37,930 So in this case, we're trying to identify execution into sections where code doesn't exist or that sort of stuff. 386 00:28:37,930 --> 00:28:43,510 So what yellow is going to be, this is going to be the standard, normal compiler generated code. 387 00:28:43,750 --> 00:28:51,470 Dark green is going to be where the sections are present in the pack version, so this would be something like executing inside of the P header. 388 00:28:52,050 --> 00:28:58,410 Light purple is where the memory has been allocated for run time but isn't present in the actual executable. 389 00:28:58,990 --> 00:29:05,030 And dark red is one that I wanted to really point out, which is actually the high entropy version of the code. 390 00:29:05,070 --> 00:29:13,350 So this would be sort of execution inside of compressed or encoded or encrypted or whatever you want to call it. 391 00:29:13,430 --> 00:29:16,050 The other thing that I wanted to point out is light red. 392 00:29:16,530 --> 00:29:19,830 These instructions are not in the pack executable at all. 393 00:29:20,030 --> 00:29:24,290 And then line green, this is where the operands aren't going to actually match. 394 00:29:24,310 --> 00:29:31,590 So this would be any sort of shifting decode frame type attack where you're executing code over and over. 395 00:29:32,790 --> 00:29:37,110 Okay, so these colors were chosen arbitrarily. 396 00:29:37,230 --> 00:29:47,110 I kind of like that they, I think that they look good, but I did show them to one of my friends, Kazmir, and he looked at it and he says, that's great, Danny, but why are all your colors brown? 397 00:29:47,850 --> 00:29:50,250 So it turns out he's red-green color blind. 398 00:29:50,410 --> 00:30:00,850 And so I sat down with Kazmir and he was really nice enough to help me go over things and pick out a set that looked okay. 399 00:30:00,850 --> 00:30:02,910 But I didn't really like the way they looked. 400 00:30:02,910 --> 00:30:13,690 So inside the code there's actually a set of instructions that are available for color blind people and I'm also going to make this available, but for right now it's not compiled by default. 401 00:30:14,010 --> 00:30:19,870 So any feedback on this would be really appreciated, so I do want to make sure that it's a useful tool all around. 402 00:30:20,750 --> 00:30:34,130 Okay, so the architecture is we've got the ether analysis system, which plugs into a program that takes those trace files and generates the graphs with the OGDF, or Open Graph Display Framework. 403 00:30:34,850 --> 00:30:41,290 And Open Graph Display Framework is the thing that makes the decisions about where to actually place the vertices and locate them and that sort of stuff. 404 00:30:41,290 --> 00:30:47,690 So this is a really awesome library and if you get a chance to use it, it's, I highly recommend it. 405 00:30:47,770 --> 00:30:53,310 It's very similar to GraphViz, but what's nice about this over GraphViz is it works with a large data set. 406 00:30:53,310 --> 00:30:59,910 So I've had millions and millions of vertices inside of here and it hasn't choked on it, but it will take all your memory. 407 00:31:00,750 --> 00:31:01,730 But that's okay. 408 00:31:02,570 --> 00:31:07,570 Finally, we get to Vera, and Vera is the OpenGL component to this program. 409 00:31:07,730 --> 00:31:14,070 And so what Vera's going to do is actually display this and allow you to start analyzing it. 410 00:31:14,910 --> 00:31:29,770 Okay, so the basic steps are to run an instruction trace with ether, transfer that trace file to the analysis box, then run gen graph on that output, and then those resulting GML files, or the graph language files, are going to be open inside of Vera, 411 00:31:29,770 --> 00:31:32,410 and then you can use that to actually correlate instructions. 412 00:31:33,450 --> 00:31:35,270 Okay, so let's go ahead and do a demo. 413 00:31:44,460 --> 00:31:49,320 Okay, so we start back at our same place with the ether instruction. 414 00:31:49,320 --> 00:31:58,600 So the VM's already started, so what I'm going to do is an instruction trace and give it the name of the executable to look for, and then just redirect the output of this to a trace file. 415 00:31:59,640 --> 00:32:11,520 So this is going to run, and then over on the VM side, I'm just going to start executing the program, and again, I want to make sure that I have that task manager up so that I can stop this here. 416 00:32:12,760 --> 00:32:27,880 Okay, so Netbull gets executed, gets started, and then we wait for a little bit of time to elapse, and so it might not be easy to see, but when you move the mouse around, it gets a little jumpy, so you know that's actually the case where things are going on. 417 00:32:27,880 --> 00:32:30,420 But generally, when you get this icon down here, it means it's running. 418 00:32:32,600 --> 00:32:33,200 Okay. 419 00:32:33,600 --> 00:32:35,940 So now we can stop it from executing. 420 00:32:38,480 --> 00:32:39,560 Close this. 421 00:32:40,600 --> 00:32:46,760 Stop ether, and then at this point, we can look at the trace file and see how big it is. 422 00:32:46,760 --> 00:32:53,180 It's roughly about 250 megs, and so at this point, what we want to do is transfer it to our analysis system. 423 00:32:55,540 --> 00:33:06,100 And so this is a good reason to point out that, you know, when you're running a live demo, I know live demos are the way to do it, but I decided to save you all the intrigue of watching 250 megs transfer over the network. 424 00:33:06,720 --> 00:33:08,700 So that's why I did this. 425 00:33:08,740 --> 00:33:09,700 You're welcome. 426 00:33:12,860 --> 00:33:13,640 Okay. 427 00:33:13,640 --> 00:33:15,060 So it's copying. 428 00:33:15,500 --> 00:33:16,480 It's done. 429 00:33:16,480 --> 00:33:18,080 It's the world's fastest network. 430 00:33:19,340 --> 00:33:25,760 We run gen graph on the program, so gen graph just handles the graph layout and builds the GML files. 431 00:33:25,860 --> 00:33:33,860 So we give it the trace file that we copied over, the original executable, so it can do its analysis, and also the output that we want to put this at. 432 00:33:33,980 --> 00:33:40,780 So this, too, takes a little bit of time to run, and in this time, I'm generating two basic implementations. 433 00:33:40,820 --> 00:33:44,960 The first one is the instruction base graph, and then the next one is the basic blocks. 434 00:33:45,800 --> 00:33:48,460 So once this gets done, what's this? 435 00:33:49,100 --> 00:33:49,700 Okay. 436 00:33:49,700 --> 00:33:50,100 Yes. 437 00:33:50,100 --> 00:33:51,220 It's actually going backwards. 438 00:33:51,400 --> 00:33:55,240 So from there, what we want to do is actually load this inside of Vera now. 439 00:33:56,580 --> 00:33:59,720 And so this is the actual interface right here. 440 00:33:59,760 --> 00:34:09,180 So to navigate and move around and look at this graph, you simply just drag the same way you would with Google maps and use your scroll wheel to go in and out. 441 00:34:09,780 --> 00:34:15,080 The initial execution is going to be at this blue address right here. 442 00:34:15,300 --> 00:34:18,820 And then any sort of transition is going to move around inside of there. 443 00:34:18,820 --> 00:34:21,820 So what we're looking at right now is the basic block view. 444 00:34:23,540 --> 00:34:32,600 So we can zoom in, look at these sort of things, and any sort of line, the thicker the line between these, that's going to indicate the loops that are executing. 445 00:34:32,600 --> 00:34:34,940 So thin lines mean there's only one transition. 446 00:34:35,520 --> 00:34:39,740 And so it turns out that Mew actually has two stages of unpacking. 447 00:34:39,740 --> 00:34:50,120 So this initial loop that we were looking at is actually going to be the first one, which was identified via the unpacking process. 448 00:34:50,120 --> 00:34:55,220 And then the secondary decoding, which actually brings the rest of the program out, will identify more. 449 00:34:55,220 --> 00:34:58,280 And so what we're looking for are transitions in colors. 450 00:34:58,280 --> 00:35:08,060 So when we see a color change here, especially from this green to purple, this purple here is going to be representative of the address. 451 00:35:08,200 --> 00:35:10,120 So this is the basic block view. 452 00:35:10,240 --> 00:35:14,280 This should be the original entry point that we're looking for, but this is pretty close. 453 00:35:14,280 --> 00:35:17,920 So the original one was BB08 and this is BB8B. 454 00:35:18,820 --> 00:35:21,840 And if you're some kind of math genius, you can calculate that in your head. 455 00:35:22,880 --> 00:35:26,760 So then we get over to the actual execution of the program. 456 00:35:27,160 --> 00:35:30,720 And inside of here, these are all the transitions that the program makes. 457 00:35:31,880 --> 00:35:37,560 So the next thing that we're going to do is I want to show you the all instruction trace. 458 00:35:41,920 --> 00:35:43,800 And so this is a little bit more laid out. 459 00:35:43,800 --> 00:35:50,140 So one of the comments that we got when we showed this and did a user study is that it was a little bit dense information. 460 00:35:50,140 --> 00:35:53,680 So this is the actual instruction base level. 461 00:35:53,680 --> 00:35:56,600 So we see that first set of loops inside of here. 462 00:35:56,880 --> 00:36:05,800 We come to the central section and inside of this, we can see that there's one function inside of here that's making a lot of the decisions about what the program's doing. 463 00:36:05,800 --> 00:36:07,700 So this is this address right here. 464 00:36:09,200 --> 00:36:14,260 So if you're looking for the main decision point of a piece of malware or something like that, you can find that. 465 00:36:14,260 --> 00:36:20,260 But once we zoom in here, we can see that this address is actually going to be the original entry point that we were looking for. 466 00:36:20,260 --> 00:36:22,520 And so we validated it and looked at this. 467 00:36:22,600 --> 00:36:29,480 But just by doing a quick glance at this, we can figure out what the OEP is just by looking at this. 468 00:36:30,100 --> 00:36:42,140 But as far as the overall functionality of a program, any time we see this sort of long lines of single execution, this is a good indication that this is the initialization phase of the program. 469 00:36:42,340 --> 00:36:50,560 And any time that we get these branching operations right here, this is actually going to be the part where it's making a decision or actually doing the branching. 470 00:36:51,800 --> 00:36:57,900 But what's nice about Netbull is that it's got these features inside of it that are pretty common. 471 00:36:58,340 --> 00:37:03,040 So it's always got that three-way branch at the beginning and the little pigtail up there. 472 00:37:03,660 --> 00:37:11,400 This internal side right here, this is the main loop that the Trojan uses to execute and basically control the system. 473 00:37:13,420 --> 00:37:28,200 So just moving around inside of here, the next thing that we can do is we can actually zoom in and we can take these instructions right here and then open up IDA and we can use this to start correlating things. 474 00:37:28,200 --> 00:37:34,540 So once we find some interesting portion of execution, we can use that to find the address that we're looking for. 475 00:37:34,540 --> 00:37:41,180 So in this case it was 403C80 and if we zoom in and just find those addresses, we'll find that there. 476 00:37:41,180 --> 00:37:44,480 So you can use that to correlate back and forth with IDA. 477 00:37:44,620 --> 00:37:49,920 Eventually there will be an IDA module but I ran into a couple bugs that prevented me from releasing it on time. 478 00:37:50,460 --> 00:37:54,960 But you can use this as an initial stopgap solution, stopgap. 479 00:37:56,480 --> 00:37:57,520 Okay. 480 00:37:58,660 --> 00:38:00,400 So that's Vera. 481 00:38:05,270 --> 00:38:06,930 Let's go here. 482 00:38:14,620 --> 00:38:15,880 Thank you. 483 00:38:16,740 --> 00:38:17,440 Okay. 484 00:38:17,440 --> 00:38:28,020 So now I, the next thing that I did is I took a bunch of pictures which were basically the different version or the same version of Netbull packed with a whole bunch of packers. 485 00:38:28,020 --> 00:38:35,280 But in this case, this is Netbull and it has the same structure. 486 00:38:35,280 --> 00:38:42,560 So we saw this initialization portion here, this branch structure and then this tight knot of execution inside of here. 487 00:38:43,280 --> 00:38:46,680 So zooming in, this is the same view that we were looking at in the demo. 488 00:38:47,480 --> 00:38:49,420 So now we get into some of the packers. 489 00:38:49,420 --> 00:38:58,180 So this is UPX and UPX starts out with some, this red region or the dark red region which is this highly compressed code area. 490 00:38:58,400 --> 00:39:02,640 And then we transfer into this light purple or lavender. 491 00:39:02,700 --> 00:39:03,220 Okay. 492 00:39:03,220 --> 00:39:09,680 I'm not good with colors but... So lavender is actually means it's a size of data zero. 493 00:39:10,020 --> 00:39:14,360 So this is where the code is actually unpacking itself and then running the program. 494 00:39:15,080 --> 00:39:21,940 We see that the original entry point is immediately after the high entropy code and we get into the size of data zero. 495 00:39:23,040 --> 00:39:24,960 Next is ASPAC here. 496 00:39:25,020 --> 00:39:28,360 We start out with the blue instruction right here. 497 00:39:28,360 --> 00:39:38,200 It goes into these yellow instructions and then it unpacks itself and then we get a transition into this red portion of the program which is where the unpacker was compressing itself. 498 00:39:38,220 --> 00:39:40,560 So this is a good way to profile these sort of things. 499 00:39:41,680 --> 00:39:42,040 Okay. 500 00:39:42,040 --> 00:39:43,300 Same thing with FSG. 501 00:39:43,300 --> 00:39:50,020 It's got a smaller or more compressed set of instructions and then we transition to the higher portion of the program. 502 00:39:50,060 --> 00:39:52,680 And this graph here looks a little bit different. 503 00:39:52,680 --> 00:40:00,320 And the reason it looks different from the other ones is that there's a non -deterministic portion of the OGDF rendering system. 504 00:40:00,320 --> 00:40:04,480 But you can still pull out some of the various features here. 505 00:40:05,440 --> 00:40:05,820 Okay. 506 00:40:05,820 --> 00:40:06,480 Mew. 507 00:40:07,020 --> 00:40:08,180 Mew is really nice. 508 00:40:08,180 --> 00:40:09,920 This is the one that we looked at right there. 509 00:40:10,600 --> 00:40:14,280 It's got a whole bunch of different transitions of colors but the general same format. 510 00:40:14,820 --> 00:40:15,880 And then TLock. 511 00:40:16,080 --> 00:40:26,040 TLock actually has a long set of instructions and I'm assuming that it uses some shifting decode frame to actually encrypt itself and rerun a lot of these executions. 512 00:40:27,340 --> 00:40:27,900 Okay. 513 00:40:29,040 --> 00:40:39,240 So one of the things that I did with this is I took a sample from OC's collection and called Mebroot, which is a pretty hardcore virus, and analyzed it inside of Vera. 514 00:40:39,500 --> 00:40:43,600 And so when I was initially looking at this, it seemed to be idling for long periods of time. 515 00:40:43,600 --> 00:40:56,900 So actually executing this, I knew it was actually executing because my friend and I'm really glad I made friends with him, the network manager at my school said, hey, do you know you've got malware on your box? 516 00:40:56,900 --> 00:40:58,640 He's like, yes. 517 00:40:59,220 --> 00:41:01,320 But thank you, that validated that. 518 00:41:01,620 --> 00:41:05,780 So what Mebroot is, is it's a hybrid user mode and kernel-based malware. 519 00:41:05,780 --> 00:41:16,920 So when I initially executed it for maybe 30 seconds and stopped it, I saw that there was this basic execution right here where it just sat inside of this, but it wasn't really doing anything. 520 00:41:17,640 --> 00:41:22,000 So essentially it just sits in here for 30 minutes waiting for us to get bored. 521 00:41:22,080 --> 00:41:31,540 So I accidentally left it running overnight and tried to look for any sort of unpacking program that it was running after. 522 00:41:32,040 --> 00:41:40,860 So once it got through that unpacking program, it transitioned into this main area of execution, which was the top portion of this loop, and got going. 523 00:41:40,860 --> 00:41:43,960 So this is the entire graph of execution. 524 00:41:44,240 --> 00:41:52,560 We start out with the initialization, this is the 30-minute busy loop, secondary initialization right here, and then there are three main portions of the program. 525 00:41:52,740 --> 00:42:07,720 So reverse engineering it, this was the main unpacking loop, and these are two other secondary decoders that I didn't figure out, but this kernel code insertion actually occurs at this point, and that's when the executable stops and your system's then infected. 526 00:42:09,360 --> 00:42:10,320 Okay. 527 00:42:14,520 --> 00:42:26,760 Okay, so Danny's been teaching these reverse engineering classes using the more traditional approach, not using Vera, but using this traditional, sort of traditional approach, it's his version of it anyway, for quite a while. 528 00:42:26,760 --> 00:42:40,740 And recently at one of his classes, after having taught the class for, you know, spending a week on reverse engineering, he took Vera to show these people that were in the class and see what they thought of it. 529 00:42:40,780 --> 00:42:52,620 So the first comment in this is it's a very small user study, in part because there's not a lot of really good reverse engineers out there you can get together for a reverse engineering user study, okay. 530 00:42:53,200 --> 00:43:00,180 The second thing is this was a training class, so you might say, well, but you're taking all newbies to do this. 531 00:43:00,180 --> 00:43:04,380 Well, there were two people in the class that hadn't done reverse engineering before. 532 00:43:04,880 --> 00:43:10,140 There were, I think, two people that had a lot of experience, and the other two had quite a reasonable amount. 533 00:43:10,140 --> 00:43:19,440 So this is, although a very small sample, it's a pretty good representation of what we would expect in the reverse engineering community. 534 00:43:19,780 --> 00:43:28,800 So he had them analyze two different packed versions of NetBull, and I'm just going to go through this very quickly because we're about out of time. 535 00:43:29,560 --> 00:43:39,140 Basically trying to see if the things that he's just walked you through doing in the demo, whether new users, whether this helps them or not. 536 00:43:39,460 --> 00:43:50,920 They're supposed to find the original entry point, then find these different parts of interest, the packer code, the initialization, the main loops, and if they can, that's great. 537 00:43:50,920 --> 00:43:52,720 Especially if it's a little faster. 538 00:43:53,020 --> 00:44:03,460 So original entry point, you'll see users 1 and user 3 were the two newbies who had never before this week done any reverse engineering. 539 00:44:03,660 --> 00:44:11,160 And one of them, you know, we've got the two different packers, one of them with one packer finds the OEP, the other one doesn't find it with either one. 540 00:44:12,220 --> 00:44:21,340 For the initialization, in one case they all recognize it, in one case the two new people can't find the initialization code. 541 00:44:21,740 --> 00:44:24,300 Main loops, a little better performance. 542 00:44:24,300 --> 00:44:30,520 We have one person with one packer can't find the main loops of the program, which I find hard to believe. 543 00:44:31,960 --> 00:44:42,740 Then overall evaluation, they were asked were they likely to use this again, and that's in the light lavender, and would they recommend it to others, and that's in the pink. 544 00:44:43,020 --> 00:44:51,080 So both for the new people and for people with a lot more experience, they thought this worked pretty well and they would recommend it. 545 00:44:52,320 --> 00:44:57,660 The basic gist that comes out of this is there's more work to be done. 546 00:44:58,460 --> 00:45:00,060 Yay PhD students. 547 00:45:00,300 --> 00:45:02,140 Talk about the work you need to do yet. 548 00:45:04,480 --> 00:45:05,200 Okay. 549 00:45:06,440 --> 00:45:07,100 Thank you. 550 00:45:07,860 --> 00:45:12,240 So we basically need a better way to identify the beginning and ends of loops. 551 00:45:12,240 --> 00:45:13,800 That was a good observation . 552 00:45:14,220 --> 00:45:23,840 A lot of these loops became overlapped and were a little bit convoluted , and it would really be nice to be able to search for these memory addresses and see the basic blocks it matched. 553 00:45:24,480 --> 00:45:28,700 So the future work that we're going to get into is general GUI and bug fixes. 554 00:45:28,700 --> 00:45:32,500 Right now it's pretty unsophisticated , so I want to make that a little bit better. 555 00:45:32,660 --> 00:45:35,380 I'd like to start doing some memory access visualization. 556 00:45:35,580 --> 00:45:38,680 Ether provides an awesome way to do that, so I definitely want to get there. 557 00:45:39,000 --> 00:45:45,760 Integrate system calls, look at the function call boundaries, and then get a little bit of more interactivity with the unpacking process. 558 00:45:46,160 --> 00:45:56,940 The other nice thing that would be cool is that it'd be really nice if you could use something like WinDebug or Ali or Ida's debugger inside of the Ether system and all the functionalities there. 559 00:45:57,020 --> 00:45:59,160 It's just a matter of making it together. 560 00:46:00,020 --> 00:46:01,520 So conclusions. 561 00:46:01,720 --> 00:46:04,540 Visualization makes it easy to identify the OEP. 562 00:46:04,780 --> 00:46:07,460 There's no actual statistical analysis needed. 563 00:46:07,980 --> 00:46:10,560 You can actually identify program phases. 564 00:46:10,560 --> 00:46:17,420 The graphs are pretty simple, and the preliminary user study shows that other people don't think we're full of it. 565 00:46:18,440 --> 00:46:21,460 Okay, there are some tripping hazards that are right here. 566 00:46:21,460 --> 00:46:25,660 Basically, use 64-bit version of Debian Sarge. 567 00:46:26,040 --> 00:46:31,060 Follow the instructions that Artem and Paul have worked so hard on to the letter. 568 00:46:31,880 --> 00:46:36,020 I was guilty of not doing this, and then I reread it, and it was much easier. 569 00:46:36,020 --> 00:46:51,160 So anyway, it has to be a 32-bit Windows XP service pack 2 image, and you have to disable DEP, large pages, multiple CPUs, and for God's sake, whatever you do, kill the program before inside of Windows before stopping Ether. 570 00:46:52,280 --> 00:46:55,340 Okay, so closing thoughts, Ether's awesome. 571 00:46:55,380 --> 00:46:57,760 Many, many thanks to Artem and Paul. 572 00:46:57,760 --> 00:46:59,920 This is some excellent, excellent work. 573 00:47:00,000 --> 00:47:05,020 If you get anything out of this, I think that more people should be using Ether because it's just so completely cool. 574 00:47:06,500 --> 00:47:10,460 Source code tools and the latest slides are on offensivecomputing.net. 575 00:47:10,520 --> 00:47:13,060 I do have an initial version of this out. 576 00:47:13,060 --> 00:47:14,800 Source code will be up later. 577 00:47:15,880 --> 00:47:21,700 If you use this tool, please give me some feedback, and a more formal treatment of this is going to be at VISSEC 2009. 578 00:47:22,720 --> 00:47:25,620 So, again, okay. 579 00:47:26,100 --> 00:47:30,940 And then thanks to all these people, they were very instrumental in making this whole thing happen. 580 00:47:31,380 --> 00:47:36,980 So, with that, I believe we're going to the Q&A room, which is 106. 581 00:47:37,840 --> 00:47:38,380 Goon? 582 00:47:38,380 --> 00:47:39,200 Yeah, okay. 583 00:47:39,600 --> 00:47:44,740 So, Q&A room 106, and then we'll be available after the talk for a little bit to talk to you. 584 00:47:44,740 --> 00:47:46,300 So, thank you very much for coming out. 585 00:47:46,300 --> 00:47:46,780 you