Okay, we're about time so thank you again for being here. Um, hopefully you've been enjoying DEF CON. Closing ceremonies will be soon here for the village. Later on you can go and head out to uh, closing ceremonies for DEF CON. If this is your first time, hopefully you had a good time. I hope that you made some friends and if you haven't, then please talk to the person next to you. They might uh, be into the same things that you are. Uh, and I really recommend you go to the closing ceremonies. It's always a lot of fun. Again, thank you for being here. Cheers. Round of applause. Alright, welcome. Uh, really cool way to finish up the day. Uh, understudy 77, he is uh, not only paranoid but he is actually a-paranoid. Like that's, that's in his title. How cool is that, right? So, um, he's a paranoid with Verizon. Um, head of security operations. Head of security operations. And um, he's going to talk, talk to you guys a little about uh, hold on. Okay, cool. Um, he's going to talk with you guys about uh, an introduction of malware RE, reverse engineering. If you haven't done it before, he and I were just talking. Um, this is a really cool talk because it's going to be an anybody can do malware reverse engineering kind of talk. So, really looking forward to this. Give him a hand. Uh, sorry just to interrupt. We just, we just, the open talk just ended so if you hear a little bit of noise it's because of that. So, why don't we just give him a good applause to everyone that participated in the open talk because they just completed. CTF is over. Sorry for that. So, I want to start off at the end of the weekend by asking, did everybody have a really good DEF CON and Hacker Summer Camp? All right. So, I've been here most of the weekend and I want to say two things. First off, I want a round of applause for all the volunteers and organizers of Blue Team Village. They kicked ass, did a really good job and a lot of work. And secondly to Open Sock. Um, it was an awesome CTF and I sat up here in the evening and watched them rebuild the whole thing because everybody killed it. So, they worked tirelessly. I'm sure they're all tired and somebody should buy them beer. So, let's do an introduction to malware analysis. Uh, I'll start with the introductions. I'm the head of the security operations center at Verizon Media. I was an IR and breach consultant once upon a time, slash threat hunter. Um, I'm probably a little bit rusty on this topic so don't hold anything too far against me. Management. Uh, and I'm pretty shitty at Twitter. Now, let's talk about what this is and what this isn't. Um, I have not done this every day in a little while. I love teaching this because every time I add something new and I get to do something new and learn something new. Um, there's a lot more tools and different things than what I'm going to be using. This is very much an introduction. Um, I built this specifically to lower the entry barrier and make the concept of analyzing malware seem not so difficult. So, some people may or may not be my target market and that's okay. But, I just want to make sure that I'm very clear about what this is going into it. So, we can talk a little bit about what tools we're going to be using primarily. I run Ubuntu 14.04 with Remnux. Remnux is an open source malware analysis distro. Oh, I should mention as well, photos are fine this way. Um, I wouldn't take them that way but I know that's a sensitive topic so I want everybody to know I don't care. Um, in Remnux we're going to use some tools like PDF ID, PDF parser, um, OLE tools and VMs. From a VM perspective we're going to be looking at things like Process Explorer, RegShot, Fiddler, Wireshark. Um, we're also going to kind of touch a little bit on Cuckoo Sandbox and how you can kind of automate some of this process that we're going to go over as well. So, let's set up the scenario. You are a security analyst for the Daily Bugle. You received an alert or notification about a suspicious email with an attachment. You got a copy of that attachment. So you have a PDF right now. So now we can jump right into it. Into the good part. By the way, this is all demo pretty much and I've prayed intensely to the demo gods that this is going to work out okay. So, we have a PDF right here. Here's our suspicious PDF. We can do a couple things to look into this. I like to start with PDF ID. Is this big enough? Can everybody read it? I tried to make the size really big. Great. So, I'm already in my directory and we can hit PDF ID and our file name. And we can see what's going on with this. So, if we look through this, this is going to tell us in the header what's there. So, this is going to tell us objects. This is going to tell us JavaScript. Importantly in this case, this is going to tell us that we have an embedded file. That's interesting. Why would you put a file inside your PDF? So, there's a couple different ways we can get it. We can go to a sandbox. We can open the PDF and we can get the file. Or we can use some other tools. But let's see if we can find out some more information about it first. So, I'm going to go ahead and clear this out. And then let's see what we can find out about that file. And let's start with the file name and see if we can find that. So, embedded files. Looks like a Word doc. 602803.doc. Also interesting. What can we find out about that file? Or general information about this PDF in general. Or more information about this PDF in general. And this is where the demo stuff happens. Because I forget to type things. So, we see that there's an embedded file. We can go through. There's the name. Some additional information. This will basically break down the whole PDF and give you general information from it. It's really useful. It's not as human readable as either of the other tools we just talked about, though. So, here's our who wrote and who made. So, now we need to get that. And preferably I think we'd like to get that in a safe way. Although I do like clicking on everything that I can click on. I find that that's one of my favorite things in this world to do. But we'll do it the safe way. So, we'll do detach again. We know there's only one file there. So, we can do save all. And then we can hit step one. So, if you take a look here, this is all laid out for ease of use in case something breaks. But if I run this and we take a look back there, we've now saved out our document. Easy. So, we've now successfully extracted a document from a PDF file. So, now we get into analysis of that document. There's no internet for this. Typically I would be on a VPN and online. But I don't really want to be executing live malware throughout this experience. So, I'm going to go ahead and I'm going to open up a VM. And we're going to start there. So, we will start with opening up this document and seeing what we see. Because I find that to be fun. So, if we take our doc, we move it over to our VM. We can run a couple things here. And we're going to talk more in-depthly about different tools as we get into the file analysis as well. So, as soon as this paces, this is the downside of live demos, right? I can start opening things though. For anybody unfamiliar, Fiddler is basically a web debugger. So, if I have, if I'm suspicious that web based call outs are going to happen or something of that nature and I'm not worried about just general TCP connections, I like to use Fiddler because it displays everything really nicely and very easily. So, I'm a big fan. We'll use Wireshark later as well. Come on. You know the really crappy part about this is I practiced this six times and had no issues. And now, everything wants to freeze. Cancel. Let's try that again. Hey, there we go. It's back. All right. So, we have a document. We have something capturing web traffic. And right now, we're going to get something capturing processes as well. For this, we'll use process explorer. Process explorer is essentially like task manager on steroids and will give you a lot more information. Yes. So, interesting thing. Process explorer is going to be pretty live. So, things are going to disappear. Things are going to go away. Where Fiddler is going to record. So, in this use case, I tend to always keep process explorer top so that I can pay attention to it quickly. And then I'll go back to and look at the network traffic afterward. So, as we open up this document, we can see here that there is a macro. We can also shrink this down so it's out of our way. And we can enable content because we like to live dangerously. So, we can see WinWord here. We can see PowerShell just popped up and did a lot of things. And now, it's gone. So, let's move over here and see what else happened. A lot of these are going to be Microsoft because I don't open Word that often. But I see a couple things that look kind of suspicious over here. They can't go anywhere. But that's not traffic I would expect. That's relatively suspicious. So, it's trying to get something. And if I expand this out a bit, we can go take a look and see if it did anything. Although, we probably won't see very much because it's not connected to the internet. Where are you? So, that's one way without network connection that we can get access to see this kind of stuff. So, here's something interesting. We see two URLs at least in this use case. It couldn't connect to one. It jumped to another. A lot of different pieces of malware will have multiple URLs built in. In the case of those multiple URLs, if you connect to the first one, meaning if the first time you run it, you're on a virtual machine that connects to the internet, you might never see the second piece. So, I tend to run everything first offline and then run online. I also tend to let a lot of this stuff sit for several hours to see if anything happens afterward. But in this case, I think there's an easier way to go through this data. So, we can go ahead and we can close out some of this stuff. We'll keep some of it open. And we can go back over here. So, there's a tool suite called OLE tools. Which basically will look at things and tell us what they are. In this case, we're going to use OLE VBA because we know there's visual basic. Step two. So, we know we have a macro user form one. It can auto exact document open. It may execute or may run an executable or a system command which it launched CMD. Hex encoded strings detected and executable file name being that it ran CMD. So, if we want to see more on this, hit D to decode. And again, pipe more. So, this is going to give us the full context around that. So, just from the beginning, we can see call command line, call PowerShell. No profile. So, it's going to ignore any built in PowerShell settings. Window style hidden. So, you're not going to see it run. Executable bypass. So, it's going to try to bypass execution policy that you have on your computer and run locally. And then we've got a whole bunch of other stuff going on here. Just numbers. And numbers and numbers and numbers. So, what that data ends up looking like is this. Not really super useful yet, right? So, we could probably assume that this entire section here is encoded. Actually, this entire section here is decimal encoded. Is anybody here or everybody here familiar with a tool called CyberChef? Great tool for this kind of stuff. Makes everything very fast. So, I can go in here. I can paste all that in. And I can go from decimal. Well, that didn't work. But everything is comma delimited. And you have to specify that. So, if I specify comma delimited, now we have a lot more information. So, we can see some stuff. But there's still a lot going on. So, I can see that there's an XOR key. This looks like byte string. Some pieces of URLs down there. But there's a lot going on with this. And this is kind of an interesting way to encode an additional layer. Basically, what they're doing is they're shifting numbers. So, like in URLs, they're saying 10, 1, 13. And that's taking this list here and counting from that list, that number. So, if we use that and take a look at that in another way, that's the wrong, oh, no, that's the right one. Because that's this. We can also see an executable down there. So, if we use that and we want to get rid of that, we'll use URLs as an example. So, I took each one of those URL pieces. I haven't found an automated way to do this, by the way. If anybody knows an automated way to do this, that would be great. Because manual takes some time. Count them from 0 up. So, 0 to 20. And then piece these together. 10, H, 1, TTP, and so on and so forth. And you now have three URLs. So, we saw two. We didn't see the third one. But we know that there's three hard-coded URLs in this sample. Or in this piece of code. If we deobfuscate the whole thing, it gets more interesting. So, we see our PowerShell. We see no profile. We see hidden. We see executable bypass. And now we start to get into some other interesting stuff. So, some variable calling. There's an XOR key in there for XOR encoding. Um, byte string link sets. Here's our URLs. And then we start to get into down here. So, write host URL. There's our file. That we're going to see. Here's our write. New object. Download file invoke URL. And then unXOR. And then write bytes unXOR and start said process. So, what that means, and this is a little bit out of scope of what I'm going to talk about throughout the whole thing. But it's worth mentioning. If I go to one of those URLs and I WGIT and I pull down that file, it's an incomplete file. It's an XOR file that needs to be unencoded again, which this script does. Um, I've already done that part. So, I already have the completed file. So, we can start talking about that completed file. So, now we get down to an EXE. So, we have an EXE. We can take a look at it. We're unsure. And now is where we get into running malicious files. So, same system. We're going to have process explorer up. In this case, we're going to use Wireshark. And I'm going to hide that off in the bottom. And we're going to use another tool called RegShot. So, RegShot will take two snapshots of your registry at different times. So, I click a button, it captures the entirety of my registry. I click another button, it captures the entirety of my registry again. And then compares the two files for any potential changes. So, we'll go ahead and pop that open. And we'll take our first shot. Now, none of this is an exact science. If you have any background processes running, things that can affect your registry, those things may come up as well. So, unless it's a completely clean system, you might run into some things. One of the reasons why I didn't restart this is so that it would be cleaner and all background processes would finish running. So, that I would get the best shot possible. So, now we will move over our file. We've got everything open. I want to make sure Process Explorer is front and center. And we'll run it. So, we see here it is. And it's making a call to SVCHost, which is Windows Service Host File. And now it's gone. But, SVCHost with that file still there. That's interesting. It's doing something. Do we have any network traffic? In this case, I'm just going to filter for TCP. And we have network traffic. Not much of any network traffic, because, again, not connected to the internet. But, that's an unexpected call. I don't know why my computer would be going to 199.36.194.27. So, we have network traffic, too. So, we have network traffic. We have a suspicious SVCHost running. We can take a look at the properties of that and kind of go through. We can continue to see the parent process here. We can continue to see what it's doing, what it looks like, if there's an auto start location, the command line that was run, where it's running from. Get performance graphs of how it's running. General performance of it. GPU graph. Threads that it's running and strings of that file. So, this is strings of the actual SVCHost. We can run strings of the specific file, as well, over here. Strings are... I don't know how to properly explain them. Step 8. Step 9. But, you can go through this and you can find some interesting things. So, going through this, a lot of it's going to seem a little bit out of place, but I might be able to find some interesting calls. And I know there's a couple interesting ones in here. So, I can see a couple things right through here. So, set class, registry, call message filter, some calls to some DLLs, initializations, all of these things are kind of the full word pieces of the pieces that I'm potentially interested in when I'm going through this. This might give me an idea of what the file does. Before I run it or after I run it or whenever. I'll get some idea. And if we look at the registry, some of that should match up. So, we'll go ahead and take our second shot. And then we'll compare. So, let's see. We added three keys. Google one, that's probably Google doing something. Microsoft tracing to SVC host, that's expected. We saw that file kind of launch from SVC host. So, we expect that. But now we know it's in registry. We have enable file tracing, enable console tracing. And again, this is very much a touch base on things. So, I'm not going to go into what every one of these things may mean. Just how to run it, how to find it, some things that might be concerning or interesting. So, file directory. Then we get into our modified values, which we're also going to get some stuff in here. I'm not as good at reading text as I used to be. So, looking for potential current versions of different file pieces, window placement, so on and so forth. So, we have network traffic. We have a rogue process that looks like a legitimate Windows process and we have registry files that have changed. So, there's a couple different ways that you can go about this. You can reimage a box like most places do or you can go kind of harp in on each one of those individual problems. Piece by piece. There's also a much easier way to do this, although I genuinely suggest that everybody kind of do it in an automated or in a manual fashion as they're learning this process. I also realize that I'm speeding through this really fast. So, I hope I'm not like blowing anything off. I tend to go a little quick. Speak louder? Sorry. Yeah, I was standing back there yesterday and I realized I couldn't hear much either. No problem. So, automated sandboxing. Is anybody not familiar? Familiar? We'll talk about it anyway. Everything here is free and open source. Everything that I'm using throughout the course of this is free and open source. So, you can do it at home. As we get into automated sandboxing, you can build this, set it up yourself. You need a VM, some scripts to point to it, things of that nature. And it's literally drag and drop. So, I can take this file, I can drag and drop it to submit and then I can tell it a whole bunch of things. Do I want it to connect to the internet? Yes, no. Do I want to give it a priority? What's the time out? So, how long do I want to let this run for? Now, again, one of the things I like about running something manually is I will let a file, if I'm doing an engagement or was doing an engagement, I would often let a file run for like 24 hours. See if it did anything else interesting in that time period. In this case, you're looking at 60 to 120. You can give it whatever set you want, but it might not get any more information. You can add remote control, enable injection, dump process memory, um, dump full memory, and a whole bunch of other options. There's also a wild amount of add-ons that exist for this tool. So, you can add just about everything you want. Now, that said, even though I'm going fast, if I run this right now, it'll take like 10 minutes probably to go through and boot. But I've already run it because, again, I'm terrified something's going to break. So, we can just look at the report. So, same file we looked at before, let's see if anything matches up. Cuckoo also adds a whole bunch of base signatures. So, it's looking for things that look suspicious, essentially. So, we can see a couple different things as we go through this. We can, I like to start with red. Red is bad. Yellow could be bad. Blue, maybe. Order of priority by color. Um, attempts to identify installed AV. It's looking for trend micro. Deletes its original binary from disk. We watched that happen. Collects information about some other installed applications. Queries details from the computer. So, you can get a lot of general information from this. Just from running something in a sandbox. You can also find about a bunch of them online. But full disclaimer, don't use like things that you're using for work and then upload them to some website. Um, unless where you work for is cool with that, then by all means. Um, and then here we see our IP address. Although, it does look like after six years that IP address has finally died. Um, the last time I did this a couple months ago, it wasn't dead. It was, everything was still completely live. And I was amazed by that because this is a six year old piece of malware. Proving that this stuff never really goes out of style. Like, it still exists and functions and runs. Um, it'll also give us any of the network connections, anything that we saw. Again, if your box isn't completely clean though, you will add in some extra things that could hurt. We can look at some static analysis of that file. So we can look at any compile time or PDB path. Any imports for DLLs, which we saw some of those when we went through strings. Any artifacts that were extracted during that time frame from that file. In this case, there were no other ones. Behavioral analysis. This shows us that process tree. The file itself goes to SVC host. Any network analysis that we have. So we can look at general host connections. You can also pivot to MOLOC. Good shout out to MOLOC, even though I'm not going to cover that because Verizon Media, the company that I work for, makes it and open sources it. So it's a good shout out. Um, but you can pivot right to MOLOC for full packet capture. It'll tell you about any files that potentially dropped. In this case, the dropped file was the file we looked at. Um, process memory. It'll pull as well. So any potential URLs that exist in process memory. Again, all of these might not be related to that file. Um, because this is not quite as clean as I would have liked it when I ran this sample. So you get a kind of a good idea of what you can look at from this perspective. And there's a lot of other tools too. Say you're not a Linux guy, you're a Windows guy. If I hop back into here, which is horribly, horribly infected, and I copy my file back in, there's a tool called, not that one, PE Studio. That's it. So PE Studio essentially does a lot of this from a straight RE perspective. So you can just drag and drop a file for analysis. It'll kick into analysis with said file. Um, it will connect to virus total and look for that hash and give you any indicators. If this thing did connect to virus total, it would light up like a Christmas tree. I think it's like 46 out of 64. Um, it'll give you any potential indicators based by severity. So installation of hooks, blacklisted libraries, different section names being blacklisted. Again, we see some of the same things that we saw from each investigation method and maybe a little bit more as we go through each one of these processes. Um, when you get into that, it'll tell you certain sections, um, string analysis and the strings that it found that were weird. So the string analysis that we did via command line, this does, and it'll call out the things that are blacklisted. So, there's our DLL calls. Very, very convenient tool, also free. Um, but has to be run on Windows, which means you have to drop it from Windows, so make sure it's on a box that you don't mind completely screwing over. So, that's about the course of the demo. So let's kind of loop back in and talk a little bit about this. So, as a security person, all of us blue team-ish, what can we do with the information that we got? So we have a file. We know the hash. We have endpoint detection software, we can block that hash. We can look for that hash across our network. We have call-outs in multiple areas. So we have the initial call-out from the document that downloads the file. We can use that to see if anybody else potentially downloaded the file. We can also use the actual call-out with the semantics cert, the IP call-out, to see if anything went wrong or if anybody is infected with that file. Just because it tried to download doesn't mean it's infected. Something could have stopped that. So we have a whole host of information that we can use in our environment, especially if this came in as an email, it probably went to more than one user. So we can take a whole host of all the information that we pulled and get an idea of what this looks like across the scope of our whole network. Which is super useful in any situation. So, I like to leave this kind of stuff in case anybody wants to take pictures of this kind of stuff. So we have different commands that were run, um, the very specific commands. I'll give everybody a minute on that one. Lot of phones up. Good. Good. I, I keep them up because then we have the picture slide which is links to all different kinds of tools. Virus total is an amazing tool for seeing what AV vendors know about different stuff. URL void and IP void, great for IP and URL reputation. Um, malware.com is a very similar to cuckoo online sandbox that you can upload stuff to. Then there's a bunch of different tips. Um, reverse engineering tips, a lot from Lenny Zeltzer who's fantastic at this. There's great sans courses on the topic and I personally love the malware analyst cookbook and practical reverse engineering. If this is something that you want to get into, these are some of my recommendations. The next recommendation page however is a little bit more dangerous. Links to live malware. And I, I say disclaimer right now, use those at your own risk. Um, I suggest having a separate box. This box is literally the user name is guest and the host name is like malware. There's no identifiable information to me on this box whatsoever. I've never logged into a personal account. I've never done any of that. But again, paranoid. Maybe you don't need to do quite that, but that's my thing. But there you have some links to live malware. End of speech. However, I do have stuff for the three best questions. If anybody has any. So why don't I use process hacker instead of sys internals? Probably just stuck in my ways and I don't do it every day anymore. So easier to use procmon to capture the log and then look through the processes afterward. And I agree, it's more time consuming and harder to show like this though. So, VM aware malware, what method would I use to test that? Right? If it won't run on a virtual machine. Um, so I not only have this box, I have a couple other hard boxes that I can use to test this stuff on. Um, and just a base image, like a base windows image wipe. Um, a lot of stuff will run in virtual machine and it's much easier to teach this because I have both tools in the same place. But I have another laptop specifically with wipeable images that I can use for anything that's VM aware. What's that? For the image wiping? It's some enterprise tool. So, how often do I see something new is the question. And admittedly I don't do this every day anymore. But I will say that when I did IR it was in waves. So, you would see essentially the same thing a lot for a little while and then something new a lot for a little while and then something new a lot for a little while. Um, crypto miners when I was rolling out of IR and into management were the big thing. And just personal opinion, if somebody is going to hit you with that, like that's, it couldn't be better than that. Like there's not a lot of damage there. But it's waves. But eventually, I just talked to one of my IR buddies who was here the other day and he said, uh, 10 years he's seen basically the same thing over and over again. It doesn't change that much. So, when it comes to malware that's reaching out to CNC, what do you use to spoof the connections? Typically, I don't. Um, I log into a VPN and I let it make connections. I think you get a much more full picture of what happens when you let communication happen. What's that? Why attach it to an email instead of Google docs? Oh, so why not, from an attack perspective, not upload the PDF to Google docs instead of attaching it to an email? And that happens a lot more now. But it was just a setup scenario to start the conversation. Oh, why didn't I just upload the PDF? I don't know. Go ahead. I have and I actually have a sample of it sitting on this box, too. Um, Emotet V4, actually, I believe. I worked a big case with that. Um, you find certain things. So, like, polymorphic malware, for anybody not familiar, is malware that can change enough to change its hash to make it harder to detect, essentially. Um, and a couple other attributes. So, Emotet V4 is a module-based piece of malware that can call out and download different things and it's constantly changing itself on the system. So, in one of the cases that I used for that, I found common identifiers of the type, which specifically in this case, it was unsigned binaries under or between 60 and 74 kilobytes. And I tracked it down that way and got probably 150 different hashes until we could get Navy Vendor to do stuff. You come here, you get a gift. Yeah. So, did you say static analysis to intent? Significantly more difficult, um, from that base analysis to go into intent. Um, you're starting to get into real serious reverse engineering to get down into the code of exactly what it does outside of what you see from a dynamic perspective. Um, however, I have found that in many cases, and this is just me, like, I'm a horrible reverse engineer, I'm not going to lie. Because when I did IR, no company wanted to pay for that. They just wanted to know how to find it, how to get rid of it, and make sure it was gone. So, I just run a base VM, but I'm also sitting on a Linux box and I'm only messing with executables in this case. So, I don't do any specific VM isolation for this. What do I use to find different variances other than registry keys of the same malware? That's really interesting. And a really good question. I actually have to think about that. Also, come up here. You get a thing. Um, I mean, registry keys not being the only method of persistence in general either. So, any general auto runs that potentially exist, or any other normal common persistence mechanisms, but man, you're really stumping me with that question. So, the risk of letting network connections happen and what kind of setup I have in a lab and or VPN to accept that risk. And I will start that with a story of the one time I forgot to turn on my VPN and executed something that was terrifying and I thought I was screwed. Like, I thought I was going to get owned after I executed this thing because I completely forgot to turn it on. I was terrified for at least a week or two. I never made that mistake again, though. So, and all the fake DNS and stuff is really good, too, but it doesn't necessarily give you the full picture. So, I used private internet access for a long time and I was pretty happy with it. I switched over to Nord recently and I'm pretty happy with that, too. Um, depending on what I look at, I usually run it on host system, not on VM, so that my host system's coming from that location. I have seen a little bit of malware that's like location specific, so if you VPN, it's not necessarily going to execute anyway. But again, few and far between. Um, I've been pretty happy with standard out of the box VPN service. I haven't had problems in the five or so years that I did this regularly. Uh, I, I don't mind sharing the slides. I have no problem with that. So, is there anywhere that I can share the slides? Perfect. It'll be on blueteamvillage.org. Oh, another one. Go ahead. So, without getting into any of the ones that I can't talk about, um, one of the most interesting ones I've ever seen from a commodity perspective was that Emotet v4 sample. Because the initial payload was not malicious at all. And then it would call out and download modules, including SMB spreaders, um, different ransomware and like banking Trojan stuff. It could install other malware and it changed like every five minutes. So, trying to get a handle and I watched it shut down a company in two hours. Like completely shut down a company in two hours. So, trying to get a handle on what that was to clean it up when it kept changing was one of the most fun and stressful weekends of my life. It was also one of, on my birthday weekend, which was wonderful because I was supposed to be on vacation. Anything else? If not, thank you very much for your time, everybody.