[00:00.000 --> 00:02.580] Okay. How's everybody doing? [00:03.800 --> 00:07.560] All right. Let's give a big hand and welcome our presenters here. [00:07.560 --> 00:10.200] Danny Quist and Laurie LeBrock. [00:15.850 --> 00:20.610] Thank you very much. So this is Reverse Engineering by Crayon. [00:20.610 --> 00:23.670] I'm going to talk a little bit about some hypervisor-based malware analysis [00:23.670 --> 00:27.390] and visualization tools that I've developed here. [00:27.650 --> 00:31.450] So my name is Danny Quist. I founded Offensive Computing. [00:31.450 --> 00:35.470] Also a PhD candidate at New Mexico Tech. I do reverse engineering [00:35.470 --> 00:37.430] and I teach reverse engineering. [00:38.490 --> 00:42.350] And I'm Laurie LeBrock. I guess I need a mic. [00:42.370 --> 00:46.810] I'm Laurie LeBrock. I'm an associate professor and fortunately get to work with Danny, [00:46.810 --> 00:50.090] run the scholarship for service program at New Mexico Tech. [00:50.370 --> 00:55.110] And Danny's going to present essentially all of this because it's really his work. [00:57.590 --> 00:58.630] Okay. [00:58.630 --> 01:03.010] Wow. 30 seconds into the talk and there's already booing. Thanks guys. [01:03.650 --> 01:06.430] I do have a fire extinguisher here I was told not to use. [01:06.430 --> 01:07.790] That makes me want to use it. [01:09.530 --> 01:14.730] Okay. So what we're going to talk about is get started talking about [01:14.730 --> 01:18.690] the reverse engineering process. Then I'll talk a little bit about hypervisors. [01:18.790 --> 01:23.150] And then specifically Xen and Ether, which are pretty awesome. [01:23.390 --> 01:26.850] And how we modify the reverse engineering process to work [01:26.850 --> 01:29.930] with these. And then I'll show my visualization tool Vera. [01:30.270 --> 01:33.650] And then I'll show you some real reversing that I did with this. [01:33.790 --> 01:38.870] And then some results of this process. Okay. So let's get started by looking at [01:38.870 --> 01:42.390] the reverse engineering process. The first step with this is [01:43.070 --> 01:46.750] and this is just my process and the one that I teach and the one that I've had [01:46.850 --> 01:50.710] a lot of good luck with. It's by no means everybody's one. [01:50.710 --> 01:54.690] But this is just what I use when I'm doing it. So that's the big caveat there. [01:54.690 --> 01:58.730] So the first thing that I do is I set up an isolated environment. This is something like [01:58.730 --> 02:02.470] VM wearers and virtual PCs. Some sort of dedicated hardware. [02:02.710 --> 02:06.350] Then we get into the initial analysis. And this is using the real high level tools [02:06.350 --> 02:10.430] like Sysinternals to look for system calls and monitoring any sort of [02:10.430 --> 02:14.850] operating system state change. The next one is removing deobfuscation [02:14.850 --> 02:18.670] and dearmoring a program. So this is unpacking using [02:18.670 --> 02:21.910] debuggers, Saffron or Ether. Then we get into [02:22.950 --> 02:25.690] disassembly. So this is with Idapro or Olidebug or [02:25.690 --> 02:30.030] Dumpbin if you're so inclined. And then the next part is [02:30.030 --> 02:33.630] identifying relevant and interesting features. And so this is where [02:34.410 --> 02:37.630] a lot of newbies have trouble with the process and something that I wanted [02:37.630 --> 02:41.670] to address. So the two things that we're going to talk about here [02:41.670 --> 02:45.610] are specifically going to be addressed is that we're going to look at dearmoring or [02:45.610 --> 02:49.970] deobfuscation. And this is using a tool called Ether, which is [02:49.970 --> 02:54.290] completely cool. And are Paul and Artem here? [02:55.010 --> 02:57.810] Oh, okay. All right. So good. I know Artem [02:57.810 --> 03:01.990] embarrasses you. And then identifying the interesting features is the thing [03:01.990 --> 03:06.050] that the visualization tool is going to do. Okay. So setting [03:06.050 --> 03:10.090] up an isolated runtime environment. The point of this is just to protect yourself [03:10.090 --> 03:13.990] from the code. And this is, you know, assuming that it's pretty [03:13.990 --> 03:17.930] difficult to actually break out of the VM. It also makes a [03:17.930 --> 03:21.990] known good baseline environment to allow you to do backtracking if something bad [03:21.990 --> 03:26.090] happens. So execution initial analysis. [03:26.090 --> 03:29.870] This is just to get the extremely high-level overview of what code's doing without looking at [03:29.870 --> 03:34.050] assembly. And so this is looking for changes on the file system, changes in the behavior [03:34.050 --> 03:37.310] of the system, network traffic, and overall performance. [03:38.710 --> 03:42.450] Okay. So now removing software armoring. [03:42.450 --> 03:45.970] Software armoring are just protections to prevent reverse engineering or [03:45.970 --> 03:49.870] make the program smaller or protect it in some manner. And this is done via [03:49.870 --> 03:54.330] packers, which are just self-modifying code. And there's a whole lot of research out there on this. [03:54.390 --> 03:58.150] Alibone, Saffron, Polyunpack, Renovo, Ether, and Azure. [03:58.250 --> 04:00.310] So this research is going to use Ether. [04:01.750 --> 04:06.190] Okay. So let's talk a little bit about the packing problem. All a packer is is it's a [04:06.190 --> 04:10.590] self-modifying portion of code. It has a small decoder stub that [04:10.590 --> 04:13.790] decompresses the main executables and then restores the imports and then allows the program to [04:13.790 --> 04:17.050] execute normally. And this just plays tricks with the [04:17.930 --> 04:21.870] executable. It does the bare minimum amount of work to get things loaded up [04:22.970 --> 04:25.910] and hides imports and that sort of stuff. And it's basically [04:25.910 --> 04:29.710] just to trip up any of the tools. So the way this looks [04:29.710 --> 04:33.750] is that we'll have a PE file right here and you'll have a normal unpacked file [04:33.750 --> 04:37.810] and you apply a packer to it and what happens is that you get the compressed [04:37.810 --> 04:41.350] or obfuscated code with a small decoder stub on the right. [04:42.110 --> 04:45.470] Okay. There's some other troublesome protections. [04:45.470 --> 04:48.490] The first one is virtual machine detection. You can get [04:48.490 --> 04:50.990] some of these things that are put out. [04:53.510 --> 04:57.030] Also we developed a tool called OCVM detect. [04:57.610 --> 05:01.590] But generally detecting that you're inside of a VM is very, very easy. [05:01.590 --> 05:05.650] And so there was an excellent paper that if you haven't read it yet, you should. [05:05.650 --> 05:09.110] It's called Attacks on Virtual Machine Emulators by Peter Ferry. [05:09.110 --> 05:12.510] What this does is it goes through every single VM that [05:13.110 --> 05:16.850] was available at the time and he gives roughly 10 [05:16.850 --> 05:21.010] assembly instructions about how to detect all of them. It's all for 16-bit [05:21.010 --> 05:25.070] mode of a DOS program, but it's pretty easy to translate into the 32-bit [05:25.070 --> 05:29.070] equivalent. Debugger detection. This is just looking [05:29.070 --> 05:32.110] at the process execution block and checking to see if the [05:32.730 --> 05:37.150] is being debugged flag is set. And also the eflags trap flag is going to be set [05:37.150 --> 05:41.730] there. Timing attacks deal with the time step counter. [05:41.730 --> 05:45.130] And the time step counter, you just take a, you pull it before [05:45.130 --> 05:49.710] and then run some instructions and pull it after and then see if things are inordinately large. [05:49.870 --> 05:52.130] And so this turns out to be a very effective tool. [05:53.710 --> 05:57.270] Okay, so all this is very annoying for the reverser and [05:57.270 --> 06:01.350] there's basically two methods for circumvention. The first one is that you can know about all the possible [06:01.350 --> 06:05.130] protections and get into the cat and mouse game of trying to remove those [06:05.130 --> 06:09.230] or you can make yourself invisible. So the second one is [06:09.350 --> 06:12.890] a lot less work. So being a good grad student, I chose the lazy way. [06:14.830 --> 06:17.290] So there's been a couple... [06:17.290 --> 06:21.490] Sorry? I just have water here, so... [06:21.490 --> 06:24.950] Can we get security here? This guy's causing problems. [06:26.330 --> 06:27.470] Thanks, honey. [06:31.790 --> 06:33.010] Okay, so [06:33.010 --> 06:36.810] software-based VMs... I always wanted to be that guy at DEF CON, too. [06:36.850 --> 06:40.990] All right, so software-based virtual machines. [06:41.050 --> 06:45.150] These are things like Renovo and PolyUnpack and the Dynamics Box Unpacker. [06:45.850 --> 06:48.910] The problems with these is that they get into issues where detecting [06:48.910 --> 06:53.070] these is actually pretty easy. So the Intel CPU is never really meant [06:53.070 --> 06:57.370] to support virtualization and they don't emulate these bug for bug. [06:58.850 --> 07:01.070] Okay, so OS integrated debugging. [07:01.070 --> 07:04.990] This is Saffron and Olibone. Both of these systems abuse the [07:04.990 --> 07:08.730] page fault handler and sets a supervisor bit on running pages [07:09.350 --> 07:13.290] so that you can actually get some sort of idea of the execution [07:13.290 --> 07:17.090] inside of there. The problems with these and one of the problems I had with [07:17.090 --> 07:21.010] Saffron is it destabilized the system. It was very good at unpacking [07:21.010 --> 07:25.010] something once, but if you wanted to run the system or do anything else [07:25.010 --> 07:28.950] with it, you basically had to reboot and do the process again. So it wasn't very [07:28.950 --> 07:32.690] flexible for implementing an automated unpacking system. [07:33.470 --> 07:37.110] The other problem with that is that you couldn't actually do any sort of [07:37.110 --> 07:41.030] fine grain monitoring. You basically got things on the page boundaries. [07:43.110 --> 07:45.010] Okay, so now we get [07:45.010 --> 07:48.950] into the awesome. So there's a fully hardware virtualization monitoring [07:48.950 --> 07:52.870] system called Ether. It was built by Artem Dynaburg and [07:52.870 --> 07:56.650] Paul Royal from Georgia Tech. This is a Zen based [07:56.650 --> 08:00.910] hypervisor system. Ether has a couple of things [08:00.910 --> 08:04.530] that monitor for system calls, instruction traces, memory [08:04.530 --> 08:08.570] writes, and basically all the interaction with the OS is done via the [08:08.570 --> 08:12.810] shadow page table inside of the Zen hypervisor. [08:13.790 --> 08:16.770] So the problem is, which isn't really a problem, [08:16.770 --> 08:20.450] is that it requires dedicated hardware, but what it buys you is that you get an actual [08:20.450 --> 08:25.210] VM environment that you can use to restore a lot of this too. So it's actually very flexible. [08:26.390 --> 08:29.590] Okay, so back to the reverse engineering process. [08:29.930 --> 08:33.070] Disassembly and code analysis, this is one of the most nebulous portions [08:33.070 --> 08:37.070] of the process. And when I'm teaching this, this is the one that the students get [08:37.310 --> 08:41.390] a little bit frustrated at because this is something that you only get after you've done a lot of reversing. [08:41.390 --> 08:43.950] So how do you get a lot of reversing experience? By reversing. [08:44.570 --> 08:49.150] And it largely depends on intuition. And you get into this issue [08:49.150 --> 08:53.170] where a lot of times you focus too much on the actual assembly code and not [08:53.170 --> 08:57.130] the overall view of the program. So fighting analyst fatigue [08:57.130 --> 09:01.110] is something I like to address. Get to the meat of the problem before it's [09:01.110 --> 09:05.170] so you can avoid the issues. Okay, and [09:05.170 --> 09:09.410] finding interesting and relevant portions of the program. So just like the disassembly [09:09.410 --> 09:13.090] portion, this requires a lot of experience. Some typical starting [09:13.090 --> 09:17.310] points is looking for interesting strings, looking for API calls, and [09:17.310 --> 09:21.230] looking at any sort of interaction with the operating system. And so this [09:21.230 --> 09:25.170] is a fundamentally imprecise process and beginners [09:25.170 --> 09:29.150] typically have problems with this because until you get to where you understand this a little bit, it's [09:29.150 --> 09:33.210] hard to know where to start. Okay, so let's [09:33.210 --> 09:36.030] talk about hypervisors for a little bit. [09:41.640 --> 09:45.020] There's been a lot of hype about this over the last few years and I'm [09:45.020 --> 09:49.100] not trying to propel this anymore even though the talk title probably [09:49.100 --> 09:53.120] suggests it. But one of the things [09:53.120 --> 09:57.200] is that a lot of the new hypervisor-based root kits, like BluePill [09:57.200 --> 10:01.100] and that sort of thing, have led a lot of the defensive tools. And just like [10:02.720 --> 10:05.280] always, the offensive need to hide [10:05.280 --> 10:09.920] yourself from a running process or from any sort of introspection from a [10:09.920 --> 10:13.380] piece of code inside the operating system works well in this environment. So [10:13.380 --> 10:17.440] that's what we're going to utilize here. [10:17.440 --> 10:21.200] And one big feature that we're trying to take advantage of is the detection of hardware-based [10:21.620 --> 10:25.660] virtualization is not widely implemented. That's not to say it's impossible, [10:25.660 --> 10:28.960] it's just that I don't see too much of that out in the wild. [10:31.040 --> 10:32.420] Okay, so there are a couple of [10:33.700 --> 10:37.700] hypervisor implementations. VMware ESX server, I've had some good luck running. [10:38.260 --> 10:40.600] This is a commercial solution from VMware [10:41.160 --> 10:44.360] and it mostly avoids a lot of the VM detection issues. [10:44.980 --> 10:49.020] Linux kernel virtual machines, this is what I use as my base environment [10:49.020 --> 10:53.120] when I'm basically reverse engineering. And that's just to [10:53.120 --> 10:57.120] prevent me from running malware on my home system. Which, not to say [10:57.120 --> 11:00.140] that never happens. Or my base system. [11:00.440 --> 11:04.980] And then Xen. Xen is really nice because it's got an excellent set of tools [11:04.980 --> 11:08.940] for introspection. And a lot of this has really been led by Georgia Tech, so [11:08.940 --> 11:12.900] hats off to you guys there. But what's nice about Xen [11:12.900 --> 11:16.960] is it uses a standard QEMU image format that's been set up a long time before. [11:16.960 --> 11:20.640] And it's an API that's fully controlled via Python. [11:20.660 --> 11:22.540] So you can integrate into tools. [11:27.160 --> 11:28.900] Okay, so let's talk about [11:28.900 --> 11:33.020] Xen and Ether. So Ether is a set of patches [11:33.020 --> 11:37.080] to the Xen hypervisor that's used to instrument a Windows system. [11:37.300 --> 11:41.080] And so it has a bunch of base modules that allow you to do instruction tracing, [11:41.080 --> 11:44.960] API tracing, and unpacking. And so one of the best papers [11:44.960 --> 11:48.840] I've read in a couple years is this Ether malware extensions via hardware [11:48.840 --> 11:52.820] virtualization extensions. And this was, again, written by [11:52.820 --> 11:56.760] Artem and Paul and a couple other people at the ACM CCS conference. [11:56.760 --> 12:00.740] So if you haven't read this, it's extremely high quality and very useful. [12:00.820 --> 12:04.880] Especially compared to other academic research. So you should [12:04.880 --> 12:09.020] definitely check this out. So Ether's [12:09.020 --> 12:12.920] event tracing. This is what it's using to detect events on the system. [12:12.920 --> 12:16.840] So we talked about system call execution, instruction execution, memory [12:16.840 --> 12:20.980] writes, and context switching. But what's nice about it is it also gives you [12:20.980 --> 12:24.840] covert monitoring. So there's no modifications to the base system, which [12:24.840 --> 12:29.040] means that it's very hard to detect. So instruction [12:29.040 --> 12:33.000] tracing inside of Ether is implemented by setting the trap flag inside of the E flags [12:33.000 --> 12:36.740] register. And then modifications to that is handled via the [12:36.740 --> 12:40.920] push F and pop F instructions. So these are intercepted by the hypervisor and [12:40.920 --> 12:45.100] used for watching that. So modifications to the single [12:45.100 --> 12:48.780] stepping process to look and see if it's being single stepped is effectively [12:48.780 --> 12:53.180] hidden. Okay. Memory and system calls. [12:53.180 --> 12:56.800] Memory writes are tracked by manipulating a shadow page table. [12:56.880 --> 13:00.820] So this gives you access to all the read to and written memory. System [13:00.820 --> 13:05.080] calls. This modifies the sys enter EIP register to point to a [13:05.080 --> 13:09.200] non-page address. And when any sort of access is hit to that, Ether logs that. [13:09.200 --> 13:14.660] And also logs the instruction to catch the older system calls. [13:16.000 --> 13:20.020] Okay. So the this architecture, you start out with a Linux DOM [13:20.020 --> 13:23.160] zero management system. This is basically a Linux system that you run [13:23.160 --> 13:27.140] all your tools on. This is going to have the VM disk image and Ether [13:27.140 --> 13:30.280] management tools. And then it's going to work with the Zen hypervisor, [13:30.280 --> 13:33.640] which will have the Ether patches. And then work with an instrumented [13:33.640 --> 13:39.180] Windows XP service pack 2. Okay. So I made a couple of extensions [13:39.180 --> 13:43.420] to Ether. The first thing is I moved some of the unpacking code [13:43.420 --> 13:47.820] from the hypervisor into user space. I put a little bit more [13:47.820 --> 13:51.400] user mode analysis in this. And I also repaired the portable [13:51.400 --> 13:55.380] executable rebuilding system. And this is just to allow you to [13:55.380 --> 13:59.720] actually disassemble it inside of IDA. And then there's a lot of [13:59.720 --> 14:03.000] other monitoring for executables that will be released a little [14:03.000 --> 14:09.800] bit later. So the user mode unpacking, what this is, is all [14:09.800 --> 14:13.460] we're trying to do is watch for and monitor all the memory writes [14:13.460 --> 14:17.700] and executions. And so we keep all the memory writes inside of a [14:17.700 --> 14:20.880] hash table. Whenever we see a execution inside of one of those [14:20.880 --> 14:24.320] memory writes, we assume that it's a candidate original entry [14:24.760 --> 14:28.620] point and then take a dump of the image. This isn't perfect, but [14:28.740 --> 14:31.360] it's a decent solution. And it certainly helps you to get some [14:31.980 --> 14:35.200] unpacked code. The other nice thing about moving this out of [14:35.200 --> 14:38.280] the hypervisor was that there's a little bit of scaffolding for [14:38.280 --> 14:44.300] future modifications. PE repairs, to implement this, this is, [14:44.300 --> 14:46.700] there were a couple issues. First of all, the sections weren't [14:46.700 --> 14:50.600] aligned. The address of the entry point was invalid. And it [14:50.600 --> 14:53.400] wouldn't load inside of IDA correctly. So basically all I [14:53.400 --> 14:56.940] did is I took the code from ollie dump and used that to fix the [14:56.940 --> 15:00.480] section offsets and repair the resources as much as possible. [15:00.480 --> 15:03.560] And then setting the address of the original entry point to the [15:03.560 --> 15:08.580] correct place allowed it to be loaded inside of IDA. Okay? So [15:08.580 --> 15:11.320] the results from this is that you get it close to a truly [15:11.320 --> 15:15.680] covert analysis system. Ether is nearly invisible. It's still [15:15.680 --> 15:19.560] subject to blue pill detection. So we can start playing that [15:19.560 --> 15:22.640] game. But I think it's a game that's worth playing. So get [15:22.640 --> 15:25.780] started with that. The next thing that we get is fine grain [15:25.780 --> 15:29.240] resolution of program execution. And since you get memory [15:29.240 --> 15:33.000] monitoring, we can start doing some cool stuff with it. So we [15:33.000 --> 15:36.480] can start looking at these files inside of IDA and a lot of [15:36.480 --> 15:41.160] other tools. Okay. So I want to give a quick demo of how ether [15:41.160 --> 15:56.600] works. Or at least the unpacking portion. Okay. So we're going [15:56.600 --> 16:01.180] to start by loading the file up inside of IDA. And just to [16:01.180 --> 16:03.960] verify that this is actually a packed executable, we can see [16:03.960 --> 16:06.880] that the, we get the standard warning about the import [16:06.880 --> 16:10.640] segments being destroyed. And if we allow IDA to continue [16:10.640 --> 16:15.940] executing, we can see that it's generally not finding anything. [16:15.940 --> 16:19.580] The start function is pretty miserable. It's missing strings. [16:19.760 --> 16:24.860] So there's not actually stuff inside of here. And the [16:24.860 --> 16:27.700] functions are pretty much nonexistent. And the import [16:27.700 --> 16:31.640] address, it just has the suspicious get proc address and [16:31.640 --> 16:35.060] load library. So in this case, things are pretty bad. Also, [16:35.060 --> 16:37.880] this top visualization bar inside of IDA doesn't have a lot [16:37.880 --> 16:40.820] of blue codes. That's a good indication that things are all [16:40.820 --> 16:47.890] hosed. Okay. So what we're going to do is actually start [16:47.890 --> 16:51.590] running this inside of ether. To do that, this is just going [16:51.590 --> 16:57.410] to be a Linux box here. So this is my ether system. And I'm [16:57.410 --> 17:00.830] just going to mount the QEMU image. This handy command and [17:00.830 --> 17:05.810] the 3G driver for NTFS you can use to copy the file over. So [17:05.810 --> 17:11.570] this is pretty straightforward. So we get that copied in. And [17:13.110 --> 17:15.730] even though this is a video, you can see how slow I type. [17:18.610 --> 17:24.230] Okay. So we're copying this over. Once we get the file [17:24.230 --> 17:28.070] copied over, what we want to do is we actually want to start [17:28.070 --> 17:30.910] the virtual machine up. So what I'm going to do is use the [17:30.910 --> 17:34.310] standard Zen commands to get this started. So this is going [17:34.310 --> 17:37.330] to be XM create and then you give it the config file of what [17:37.330 --> 17:45.530] you're looking for. Okay. So once I get started, you get [17:45.530 --> 17:49.150] this message. And once you've got that, you should be able to [17:49.150 --> 17:52.670] open up a VNC image and we can see here that our Windows [17:52.670 --> 17:59.970] machine has actually started. Yeah. All right. So Windows. [18:01.390 --> 18:05.930] Wait for it. Okay. So once we have that, we actually get the [18:05.930 --> 18:08.070] screen and everything's happy and we've got our virus right [18:08.070 --> 18:11.630] here. So everything's ready to go. So one thing when you're [18:11.630 --> 18:14.470] using Ether that you want to be careful of is you want to be [18:14.470 --> 18:18.950] able to load the task manager so that you can actually kill [18:18.950 --> 18:22.730] execution of the program when it's running. So this turns out [18:22.730 --> 18:25.350] to be a pretty important thing to do unless you like your box [18:25.350 --> 18:28.950] rebooting. Okay. So what we're going to do is do an XM list to [18:28.950 --> 18:34.450] get the ID out of here. So in this case, it's nine. And then [18:34.450 --> 18:37.510] we're going to actually start running the Ether tool. So this [18:38.170 --> 18:42.450] will be Ether. Give it the ID that you want. The user mode [18:42.450 --> 18:48.190] unpack code. The executable that you want to watch for. And [18:48.190 --> 18:51.530] then a local copy of that executable. And so once you've [18:51.530 --> 18:57.130] got that up and running, we can see that this is a good sign [18:57.130 --> 18:59.830] that Ether's happy. It's at the filter name to be mu under bar [18:59.830 --> 19:01.930] net bowl. So whenever it sees a context switch into this [19:01.930 --> 19:08.300] process, it's going to pull it out. And at this point, what [19:08.300 --> 19:11.940] we're going to go over and do is over on this system, we're [19:11.940 --> 19:16.340] going to run the virus. So we're running net bowl. And we can [19:16.340 --> 19:19.060] see that net bowl's going to start taking about 100% of the [19:19.060 --> 19:23.100] CPU and it gets a little bouncy. Or like it gets a little [19:23.100 --> 19:26.760] sluggish inside of there. So in this case, we fixed the dump [19:26.760 --> 19:32.900] image to have an RVA of this 421340. So this is a good [19:32.900 --> 19:36.960] candidate dump. And we'll allow this to execute a little bit [19:36.960 --> 19:40.860] longer until we see the actual icon for the program pop up. So [19:40.860 --> 19:43.680] one of the reasons I use net bowl so often is it's pretty [19:43.680 --> 19:46.980] benign. But it's still got the malicious component to it so you [19:46.980 --> 19:50.020] can watch and see that things are executing. So this actually [19:50.020 --> 19:52.780] takes a little bit of time. So I am a little bit of time [19:52.780 --> 19:57.200] dilation to go on. All right. So the next thing we get is a [19:57.200 --> 20:04.180] fixed dump image to have an OEP of RVA BBO8 or 40BBO8. And so [20:04.180 --> 20:08.280] this is actually the original entry point for the program that [20:08.280 --> 20:12.080] I verified by manually reversing this. Okay. So it's very [20:12.080 --> 20:14.560] important to kill the process inside of Windows before you [20:14.560 --> 20:19.900] stop Ether. Otherwise, hilarity ensues. So we've got that [20:19.900 --> 20:27.180] going. Then we stop Ether. And then inside of this, we should [20:27.180 --> 20:29.840] have a listing of directories. And then for each one of these [20:29.840 --> 20:32.920] files, there's the original address. So we've got new net [20:32.920 --> 20:35.880] bowl image and then the address that it stopped. And then this [20:35.880 --> 20:41.300] dash fixed is the corrected image inside of here. Okay. So [20:41.300 --> 20:44.200] now what we can do is we can take this image and load it up [20:44.200 --> 20:48.420] inside of IDA pro and we should start seeing some good things [20:48.420 --> 20:50.960] here. So what we're going to do is pull the fixed image up. [20:53.080 --> 20:57.860] Fixed. Load that up inside of IDA. And then once we start [20:57.860 --> 21:01.080] loading it, we can see that things are a little bit happier. [21:01.380 --> 21:04.300] So IDA is making noises like it's found the right compiler [21:04.880 --> 21:08.060] signatures that it's used to. It's found a lot of the [21:08.060 --> 21:11.640] unpacking code and that sort of stuff. So we get actual [21:11.640 --> 21:15.420] visualization. The functions exist inside of here. We get our [21:15.420 --> 21:20.760] references and everything that we come to expect from this. So [21:20.760 --> 21:23.980] we get these functions. Strings, this is a good indication [21:23.980 --> 21:27.260] that we've got net bowl unpacked. So in this case, we've [21:27.260 --> 21:29.780] got the HRH's net bowl, which I presume is what the AV [21:29.780 --> 21:36.060] companies named the virus after and all this other stuff. Okay. [21:37.740 --> 21:40.580] So again, we can follow links and that sort of stuff. All of [21:40.580 --> 21:47.340] that works and we're all set to go there. Okay. So this is an [21:47.340 --> 21:52.520] example of Mew's net bowl. And one person brought up a point [21:52.520 --> 21:56.500] like, so what? It's Mew. It's easy to do. But this unpacker [21:56.920 --> 22:00.120] is really awesome. It works on pretty much everything. So I [22:00.120 --> 22:04.700] ran the media through this and it does a great job. So if we [22:04.700 --> 22:07.420] could just like clap for Artem right now. It's pretty cool. [22:13.700 --> 22:21.540] Thank you. All right. So with that said, we'll talk a little [22:21.540 --> 22:24.680] bit more about what's going on. So there are a couple of open [22:24.680 --> 22:28.220] problems. The unpacking process produces a lot of candidate [22:28.220 --> 22:31.560] dump files. So this algorithm that we have is a little bit [22:31.560 --> 22:35.440] imprecise. So what we want to do is we want a better way to [22:35.440 --> 22:38.560] find the original entry point. The other thing is that import [22:38.560 --> 22:41.540] rebuilding is still an issue. That's something I'm working on [22:41.540 --> 22:43.600] at this point, but I haven't had a chance to integrate it in [22:43.600 --> 22:47.800] yet. And so the other thing I'd like to do is do some analysis. [22:47.800 --> 22:51.480] So this is going to be the next thing here. So we can integrate [22:51.480 --> 22:55.440] this into our process by allowing somebody to figure out [22:55.440 --> 22:57.740] to know what to look for inside of here. Because this is the [22:57.740 --> 23:00.820] thing that people have trouble with most of the time. So once [23:00.820 --> 23:03.360] you have an idea of the execution flow of a program, [23:03.360 --> 23:06.280] it's really nice to be able to look at this. So software [23:06.280 --> 23:10.100] armoring is pretty much made to be a trivial process and is [23:10.100 --> 23:14.320] extremely easy. Okay. So let's get to the visualization [23:14.320 --> 23:19.700] portion. One of the goals I set out with when I was doing this [23:19.700 --> 23:22.740] visualization is to be able to quickly subvert the software [23:22.740 --> 23:26.240] armoring process. So in the case of Netbull, we only had two [23:26.240 --> 23:29.380] images that we were trying to detect there, our two candidate [23:29.380 --> 23:33.580] dump files. But what I'd like to do are in other samples, [23:33.580 --> 23:36.100] especially with more complex packers, you end up getting [23:36.100 --> 23:38.780] thousands of them. So we want to make that process a little [23:38.780 --> 23:43.580] easier. The other thing is for various portions and phases of [23:43.580 --> 23:47.500] the program, I wanted to identify initialization, main [23:47.500 --> 23:50.060] loops, and the end of the unpacking code. So figure out [23:50.060 --> 23:52.960] where the self-modifying code ends, which is the OEP [23:52.960 --> 23:55.920] detection, and figure out some of the dynamic runtime behavior [23:55.920 --> 23:57.880] of the program, and also integrate it with some of the [23:57.880 --> 24:03.680] tools that we're used to, like IDA. So I made this program [24:03.680 --> 24:06.260] called Vero, which is visualization of executables for [24:06.260 --> 24:10.200] reversing an analysis. But really it was just a contrived [24:10.200 --> 24:13.740] name to name something after Jane's gun in Firefly, and so [24:13.740 --> 24:16.580] I was finally glad to have a program that I could do that. [24:17.740 --> 24:22.440] So when you're looking at this, it's... the code's pretty [24:22.440 --> 24:25.540] simple. It's kind of a Fisher-Price, my first MFC and [24:25.540 --> 24:29.420] OpenGL application. But generally, it uses a lot of the [24:29.420 --> 24:32.740] OpenGL rendering and integrates with IDA Pro, and it's fast, [24:32.740 --> 24:38.000] small, and has a low memory footprint. Okay. So with that, [24:38.000 --> 24:39.200] I'll turn it over to Lori. [24:40.320 --> 24:44.120] So this is just a graph preview, which on... you know, the [24:44.120 --> 24:46.360] fortunate part is there's now a graph in here at the beginning [24:46.360 --> 24:50.160] instead of without one. The bad news is it's zoomed out so far [24:50.160 --> 24:54.600] you can't see nodes versus edges. But the idea here is that [24:54.600 --> 24:57.960] we're going to use a graphical representation so that you can [24:57.960 --> 25:01.500] see what the different phases of computation are and where [25:01.500 --> 25:06.920] your time is being spent. So the vertices here actually [25:06.920 --> 25:10.940] represent addresses. It could be the address of a specific [25:10.940 --> 25:14.140] instruction, or it could be, as you see at the bottom, the [25:14.140 --> 25:16.580] address of the beginning instruction in a basic block, [25:16.580 --> 25:21.600] either one of the two. And the edges represent a... an [25:21.600 --> 25:25.080] execution on a path. So you're going from one instruction to [25:25.080 --> 25:28.460] the next. What path did you take? That's an execution. The [25:28.460 --> 25:33.100] more time some... a transition happens, the heavier the weight [25:33.100 --> 25:36.140] on the edge. So that gives you an idea of how... where you're [25:36.140 --> 25:40.480] spending your time in the execution. The basic blocks, for [25:40.480 --> 25:43.520] any of you who have done the low-level compiler stuff and [25:43.520 --> 25:46.080] that sort of thing, you see those are just... it's straight [25:46.080 --> 25:49.240] line code. So no transfer of control except from one [25:49.240 --> 25:53.360] instruction to the next in the stream. There's no conditionals, [25:53.360 --> 25:57.980] none of that stuff. So basic blocks give you a real simple [25:57.980 --> 26:00.980] way of getting a hold on a little bit more code at a time [26:00.980 --> 26:05.060] than a single instruction. That makes this potentially useful [26:05.060 --> 26:08.320] for commercial codes. But as you're going to see, some of [26:08.320 --> 26:12.040] the next steps in this will be looking at doing functions and [26:12.040 --> 26:16.560] handling function-level sorts of things because you, again, [26:16.560 --> 26:19.600] you still get... you saw that... that graph is actually a [26:19.600 --> 26:23.500] very small graph compared to what graph theorists look at, [26:23.500 --> 26:27.360] but they get kind of big and complex. So the basic blocks [26:27.360 --> 26:31.000] give you a way of compressing some of this. The instruction [26:31.000 --> 26:33.100] view, where you're looking at every single instruction [26:33.100 --> 26:36.780] becomes a node in the graph. Gives real pretty graphs. [26:36.780 --> 26:39.300] Danny likes those nice big swoopy graphs, as he calls [26:39.300 --> 26:42.800] them. So they may have some aesthetic value because they're [26:42.800 --> 26:46.420] pretty to look at, but again, any kind of commercial code [26:46.420 --> 26:49.060] and they're just too big to be able to figure out what's [26:49.060 --> 26:55.360] going on. So again, those transitions between addresses, [26:55.360 --> 26:59.220] they're going to give us more information about where we're [26:59.220 --> 27:03.080] spending time in the graph. But there's an assumption [27:03.080 --> 27:06.780] here that I just need to point out, and that is the [27:06.780 --> 27:10.500] assumption is that during this single execution, so this [27:10.500 --> 27:13.060] is for a single execution of the code, during that single [27:13.060 --> 27:15.780] execution of the code, the thing you're looking for [27:15.780 --> 27:21.100] happened. So if you get something that every 50th time [27:21.100 --> 27:24.760] it's executed, it does something, you're not likely to [27:24.760 --> 27:28.000] find that using this approach. And so some future work [27:28.000 --> 27:31.620] can look at doing more statistical base, where are [27:31.620 --> 27:33.960] executions different when you don't change the input [27:33.960 --> 27:37.560] file sort of thing. But at the moment, you run it once, [27:37.560 --> 27:40.140] you get these graphs, they tell you where things are [27:40.140 --> 27:45.240] executed more. So looking at these edges, wherever you [27:45.240 --> 27:49.440] see from one node coming out multiple lines, that means [27:49.440 --> 27:51.220] there was a decision point there and there are multiple [27:51.220 --> 27:56.900] paths you can go to the next instruction. The thing that's [27:56.900 --> 28:00.500] really interesting, although somewhat arbitrary, is how [28:00.500 --> 28:02.980] the colors are assigned and what they mean. So I'm going [28:02.980 --> 28:05.900] to have Danny step back up here and talk about what [28:05.900 --> 28:09.620] these different colors in the graph mean when you're [28:09.620 --> 28:11.520] trying to find information. [28:14.130 --> 28:16.830] Okay, so again, these colors were chosen sort of [28:16.830 --> 28:20.830] arbitrarily. And what these represent are the relation [28:20.830 --> 28:27.190] of the file that has been dumped from Ether to what's [28:27.790 --> 28:31.610] actually on disk. So in this case, we're trying to [28:31.610 --> 28:34.930] identify execution into sections where code doesn't [28:34.930 --> 28:39.690] exist or that sort of stuff. So what yellow is going to [28:39.690 --> 28:42.070] be, this is going to be the standard, normal compiler [28:42.070 --> 28:45.210] generated code. Dark green is going to be where the [28:45.210 --> 28:48.810] sections are present in the pack version, so this would [28:48.810 --> 28:52.530] be something like executing inside of the P header. Light [28:52.530 --> 28:56.050] purple is where the memory has been allocated for run time [28:56.050 --> 29:00.110] but isn't present in the actual executable. And dark red [29:00.110 --> 29:02.310] is one that I wanted to really point out, which is [29:02.310 --> 29:05.330] actually the high entropy version of the code. So this [29:05.330 --> 29:10.130] would be sort of execution inside of compressed or [29:10.130 --> 29:13.350] encoded or encrypted or whatever you want to call it. [29:13.430 --> 29:15.390] The other thing that I wanted to point out is light [29:15.390 --> 29:19.050] red. These instructions are not in the pack executable [29:19.050 --> 29:22.810] at all. And then line green, this is where the operands [29:22.810 --> 29:26.370] aren't going to actually match. So this would be any [29:26.370 --> 29:30.090] sort of shifting decode frame type attack where you're [29:30.090 --> 29:35.350] executing code over and over. Okay, so these colors [29:35.350 --> 29:38.730] were chosen arbitrarily. I kind of like that they, I [29:38.730 --> 29:41.510] think that they look good, but I did show them to one [29:41.510 --> 29:44.390] of my friends, Kazmir, and he looked at it and he [29:44.390 --> 29:46.390] says, that's great, Danny, but why are all your colors [29:46.390 --> 29:50.430] brown? So it turns out he's red-green color blind. And [29:50.430 --> 29:56.370] so I sat down with Kazmir and he was really nice enough [29:56.370 --> 29:59.350] to help me go over things and pick out a set that [29:59.350 --> 30:02.370] looked okay. But I didn't really like the way they [30:02.370 --> 30:05.470] looked. So inside the code there's actually a set of [30:05.470 --> 30:08.270] instructions that are available for color blind people [30:08.270 --> 30:10.630] and I'm also going to make this available, but for [30:10.630 --> 30:15.130] right now it's not compiled by default. So any feedback [30:15.130 --> 30:17.470] on this would be really appreciated, so I do want [30:17.470 --> 30:19.870] to make sure that it's a useful tool all around. [30:20.750 --> 30:23.730] Okay, so the architecture is we've got the ether [30:23.730 --> 30:27.650] analysis system, which plugs into a program that takes [30:27.650 --> 30:31.130] those trace files and generates the graphs with the [30:31.130 --> 30:35.570] OGDF, or Open Graph Display Framework. And Open Graph [30:35.570 --> 30:37.550] Display Framework is the thing that makes the decisions [30:37.550 --> 30:40.250] about where to actually place the vertices and locate [30:40.250 --> 30:42.490] them and that sort of stuff. So this is a really [30:42.490 --> 30:45.550] awesome library and if you get a chance to use it, [30:45.550 --> 30:48.830] it's, I highly recommend it. It's very similar to [30:48.830 --> 30:52.070] GraphViz, but what's nice about this over GraphViz is [30:52.070 --> 30:54.890] it works with a large data set. So I've had millions [30:54.890 --> 30:57.630] and millions of vertices inside of here and it hasn't [30:57.630 --> 30:59.910] choked on it, but it will take all your memory. [31:00.750 --> 31:01.730] But that's okay. [31:02.570 --> 31:05.850] Finally, we get to Vera, and Vera is the OpenGL [31:05.850 --> 31:08.670] component to this program. And so what Vera's going [31:08.670 --> 31:12.410] to do is actually display this and allow you to [31:12.410 --> 31:14.070] start analyzing it. [31:14.910 --> 31:17.470] Okay, so the basic steps are to run an instruction [31:17.470 --> 31:20.710] trace with ether, transfer that trace file to the [31:20.710 --> 31:23.990] analysis box, then run gen graph on that output, [31:23.990 --> 31:26.890] and then those resulting GML files, or the graph [31:26.890 --> 31:29.250] language files, are going to be open inside of [31:29.250 --> 31:31.030] Vera, and then you can use that to actually [31:31.030 --> 31:32.410] correlate instructions. [31:33.450 --> 31:35.270] Okay, so let's go ahead and do a demo. [31:44.460 --> 31:47.380] Okay, so we start back at our same place with [31:48.020 --> 31:50.720] the ether instruction. So the VM's already started, [31:50.720 --> 31:52.340] so what I'm going to do is an instruction trace [31:52.340 --> 31:54.240] and give it the name of the executable to look [31:54.240 --> 31:57.160] for, and then just redirect the output of this [31:57.160 --> 32:02.200] to a trace file. So this is going to run, [32:02.200 --> 32:05.360] and then over on the VM side, I'm just going [32:05.360 --> 32:07.400] to start executing the program, and again, I want [32:07.400 --> 32:09.060] to make sure that I have that task manager up [32:09.060 --> 32:11.520] so that I can stop this here. [32:12.760 --> 32:16.780] Okay, so Netbull gets executed, gets started, [32:16.780 --> 32:18.600] and then we wait for a little bit of time [32:18.600 --> 32:22.300] to elapse, and so it might not be easy to see, [32:22.300 --> 32:23.720] but when you move the mouse around, it gets [32:23.820 --> 32:25.220] a little jumpy, so you know that's actually [32:25.220 --> 32:28.000] the case where things are going on. But [32:28.000 --> 32:29.480] generally, when you get this icon down here, [32:29.480 --> 32:34.520] it means it's running. Okay. So now we can [32:34.520 --> 32:41.800] stop it from executing. Close this. Stop ether, [32:41.800 --> 32:43.260] and then at this point, we can look at the [32:43.260 --> 32:47.200] trace file and see how big it is. It's roughly [32:47.200 --> 32:50.600] about 250 megs, and so at this point, what we [32:50.600 --> 32:52.380] want to do is transfer it to our analysis [32:52.380 --> 32:57.440] system. And so this is a good reason to point [32:57.440 --> 32:57.980] out that, you know, when you're running a [32:57.980 --> 32:59.400] live demo, I know live demos are the way [32:59.400 --> 33:02.200] to do it, but I decided to save you all [33:02.200 --> 33:05.040] the intrigue of watching 250 megs transfer [33:05.040 --> 33:08.700] over the network. So that's why I did this. [33:08.740 --> 33:15.980] You're welcome. Okay. So it's copying. It's [33:15.980 --> 33:19.820] done. It's the world's fastest network. We [33:19.820 --> 33:22.700] run gen graph on the program, so gen graph [33:22.700 --> 33:24.520] just handles the graph layout and builds the [33:24.520 --> 33:27.020] GML files. So we give it the trace file [33:27.020 --> 33:30.060] that we copied over, the original executable, [33:30.060 --> 33:32.160] so it can do its analysis, and also the [33:32.160 --> 33:34.280] output that we want to put this at. So [33:34.280 --> 33:36.060] this, too, takes a little bit of time to [33:36.060 --> 33:38.600] run, and in this time, I'm generating two [33:39.700 --> 33:41.800] basic implementations. The first one is the [33:41.800 --> 33:43.520] instruction base graph, and then the next [33:43.520 --> 33:46.600] one is the basic blocks. So once this gets [33:46.600 --> 33:50.460] done, what's this? Okay. Yes. It's actually [33:50.460 --> 33:52.820] going backwards. So from there, what we want [33:52.820 --> 33:54.300] to do is actually load this inside of [33:54.300 --> 33:58.000] Vera now. And so this is the actual [33:58.460 --> 34:00.940] interface right here. So to navigate and [34:00.940 --> 34:03.360] move around and look at this graph, you [34:03.360 --> 34:05.280] simply just drag the same way you would [34:05.280 --> 34:06.760] with Google maps and use your scroll [34:06.760 --> 34:10.640] wheel to go in and out. The initial [34:10.640 --> 34:12.520] execution is going to be at this blue [34:13.540 --> 34:16.380] address right here. And then any sort of [34:16.380 --> 34:18.460] transition is going to move around inside [34:18.460 --> 34:19.880] of there. So what we're looking at right [34:19.880 --> 34:24.200] now is the basic block view. So we can [34:24.200 --> 34:26.720] zoom in, look at these sort of things, and [34:26.720 --> 34:28.880] any sort of line, the thicker the line [34:28.880 --> 34:31.100] between these, that's going to indicate [34:31.100 --> 34:32.960] the loops that are executing. So thin [34:32.960 --> 34:34.940] lines mean there's only one transition. [34:35.520 --> 34:37.540] And so it turns out that Mew actually [34:37.540 --> 34:40.180] has two stages of unpacking. So this [34:40.800 --> 34:42.780] initial loop that we were looking at is [34:42.780 --> 34:45.920] actually going to be the first one, which [34:45.920 --> 34:50.120] was identified via the unpacking process. [34:50.120 --> 34:51.680] And then the secondary decoding, which [34:51.680 --> 34:53.060] actually brings the rest of the program [34:53.060 --> 34:55.620] out, will identify more. And so what [34:55.620 --> 34:57.720] we're looking for are transitions in [34:57.720 --> 35:00.380] colors. So when we see a color change [35:00.380 --> 35:04.080] here, especially from this green to [35:04.080 --> 35:06.440] purple, this purple here is going to be [35:06.440 --> 35:08.500] representative of the address. So this [35:08.500 --> 35:10.760] is the basic block view. This should be [35:10.760 --> 35:12.060] the original entry point that we're [35:12.060 --> 35:14.280] looking for, but this is pretty close. [35:14.280 --> 35:16.520] So the original one was BB08 and this [35:16.520 --> 35:19.680] is BB8B. And if you're some kind of [35:19.680 --> 35:21.220] math genius, you can calculate that in [35:21.220 --> 35:24.420] your head. So then we get over to the [35:24.420 --> 35:27.340] actual execution of the program. And [35:27.340 --> 35:28.580] inside of here, these are all the [35:29.000 --> 35:32.240] transitions that the program makes. So [35:32.240 --> 35:33.360] the next thing that we're going to do [35:33.360 --> 35:36.760] is I want to show you the all instruction [35:36.760 --> 35:43.240] trace. And so this is a little bit more [35:43.240 --> 35:44.600] laid out. So one of the comments that [35:44.600 --> 35:47.460] we got when we showed this and did a [35:47.460 --> 35:49.440] user study is that it was a little bit [35:49.440 --> 35:52.920] dense information. So this is the actual [35:52.920 --> 35:54.420] instruction base level. So we see that [35:54.420 --> 35:57.660] first set of loops inside of here. We [35:57.660 --> 35:59.420] come to the central section and inside [35:59.420 --> 36:02.020] of this, we can see that there's one [36:02.020 --> 36:03.300] function inside of here that's making a [36:03.300 --> 36:05.080] lot of the decisions about what the [36:05.080 --> 36:06.900] program's doing. So this is this address [36:06.900 --> 36:10.820] right here. So if you're looking for the [36:10.820 --> 36:12.780] main decision point of a piece of malware [36:12.780 --> 36:14.000] or something like that, you can find [36:14.000 --> 36:16.320] that. But once we zoom in here, we can [36:16.320 --> 36:17.900] see that this address is actually going [36:17.900 --> 36:19.340] to be the original entry point that we [36:19.340 --> 36:21.640] were looking for. And so we validated it [36:21.640 --> 36:23.760] and looked at this. But just by doing a [36:23.760 --> 36:25.780] quick glance at this, we can figure out [36:25.780 --> 36:29.480] what the OEP is just by looking at this. [36:30.100 --> 36:31.620] But as far as the overall functionality [36:31.620 --> 36:34.280] of a program, any time we see this sort [36:34.280 --> 36:37.860] of long lines of single execution, this [36:37.860 --> 36:40.020] is a good indication that this is the [36:40.020 --> 36:42.560] initialization phase of the program. And [36:42.560 --> 36:43.980] any time that we get these branching [36:43.980 --> 36:46.360] operations right here, this is actually [36:46.360 --> 36:47.940] going to be the part where it's making [36:48.080 --> 36:49.720] a decision or actually doing the [36:49.720 --> 36:53.900] branching. But what's nice about Netbull [36:53.900 --> 36:56.220] is that it's got these features inside [36:56.220 --> 36:58.660] of it that are pretty common. So it's [36:58.660 --> 37:00.260] always got that three-way branch at the [37:00.260 --> 37:02.440] beginning and the little pigtail up [37:02.440 --> 37:05.140] there. This internal side right here, [37:05.140 --> 37:06.960] this is the main loop that the Trojan [37:06.960 --> 37:10.300] uses to execute and basically control [37:10.300 --> 37:15.380] the system. So just moving around inside [37:15.380 --> 37:17.440] of here, the next thing that we can do [37:17.440 --> 37:20.240] is we can actually zoom in and we can [37:20.240 --> 37:22.000] take these instructions right here and [37:23.640 --> 37:26.780] then open up IDA and we can use this to [37:26.780 --> 37:29.600] start correlating things. So once we [37:29.600 --> 37:30.940] find some interesting portion of [37:30.940 --> 37:33.400] execution, we can use that to find the [37:33.400 --> 37:34.680] address that we're looking for. So in [37:34.680 --> 37:37.860] this case it was 403C80 and if we zoom [37:37.860 --> 37:40.440] in and just find those addresses, we'll [37:40.440 --> 37:42.200] find that there. So you can use that to [37:42.720 --> 37:44.480] correlate back and forth with IDA. [37:44.620 --> 37:46.220] Eventually there will be an IDA module [37:46.220 --> 37:48.060] but I ran into a couple bugs that [37:48.060 --> 37:49.920] prevented me from releasing it on time. [37:50.460 --> 37:52.740] But you can use this as an initial [37:52.740 --> 37:59.220] stopgap solution, stopgap. Okay. So [37:59.220 --> 38:15.880] that's Vera. Let's go here. Thank you. [38:16.740 --> 38:20.160] Okay. So now I, the next thing that I [38:20.160 --> 38:21.920] did is I took a bunch of pictures which [38:21.920 --> 38:25.060] were basically the different version or [38:25.060 --> 38:26.660] the same version of Netbull packed with [38:26.740 --> 38:28.400] a whole bunch of packers. But in this [38:28.400 --> 38:32.520] case, this is Netbull and it has the [38:34.100 --> 38:36.960] same structure. So we saw this initialization [38:36.960 --> 38:39.840] portion here, this branch structure and [38:39.840 --> 38:41.840] then this tight knot of execution inside [38:41.840 --> 38:44.840] of here. So zooming in, this is the same [38:44.840 --> 38:46.680] view that we were looking at in the demo. [38:47.480 --> 38:49.420] So now we get into some of the packers. [38:49.420 --> 38:52.460] So this is UPX and UPX starts out with [38:52.460 --> 38:55.180] some, this red region or the dark red [38:55.180 --> 38:56.820] region which is this highly compressed [38:56.820 --> 39:00.040] code area. And then we transfer into this [39:00.040 --> 39:03.460] light purple or lavender. Okay. I'm not [39:03.460 --> 39:07.380] good with colors but... So lavender is [39:07.380 --> 39:09.680] actually means it's a size of data zero. [39:10.020 --> 39:11.300] So this is where the code is actually [39:11.760 --> 39:13.500] unpacking itself and then running the [39:13.500 --> 39:16.480] program. We see that the original entry [39:16.480 --> 39:18.320] point is immediately after the high [39:18.320 --> 39:20.860] entropy code and we get into the size [39:20.860 --> 39:25.100] of data zero. Next is ASPAC here. We [39:25.100 --> 39:27.020] start out with the blue instruction [39:27.860 --> 39:29.140] right here. It goes into these yellow [39:29.140 --> 39:31.920] instructions and then it unpacks itself [39:31.920 --> 39:33.820] and then we get a transition into this [39:33.820 --> 39:36.120] red portion of the program which is [39:36.120 --> 39:37.540] where the unpacker was compressing [39:37.540 --> 39:39.020] itself. So this is a good way to [39:39.020 --> 39:42.040] profile these sort of things. Okay. [39:42.040 --> 39:44.060] Same thing with FSG. It's got a smaller [39:44.060 --> 39:45.920] or more compressed set of instructions [39:45.920 --> 39:48.660] and then we transition to the higher [39:48.660 --> 39:50.700] portion of the program. And this graph [39:50.700 --> 39:52.880] here looks a little bit different. And [39:52.880 --> 39:54.480] the reason it looks different from the [39:54.480 --> 39:55.660] other ones is that there's a [39:55.660 --> 39:59.660] non-deterministic portion of the OGDF [39:59.660 --> 40:01.100] rendering system. But you can still [40:01.100 --> 40:03.820] pull out some of the various features [40:03.820 --> 40:08.180] here. Okay. Mew. Mew is really nice. [40:08.180 --> 40:09.040] This is the one that we looked at [40:09.040 --> 40:11.480] right there. It's got a whole bunch [40:11.480 --> 40:12.720] of different transitions of colors [40:12.720 --> 40:14.900] but the general same format. And [40:14.900 --> 40:17.980] then TLock. TLock actually has a long [40:17.980 --> 40:20.000] set of instructions and I'm assuming [40:20.000 --> 40:21.600] that it uses some shifting decode [40:21.600 --> 40:23.940] frame to actually encrypt itself and [40:23.940 --> 40:27.900] rerun a lot of these executions. Okay. [40:29.040 --> 40:30.780] So one of the things that I did with [40:30.780 --> 40:32.460] this is I took a sample from OC's [40:32.460 --> 40:35.880] collection and called Mebroot, which is [40:36.100 --> 40:38.160] a pretty hardcore virus, and analyzed [40:38.160 --> 40:40.100] it inside of Vera. And so when I was [40:40.100 --> 40:41.420] initially looking at this, it seemed [40:41.420 --> 40:43.600] to be idling for long periods of time. [40:43.600 --> 40:48.360] So actually executing this, I knew it [40:48.360 --> 40:51.020] was actually executing because my friend [40:51.020 --> 40:52.300] and I'm really glad I made friends with [40:52.300 --> 40:54.300] him, the network manager at my school [40:54.300 --> 40:55.780] said, hey, do you know you've got [40:55.780 --> 40:58.640] malware on your box? He's like, yes. [40:59.220 --> 41:01.320] But thank you, that validated that. [41:01.620 --> 41:03.800] So what Mebroot is, is it's a hybrid [41:03.800 --> 41:05.780] user mode and kernel-based malware. [41:05.780 --> 41:08.280] So when I initially executed it for [41:08.280 --> 41:11.080] maybe 30 seconds and stopped it, I saw [41:11.080 --> 41:13.300] that there was this basic execution right [41:13.300 --> 41:15.360] here where it just sat inside of this, [41:15.360 --> 41:16.920] but it wasn't really doing anything. [41:17.640 --> 41:19.540] So essentially it just sits in here [41:19.540 --> 41:21.240] for 30 minutes waiting for us to get [41:21.240 --> 41:24.960] bored. So I accidentally left it running [41:24.960 --> 41:28.580] overnight and tried to look for any [41:28.580 --> 41:30.280] sort of unpacking program that it was [41:30.280 --> 41:33.000] running after. So once it got through [41:33.000 --> 41:34.720] that unpacking program, it transitioned [41:34.720 --> 41:36.680] into this main area of execution, which [41:36.680 --> 41:40.240] was the top portion of this loop, and [41:40.240 --> 41:42.820] got going. So this is the entire graph [41:42.820 --> 41:45.200] of execution. We start out with the [41:45.200 --> 41:46.980] initialization, this is the 30-minute [41:46.980 --> 41:49.400] busy loop, secondary initialization [41:49.400 --> 41:50.800] right here, and then there are three [41:50.800 --> 41:53.240] main portions of the program. So reverse [41:53.240 --> 41:55.180] engineering it, this was the main [41:55.180 --> 41:57.520] unpacking loop, and these are two other [41:57.520 --> 41:59.820] secondary decoders that I didn't figure [41:59.820 --> 42:02.260] out, but this kernel code insertion [42:02.260 --> 42:04.180] actually occurs at this point, and that's [42:04.180 --> 42:06.340] when the executable stops and your [42:06.340 --> 42:10.320] system's then infected. Okay. [42:14.520 --> 42:17.060] Okay, so Danny's been teaching these [42:17.060 --> 42:19.600] reverse engineering classes using the [42:19.600 --> 42:20.940] more traditional approach, not using [42:20.940 --> 42:23.140] Vera, but using this traditional, sort of [42:23.140 --> 42:24.800] traditional approach, it's his version of [42:24.800 --> 42:27.000] it anyway, for quite a while. And [42:27.000 --> 42:29.660] recently at one of his classes, after [42:29.660 --> 42:31.600] having taught the class for, you know, [42:31.600 --> 42:33.600] spending a week on reverse engineering, [42:33.600 --> 42:38.180] he took Vera to show these people that [42:38.180 --> 42:39.800] were in the class and see what they [42:39.800 --> 42:42.540] thought of it. So the first comment in [42:42.540 --> 42:45.200] this is it's a very small user study, in [42:45.200 --> 42:47.600] part because there's not a lot of really [42:47.600 --> 42:49.260] good reverse engineers out there you can [42:49.260 --> 42:50.880] get together for a reverse [42:50.880 --> 42:53.840] engineering user study, okay. The second [42:53.840 --> 42:56.820] thing is this was a training class, so [42:56.820 --> 42:59.000] you might say, well, but you're taking all [42:59.000 --> 43:01.000] newbies to do this. Well, there were two [43:01.000 --> 43:02.820] people in the class that hadn't done [43:02.820 --> 43:05.400] reverse engineering before. There were, I [43:05.400 --> 43:06.960] think, two people that had a lot of [43:06.960 --> 43:09.020] experience, and the other two had quite [43:09.160 --> 43:12.260] a reasonable amount. So this is, although [43:12.400 --> 43:13.900] a very small sample, it's a pretty good [43:13.900 --> 43:17.240] representation of what we would expect [43:17.240 --> 43:20.120] in the reverse engineering community. So [43:20.120 --> 43:22.600] he had them analyze two different [43:22.600 --> 43:26.100] packed versions of NetBull, and I'm just [43:26.100 --> 43:27.120] going to go through this very quickly [43:27.120 --> 43:30.120] because we're about out of time. Basically [43:30.120 --> 43:33.000] trying to see if the things that he's [43:33.000 --> 43:34.380] just walked you through doing in the [43:34.380 --> 43:37.660] demo, whether new users, whether this [43:37.660 --> 43:40.460] helps them or not. They're supposed to [43:40.460 --> 43:43.560] find the original entry point, then find [43:43.560 --> 43:45.840] these different parts of interest, the [43:45.840 --> 43:47.520] packer code, the initialization, the main [43:47.520 --> 43:50.920] loops, and if they can, that's great. [43:50.920 --> 43:53.220] Especially if it's a little faster. So [43:53.220 --> 43:55.500] original entry point, you'll see users 1 [43:55.500 --> 43:58.720] and user 3 were the two [43:58.720 --> 44:01.200] newbies who had never before this week [44:01.200 --> 44:04.280] done any reverse engineering. And one of [44:04.280 --> 44:05.540] them, you know, we've got the two [44:05.540 --> 44:06.820] different packers, one of them with one [44:06.820 --> 44:09.540] packer finds the OEP, the other one [44:09.540 --> 44:12.900] doesn't find it with either one. For the [44:12.900 --> 44:15.720] initialization, in one case they all [44:15.720 --> 44:18.840] recognize it, in one case the two new [44:18.840 --> 44:20.440] people can't find the initialization [44:20.440 --> 44:23.440] code. Main loops, a little better [44:23.440 --> 44:25.480] performance. We have one person with one [44:25.480 --> 44:27.340] packer can't find the main loops of the [44:27.340 --> 44:30.520] program, which I find hard to believe. [44:31.960 --> 44:34.280] Then overall evaluation, they were asked [44:34.280 --> 44:36.220] were they likely to use this again, and [44:36.220 --> 44:38.960] that's in the light lavender, and would [44:38.960 --> 44:41.660] they recommend it to others, and that's [44:41.660 --> 44:45.780] in the pink. So both for the new people [44:45.780 --> 44:46.980] and for people with a lot more [44:46.980 --> 44:48.620] experience, they thought this worked [44:48.620 --> 44:51.080] pretty well and they would recommend it. [44:52.320 --> 44:55.880] The basic gist that comes out of this is [44:55.880 --> 44:59.060] there's more work to be done. Yay PhD [44:59.060 --> 45:01.320] students. Talk about the work you need to [45:01.320 --> 45:02.140] do yet. [45:04.480 --> 45:10.160] Okay. Thank you. So we basically need a [45:10.160 --> 45:11.660] better way to identify the beginning and [45:11.660 --> 45:13.440] ends of loops. That was a good [45:13.440 --> 45:16.120] observation. A lot of these loops became [45:16.120 --> 45:18.980] overlapped and were a little bit [45:18.980 --> 45:20.360] convoluted, and it would really be nice [45:20.360 --> 45:22.380] to be able to search for these memory [45:22.380 --> 45:24.820] addresses and see the basic blocks it [45:24.820 --> 45:26.220] matched. So the future work that we're [45:26.220 --> 45:28.700] going to get into is general GUI and [45:28.700 --> 45:30.800] bug fixes. Right now it's pretty [45:30.800 --> 45:31.520] unsophisticated, so I want to make that [45:31.600 --> 45:33.260] a little bit better. I'd like to start [45:33.260 --> 45:35.380] doing some memory access visualization. [45:35.580 --> 45:37.220] Ether provides an awesome way to do that, [45:37.220 --> 45:38.680] so I definitely want to get there. [45:39.000 --> 45:40.860] Integrate system calls, look at the [45:40.860 --> 45:42.800] function call boundaries, and then get a [45:42.800 --> 45:44.340] little bit of more interactivity with [45:44.340 --> 45:47.260] the unpacking process. The other nice [45:47.260 --> 45:49.380] thing that would be cool is that it'd [45:49.380 --> 45:50.600] be really nice if you could use [45:50.600 --> 45:53.160] something like WinDebug or Ali or Ida's [45:53.160 --> 45:55.600] debugger inside of the Ether system and [45:55.600 --> 45:57.620] all the functionalities there. It's just [45:57.620 --> 46:00.460] a matter of making it together. So [46:00.460 --> 46:02.880] conclusions. Visualization makes it easy [46:02.880 --> 46:05.420] to identify the OEP. There's no actual [46:05.420 --> 46:08.520] statistical analysis needed. You can [46:08.520 --> 46:10.660] actually identify program phases. The [46:10.660 --> 46:12.500] graphs are pretty simple, and the [46:12.500 --> 46:14.940] preliminary user study shows that other [46:14.940 --> 46:18.720] people don't think we're full of it. Okay, [46:18.720 --> 46:20.640] there are some tripping hazards that are [46:20.640 --> 46:24.080] right here. Basically, use 64-bit version [46:24.080 --> 46:27.420] of Debian Sarge. Follow the instructions [46:27.420 --> 46:29.080] that Artem and Paul have worked so hard [46:29.080 --> 46:32.860] on to the letter. I was guilty of not [46:32.860 --> 46:34.880] doing this, and then I reread it, and it [46:34.880 --> 46:38.420] was much easier. So anyway, it has to be [46:38.600 --> 46:41.460] a 32-bit Windows XP service pack 2 image, [46:41.460 --> 46:43.960] and you have to disable DEP, large pages, [46:43.960 --> 46:47.040] multiple CPUs, and for God's sake, [46:47.040 --> 46:48.540] whatever you do, kill the program before [46:48.540 --> 46:51.160] inside of Windows before stopping Ether. [46:52.280 --> 46:54.460] Okay, so closing thoughts, Ether's [46:54.460 --> 46:57.240] awesome. Many, many thanks to Artem and [46:57.240 --> 46:59.160] Paul. This is some excellent, excellent [46:59.160 --> 47:01.340] work. If you get anything out of this, I [47:01.340 --> 47:02.680] think that more people should be using [47:02.680 --> 47:04.300] Ether because it's just so completely [47:04.300 --> 47:08.140] cool. Source code tools and the latest [47:08.140 --> 47:10.640] slides are on offensivecomputing.net. I [47:10.640 --> 47:13.060] do have an initial version of this out. [47:13.060 --> 47:16.500] Source code will be up later. If you use [47:16.500 --> 47:18.260] this tool, please give me some feedback, [47:18.260 --> 47:19.900] and a more formal treatment of this is [47:19.900 --> 47:24.240] going to be at VISSEC 2009. So, again, [47:24.920 --> 47:27.660] okay. And then thanks to all these people, [47:27.660 --> 47:29.280] they were very instrumental in making [47:29.280 --> 47:33.940] this whole thing happen. So, with that, I [47:33.940 --> 47:35.480] believe we're going to the Q&A room, [47:35.480 --> 47:40.580] which is 106. Goon? Yeah, okay. So, Q&A [47:40.580 --> 47:42.180] room 106, and then we'll be available [47:42.180 --> 47:44.500] after the talk for a little bit to talk [47:44.500 --> 47:45.820] to you. So, thank you very much for coming [47:45.820 --> 47:46.300] out. [47:46.300 --> 47:46.780] you