1 00:00:00,000 --> 00:00:04,680 Hi everyone. Hopefully everybody's having fun at all the parties and DEF CON in general. 2 00:00:05,740 --> 00:00:10,480 So I'm going to give a talk today about doing memory forensics on cold drives. 3 00:00:11,560 --> 00:00:13,980 Has anyone here ever done that before? 4 00:00:14,860 --> 00:00:17,480 Okay, I see a couple of you, so don't give it away. 5 00:00:18,540 --> 00:00:21,720 Awesome, so let's get started. 6 00:00:24,180 --> 00:00:27,380 So a little bit about myself. My name is Lior. 7 00:00:27,380 --> 00:00:34,220 I do blue team research for DEMISTO, playbooks, orchestration, all of that stuff. 8 00:00:35,900 --> 00:00:40,200 Before that, I used to do some reverse engineering, vulnerability research, model research, 9 00:00:40,560 --> 00:00:43,980 and I recently moved from Tel Aviv to the SF Bay Area. 10 00:00:44,360 --> 00:00:51,720 So, you know, still very cool guys, lots of technical like-minded people, cool environment, different DC group number. 11 00:00:53,960 --> 00:00:57,360 Yeah, so I'm going to start. 12 00:00:57,380 --> 00:01:09,720 I'm going to speak a little bit about memory forensics in general and hopefully convince you guys that although you have all these different tools that are either commercial, open source, to do forensics on the drives you get during cases, 13 00:01:10,120 --> 00:01:15,840 it's still worthwhile to pull out the memory forensics tools and run those on your drives. 14 00:01:17,360 --> 00:01:20,680 So what is your typical memory forensics process? 15 00:01:21,280 --> 00:01:25,980 First of all, you need to get the bit copy of memory from whatever system. 16 00:01:27,380 --> 00:01:32,680 That can end up being a lot of data, especially in servers where you've got like 64 gig RAM or above. 17 00:01:33,540 --> 00:01:38,720 So I even did it once on like a 256 gig server, and that was quite an experience. 18 00:01:39,700 --> 00:01:46,560 And then you need to somehow collect the file over to your analysis environment, and that's very, you know, bandwidth consuming. 19 00:01:47,960 --> 00:01:56,260 That's where there's recently a trend of doing live forensics remotely, directly on the endpoint, and running your analysis tools on the endpoint you're investigating. 20 00:01:56,480 --> 00:01:57,360 And that has... 21 00:01:57,380 --> 00:02:06,380 It has its own limitations, but in certain cases where you need to do a quick triage, it might be, you know, cost prohibitive to copy the whole thing over. 22 00:02:07,060 --> 00:02:15,180 In our case, we already have all the data on the drive, and it's dead box, essentially, so there's no issues around that, right? 23 00:02:15,740 --> 00:02:18,380 And then we need to somehow interpret those bits. 24 00:02:18,560 --> 00:02:26,960 So, you know, maybe you're some kind of a superhuman who can parse, you know, memory images in your head or with a hex editor or with like... 25 00:02:28,060 --> 00:02:36,860 Just a circuit analyzer or something, but most of us need some kind of tool to parse those structures out and figure out the state of the machine. 26 00:02:37,660 --> 00:02:43,520 And then we need to interpret the results, and for that, you need to understand the OS you're investigating, all the different objects. 27 00:02:43,920 --> 00:02:51,260 And there's lots of funny edge cases with like exited processes or processes that didn't exit cleanly, things like that. 28 00:02:51,340 --> 00:02:54,160 So, you know, there's experience that builds up over time. 29 00:02:55,720 --> 00:02:57,360 So why even... 30 00:02:57,380 --> 00:03:01,520 You can do memory forensics, like what's the actual motivation behind taking apart memory? 31 00:03:02,200 --> 00:03:04,900 Obviously, there's a lot of undocumented structures. 32 00:03:05,760 --> 00:03:09,720 There's a lot of changes that get made to the OS. 33 00:03:10,040 --> 00:03:17,300 So it's very time and effort consuming to maintain all those tools and do that. 34 00:03:17,420 --> 00:03:19,000 So what are the motivations behind it? 35 00:03:20,080 --> 00:03:25,680 And in general, it's about creating, first of all, attacker costs. 36 00:03:25,820 --> 00:03:27,360 And it's also about attacker work. 37 00:03:27,700 --> 00:03:34,880 So most attackers know that they can be detected on disk if they leave some kind of evidence that can make it to an investigation. 38 00:03:36,880 --> 00:03:43,540 Fewer attackers know that they can be detected in memory, purely in memory, even if they don't hit the disk at all. 39 00:03:44,420 --> 00:03:47,040 And also, it's harder to evade in memory. 40 00:03:47,180 --> 00:03:49,980 You need to take a lot more mechanisms into account. 41 00:03:50,220 --> 00:03:56,060 So by doing that, you're actually forcing the attackers to create more evasions, to spend more time building their tools, 42 00:03:56,240 --> 00:03:57,340 which is always good. 43 00:03:58,600 --> 00:04:06,620 There's also certain evasion methods, such as, you know, unlinking processes that's been around forever. 44 00:04:06,920 --> 00:04:11,240 If you do a scan of memory and you look for unlinked processes, you can find that. 45 00:04:11,580 --> 00:04:12,980 Same for network sockets. 46 00:04:13,540 --> 00:04:18,980 You can also find objects that are no longer really there at the time of the capture. 47 00:04:19,440 --> 00:04:25,920 So, for example, a socket that was created way back, even though it's not active, the object will still be in memory. 48 00:04:26,060 --> 00:04:27,360 So you can get that out. 49 00:04:27,380 --> 00:04:31,480 And that can give you, for example, the start time for a certain malware. 50 00:04:31,660 --> 00:04:34,960 If the first thing it does is call back home, you can pull out that timestamp, 51 00:04:35,020 --> 00:04:36,900 and then you get a pivot point for your investigation. 52 00:04:40,160 --> 00:04:44,920 Also, some malware will be packed on disk, but it's much easier to dump it from memory. 53 00:04:46,540 --> 00:04:53,520 So certain mitigations that malware authors do to kind of evade scans will not be effective in memory. 54 00:04:55,420 --> 00:04:56,220 And obviously, 55 00:04:57,380 --> 00:05:03,960 certain hooks in API calls, et cetera, if you dump the entire structures from the OS, you can detect those, right? 56 00:05:06,840 --> 00:05:11,240 So the leading tool for parsing memory images is volatility. 57 00:05:12,160 --> 00:05:18,020 There's also recall, which is an early fork of volatility, and that's managed by the Google team. 58 00:05:20,040 --> 00:05:22,300 And there's advantages to both. 59 00:05:22,400 --> 00:05:24,160 It's always better to use more than one tool. 60 00:05:24,300 --> 00:05:25,060 It's like a general, 61 00:05:25,680 --> 00:05:29,240 as a general forensic practice, it's better to validate your findings. 62 00:05:30,460 --> 00:05:37,880 Volatility has a lot of very useful plug-ins that you can use to detect certain kinds of activity. 63 00:05:38,300 --> 00:05:40,880 And I'm going to go over a couple of them for now. 64 00:05:43,220 --> 00:05:47,620 So sometimes it's really as simple as using what you already know. 65 00:05:47,760 --> 00:05:54,500 There is no need to go, you know, hours deep into an investigation just to later find out 66 00:05:54,500 --> 00:05:54,780 that there's something wrong with your data. 67 00:05:54,780 --> 00:05:55,040 There's no need to go, you know, hours deep into an investigation just to later find out that there's something wrong with your data. 68 00:05:55,040 --> 00:05:56,260 There's no need to go, you know, hours deep into an investigation just to later find out that there's something wrong with your data. 69 00:05:56,260 --> 00:05:57,020 There's no need to go, you know, hours deep into an investigation just to later find out that there's something wrong with your data. 70 00:05:57,060 --> 00:05:59,880 So you can see a process list here. 71 00:06:00,260 --> 00:06:03,320 And can anyone spot what's wrong in here, by the way? 72 00:06:08,840 --> 00:06:09,280 Right. 73 00:06:11,020 --> 00:06:12,300 Duskske process there. 74 00:06:12,400 --> 00:06:14,080 That's a known WannaCry process name. 75 00:06:14,180 --> 00:06:17,400 And that's really all it takes to say, oh, okay, this might be WannaCry. 76 00:06:18,600 --> 00:06:23,520 Better pull it out, pull the process out, analyze it, make sure whether it's really WannaCry or not. 77 00:06:23,640 --> 00:06:25,020 But you already found your first process. 78 00:06:25,020 --> 00:06:25,720 You already found your first hit right there. 79 00:06:25,860 --> 00:06:30,060 So do the simple stuff first before you go into the deeper stuff, right? 80 00:06:32,580 --> 00:06:40,020 Another example is using the PSScan plugin that will get you all the process objects from memory. 81 00:06:40,740 --> 00:06:42,020 This is another state. 82 00:06:42,120 --> 00:06:45,100 This is actually a memory snapshot of Stuxnet. 83 00:06:45,580 --> 00:06:49,140 And can anyone spot what's wrong here? 84 00:06:49,420 --> 00:06:52,680 Have any of you analyzed Stuxnet before or kind of seen it? 85 00:06:56,160 --> 00:06:58,800 So there's more than one LSAS process. 86 00:06:59,200 --> 00:07:02,180 And in a normal Windows machine, that's not supposed to happen. 87 00:07:02,620 --> 00:07:08,140 So just by doing these simple checks, you can already detect certain malware. 88 00:07:08,340 --> 00:07:15,640 That's just trying to essentially hide in plain sight, fooling analysts who are just reading through these lists. 89 00:07:15,840 --> 00:07:18,000 And some of these checks have already been automated. 90 00:07:18,160 --> 00:07:20,880 And there is volatility plugins to look for these things. 91 00:07:20,880 --> 00:07:28,500 So when it comes to looking for just repetitions, you know, counting instances, use automation. 92 00:07:28,880 --> 00:07:30,880 You know, don't waste your time. 93 00:07:30,980 --> 00:07:34,180 There's also, when you do this all day, you can miss stuff. 94 00:07:34,400 --> 00:07:36,320 So whatever you know, just automate it. 95 00:07:36,980 --> 00:07:39,900 Volatility has Python, has JSON outputs. 96 00:07:40,180 --> 00:07:43,560 So you can actually use or you can include it in your Python scripts. 97 00:07:43,740 --> 00:07:45,420 And you can just automate all these checks. 98 00:07:47,880 --> 00:07:49,620 So network connections, right? 99 00:07:49,620 --> 00:07:53,640 In this case, I actually hid the name of the VMM file. 100 00:07:53,840 --> 00:07:59,580 So you're looking at network connections for the PID 1484. 101 00:07:59,800 --> 00:08:02,120 So that's a process that's associated with those connections. 102 00:08:02,740 --> 00:08:06,000 And we get the ports and the IP addresses, right? 103 00:08:06,060 --> 00:08:16,540 So that obvious, there's indicators online and documented malicious IP addresses that certain exploit kits, you know, threat actors are using. 104 00:08:16,660 --> 00:08:18,380 And these rotate fairly often. 105 00:08:18,440 --> 00:08:19,560 So these indicators. 106 00:08:19,620 --> 00:08:20,560 These indicators don't last long. 107 00:08:20,800 --> 00:08:23,460 But my point here is use what's known. 108 00:08:23,760 --> 00:08:30,300 So that one on the top right is actually a known IP address for Crydex. 109 00:08:30,540 --> 00:08:33,760 So it was actually a black hole exploit kit that was serving Crydex. 110 00:08:34,100 --> 00:08:40,120 So, again, you don't need to be a top expert to do these simple steps. 111 00:08:40,340 --> 00:08:45,300 Use what's known and then go into the more complicated steps, right? 112 00:08:46,800 --> 00:08:49,560 And when we look up the process, 113 00:08:49,620 --> 00:08:51,940 it's actually responsible for these connections. 114 00:08:52,100 --> 00:08:54,100 So let's say you don't get any hits on the IP addresses. 115 00:08:54,840 --> 00:09:01,420 Try to figure out does it make sense for this process to be communicating over these ports or to be communicating at all. 116 00:09:01,660 --> 00:09:04,820 Maybe it's not supposed to create network connections. 117 00:09:05,020 --> 00:09:06,660 In this case, it's explorer.exe. 118 00:09:06,860 --> 00:09:09,140 So it's definitely worth looking into, okay? 119 00:09:12,100 --> 00:09:15,700 Another thing you can do in memory is look for mutexes. 120 00:09:16,140 --> 00:09:19,040 So those are just used by malware to. 121 00:09:19,620 --> 00:09:25,000 You can actually flag the system, the fact that a certain piece of malware has already infected the system. 122 00:09:25,860 --> 00:09:29,940 What the malware authors do not want is to hit the same machine again 123 00:09:29,940 --> 00:09:34,900 and have two instances of the same malware competing against each other, breaking each other, right? 124 00:09:35,060 --> 00:09:41,040 So what they will do is they plant these mutexes, which are legitimate Windows functionality. 125 00:09:42,320 --> 00:09:47,580 But once we know the name that the mutex uses and they have to stick to certain names, 126 00:09:47,580 --> 00:09:52,460 certain strains of the same malware, different strains might have different mutexes, 127 00:09:52,600 --> 00:09:56,620 but if you just have a list of those and there's plenty of people curating those online, 128 00:09:56,840 --> 00:10:01,220 if you see that, then very clearly it's a piece of malware, right? 129 00:10:02,140 --> 00:10:07,600 So the Avira mutex there, it's known for certain Zeus strains. 130 00:10:07,840 --> 00:10:16,260 So you do the mutant scan, you run that plugin, you run it past your list of known bad mutexes, done, right? 131 00:10:16,380 --> 00:10:17,300 Super simple. 132 00:10:17,580 --> 00:10:18,880 No reason not to use it, right? 133 00:10:21,740 --> 00:10:24,860 Sock scan, we mentioned, you know, unlinked sockets before. 134 00:10:25,960 --> 00:10:28,360 It can show you sockets that are no longer there. 135 00:10:28,500 --> 00:10:31,500 It can show you sockets that are hidden or unlinked. 136 00:10:32,140 --> 00:10:37,620 And the timestamps are super useful if you're working, if you're doing forensics investigations on timelines 137 00:10:37,620 --> 00:10:41,740 and you need a pivot point to try and figure out, okay, where did this actually start? 138 00:10:41,900 --> 00:10:44,100 How long has this been there? 139 00:10:45,260 --> 00:10:46,880 This is a very useful tool. 140 00:10:47,900 --> 00:10:48,740 Artifact to have. 141 00:10:52,700 --> 00:10:57,560 So, okay, at this point you might say, great, but I do not have the memory capture. 142 00:10:57,820 --> 00:11:03,940 So how do I do all this cool stuff that you just mentioned if all I got in my case is a hard drive, right? 143 00:11:04,020 --> 00:11:05,560 All I got is a cold drive. 144 00:11:05,840 --> 00:11:07,340 How do I get this out? 145 00:11:08,860 --> 00:11:13,340 I was actually considering putting, I looked for cold disk online, 146 00:11:13,560 --> 00:11:17,560 and I got the cover for the CD of the phone. 147 00:11:17,560 --> 00:11:19,620 It's a frozen soundtrack. 148 00:11:20,700 --> 00:11:23,600 So I was like, hmm, a lawsuit, not so much. 149 00:11:23,700 --> 00:11:24,640 Okay, forget it. 150 00:11:25,520 --> 00:11:27,040 I'll just use the IC drive. 151 00:11:27,380 --> 00:11:28,020 I like it anyway. 152 00:11:29,860 --> 00:11:34,500 So if you've looked on your C drive, you probably have seen these guys. 153 00:11:35,560 --> 00:11:40,940 So you can actually use these to do all this cool stuff I just showed, 154 00:11:41,100 --> 00:11:44,620 even though you do not have the memory image. 155 00:11:44,620 --> 00:11:51,480 So even though your evidence recovery team or whoever gave you the machine, 156 00:11:51,620 --> 00:11:54,160 unplugged it and kind of destroyed all that evidence, 157 00:11:55,420 --> 00:12:00,300 you still have some memory forensics artifacts that you can explore, 158 00:12:00,420 --> 00:12:01,860 and why not use that, right? 159 00:12:02,220 --> 00:12:10,860 So obviously the hibernation file will be appropriate to the last time the machine hibernated. 160 00:12:10,920 --> 00:12:14,220 That might be a while ago, but still in many cases, 161 00:12:14,220 --> 00:12:16,600 especially when the malware has been there for like eight months, 162 00:12:17,520 --> 00:12:19,100 that's still useful, okay? 163 00:12:20,680 --> 00:12:25,480 So the first thing to look at is actually the write and modified times for these files. 164 00:12:25,580 --> 00:12:26,960 That can give you sort of a clue. 165 00:12:27,400 --> 00:12:32,840 You cannot access these while the machine is alive because it's locked by the OS, obviously. 166 00:12:33,580 --> 00:12:38,860 So you will have to either mount it from a second OS, 167 00:12:39,020 --> 00:12:42,820 like, you know, boot from Kali or Sift, Workstation, whatever it is, 168 00:12:42,820 --> 00:12:46,340 or if you're getting the drive cold, then obvious, right? 169 00:12:46,420 --> 00:12:47,060 You just mount it. 170 00:12:48,840 --> 00:12:52,620 So the first thing you want to do, again, start with the simple stuff. 171 00:12:53,160 --> 00:12:53,980 Strings, okay? 172 00:12:54,280 --> 00:12:59,020 Any kind of IOCs or strings that you know you're looking for, 173 00:12:59,240 --> 00:13:01,320 you can scan for those, right? 174 00:13:01,600 --> 00:13:06,160 Any kind of indicators, URLs, IP addresses, domains, start with those. 175 00:13:06,240 --> 00:13:11,480 If you're looking for a specific type of activity like mining or, you know, 176 00:13:11,480 --> 00:13:17,100 like black market activity or something related to certain companies, 177 00:13:17,260 --> 00:13:20,580 other companies, competitors in cases of like industrial espionage, 178 00:13:20,700 --> 00:13:21,940 you might want to scan for those. 179 00:13:22,120 --> 00:13:24,100 That will give you a good clue, right? 180 00:13:24,640 --> 00:13:26,400 And you haven't yet parsed anything. 181 00:13:26,660 --> 00:13:28,480 You do not need any expertise. 182 00:13:30,040 --> 00:13:35,980 And obviously, you can have a whitelist to filter out strings that just come up all the time, right? 183 00:13:38,100 --> 00:13:40,580 And there are a couple caveats to that. 184 00:13:40,580 --> 00:13:44,660 The hibernation file is compressed on disk, so you will need to convert it first. 185 00:13:46,180 --> 00:13:49,900 And you do need some context for all this data. 186 00:13:49,980 --> 00:13:56,960 In the case of like the page file, it's essentially a bunch of pages that were moved to disk, right? 187 00:13:57,060 --> 00:13:58,780 There's no real context there. 188 00:13:58,820 --> 00:14:01,240 You're missing some tables from memory. 189 00:14:01,360 --> 00:14:05,860 If you have the hibernation file and a matching page file, you may be able to reconcile those. 190 00:14:06,100 --> 00:14:10,460 But the page file, essentially, you just need to iterate over all these pages. 191 00:14:10,460 --> 00:14:11,760 And there are some tools to do that. 192 00:14:11,820 --> 00:14:12,640 I'm going to show you right now. 193 00:14:15,480 --> 00:14:17,960 So the next thing you can do is file carving, right? 194 00:14:18,040 --> 00:14:22,620 So other than just simple strings, and you should use, you know, both ASCII, Unicode. 195 00:14:22,800 --> 00:14:27,460 If you're dealing with non-English text, you might want to make sure to test your tools. 196 00:14:27,600 --> 00:14:31,820 Make sure that you're actually getting those other languages as well, 197 00:14:31,900 --> 00:14:33,460 so you don't miss important evidence. 198 00:14:34,400 --> 00:14:39,340 And then for file carving, we're essentially just looking for the headers for known file types. 199 00:14:39,340 --> 00:14:46,380 And we can find images, documents, you know, encrypted volumes sometimes. 200 00:14:46,800 --> 00:14:51,020 So there's a lot to be found, and there's known tools to do that. 201 00:14:51,100 --> 00:14:55,620 They have the databases of magic numbers to just look for the different file types. 202 00:14:55,820 --> 00:14:59,500 And you'd be amazed what you can get from these tools when you just scan 203 00:14:59,500 --> 00:15:04,660 and get out all kinds of documents and stuff people thought they deleted, but not so much. 204 00:15:07,640 --> 00:15:09,120 So the page file. 205 00:15:09,720 --> 00:15:10,860 Where is it? 206 00:15:11,520 --> 00:15:15,020 Usually, it's at the C drive, pagefile.sys, just like I showed earlier. 207 00:15:15,280 --> 00:15:19,240 But really, Windows can have up to 16 different page files, and they can be anywhere. 208 00:15:19,740 --> 00:15:22,040 So do not assume that it's on the C drive. 209 00:15:22,360 --> 00:15:25,000 Go, hit the registry, look for this key. 210 00:15:25,180 --> 00:15:29,380 Then you can get exactly where the page files are, how many there are, et cetera. 211 00:15:30,680 --> 00:15:32,140 So what's in a page file? 212 00:15:32,340 --> 00:15:38,500 I actually already said that it's a bunch of memory pages that were swapped to disk. 213 00:15:39,960 --> 00:15:41,680 So there's no particular order. 214 00:15:41,820 --> 00:15:43,980 There's no real context tying those together. 215 00:15:44,540 --> 00:15:49,900 But there is a tool called PageBrute, and I have, like, the GitHub link on here. 216 00:15:51,000 --> 00:15:55,380 Essentially, that can run the Yara scan on each page separately. 217 00:15:55,620 --> 00:16:01,080 So you can use your entire Yara arsenal to scan against that entire page file, look for hits. 218 00:16:01,360 --> 00:16:03,760 You can find fragments of malware. 219 00:16:03,880 --> 00:16:05,940 You can find IOCs, et cetera. 220 00:16:09,340 --> 00:16:12,280 The swap file, that's actually a less common one. 221 00:16:12,560 --> 00:16:13,440 It's newer. 222 00:16:13,600 --> 00:16:15,040 It's on Windows 8 and 10. 223 00:16:15,580 --> 00:16:21,720 And it's actually used by the newer apps that are on the Windows UI that are Metro-style apps. 224 00:16:22,620 --> 00:16:24,780 It's a separate swap space for those. 225 00:16:25,040 --> 00:16:33,620 So if you're looking into any kind of activity used by those apps, you kind of have it separately in a dedicated file. 226 00:16:33,860 --> 00:16:37,380 So that really helps you weed out all the other stuff you don't need. 227 00:16:37,380 --> 00:16:40,480 In those cases, it's really worth looking at. 228 00:16:40,600 --> 00:16:45,740 In general, if you're not sure what you're looking for and it's not very focused, I would probably have a look at that, 229 00:16:45,880 --> 00:16:48,920 see maybe there's some useful data in there. 230 00:16:51,360 --> 00:16:53,060 So crash dumps. 231 00:16:53,060 --> 00:16:58,340 You know when you run some kind of software and it crashes and it creates those nice dump files? 232 00:16:58,680 --> 00:17:02,480 That's actually data from memory from that process. 233 00:17:02,760 --> 00:17:05,780 So it really depends which process crashed. 234 00:17:05,840 --> 00:17:07,000 So if it's a browser. 235 00:17:07,380 --> 00:17:09,440 You might have some data from the cache. 236 00:17:09,680 --> 00:17:13,220 You might have some information on pages that were open at the time. 237 00:17:13,280 --> 00:17:18,000 So it can be very useful, especially if it's a miner that crashes the browser. 238 00:17:18,160 --> 00:17:20,640 You might have that miner still in memory, right? 239 00:17:21,620 --> 00:17:29,280 And if it's a password manager, I actually haven't done this research yet, but that could be a next step for any of you guys. 240 00:17:29,320 --> 00:17:36,660 If you want to try running a password manager, crashing it, looking at the memory dump, see if there is anything useful in there. 241 00:17:36,660 --> 00:17:41,720 Because if that's the case, then it's definitely worrisome. 242 00:17:43,300 --> 00:17:45,540 Definitely want to make sure those are not in there, right? 243 00:17:47,460 --> 00:17:50,760 So now we're going to move to talk about hibernation. 244 00:17:52,220 --> 00:17:57,240 So the hibernation mechanism in Windows, everybody knows when you close kind of your laptop, 245 00:17:57,360 --> 00:18:04,880 you can either suspend it, kind of keep it in low memory, low power mode, or you can entirely take the memory, 246 00:18:05,080 --> 00:18:06,360 move it to disk. 247 00:18:06,660 --> 00:18:07,920 Save it as a hibernation file. 248 00:18:09,620 --> 00:18:11,580 And then it does not consume any power, right? 249 00:18:11,620 --> 00:18:12,620 It's essentially turned off. 250 00:18:14,220 --> 00:18:19,220 So Windows will actually mark the page file. 251 00:18:19,320 --> 00:18:24,120 If it becomes corrupt, it will change the magic number at the beginning. 252 00:18:27,800 --> 00:18:36,200 Yeah, so when you get a hibernation file, you can take a look at that magic number and see the current state of that hiber file. 253 00:18:36,900 --> 00:18:41,780 When you get the hibernation file, you want to convert it to a format that's usable by volatility. 254 00:18:42,120 --> 00:18:49,980 And then you can actually use all those cool plug-ins that I showed you earlier on that resulting raw image file, right? 255 00:18:50,280 --> 00:18:57,780 So the image copy plug-in for volatility, you run that once you get a raw memory image out of that, 256 00:18:57,820 --> 00:18:59,140 and then you can use that from now on. 257 00:18:59,260 --> 00:19:05,080 You can also operate directly on the hibernation file, but it will need to do decompression every time. 258 00:19:05,100 --> 00:19:06,060 That's kind of a waste. 259 00:19:06,060 --> 00:19:07,840 So just do that once. 260 00:19:08,100 --> 00:19:09,940 Work on the raw memory file from then on. 261 00:19:10,860 --> 00:19:16,620 There's also a tool from Kome from MathSwish, Hybrid2Bin. 262 00:19:17,460 --> 00:19:24,380 So he's one of the first people to do research on this whole hibernation file forensics and analysis. 263 00:19:24,920 --> 00:19:27,080 And he wrote some very useful tools around that. 264 00:19:27,160 --> 00:19:29,360 So you might want to check out his website as well if you're interested. 265 00:19:31,740 --> 00:19:33,040 So some caveats. 266 00:19:33,580 --> 00:19:36,040 In certain cases, the hibernation file, 267 00:19:36,060 --> 00:19:38,860 will be zeroed by Windows, especially in later versions. 268 00:19:39,660 --> 00:19:44,880 Volatility has some brute forcing kind of handlers to work around that. 269 00:19:45,520 --> 00:19:50,200 If you want to know more about that part, I recommend The Art of Memory Forensics. 270 00:19:50,260 --> 00:19:53,960 It's a very cool book, very comprehensive if you want to get more into that. 271 00:19:54,920 --> 00:19:57,480 And also getting the profile. 272 00:19:57,860 --> 00:20:00,860 So volatility does need to know the OS it's analyzing. 273 00:20:01,080 --> 00:20:03,400 So it needs to know the profile of the OS. 274 00:20:03,400 --> 00:20:09,040 So if you have an offline drive and you do not have enough information around the case, 275 00:20:09,240 --> 00:20:13,620 you might need to go into the registry and pull that out so you know which profile to use. 276 00:20:13,740 --> 00:20:14,660 And then you can go from there. 277 00:20:16,500 --> 00:20:24,780 Another caveat about the hibernation file is that before the Windows system hibernates, 278 00:20:24,860 --> 00:20:27,560 it will actually close all the network connections. 279 00:20:28,900 --> 00:20:33,360 So you can still scan for resident socket. 280 00:20:33,360 --> 00:20:36,000 It's in memory of connections that were closed, 281 00:20:36,180 --> 00:20:38,760 but you won't see any connections still open. 282 00:20:38,980 --> 00:20:42,400 So just keep that in mind when you're analyzing hibernation files. 283 00:20:42,780 --> 00:20:47,060 And that's why it's also important to know when you get a raw image of memory, 284 00:20:47,320 --> 00:20:48,960 you should ask where did this come from. 285 00:20:49,080 --> 00:20:50,560 Is it from like a hibernation file? 286 00:20:50,800 --> 00:20:52,000 Is it directly from a box? 287 00:20:52,200 --> 00:20:53,860 You might be able to figure that out yourself, 288 00:20:54,040 --> 00:20:55,140 but it can just save you time. 289 00:20:55,200 --> 00:20:56,560 So it depends on the context. 290 00:20:57,640 --> 00:21:01,660 And obviously, if malware is hooking that functionality, 291 00:21:01,660 --> 00:21:04,440 it can actually realize that, 292 00:21:04,500 --> 00:21:06,420 oh no, the system is going into hibernation. 293 00:21:06,720 --> 00:21:10,700 I might want to shut down and clean everything up before that happens, right? 294 00:21:11,220 --> 00:21:16,340 So in those cases, you might not see malware inside of the hibernation file. 295 00:21:16,480 --> 00:21:19,160 So that's not easy to do, but it's technically possible, 296 00:21:19,380 --> 00:21:21,020 because the malware controls the OS. 297 00:21:21,280 --> 00:21:22,660 It can see that as well. 298 00:21:23,420 --> 00:21:25,460 So that's important to keep in mind. 299 00:21:27,440 --> 00:21:31,640 So the last thing I wanted to mention, 300 00:21:31,660 --> 00:21:33,980 is the volume shadow copies. 301 00:21:34,480 --> 00:21:39,020 So have any of you ever analyzed a piece of malware 302 00:21:39,020 --> 00:21:43,040 and seen VSS admin in there as a string? 303 00:21:43,340 --> 00:21:47,680 So in recent years, that's becoming increasingly popular 304 00:21:47,680 --> 00:21:51,140 because of ransomware trying to clear those volume shadow copies 305 00:21:51,140 --> 00:21:52,760 so that you can recover your files. 306 00:21:53,320 --> 00:21:57,560 But in this case, I'm actually mentioning another useful part 307 00:21:57,560 --> 00:22:01,200 of volume shadow copies that's useful for defenders. 308 00:22:01,900 --> 00:22:06,780 The volume shadow copies will include previous versions of those files. 309 00:22:07,120 --> 00:22:09,880 So even if some crash dumps were deleted, 310 00:22:10,160 --> 00:22:14,280 if it's a server, volume shadow copies will be turned on by default. 311 00:22:14,820 --> 00:22:19,260 So you will have multiple versions of the hibernation file to work with. 312 00:22:19,360 --> 00:22:22,380 You can actually diff those, and you can find changes, 313 00:22:22,440 --> 00:22:25,560 you can find processes that have been open the whole time, right? 314 00:22:26,360 --> 00:22:31,160 You can do a timeline of that, right? 315 00:22:31,160 --> 00:22:33,500 So you can take all of those different hibernation files, 316 00:22:33,740 --> 00:22:38,320 do a diff on your findings, throw all of those into plazo, log to timeline. 317 00:22:38,620 --> 00:22:41,420 You can have a huge amount of data to work with. 318 00:22:41,700 --> 00:22:44,240 So just keep in mind those volume shadow copies. 319 00:22:44,380 --> 00:22:46,140 You can find very useful stuff on there. 320 00:22:46,160 --> 00:22:47,780 Always remember to look for those. 321 00:22:48,480 --> 00:22:50,080 And when you do that offline, 322 00:22:50,460 --> 00:22:53,560 SIFT workstation has a very useful tool to do that. 323 00:22:54,340 --> 00:22:57,540 You can just mount any of those volume shadow copies, 324 00:22:57,720 --> 00:22:59,940 get the data out, and you're pretty much done. 325 00:23:05,860 --> 00:23:11,120 Okay, so I actually ran through that a lot faster than I thought. 326 00:23:12,920 --> 00:23:17,800 Are there any questions, any follow-ups you want to share? 327 00:23:17,880 --> 00:23:19,820 Have you done any of this before yourself? 328 00:23:20,920 --> 00:23:22,500 I see a question back there. 329 00:23:26,120 --> 00:23:26,680 Sorry? 330 00:23:32,260 --> 00:23:33,280 Yes, it does. 331 00:23:33,780 --> 00:23:34,220 Yes. 332 00:23:36,620 --> 00:23:37,060 Awesome. 333 00:23:38,260 --> 00:23:39,080 Yeah, go ahead. 334 00:23:39,400 --> 00:23:40,440 Any thoughts on 335 00:23:41,160 --> 00:23:43,320 figuring or forcing the hibernation mode 336 00:23:43,320 --> 00:23:46,740 to constantly drop the hibernation file 337 00:23:46,740 --> 00:23:48,300 as they click, you know, memory-friendly? 338 00:23:48,860 --> 00:23:49,300 Absolutely. 339 00:23:49,540 --> 00:23:50,920 Yeah, you can definitely do that. 340 00:23:51,000 --> 00:23:53,680 You can turn on your PowerCFG slash H, 341 00:23:53,740 --> 00:23:54,480 you know, you turn it on, 342 00:23:54,980 --> 00:23:56,040 and then you do a shutdown, 343 00:23:56,720 --> 00:23:58,220 and, yeah, absolutely. 344 00:23:58,340 --> 00:23:59,280 So that's a very good idea. 345 00:24:01,160 --> 00:24:02,020 If you want to run commands on it, 346 00:24:02,420 --> 00:24:03,240 you can do that, 347 00:24:03,320 --> 00:24:04,580 drop the hibernation file, 348 00:24:04,800 --> 00:24:05,900 and get it later. 349 00:24:06,080 --> 00:24:07,420 Just grab the disk and go, right? 350 00:24:08,360 --> 00:24:09,400 Yeah, so thanks for that. 351 00:24:13,780 --> 00:24:14,480 Okay, great. 352 00:24:14,620 --> 00:24:16,100 So thanks, everyone, for coming, 353 00:24:16,220 --> 00:24:18,340 and have a great rest of DEF CON.