Okay, my name is Nick Harbour. I work at a company called Mandiant. It's at the bottom of the slide. We're an incident response company. Me, personally, I lead the malware analysis team at Mandiant, so reversing's my thing. This talk is going to be kind of primarily aimed at reverse engineers or people who are getting into reverse engineers. And there will be a lot of code on the slides. There will be some assembly code that freaks you guys out. You can go ahead and bail now. I won't be offended. You don't have to understand every bit of it, though. There's still going to be a lot of content in here for people who are absolutely brand new, don't know how to code, that sort of thing. All right, so as far as the agenda, I'm going to start out, get some terminology out of the way so nobody's mystified whenever I start throwing out some terms. I'm going to talk about the history of dynamic analysis and the current techniques that people are using in the field and the current techniques that I use when I'm doing malware analysis. And like I said, this is a reverse engineering talk, and I'm going to talk about the history of dynamic analysis and since I'm a malware analysis guy, it's always going to be with a hint of malware analysis. I know there's several different disciplines of reversing. I'm pretty much always going to take the discipline of malware. So basically, at the end, the carrot at the end of the stick for this talk will be a new tool, and I'm going to basically give you a mini setting it up throughout the talk and how it compares and contrasts with other tools that are currently out there. All right, so a little bit about reverse engineering. We split it off into two different... Actually, let me just take this out. This is really annoying. All real hackers have their dog as their background. Yeah, he is. Oh, okay. Yeah. All right. All right, so we split off reverse. Reverse engineering into two main disciplines, or two main categories. Static analysis, which is everything that doesn't involve actually running the code. Analogy there being like an autopsy. You know, it's dead. You're picking it apart. You're figuring out what it does. The other half of the picture is dynamic analysis, which is, you know, you're letting the malware run. You're seeing what it does, observing its behavior. So the tool that I'm going to be presenting about and the techniques we're going to be talking about are solely contained within the dynamic analysis family of techniques. So you're actually going to have to run the software to actually use these analysis techniques. So the current approaches out there are... Wait for it. Network monitoring. Yeah, of course, you know, setting up virtual networks. A lot of this is accomplished with VMware. It's what we currently use. This is certainly accomplished by people at the very basic level. Before you know anything about disassembly or any of that, you can set up Wireshark. You know, do some basic behavioral analysis on malware. Getting more complicated, expensive solutions like Norman Sandbox and CWSandbox, which these products are good. They can pretty much do everything that my tool is going to do. My tool is free. Their tool is tens of thousands of dollars. So I'm not going to claim to be, you know, beating everybody at everything free because this is a project in my own personal time, which is not copious. Oh, and the main tool I personally use, because it is also free and we get pretty good results from our analysis, is Sysinternals Process Monitor. I think quite a few of you have used it. It's very, very popular. I'm going to be comparing mainly with that. And debuggers can do a lot of this stuff. The whole point of my tool, though, is going to be, I'm going to be doing a lot of process tracing and API interception and all that without acting as a debugger. So if you've been thinking of, you know, heckling me with a question like, why don't you just use Immunity Debugger or whatever, the whole point is to be not using a debugger. I'm sure a debugger can do that. I think it would work great in most circumstances for these things. Just there needs to be a tool out there to do that kind of thing without being a debugger at all. All right. Kernel-level monitoring. So this is the technique employed by Process Monitor, by Sysinternals. Here's a normal kind of graph of what happens when you do a system call in Windows. You have a user mode process like, I don't know, notepad.exe. It issues a call called create file. This is something that's issued to the programmer in the application that can make this function call. And the code for that initially is provided by libraries. In this case, kernel32 is the library that provides that call. And all that happens in kernel32, which is totally in user space, is it performs a system call. The system calls have to be implemented in this SSDT, the system service descriptor table. So it's kind of like an array of pointers in the kernel. Essentially, I'm going to oversimplify the hell out of this whole process just for the sake of time. And then these go, and the kernel maps these to the actual handlers of the functions. So how Process Monitor works is they basically load a driver that hooks these SSDT entries. And so every time one of these is called, they'll eventually call the real thing. But along the way, they're going to report back and say, hey, somebody called this. You know, capture the event and take note of it. So advantages to that technique, every system call will be captured. You'll have a, that's a pretty good coverage as long as you're capturing everything in that table. Really kind of difficult to get around it. Certainly no way that I know of from user land that you can do something like create file without actually calling the actual service. Disadvantages, not every important function that we care about from the malware analysis or reverse engineering perspective is implemented as a actual system call. So there's important things like if you're wanting to see what functions, piece of malware is trying to load for later on, you'll see process function calls like get proc address. That's completely implemented in kernel 32, I believe. And that's never going to be a system call, but you're still going to want to see it happen. And also calls to internal DLLs, of course, will never be trapped. You're only going to see that the actual system call that happens from the process. That's implemented in kernel 32 or DLL directly into the actual kernel itself. Another disadvantage, you're going to see a lot of like housekeeping stuff. So every time you launch a process, like you make a hello world program, all it does is print hello world to the screen. You can use process monitor to fire up hello world. You're going to see thousands upon thousands of system calls happening just for hello world.exe. Now with skill, you can kind of filter that down. And weed it down and get down to the beat. But still, it's not a perfect system. You're seeing a lot more data than you really care about. I think we can do a little better. Well, here's a screenshot of process monitor. Initially, when I put this in, I was going to talk in detail about it. But we'll just look at it whenever we get to the actual demo. Basically, I'm going to fire up some stuff, monitor with process monitor, process monitor, and then monitor with my tool. You can see the difference. I think it'll be pretty apparent. But basically, this is a list of every system call that's happening. And this is currently filtered just for notepad.exe. So you can see all I did was fire up notepad. And I have 132,000 events, which is the system calls, of which it's currently showing 793 on the screen. And this is really nothing important happening at all. So another technique to do API call monitoring for reverse engineering is using a debugger, which is pretty good. You can trap function calls all day long. Not just system calls. A lot of that same stuff I'm going to be doing you can certainly implement in a debugger. Certainly a scriptable debugger is a very good solution. And the trap calls are going to be, you can potentially get them to be more highly relevant to the trap program using techniques that I'll be talking about later. The only disadvantages, well, the main disadvantages, you have to act as a debugger. Once you act as a debugger, then you're kind of thrown into the fight of this cat and mouse game of debugging and anti-debugging and anti-anti-debugging. You can play in that game if you want. I was just kind of looking for an easy, cheap way to get, circumvent the whole thing and not have a debugger involved whatsoever. All right, so there's lots of different types of hooks. I'm specifically going to be talking about inline hooks. This is the technique I chose. I think it's probably the most robust technique for the long haul. So I chose to implement it first and not even bother with other hooking types. Anyway. Inline hooks can basically, you can trap any function call, not just system calls. Currently the tool I'm going to be talking about only traps. It can only walk through exports of DLLs and trap those. But on down the line, who knows, we can do anything. The trap calls can be highly relevant to the program's operation because we're not going to be seeing any of those process housekeeping system calls like we saw for Notepad. No device driver required. Not operating as a debugger. The only disadvantage is it's kind of a pain. I mean there's really a lot of issues with it. And the tool that I'm going to be releasing certainly is going to show that. It's not fully, I mean this isn't, it's not on the Mandiant site yet because it's not a full, it's not bulletproof yet. It's very much prototype. You can play around with it, kick the tires, write some scripts, that sort of thing. It is not the be all end all tool yet. I think it will be a great piece of work maybe in a couple months. Check back. But anyway. It is a pain. Here's the whole idea. With inline hooks, we basically load stuff in the user space that handles, that traps the functions we're interested in and handles them all in user space so the kernel is never affected. It's basically the same graph we saw earlier, just you see the difference in where the hook handling is moved. All right. So what the heck is an inline hook? Inline hook is basically you're going to where the function exists and you're modifying the code. At that actual function. The assembled code for the function. And to implement these, just a little background in case you have no idea what the heck, how this all works. You basically have to find a function of interest. You have to disassemble the beginning of a function. And this is very important. And this differs from the way a lot of malware will do it. For example, if malware is going to install an inline hook to trap like the send function in Winsock to, you know, so it can monitor every outbound packet. They can pretty much know exactly what code is going to be at the send function. They don't need to disassemble it on the fly to figure out if they can install a hook or not. They can just blast over it and be done with it. Since we have a very general solution where things aren't known at the beginning, we have to disassemble. So I'll talk more on that in a minute. We disassemble. If possible, we overwrite the beginning bytes of the function with a jump or a call instruction. And the jump or call instruction that we write at the very beginning of the function points to our own block of code that's loaded into the process somewhere. Now, like I said, we're going to talk about why we disassemble. Take, for example, this little function right here. XOR, EAX, EAX and return. This is a very simple function that just returns zero. It's only three bytes. A call or a jump instruction of the type that we need is five bytes. If we overwrite this three byte function with five bytes of data, we're overwriting two bytes of God knows what. It might be just padding, but it might not be. So for safety, we're going to disassemble just for the purpose of figuring out if we have enough space to overwrite. Actually, there's one other purpose, and I'll get to that in a second. So here's a more complicated function. This is more like what you would actually see. This is a function prolog at the beginning. It basically just sets up the stack for a function. You don't need to worry about it. Just note that these four instructions are at the very beginning of this function. Once the hook is installed, I've installed a jump hook right here. You can see we overwrote basically, was it five bytes? So these two instructions and two bytes of this third instruction have been overwritten. So every piece of data starting after this first five bytes here is just unused. Because theoretically, whatever our jump handler is doing, if it's going to recreate these instructions, it has to jump back right here to let the program continue. These are just kind of unused. And there's different schools of thought on how you actually implement the hook handler. If you want to completely do something else and never return to the function. In my tool, what I actually do is I implement it with a call right here instead of a jump. And eventually the handler jumps back to this exact point after it's recreated the functionality that it overwrote. So that's another reason I use a disassembler is to figure out exactly what I need to do once I've finished playing with the function. All right, so once you have the hook function, what the heck do you do with it? You can inspect it. This is the terminology I use. I'm sure other people use different terminology. There's no standardization. I say inspect and intercept. Inspect being I want to let the function continue once I'm done doing whatever I'm doing. I just want to look at the stack, see what arguments are being passed in, do things like that. Intercept is I want to look at the stack and look at the arguments and all that junk. I just don't want to actually call the function once it's finished. So in this tool, it has the capability to basically, you can script a response whenever you hook something. So I can hook. The example I like using here is get host by name, which is the function in the Winsock library to do a DNS lookup. So we can script a response to get host by name to basically always kick back the same IP address for every DNS response, which is a good first step in sandboxing. And that would be an intercept operation as opposed to inspect. If we're just monitoring the API calls, as the program runs, that's all interception. So I kind of jumped the gun there on the rolling your own sandbox. Get host by name is my favorite to start out with because it's very easy to understand, very clear to implement. I'll show you the code to implement it. You can do much more complex things, and this will all be down the road. I don't have much of this implemented yet, but you can do things like you can trap the call to connect to just kick back like a pseudo handle so that every successive send or receive to that pseudo handle, you just check if it's like the value dead beef, and if it is, handle it with your own Python code as opposed to letting Winsock handle it and really send it out across the wire. Same thing could happen with the file handles. Create file, read file, write file, all that stuff. We can do the same thing. All right, before we get too far, I'm just going to... This technique hasn't been documented anywhere, and it's a technique I use for unpacking on a daily basis, and it's kind of what got me in the mindset of thinking about inline hooks for so many years. I'm just going to go ahead and briefly talk about this pack, the technique I use for unpacking. The reason I use this technique is it doesn't involve debuggers whatsoever. With just some basic hooking, we can easily unpack code. The first thing you need to do to unpack code with inline hooks is disable this thing called known DLLs. Basically, if you have a DLL listed in known DLLs, which most of the important system DLLs are, it'll always use the version that's in C colon backslash Windows system 32. For example, kernel 32 is always in that directory, and it's always listed in this key, so it's always going to use that regardless of the regular DLL search path. The DLL search always goes to the current directory, the application startup directory, and then eventually works its way back to the system directories. We disable this key, which in my malware VM, that's what I have disabled all the time so I can easily do this. You disable this key, you reboot. I copy kernel32.dll to the current directory that I have the malware in that's packed. Now, basically, whenever I run that malware, it's going to use the local copy that I just copied as opposed to the actual system 32 copy. The difference here is we're going to be modifying that version of kernel 32. If we tried to modify the one in system 32, we can't because of Windows file protection. Theoretically, you could disable it, but you don't want to do it, trust me, because we're going to install a hook, and that would be bad to do system-wide. Next thing we need to do is find a function that's likely to be used in the unpacked code. I like writefile, git command line is good. Basically, packer stubs, when they go to unpack a binary, there's not a whole lot of win32 functions there. We need to find one that the unpacked binary is going to use that the packer stub isn't going to use. I've never seen a packer stub, which in this process of unpacking the binary, calls writefile. Potentially, they could call git command line, but writefile is my favorite. I always hook that first, and if it doesn't work, eh, I move on. Then you've got to find the location of that function within kernel 32. I'm talking about the physical location within the file that that function starts. I'm going to omit the details of that process. It's a lot of math and calculating. Once you find where that function actually starts, you just replace the first two bytes with EBFE, which is an infinite loop in Intel. Just do that with a hex editor, and then you launch the packed binary, and as long as it calls that function that you just installed that little hook to, as soon as it hits that function call, the CPU usage spikes and the process is effectively hung. At this point, then I just attach to it and dump process memory. It's basically hung in a place where it can't do any anti-debugger checks unless potentially they have another thread running or something like that. I just thought I'd throw this in here, two slides to officially document something which I use on a daily basis, which I haven't seen anybody else document. Move on. Now I'm going to talk about the actual tool. I've named it API thief. There were better names out there at some point in time, but I'm searching on the net. Everybody's taking all the good ones, so I'm left with API thief. How this thing works, as opposed to doing the on disk API hooking like the Microsoft detours library or the technique I just showed you, this thing operates completely in memory. What we do is we launch a process in a suspended state, then we use process injection to inject the DLL into that process. This is interesting to note because we launched it in a suspended state. We do process injection to get that DLL loaded. That's operating on a thread that's executing before main thread ever starts. If you've ever played with processes in a suspended state, there's nothing going on. If it imports like 50 DLLs, as long as it's still in that suspended state, none of those DLLs get loaded. They only get loaded after you resume that main thread. This DLL that we inject operates completely before the actual main code of that program. It's the job of this injected DLL to run through the Win32 API functions and Kernel32 and all that and anything that we specify, really, to go through and hook them. Basically how it operates is it installs these hooks and they all point back to a single function dispatcher and then that function dispatcher is responsible for figuring out what it needs to do once the hooked function has actually been called. I'll talk about the design of it here in just a second, but basically there's Python on the back end which is responsible for figuring out A, if you should hook a function, and if so, what kind of hook should you install, and also once a hooked function has been called, what do you do with it? Do you intercept? Do you inspect? Do you write data to the process? Do you fix the return value to be a certain value? All that stuff is handled by Python. Quick note on the design. The injectable DLL is written completely in C with a lot of inline assembler. Not just because I love assembler, but there's very specific reasons the way that that function dispatcher needs to operate, and I'll show you that in a minute. It needs to be an assembler. It has a built-in disassembler. It's actually a complete disassembler, which is probably a bit more than is really needed for this function, but maybe on down the road we can do more with it. The GUI is written in C sharp. The iron Python is embedded, which is basically Python implemented in the .NET framework, so it's not going to be used in the same Python environment that may be installed on your box. So just be aware of that. But it does have a complete Python library along with it, and it pretty much works the same as you would imagine. All right. Now, how I differ from other types of inline hooking. The main difference is, I implement the hooks with a call instead of a jump. That's pretty rare. Normally, like from a malware perspective or a rootkit perspective, you're installing a hook, everybody just throws it into a jump, and they're fine, because they typically have like a one-to-one mapping on functions that they hook to handlers that they've installed. So if they hook create file, they have a function which handles create file and does all the create file stuff. We don't have that luxury with this tool, because this solution is very generic. At the time we're writing the tool, you have no idea how many functions you're going to hook, or what those functions are, or any of that stuff. That's all up to the Python code, which could be customized or actually written at runtime of the program. So we can't have individual functions inserted into the process which handle each one of these things uniquely. So basically, we use a call instruction instead of a jump so that all, every hook we install, they all point back to the same function which handles that hook. And if you know the difference between a call and a jump, is a call pushes a return address on the stack. So if we put the call instruction at the first few bytes of, let's say, create file, that return value that it pushes on the stack when it calls our dispatcher is going to be different than the return value coming from, let's say, write file. There are going to be two completely different values. And we can know exactly which function we're coming from, which hooked function, based on that return value. So we can write a single general hook handler which can handle any hook function, and we can hook as many functions as we want, and they're all fine. So that's just a little segue into why I'm using hook instead of jump. Nobody probably cares. All right, so all hooks point to the same dispatcher. Currently, I'm using named pipes to communicate back to the GUI. That can be sockets in the future. I don't really care. This was just, initially, I was just only thinking locally, and I just simply named pipes. No big deal. And there's a persistent thread running in the target process, which could be used for communications. For example, if the process is running and you just need to get a list of loaded modules or install a new hook, that's all happening in another behind-the-scenes thread. So you don't have to wait for a hooked function to be called to actually have some interaction with that process. All right. And like I said before, the Python layer handles all the logic on what functions to hook. So we're going to see some plug-ins and whatnot that go through and specify lists of functions to hook and whatnot, but all that stuff can be written by you once you download the package. The entire plug-in framework is in the Python layer, so it's completely up to you. Here's the actual function dispatcher. Like I said, there would be some assembly in the slides, so this is it, the next two slides. Just for anybody who is morbidly curious enough to know exactly how this thing is working, basically, you have to... This is a declspec naked function, which is in C, a function in which you yourself are responsible for setting up and destroying your own stack frame. It's kind of crazy, but the reason we have to do that is we need access to the actual return pointer on the stack. So we have that call instruction from wherever the hook is installed calling this function. This function needs to look at that return pointer on the stack so that it knows exactly what function called it. And the only way you can do that that I know of is declspec naked. That's portable, at least. We also grab the pointer from the stack of the original function that called this. The reason we actually look at that original pointer is so that we can filter out between where that API call got called from. So we're really only interested in calls that are coming from, like, our executable. So if I launch Notepad, I only care about calls from Notepad. I don't care about if Notepad calls kernel 32 and kernel 32 calls something. I don't want to see that call. I only want to see the call from Notepad to kernel 32. So this is one reason that I'm going to get much more condensed data than Process Monitor. Process Monitor's not going to do any type of filtering based on where the API call is coming from. You're just going to get a dump of everything. So recursive calls, you're going to get all that in Process Monitor. Not in mine. Some people might be thinking, well, if you're going to be intercepting calls, there's kind of an issue here with standard call versus C-deckle calls. Mainly, there's a difference here between which function is responsible for fixing the stack based on the number of parameters passed in. It's kind of an issue, but here's basically how I handle that. It's up to, this is where we actually call process inspection commands. This will get commands from the GUI on what to do to the process. So it's actually responsible, it's the responsibility of the Python code to tell the hooked process how many bytes it needs to subtract off the stack at the beginning, or add to the stack at the end of the function. So it basically does that fix-ups as long as the Python code has done its job right. And you've told it, hey, this thing had two parameters, you know, fix the stack and let the program continue. And it basically puts a value on the stack and then plays with the stack pointer and returns to it. At this return, it actually jumps back to the original caller, not to where that hook is. So, and this is for an intercept, by the way. This is not for an inspect. Remember, inspect, it actually lets the original function get called. This is only in the case that we're actually intercepting that call and doing something else instead of it. All right. API Thief has a full protocol. There's other tools out there. Before I, actually, after I started this process, I learned about, like, iDefense had a tool called API Logger, which did similar. It installed a few fixed inline hooks and handled them in a very simple way. And it just kicked, blindly kicked data over a socket back to the GUI. The problem with this, though, not thread safe. So if you had multiple threads kicking stuff back, you're basically getting, you're going to get overlap data. You know, if one system call had a whole bunch of data, it's passing back and it did it over several sends. You're going to get all that data just kind of garbled together, presented to you, the reverse engineer. So as long as you, by implementing a protocol and having it all thread safe and all that, it gets nice, clean output back all the time. So that's why I went down that path. And the protocol supports a few primitives. And this is, these are commands that can be sent to the hooked function to get back data. So when a hooked function is called, the GUI can send it a request to get the ESP value, which is the stack pointer. And from that, then we can basically figure out what arguments are on the stack and all that jazz. You can also get the FS register, if you guys are familiar with what that points to. All the good juicy tidbits you can get once you know the value of that. We can set the EAX value. This is what the return value of the function will be. So in the case that we actually intercept a function, instead of just inspecting it, we want to set a return value, you know, so the rest of the program can continue. And this is the command that will actually set that. Set param size is what I was talking about earlier, where you want to set the number of arguments that are passed to the function. No big deal. Here's an example of the protocol being called. Here's a hooked function gets called. It sends a request to say, hey, a hook was called. The GUI tells it whether or not to do an intercept or to do an inspect with another packet that comes back. Message, technically. And we have a type message called response success. This is actually going to contain the data. So when he says, for example, get ESP value, the response success message is actually going to contain the four byte value of the ESP register. So this is just a little example of doing an intercept. All right, looking at the actual Python API, you don't have to know really much of how the protocol works. It's pretty much easy to handle from the Python layer. So the Python scripts have the ability, you have the functions inspect and intercept. So once your hook handler gets called, it's up to you in Python to know, hey, do I want to inspect this or do I want to intercept it? And you just simply say inspect, and it'll go down that path. Once you're finished doing whatever you want to do, you call continue, and then the program continues on. So you could potentially, like, if you wanted, like, a message box to pop up or something like that, you can have, or a mechanism to have you step through a program and making you click something to actually click through each system call, it's perfectly doable because it won't continue until you actually tell it to continue. Report is how we get information to the GUI console. You'll see it have a nice little scrolling window of messages coming out, and that's how you send a message. I have some wrappers here called git arg and git args. In Python, this will return either a single argument or an array of arguments to the function, and it's just going to return the D words on the stack. So it's, if the D word actually points to a string, you'll have to do some other things to actually go out and get that string. I have wrappers for read asking, read uniting, and code string. Set return value. And last but not least, alloc read and write. So we can allocate memory in the other process, read and write memory. These are just called the win32 functions behind them, so no big secret there. But once you have the ability to intercept a function and read, write, and allocate memory into it and set the return values, you can really pretty much do anything you want. You can recreate any API function and screw with it however you want. So here's an example Python script. This is actually a plug-in that handles beep. And this is the complete plug-in. I know it's hard to see in the back. I'll get to the important functionalities down here in the actual beep handler. And you can see back on this slide, I just called it register hook and told it what I wanted to hook. Register hook is implemented in Python too, so if you didn't like the way that works, you can do it yourself. So here's the handler for beep. And beep is just a function which supposedly takes the frequency to beep and the duration to beep. If you don't have the device driver, it's just going to error out. But it's a useless function pretty much nowadays. So I'm just showing it here to demonstrate. This particular function is going to intercept it, so the real beep is never going to get called. It's going to get the arguments that were passed into it. Like I said, there's two arguments. It's going to report those to our GUI console. And since this is a standard call function as opposed to a CDECL call, we have to set the stack pointer back because it's up to this function to adjust the stack after the call, not the function that called it. So we have to call set param size and tell it to set 8 bytes. And then I set the return value to 1, which in this case means success or true. And this will actually get handled. Here's an example of a get host by name sandbox function. Very simple. At the beginning, we call intercept. I get the first argument to the function with git arg. I read the ASCII string that that points to because you just passed it the name, the DNS name that you want to look up. So at this point, host contains that DNS name. I go ahead and report that to the console so we know what we're looking up. Then I allocate memory. I allocate 4 bytes. And I write this value into it. And that's 127.0.0.1. And then I set the return value to be that pointer that we just allocated. So this is going to handle git host by name. And git host by name is always going to return 127.0.0.1. And it's also going to report to the screen what we're trying to look up. And so you can see it's not all that complicated. And I apologize. I'm not the greatest Python programmer. I just implemented it here to have a decent little convenient extension language. I'm not a purist or anything. So if I'm doing stupid stuff, you can tell me about it. I don't care. All right. So here's API Thief. Like I said, it's very prototype-ish, so I don't have an icon yet. So what we have here, hopefully everybody can see, down here at the bottom, there's a text box where you can specify the command line. You can specify a full command line with arguments and everything. I'm just going to simplify the process here by clicking on the three dots to let you select an executable. And I wrote a small binary here just to get a really simple test. All this thing does is call, like, create file, then it calls beep, and it calls a few other things. So once I've selected that, here's the command line down here. There's really nothing happening yet. We have to hit this initialize button. What initialize is going to do is spawn the process in a suspended state, then inject the DLL. Whenever I hit initialize, though, I have to make sure that my plug-ins are selected, because I can't change those after the fact. And the plug-ins I have here is a basic Win32 API monitor, which I'll show you some of the code for. It's really simple. And that git host by name trap, I'm going to go ahead and enable that plug-in. There's another one that comes with the package on my website called the load library hook. I'm not going to use this for these demos. Basically, you'll need this plug-in if you need to hook a DLL that gets called later by load library at runtime, go ahead and load the load library hook plug-in. So it'll basically recurse down anything that's loaded at runtime, because currently it's only going to hook what it's going to see in memory to begin with. So I call initialize. And you see create a process, injected API thief dot DLL. API thief initialized, ready to launch. So the next step would be to click launch. Let me go ahead and browse a few things. This is kind of useless data at this point, but it went ahead and reported back to me a list of loaded modules in this process space. I also have down here, I can browse the hooks that are installed. So I have that basic Win32 API plug-in loaded, and that's hooking a whole bunch of important API functions. So I can browse the list. It's quite extensive, and I apologize it's not in alphabetical order. And I loaded the plug-in for git host by name, and you can see Winsock232.dll has git host by name hooked. You probably can't see all the way in the back, but there's magnifying glasses, which mean inspect, and then there's the little script icons, which means it's going to intercept. It's going to run a script instead of calling that function. And there's also a script window. This is, to be perfectly honest, completely useless right now. In this release of the tool, eventually, maybe it'll be cool. Oops. But... Oh, I've got to launch it first. Let me go ahead and launch. The script broke. Anyway. I launched... So I went ahead and clicked launch, and it kind of... Oh, Tim? Okay. You can see it called git system time is file time. That's something that happens in the C runtime code at startup. And in this case, that's the only kernel 32 function that was called. There are more functions that get called. It's just I only have the plug-in to trap kernel 32 functions. So it caught that one. It caught a load library call on PSAPI, which is in the code. Caught a call to create file, C column backslash test dot text. You can see here it called beep, and then it called sleep. Sleep is an interesting one for malware analysis, too, because if we can intercept sleep and just report that it's trying to sleep, and then not actually sleep, that can simplify a lot of people's lives. Because a lot of times, malware will try to wait for some crazy amount of time, and you'd have to go through and do a lot of static analysis to figure out how long it's trying to wait for. In this case, we can basically just tell it never sleep. So this is a very simple list of functions, and this basically maps exactly to the function of this program. The main function, I just coded a few things really quick, and you see that's all I get. I should have launched... I should have been monitoring with process monitor while I did that. Oh, well. On the next demo, we'll do that. Oops. So let me do a more complicated one. I'm going to do... Oops. I'm going to do notepad dot exe. Just so you can see, I'm not completely full of shit and using rigged demos. Notepad is... It's not the most complicated program in the world, but it's at least complicated enough that it will screw up your life. I'm going to just do the basic Win32 API, but I'm going to do process monitor, click initialize, and... Oh. Go ahead and launch process monitor here. All right. I already have a filter set up. That's why. Anyway. All right. So I launched notepad. Notepad is now popped up on the screen over here. You can see my data. I don't have very much. I have, you know, get proc address here for register pin app. I have a few string compare functions. These are implemented in kernel 32. There's string comparison, string cat, all that. And this is something you're never going to see with procmon. You're never going to see that this process was doing a string comparison. For example, you know, untitled notepad, a string cat, because that's not a system call. That's only a kernel 32 function call. So here I am scrolling through the process monitor output, and I have 327 events. Most of this has nothing to do with what the programmers of notepad.exe designed. This is just stuff that's happening. For example, every DLL that gets loaded, you have to, there has to be a create file for that DLL and all this other stuff. There's a lot of registry keys that just happen. This is stuff we don't care about for malware analysis, or for the most part, reverse engineering. In this particular example, I really needed to hook more user 32 functions to get, to get the idea of what's going on, but you can see the idea of where we're going with this. Yeah. Go ahead and close that. Okay. So, oh, actually, there's one more thing I wanted to do with notepad. I have to do notepad. Go ahead and launch this again. I want to, like, save a file out. So, I'm going to say, you know, hi, DEF CON, save as. Okay. Test.txt. And then, down here at the bottom, you'll see what the functions are called. There's the string cat on test.txt. There was a create file up here, and I called a write file. Set into file. Much less data than this, which is showing us 15,000 events for this same process. Yeah. . . . . . . . . . . And, And, I think I'm getting , um, ushered off the stage here in like one minute. So, uh, my tools are available right now at rnicrosoft.net. That's not an M. , and don't sue me if you are, work for a company that might take offense. Um, eventually, the tool will be up on mandiant.com, and you can contact me here. If you have major bug reports, uh, in the next couple months, Don't even bother. I know anybody can send an email. There's tons of bugs right now, so maybe hold off a little bit on calling me out and trying to yell at me and scream at me. Just be nice. I'll show you a puppy. Yeah, be nice. All right, well, thank you. You guys have been great. Thank you.