1 00:00:00,000 --> 00:00:09,120 Next up, we have Mark Mager on Stop and Step Away from the Data, Rapid Anomaly Detection, via Random Note File Classification. 2 00:00:09,500 --> 00:00:13,600 We'd like to thank our sponsors, Endgame, Silance, Tinder, and Sophos. 3 00:00:13,860 --> 00:00:17,600 And reminder, if you could, please sit down in the seats. 4 00:00:17,620 --> 00:00:19,280 We don't want to have a fire code violation. 5 00:00:19,720 --> 00:00:21,080 With that, enjoy the talk. 6 00:00:27,740 --> 00:00:28,360 All right. 7 00:00:28,380 --> 00:00:29,080 Morning, everybody. 8 00:00:30,460 --> 00:00:33,260 So just getting things a little bit about me. 9 00:00:33,340 --> 00:00:39,680 I'm not a data scientist, so take whatever I say up here on stage with a very big grain of salt, 10 00:00:39,760 --> 00:00:44,720 and please feel to ridicule and embarrass me after the talk about the things that I get wrong. 11 00:00:45,560 --> 00:00:46,920 But anyways, a little bit about me. 12 00:00:46,960 --> 00:00:51,120 I'm a senior malware researcher at Endgame, typically do reverse engineering and sensor development. 13 00:00:51,480 --> 00:00:57,200 And the past two and a half years, pretty much since I've been at Endgame, I've been doing ransomware protection research. 14 00:00:59,240 --> 00:00:59,960 Just again. 15 00:01:00,000 --> 00:01:10,500 To the agenda, I'm going to provide a brief overview of ransomware, what your current detection methodology looks like, ransom notes. 16 00:01:10,900 --> 00:01:17,340 And then I'm going to delve into some exploratory research about the detection research that I did, 17 00:01:17,880 --> 00:01:24,680 and then discuss in depth the proof of concept framework that I came up with, and then wrap things up in conclusion. 18 00:01:24,800 --> 00:01:26,240 Hopefully, I have a little bit of time for questions. 19 00:01:27,520 --> 00:01:29,980 So if you don't know about ransomware... 20 00:01:30,000 --> 00:01:36,460 Ransomware, basically, it's a software that's written to deny users access to data on their host. 21 00:01:37,220 --> 00:01:43,200 The most typical approach is through encrypting individual files on a file system. 22 00:01:43,600 --> 00:01:48,000 And the file extensions are what's going to be targeted. 23 00:01:49,540 --> 00:01:57,480 So think of high-value documents like PDFs, text files, Word document, Excel spreadsheets, things of that nature. 24 00:01:58,200 --> 00:01:59,840 And so there's... 25 00:02:00,000 --> 00:02:08,120 There's two typical types of output from ransomware, the encrypted files that I was just alluding to, and the actual ransom notes. 26 00:02:09,800 --> 00:02:14,960 So detection methodology can be broken down pretty simply into two areas right now. 27 00:02:15,400 --> 00:02:23,420 You have static detections, which are either going to be signature-based, signature or heuristics-based, or machine-learning-based. 28 00:02:24,100 --> 00:02:29,300 The main benefit to this approach is that all data is preserved. 29 00:02:30,000 --> 00:02:31,300 If the detection is successful. 30 00:02:31,720 --> 00:02:41,640 But the drawback is that you essentially have one chance to detect whether a binary is ransomware or malware or not. 31 00:02:41,960 --> 00:02:46,300 And if we miss that, then all data is going to be compromised on the host. 32 00:02:47,320 --> 00:02:53,800 And for dynamic detections, basically, the way those work is it's a process that's going to be running in the background. 33 00:02:55,460 --> 00:02:59,460 That's going to monitor for any sort of anomalous behavior on the host. 34 00:03:00,260 --> 00:03:03,500 There can be a focus on detecting encrypted files. 35 00:03:04,020 --> 00:03:14,800 In certain cases, some approaches leverage canary files, which are files that are written to disk and, you know, kind of spread out in different locations. 36 00:03:14,940 --> 00:03:19,820 And if they're modified in particular ways, then that can be a trigger for an alert. 37 00:03:20,340 --> 00:03:28,840 So the main benefit for dynamic detections is that, you know, hypothetically, as a process is executing, 38 00:03:29,100 --> 00:03:29,980 there will always be a trigger for an alert. 39 00:03:30,000 --> 00:03:32,460 There will always be an ongoing chance that it will be detected. 40 00:03:32,660 --> 00:03:38,220 So it's not just there's one initial chance to detect and then, you know, your host is after that. 41 00:03:39,060 --> 00:03:42,480 But, you know, so should still be able to detect it later on. 42 00:03:42,820 --> 00:03:57,160 The drawback to dynamic approaches is that essentially you're sacrificing a large amount of files in order to determine whether or not there's ransomware executing on the host. 43 00:03:58,480 --> 00:04:03,400 Maybe in certain cases, it's easier to detect the anomalous behavior. 44 00:04:03,820 --> 00:04:08,640 In some cases, it might, you know, either be impossible or take a very long time. 45 00:04:10,200 --> 00:04:14,040 So how can we improve what the current saving art is right now? 46 00:04:14,780 --> 00:04:17,640 Probably the best approach is to combine 47 00:04:18,460 --> 00:04:20,680 benefits of static and dynamic detections. 48 00:04:20,920 --> 00:04:25,900 In the ideal case, yes, you would detect everything with machine learning immediately. 49 00:04:26,080 --> 00:04:27,140 Nothing would ever, you know, be able to detect anything. 50 00:04:27,140 --> 00:04:28,060 You would never execute on the host. 51 00:04:28,860 --> 00:04:30,480 But that's not always the case. 52 00:04:30,640 --> 00:04:32,380 You know, there is definitely false negatives. 53 00:04:32,960 --> 00:04:38,200 So you need a robust dynamic detection to serve as a fallback. 54 00:04:38,400 --> 00:04:46,740 So leveraging a layered security approach is probably, you know, the most recommended way to make sure you're covered for ransomware. 55 00:04:48,160 --> 00:04:54,880 Optimizing your machine learning models to specifically classify ransomware as opposed to just malware specifically. 56 00:04:55,760 --> 00:04:57,120 That can prove very beneficial. 57 00:04:57,140 --> 00:04:58,340 For this problem. 58 00:04:58,920 --> 00:05:14,360 And then to go back to dynamic detections, perhaps there might be a way to boost the time or reduce the amount of time that's required for detecting anomalous behavior. 59 00:05:16,980 --> 00:05:18,920 So getting into ransom notes. 60 00:05:19,780 --> 00:05:21,520 A little bit of background on this. 61 00:05:22,120 --> 00:05:25,300 Since I've been doing ransomware research for about two years or so, 62 00:05:25,340 --> 00:05:27,120 I've executed indebted ransomware. 63 00:05:27,140 --> 00:05:33,440 I've designated, you know, probably almost thousands of files manually in a virtualized environment. 64 00:05:33,780 --> 00:05:36,960 And kind of studied how the output typically looks. 65 00:05:37,260 --> 00:05:49,220 And then, you know, as sort of an aside, I was seeing ransom notes being written to disk in multiple ways, multiple directories, multiple formats. 66 00:05:49,520 --> 00:05:54,880 So what kind of got the gears turning for research that I'm presenting today is that 67 00:05:54,880 --> 00:05:59,940 I started kind of seeing a pattern in how the ransom notes looked. 68 00:06:00,180 --> 00:06:05,380 And so I wanted to explore that to see if there was a way that we could kind of classify those. 69 00:06:05,560 --> 00:06:12,680 And see if there was something there that kind of unites all of them and makes them easy to detect using AI. 70 00:06:14,660 --> 00:06:16,300 So just to go back a little bit. 71 00:06:16,360 --> 00:06:16,880 Ransom notes. 72 00:06:17,680 --> 00:06:20,060 Files that are written to solicit a ransom payment. 73 00:06:21,280 --> 00:06:23,260 They come across in multiple file types. 74 00:06:23,260 --> 00:06:27,820 The most typical format is TXT files, plain text files. 75 00:06:28,260 --> 00:06:34,280 But you also see ones that are in more formatted text formats such as HTML, RTF. 76 00:06:35,820 --> 00:06:41,200 And there's also images or even like GUI based like little .NET programs. 77 00:06:42,960 --> 00:06:45,860 Ransom notes are going to be one of the first files that are written to disk. 78 00:06:46,120 --> 00:06:48,840 And sometimes they're even written to every directory. 79 00:06:48,960 --> 00:06:53,240 Essentially, the adversary is trying to be as noisy as possible. 80 00:06:53,260 --> 00:06:55,500 In the hopes that they frustrate the users enough. 81 00:06:55,600 --> 00:07:00,020 And get the point across that their data has been totally compromised. 82 00:07:00,180 --> 00:07:03,380 And they have to provide the ransom to getting their data back. 83 00:07:05,080 --> 00:07:10,840 So we'll go back through here and look at a few ransom notes to kind of get a general idea of what I'm talking about. 84 00:07:11,580 --> 00:07:13,600 So this one is from CryptoLocker. 85 00:07:13,720 --> 00:07:17,940 And they kind of lead off with just saying your files are encrypted. 86 00:07:18,620 --> 00:07:23,240 And then they talk about you don't have access to your data. 87 00:07:23,260 --> 00:07:23,980 This is a description piece. 88 00:07:24,100 --> 00:07:25,300 So you can't recover your files. 89 00:07:26,660 --> 00:07:28,260 They want you to email them. 90 00:07:28,460 --> 00:07:36,680 And they're providing a specific time window for how long the ransom will be valid essentially. 91 00:07:37,080 --> 00:07:41,380 And then they even get into talking about the AES encryption that they're hypothetically using. 92 00:07:42,980 --> 00:07:44,460 Going on to the next sample. 93 00:07:44,580 --> 00:07:46,940 It pretty much starts out with the exact same way. 94 00:07:47,300 --> 00:07:48,620 All your files have been encrypted. 95 00:07:49,080 --> 00:07:52,520 And then they say something similar about all your documents are encrypted. 96 00:07:53,260 --> 00:07:53,960 Can't recover. 97 00:07:54,160 --> 00:07:59,220 Please pay us .01 bitcoin to a specific wallet ID. 98 00:07:59,840 --> 00:08:01,780 And then they also provide email address. 99 00:08:03,100 --> 00:08:07,800 And finally, here's an actual image based ransom note. 100 00:08:07,940 --> 00:08:12,280 And if you'll pay particular attention, they were requesting 100 bitcoin. 101 00:08:12,380 --> 00:08:16,000 Which is approximately $750,000 right now. 102 00:08:16,140 --> 00:08:20,220 So not exactly sure how successful they were with this ransomware campaign. 103 00:08:20,600 --> 00:08:22,900 But they were at least pretty pricey. 104 00:08:24,180 --> 00:08:29,740 So as we saw from even just looking at three very disparate samples of ransom notes. 105 00:08:29,900 --> 00:08:32,120 You can kind of see a template kind of form. 106 00:08:32,660 --> 00:08:36,260 They typically lead off with saying something about your files have been encrypted. 107 00:08:37,540 --> 00:08:39,680 Sometimes they provide a family name. 108 00:08:39,900 --> 00:08:49,320 And then they'll sometimes get into talking about the actual encryption that was implemented as part of the ransomware. 109 00:08:50,480 --> 00:08:52,500 They get a point across that. 110 00:08:52,500 --> 00:08:57,040 That files can't be recovered without a decrypter that they'll provide. 111 00:08:57,460 --> 00:09:01,520 Only if the ransom is provided. 112 00:09:02,180 --> 00:09:05,200 And then potentially provide email address. 113 00:09:05,320 --> 00:09:11,260 And then a time window for when their ransom essentially will be invalid. 114 00:09:13,680 --> 00:09:18,720 So as I previously said in my intro, I'm not a data scientist. 115 00:09:18,800 --> 00:09:22,320 So exploratory research for me in this case. 116 00:09:22,320 --> 00:09:27,220 Was just developing a better familiarity with data science concepts. 117 00:09:27,640 --> 00:09:28,980 And different tools I'd use. 118 00:09:29,700 --> 00:09:31,780 And then moving on from there. 119 00:09:31,980 --> 00:09:36,680 I need to collect a big enough corpus of ransom notes. 120 00:09:37,400 --> 00:09:39,520 In order to do some training. 121 00:09:40,120 --> 00:09:41,720 And on the flip side of that. 122 00:09:41,860 --> 00:09:46,560 We need to put together a nice base representative benign data set. 123 00:09:47,320 --> 00:09:48,740 To go with the ransom notes. 124 00:09:48,740 --> 00:09:53,300 And the overarching goal of the exploratory research. 125 00:09:53,360 --> 00:09:57,960 Is to determine if this approach can possibly work for classification. 126 00:10:00,340 --> 00:10:02,100 So tools I'm using here. 127 00:10:02,320 --> 00:10:04,240 Pretty much just use Anaconda for everything. 128 00:10:04,600 --> 00:10:06,240 Which came bundled with Python 3. 129 00:10:07,040 --> 00:10:07,940 Jupyter Notebook. 130 00:10:08,100 --> 00:10:10,140 And also use scikit-learn. 131 00:10:11,920 --> 00:10:14,240 So delving into the data sets a little bit. 132 00:10:14,460 --> 00:10:15,240 Benign data. 133 00:10:15,240 --> 00:10:18,100 I just ended up using the 20 news groups data set. 134 00:10:18,200 --> 00:10:19,680 Which probably most of you are familiar. 135 00:10:20,660 --> 00:10:23,660 That's a list of the actual 20 news groups that are part of that. 136 00:10:24,240 --> 00:10:25,720 And then for the ransom notes. 137 00:10:25,980 --> 00:10:31,040 It's definitely a little tougher to put together a large collection of ransom notes. 138 00:10:32,180 --> 00:10:37,480 Not every ransomware family writes them out to disk. 139 00:10:37,700 --> 00:10:40,560 So going through and kind of manually doing the research. 140 00:10:40,600 --> 00:10:43,560 And figuring out which families actually drop notes. 141 00:10:43,880 --> 00:10:45,220 Can be a little tedious. 142 00:10:45,240 --> 00:10:49,220 So a lot of this involved manually detonating ransomware samples. 143 00:10:49,380 --> 00:10:51,120 Over a period of years. 144 00:10:52,240 --> 00:10:53,780 Collecting the ransom notes. 145 00:10:54,600 --> 00:10:55,340 You know. 146 00:10:55,340 --> 00:10:56,280 Storing them off. 147 00:10:56,440 --> 00:10:58,740 And then kind of digging them out for this project. 148 00:10:59,360 --> 00:11:00,380 But also. 149 00:11:01,320 --> 00:11:02,760 Searching through blog posts. 150 00:11:03,280 --> 00:11:03,840 Twitter. 151 00:11:04,140 --> 00:11:05,820 And a lot of things like that. 152 00:11:05,960 --> 00:11:08,920 I was able to collect enough samples. 153 00:11:09,140 --> 00:11:10,920 To feel confident. 154 00:11:11,000 --> 00:11:12,320 I had something that was representative. 155 00:11:12,660 --> 00:11:13,860 Of ransomware in general. 156 00:11:16,700 --> 00:11:18,160 So the actual approach. 157 00:11:18,320 --> 00:11:19,140 That I was taking. 158 00:11:19,240 --> 00:11:20,380 For the explored herd research. 159 00:11:20,480 --> 00:11:22,820 Is we're just going to go with unlabeled data. 160 00:11:23,180 --> 00:11:25,340 We're going to take the 20 news groups data set. 161 00:11:25,760 --> 00:11:28,180 And then we'll combine that with the ransom notes. 162 00:11:28,360 --> 00:11:30,860 And so we'll take a clustering approach. 163 00:11:30,980 --> 00:11:31,740 Using kmeans. 164 00:11:33,060 --> 00:11:34,880 And set it to 21 clusters. 165 00:11:35,500 --> 00:11:37,000 And the way we write with that. 166 00:11:37,120 --> 00:11:39,040 Is we'll use the 20 news groups data set. 167 00:11:39,220 --> 00:11:40,120 And ransom notes. 168 00:11:40,240 --> 00:11:41,180 And we're going to hope that. 169 00:11:42,020 --> 00:11:43,160 With the 21 clusters. 170 00:11:43,160 --> 00:11:43,980 The way they kind of. 171 00:11:45,820 --> 00:11:46,520 Settle down. 172 00:11:47,820 --> 00:11:48,440 You know. 173 00:11:48,440 --> 00:11:49,760 That they'll be distinctly. 174 00:11:50,100 --> 00:11:51,980 Each of the news groups will be in their own cluster. 175 00:11:52,220 --> 00:11:54,500 And the ransom notes will stick together in their own cluster. 176 00:11:55,600 --> 00:11:56,400 In order to. 177 00:11:57,020 --> 00:11:58,560 Analyze the data a little closely. 178 00:11:58,800 --> 00:12:01,180 We'll take a look at the data. 179 00:12:01,240 --> 00:12:03,200 Using an account vectorizer. 180 00:12:03,380 --> 00:12:04,840 And a tfidf vectorizer. 181 00:12:07,300 --> 00:12:08,620 So getting started. 182 00:12:08,880 --> 00:12:10,760 Just to do some very basic. 183 00:12:10,840 --> 00:12:11,620 Data prep. 184 00:12:13,160 --> 00:12:13,600 For tokenization. 185 00:12:13,680 --> 00:12:15,580 We're just going to strip out newline characters. 186 00:12:16,380 --> 00:12:17,280 Convert to lowercase. 187 00:12:17,660 --> 00:12:18,600 Strip out null bytes. 188 00:12:19,320 --> 00:12:20,260 Just things like that. 189 00:12:20,320 --> 00:12:21,720 To just get the data starting to. 190 00:12:23,560 --> 00:12:24,800 Make a little bit more sense. 191 00:12:25,060 --> 00:12:26,480 And then when we do the actual tokenization. 192 00:12:27,000 --> 00:12:29,580 We're going to limit it to alphanumeric characters. 193 00:12:29,940 --> 00:12:30,340 Only. 194 00:12:30,740 --> 00:12:32,780 We're going to strip out any stop words. 195 00:12:32,840 --> 00:12:35,860 That are in the default spaCy stop words list. 196 00:12:36,460 --> 00:12:37,840 And we'll do limitization. 197 00:12:38,180 --> 00:12:39,280 So in a. 198 00:12:40,420 --> 00:12:42,160 Very quick example here. 199 00:12:43,160 --> 00:12:43,460 We can actually. 200 00:12:43,580 --> 00:12:44,520 Turn it into a crypt. 201 00:12:46,900 --> 00:12:48,340 So here's just a. 202 00:12:48,440 --> 00:12:50,800 Very quick overview of how. 203 00:12:51,800 --> 00:12:52,880 The tokenization. 204 00:12:53,340 --> 00:12:53,920 Worked. 205 00:12:54,320 --> 00:12:56,400 And for this. 206 00:12:56,720 --> 00:12:57,800 Example actually took. 207 00:12:58,100 --> 00:13:00,820 A very small blurb for a ransom note. 208 00:13:01,080 --> 00:13:02,180 And passed it in. 209 00:13:02,300 --> 00:13:04,640 And you can see how it actually breaks down. 210 00:13:05,440 --> 00:13:06,600 Two very. 211 00:13:07,480 --> 00:13:08,560 Very core. 212 00:13:08,820 --> 00:13:09,760 Set of words there. 213 00:13:09,920 --> 00:13:11,760 File encrypts and bitcoin gets a payment. 214 00:13:13,160 --> 00:13:13,340 Which is. 215 00:13:14,600 --> 00:13:16,200 Very descriptive of exactly. 216 00:13:16,260 --> 00:13:17,200 What they're going for. 217 00:13:18,200 --> 00:13:18,980 So now. 218 00:13:19,280 --> 00:13:21,140 Not sure how well you can see up there. 219 00:13:22,740 --> 00:13:25,340 Breaking down the most common features. 220 00:13:25,420 --> 00:13:26,480 That we're seeing in the. 221 00:13:27,400 --> 00:13:28,620 173 ransom notes. 222 00:13:29,020 --> 00:13:30,860 We see a lot of. 223 00:13:30,940 --> 00:13:32,180 The same sort of words. 224 00:13:32,360 --> 00:13:34,340 We see things describing. 225 00:13:35,260 --> 00:13:36,100 You know files. 226 00:13:36,400 --> 00:13:37,720 With data being encrypted. 227 00:13:39,000 --> 00:13:41,060 Bitcoin course encrypt decrypt. 228 00:13:41,700 --> 00:13:42,340 You know. 229 00:13:43,160 --> 00:13:44,020 Things along that sort of nature. 230 00:13:44,500 --> 00:13:46,500 Like even just looking through those words. 231 00:13:46,660 --> 00:13:47,700 You might be able to. 232 00:13:48,460 --> 00:13:50,320 Construct what the purpose of. 233 00:13:50,440 --> 00:13:51,460 A ransom is. 234 00:13:51,680 --> 00:13:53,000 Without having any sort of context. 235 00:13:53,980 --> 00:13:55,600 And then when we break it out to. 236 00:13:56,900 --> 00:13:57,380 Bigrams. 237 00:13:57,560 --> 00:13:58,880 Things make a little more sense. 238 00:13:59,420 --> 00:14:01,020 Because you're working with. 239 00:14:01,360 --> 00:14:02,120 Phrasing so. 240 00:14:03,440 --> 00:14:05,320 It's not just files in a vacuum. 241 00:14:05,460 --> 00:14:06,620 It's files being encrypted. 242 00:14:06,960 --> 00:14:08,020 Files being decrypted. 243 00:14:08,820 --> 00:14:09,780 Private keys. 244 00:14:13,160 --> 00:14:14,280 To give you a little bit of an idea. 245 00:14:14,400 --> 00:14:15,260 Of what the data looks like. 246 00:14:16,680 --> 00:14:17,700 Then when we apply. 247 00:14:18,200 --> 00:14:18,900 TFID VEF. 248 00:14:20,740 --> 00:14:22,200 Looks pretty similar to. 249 00:14:22,280 --> 00:14:24,380 What we're getting from the count vectorizer. 250 00:14:25,760 --> 00:14:26,340 So yeah. 251 00:14:26,380 --> 00:14:27,440 Just gives you another view. 252 00:14:27,540 --> 00:14:28,480 Of what the data looks like. 253 00:14:30,780 --> 00:14:31,220 Now. 254 00:14:32,080 --> 00:14:34,120 Not sure how well you can see this here. 255 00:14:34,320 --> 00:14:36,480 But essentially with the 21 clusters. 256 00:14:36,720 --> 00:14:38,900 They broke out. 257 00:14:39,360 --> 00:14:41,100 Like quite nicely for us actually. 258 00:14:41,380 --> 00:14:42,860 And in cluster 3. 259 00:14:43,620 --> 00:14:44,920 Despite the ransom notes. 260 00:14:45,020 --> 00:14:46,660 Only consisting of 173. 261 00:14:46,800 --> 00:14:47,340 Unique samples. 262 00:14:48,940 --> 00:14:50,600 Versus the 11,000. 263 00:14:51,520 --> 00:14:52,920 Messages that were in. 264 00:14:53,020 --> 00:14:54,420 The 20 news groups data set. 265 00:14:55,360 --> 00:14:56,360 The ransom notes. 266 00:14:56,460 --> 00:14:59,100 All clustered together extremely well. 267 00:15:00,220 --> 00:15:01,220 That cluster. 268 00:15:01,980 --> 00:15:03,200 I believe that's. 269 00:15:03,200 --> 00:15:03,900 The top 10 features. 270 00:15:04,060 --> 00:15:05,900 That are in that cluster. 271 00:15:06,280 --> 00:15:08,440 Matches extremely well with what we've just seen. 272 00:15:08,500 --> 00:15:09,500 In the previous two slides. 273 00:15:10,680 --> 00:15:12,540 And that actually is a. 274 00:15:13,240 --> 00:15:14,000 A good. 275 00:15:15,200 --> 00:15:17,280 Test for the data set. 276 00:15:17,680 --> 00:15:18,840 Because if you'll see. 277 00:15:18,900 --> 00:15:19,460 The top. 278 00:15:20,900 --> 00:15:23,160 Entry for the news group. 279 00:15:23,260 --> 00:15:24,840 In the image to the right. 280 00:15:25,020 --> 00:15:26,080 Is cy.crypt. 281 00:15:26,160 --> 00:15:27,020 Which is the. 282 00:15:29,860 --> 00:15:31,000 Encryption news group. 283 00:15:31,040 --> 00:15:31,620 At the time. 284 00:15:32,480 --> 00:15:33,000 But yeah. 285 00:15:33,060 --> 00:15:34,120 If you see cluster 6. 286 00:15:34,260 --> 00:15:35,400 It might be a little tough to tell. 287 00:15:35,840 --> 00:15:38,600 But you can get an idea. 288 00:15:38,640 --> 00:15:39,640 Of how old the data is. 289 00:15:43,160 --> 00:15:44,780 Like that was. 290 00:15:44,780 --> 00:15:46,400 Around the mid 90's or so. 291 00:15:46,620 --> 00:15:48,160 But either way. 292 00:15:49,380 --> 00:15:50,620 Distinguishing between. 293 00:15:50,800 --> 00:15:52,720 News group discussions around encryption. 294 00:15:53,740 --> 00:15:55,340 Versus ransom notes. 295 00:15:55,420 --> 00:15:56,700 That do discuss encryption. 296 00:15:56,880 --> 00:15:58,200 At a more high level. 297 00:15:58,840 --> 00:16:00,620 That's a good initial test. 298 00:16:00,840 --> 00:16:02,840 Of how strong the data correlates. 299 00:16:04,740 --> 00:16:06,600 And so delving into. 300 00:16:06,960 --> 00:16:07,600 How. 301 00:16:08,680 --> 00:16:10,420 How the cluster actually worked. 302 00:16:11,200 --> 00:16:12,860 We want to kind of get. 303 00:16:13,160 --> 00:16:13,440 Through the hood. 304 00:16:13,560 --> 00:16:15,440 And pass in some sample data. 305 00:16:15,600 --> 00:16:17,740 So I took another ransom note. 306 00:16:18,020 --> 00:16:20,800 And passed it into the k-means predictor. 307 00:16:21,200 --> 00:16:22,640 And if you break out. 308 00:16:22,800 --> 00:16:24,000 The results for that. 309 00:16:24,900 --> 00:16:25,860 Using the square root. 310 00:16:26,000 --> 00:16:26,880 Of the sum of the squares. 311 00:16:27,160 --> 00:16:28,480 We can calculate the distance. 312 00:16:29,820 --> 00:16:30,980 From the centroid. 313 00:16:32,380 --> 00:16:33,780 For each of the clusters. 314 00:16:34,440 --> 00:16:34,920 Here. 315 00:16:35,180 --> 00:16:37,160 So in our case. 316 00:16:37,320 --> 00:16:38,540 With that ransom note. 317 00:16:38,640 --> 00:16:39,820 It did end up in cluster 3. 318 00:16:43,160 --> 00:16:43,960 Which worked out very well for us. 319 00:16:44,940 --> 00:16:46,760 For a second example. 320 00:16:47,460 --> 00:16:48,720 We kind of used. 321 00:16:48,820 --> 00:16:50,520 Something that's more generically. 322 00:16:50,580 --> 00:16:51,840 Just talking about encryption. 323 00:16:52,300 --> 00:16:54,260 But not specifically a ransom note. 324 00:16:54,940 --> 00:16:55,960 In this case. 325 00:16:56,000 --> 00:16:57,140 It actually ended up. 326 00:16:58,400 --> 00:17:00,480 Being closer matched to. 327 00:17:01,480 --> 00:17:02,300 Cluster 4. 328 00:17:02,460 --> 00:17:04,480 Which is actually entries from. 329 00:17:04,840 --> 00:17:05,980 Computer dot graphics. 330 00:17:06,880 --> 00:17:07,160 So. 331 00:17:08,260 --> 00:17:09,820 What did we learn from doing our. 332 00:17:09,840 --> 00:17:12,220 Well as I mentioned before. 333 00:17:13,160 --> 00:17:13,660 All set of data. 334 00:17:13,800 --> 00:17:14,820 But the ransom notes. 335 00:17:14,920 --> 00:17:16,660 Do cluster together very well. 336 00:17:17,200 --> 00:17:18,240 The second sample. 337 00:17:18,980 --> 00:17:20,520 Demonstrated that there is nuance. 338 00:17:20,760 --> 00:17:22,240 In how the data was clustered together. 339 00:17:24,120 --> 00:17:25,780 And from all that. 340 00:17:25,880 --> 00:17:27,340 We learned that it appears. 341 00:17:27,460 --> 00:17:29,460 That the data is going to be appropriate. 342 00:17:29,560 --> 00:17:30,080 For classification. 343 00:17:30,440 --> 00:17:32,880 So we can actually go forward. 344 00:17:32,940 --> 00:17:33,840 With an actual proof of concept. 345 00:17:35,740 --> 00:17:37,100 So for a POC framework. 346 00:17:37,400 --> 00:17:38,320 We have a few requirements. 347 00:17:38,820 --> 00:17:39,740 First and foremost. 348 00:17:43,220 --> 00:17:44,380 We need to. 349 00:17:45,120 --> 00:17:46,760 Take the file paths that are. 350 00:17:46,860 --> 00:17:47,740 Being created. 351 00:17:47,980 --> 00:17:50,120 And pass them to a model that we develop. 352 00:17:52,480 --> 00:17:53,280 From there. 353 00:17:53,360 --> 00:17:55,560 We're going to read in the actual text data. 354 00:17:55,860 --> 00:17:57,560 From the file paths that have been created. 355 00:17:58,180 --> 00:17:59,380 We're going to read in the file contents. 356 00:17:59,660 --> 00:18:00,920 And then pass that along. 357 00:18:01,120 --> 00:18:02,460 To the classifier. 358 00:18:02,620 --> 00:18:04,280 To determine whether or not. 359 00:18:04,580 --> 00:18:06,480 The data consists of a ransom note. 360 00:18:07,000 --> 00:18:08,940 And then if it is a ransom note. 361 00:18:09,060 --> 00:18:10,600 We need a way to mitigate the process. 362 00:18:13,160 --> 00:18:15,100 So to reduce the problem space. 363 00:18:15,400 --> 00:18:16,180 For this. 364 00:18:16,980 --> 00:18:18,880 We're going to put up a few restrictions here. 365 00:18:19,040 --> 00:18:20,260 We're going to stick to English only. 366 00:18:21,240 --> 00:18:23,000 And .txt files only. 367 00:18:23,360 --> 00:18:24,180 As I mentioned. 368 00:18:24,300 --> 00:18:26,060 They're the most common ransom notes. 369 00:18:27,000 --> 00:18:28,400 But that doesn't cover. 370 00:18:28,720 --> 00:18:31,560 The entire world of ransom notes. 371 00:18:32,400 --> 00:18:33,020 But yeah. 372 00:18:33,280 --> 00:18:34,040 Formatted text. 373 00:18:34,320 --> 00:18:35,620 It's going to require parsing. 374 00:18:35,660 --> 00:18:36,480 And images. 375 00:18:36,680 --> 00:18:38,760 We'd have to use OCR to extract the data. 376 00:18:38,940 --> 00:18:39,280 And it's probably. 377 00:18:43,300 --> 00:18:45,500 At least for this research. 378 00:18:45,720 --> 00:18:47,820 I figured that was out of scope. 379 00:18:47,900 --> 00:18:48,740 For what I was trying to accomplish. 380 00:18:49,240 --> 00:18:49,900 And then. 381 00:18:50,480 --> 00:18:51,920 We're going to stick to files. 382 00:18:52,080 --> 00:18:54,300 That are only less than 20 kilobytes. 383 00:18:54,500 --> 00:18:55,700 The reasoning for this is. 384 00:18:55,740 --> 00:18:57,400 Ransom notes are generally pretty small. 385 00:18:58,400 --> 00:19:00,080 Kind of going back to the template. 386 00:19:00,120 --> 00:19:01,260 I was discussing earlier. 387 00:19:03,920 --> 00:19:05,480 They're not really trying to get across. 388 00:19:05,620 --> 00:19:06,400 Too much. 389 00:19:06,500 --> 00:19:07,780 They're very utilitarian. 390 00:19:07,880 --> 00:19:10,060 Just saying hey file's encrypted. 391 00:19:10,420 --> 00:19:11,400 Please send us a ransom. 392 00:19:14,420 --> 00:19:15,680 Reducing the problem space there. 393 00:19:15,820 --> 00:19:17,140 Keeping it to less than 20 kilobytes. 394 00:19:18,000 --> 00:19:19,380 Helps out with performance as well. 395 00:19:21,180 --> 00:19:22,940 So we can break down. 396 00:19:23,120 --> 00:19:25,040 The framework. 397 00:19:25,220 --> 00:19:27,640 Into a couple of components. 398 00:19:28,020 --> 00:19:28,700 And just two. 399 00:19:28,800 --> 00:19:30,080 Pretty distinct processes. 400 00:19:30,360 --> 00:19:32,100 So we'll have a file change event listener. 401 00:19:33,380 --> 00:19:35,320 And that's going to read in the events. 402 00:19:35,500 --> 00:19:36,820 And place it into a queue. 403 00:19:36,960 --> 00:19:38,100 For a second process. 404 00:19:38,200 --> 00:19:39,460 Which will do the text extraction. 405 00:19:40,000 --> 00:19:41,900 And the actual classification of notes. 406 00:19:43,160 --> 00:19:44,940 And then if we determine. 407 00:19:45,060 --> 00:19:46,020 That there's a ransom note. 408 00:19:46,680 --> 00:19:48,660 There will be a process mitigation handler. 409 00:19:49,720 --> 00:19:51,260 That will operate. 410 00:19:53,040 --> 00:19:55,220 So here's kind of a high level. 411 00:19:55,920 --> 00:19:56,880 Diagram of. 412 00:19:57,260 --> 00:19:59,160 How a typical sort of. 413 00:19:59,220 --> 00:20:00,540 Infection scenario would play out. 414 00:20:00,580 --> 00:20:01,900 With the framework on disk. 415 00:20:02,820 --> 00:20:04,320 So you'd have ransomware executing. 416 00:20:04,560 --> 00:20:06,840 They drop a ransom note to the Ruby C drive. 417 00:20:07,120 --> 00:20:08,980 The event listener is going to be. 418 00:20:09,980 --> 00:20:11,100 Polling for events. 419 00:20:11,180 --> 00:20:11,840 At that time. 420 00:20:13,160 --> 00:20:14,600 They'll see a file creation event. 421 00:20:14,940 --> 00:20:15,500 For the ransom note. 422 00:20:15,820 --> 00:20:18,460 And then it'll pass along that file path. 423 00:20:18,660 --> 00:20:20,580 To text extractor and classifier. 424 00:20:21,700 --> 00:20:23,060 Which will read in the contents. 425 00:20:23,260 --> 00:20:25,100 Of the ransom note. 426 00:20:25,320 --> 00:20:26,100 And then. 427 00:20:26,340 --> 00:20:27,980 Do the actual classification. 428 00:20:28,540 --> 00:20:29,620 Hopefully return yes. 429 00:20:30,000 --> 00:20:31,700 And then that will result in the. 430 00:20:31,780 --> 00:20:33,040 Ransomware process being suspended. 431 00:20:35,620 --> 00:20:37,360 So for the POC framework. 432 00:20:37,620 --> 00:20:38,820 We wanted to build out. 433 00:20:38,860 --> 00:20:40,800 A more representative data set. 434 00:20:41,700 --> 00:20:42,500 So for the. 435 00:20:43,160 --> 00:20:43,180 Ransomware side. 436 00:20:43,460 --> 00:20:46,220 We'll still stick with the 20 news groups. 437 00:20:46,360 --> 00:20:48,500 But we'll take a smaller slice of it. 438 00:20:48,580 --> 00:20:50,760 Instead of the overarching 11,000. 439 00:20:51,540 --> 00:20:53,020 And then to supplement that. 440 00:20:53,260 --> 00:20:53,700 We'll. 441 00:20:55,640 --> 00:20:56,780 Leverage some of the. 442 00:20:56,840 --> 00:20:57,620 Windows text files. 443 00:20:57,740 --> 00:20:59,180 That I was kind of able to scoop up. 444 00:20:59,460 --> 00:21:01,260 So typically talking about log files. 445 00:21:01,480 --> 00:21:01,920 Reading files. 446 00:21:03,680 --> 00:21:05,300 Any sort of like installer logs. 447 00:21:05,860 --> 00:21:06,880 Things along those lines. 448 00:21:07,620 --> 00:21:08,900 And then for the ransom notes. 449 00:21:08,900 --> 00:21:11,000 Did my best to collect as many. 450 00:21:11,740 --> 00:21:13,180 Many more ransom notes. 451 00:21:13,280 --> 00:21:14,120 As I could. 452 00:21:14,820 --> 00:21:16,700 Ended up finding a bunch on pastebin. 453 00:21:16,820 --> 00:21:17,640 And a few other sources. 454 00:21:18,060 --> 00:21:19,220 So that was a great source. 455 00:21:21,220 --> 00:21:22,260 But still. 456 00:21:22,460 --> 00:21:24,360 We're left with only 350. 457 00:21:24,720 --> 00:21:26,040 Ransom notes compared to. 458 00:21:26,260 --> 00:21:27,460 11,000. 459 00:21:29,120 --> 00:21:30,160 Benign messages. 460 00:21:30,700 --> 00:21:31,180 So. 461 00:21:31,880 --> 00:21:33,540 For the classification approach here. 462 00:21:33,620 --> 00:21:36,620 We want to address a data set imbalance. 463 00:21:37,120 --> 00:21:37,940 Which is very. 464 00:21:38,900 --> 00:21:39,700 Quite large. 465 00:21:40,460 --> 00:21:42,180 So we can use SMOTE. 466 00:21:42,280 --> 00:21:44,220 To generate synthetic data for us. 467 00:21:44,400 --> 00:21:46,880 And see hopefully if that can bridge the gap for us. 468 00:21:46,940 --> 00:21:47,640 And make up for that. 469 00:21:49,340 --> 00:21:50,200 Pretty big imbalance. 470 00:21:52,500 --> 00:21:54,220 So the approach for the classifier here. 471 00:21:54,660 --> 00:21:55,460 We're going to use. 472 00:21:55,920 --> 00:21:58,500 Do feature selection via TFIDF. 473 00:21:59,260 --> 00:22:00,660 And essentially what we have. 474 00:22:00,700 --> 00:22:00,980 Is a. 475 00:22:02,440 --> 00:22:03,460 Supervised learning problem. 476 00:22:03,800 --> 00:22:05,540 We're going to label the data this time. 477 00:22:06,620 --> 00:22:07,880 As either benign. 478 00:22:08,900 --> 00:22:08,980 Or a ransom note. 479 00:22:09,740 --> 00:22:11,360 And then yeah. 480 00:22:11,640 --> 00:22:12,820 We're breaking down. 481 00:22:13,680 --> 00:22:15,900 All of this into a binary classification problem. 482 00:22:16,820 --> 00:22:18,980 Does the text consist of a ransom note. 483 00:22:19,120 --> 00:22:20,060 Or is it benign data. 484 00:22:20,580 --> 00:22:22,200 And for us. 485 00:22:22,240 --> 00:22:23,880 A naive based classifier. 486 00:22:24,540 --> 00:22:25,760 Is simple and straightforward. 487 00:22:26,100 --> 00:22:27,900 And that's the approach that we. 488 00:22:28,500 --> 00:22:29,180 You know. 489 00:22:29,440 --> 00:22:30,820 Went for immediately. 490 00:22:31,580 --> 00:22:33,300 And we'll delve into the. 491 00:22:34,100 --> 00:22:35,500 The results that we ended up getting. 492 00:22:37,020 --> 00:22:37,580 So. 493 00:22:38,900 --> 00:22:40,400 High level overview of. 494 00:22:40,740 --> 00:22:42,340 Data processing pipeline here. 495 00:22:42,840 --> 00:22:43,940 We start with our. 496 00:22:44,440 --> 00:22:45,420 Label data set. 497 00:22:45,760 --> 00:22:48,900 And we pass that along to the pre-tokenization. 498 00:22:49,160 --> 00:22:50,260 Where we're stripping out characters. 499 00:22:50,400 --> 00:22:52,220 Converting lowercase things along those lines. 500 00:22:52,740 --> 00:22:54,280 We do the actual tokenization. 501 00:22:54,620 --> 00:22:55,040 And then we. 502 00:22:56,100 --> 00:22:59,140 Get into sanitizing the data a little bit. 503 00:22:59,200 --> 00:23:01,020 By stripping out stop words. 504 00:23:01,400 --> 00:23:03,040 Anything that's not alphanumeric. 505 00:23:03,200 --> 00:23:05,160 And then do lemmatization as I mentioned before. 506 00:23:05,580 --> 00:23:06,360 We pass that along. 507 00:23:06,620 --> 00:23:08,300 To the TFIDF vectorizer. 508 00:23:08,900 --> 00:23:09,640 To vectorize the data. 509 00:23:10,520 --> 00:23:13,320 We'll use SMOTE to balance out the data sets. 510 00:23:13,540 --> 00:23:15,180 And then we'll do the actual training. 511 00:23:15,300 --> 00:23:16,480 With our naive based classifier. 512 00:23:18,400 --> 00:23:19,640 So for testing here. 513 00:23:19,820 --> 00:23:21,000 We're splitting the. 514 00:23:22,300 --> 00:23:23,060 The data. 515 00:23:23,200 --> 00:23:25,380 Into a 80-20 split. 516 00:23:25,680 --> 00:23:27,700 80% of the data will be used for training. 517 00:23:27,860 --> 00:23:30,700 While 20% will be used for testing. 518 00:23:30,900 --> 00:23:32,140 We used train test split. 519 00:23:32,460 --> 00:23:33,580 From scikit-learn. 520 00:23:33,700 --> 00:23:35,380 To handle that. 521 00:23:35,880 --> 00:23:38,880 And just to get into a brief overview. 522 00:23:38,900 --> 00:23:39,920 Of the terminology involved. 523 00:23:41,540 --> 00:23:43,080 Probably extremely common. 524 00:23:43,860 --> 00:23:45,460 And known to most of you guys. 525 00:23:45,660 --> 00:23:47,280 But the accuracy score. 526 00:23:47,500 --> 00:23:48,600 That I'm going to be referring to here. 527 00:23:48,760 --> 00:23:51,380 Is the actual accuracy classification score. 528 00:23:51,700 --> 00:23:53,040 F1 score is going to be. 529 00:23:53,120 --> 00:23:55,040 Average of the precision and recall. 530 00:23:56,380 --> 00:23:57,060 Confusion matrix. 531 00:23:57,520 --> 00:23:59,660 Just a great way to represent. 532 00:24:01,500 --> 00:24:03,760 True and false positive. 533 00:24:03,860 --> 00:24:04,540 And negative rates. 534 00:24:05,920 --> 00:24:07,740 And for our cross validation. 535 00:24:07,980 --> 00:24:08,740 We're going to use. 536 00:24:08,860 --> 00:24:08,880 We're going to use. 537 00:24:08,900 --> 00:24:10,320 A Monte Carlo approach. 538 00:24:11,620 --> 00:24:12,800 Essentially where we're running. 539 00:24:12,880 --> 00:24:13,920 Multiple runs. 540 00:24:15,980 --> 00:24:16,620 You know. 541 00:24:16,660 --> 00:24:18,680 Through building. 542 00:24:19,100 --> 00:24:20,540 And let's see. 543 00:24:20,860 --> 00:24:22,400 Training and test data sets. 544 00:24:22,920 --> 00:24:23,680 Each sign. 545 00:24:24,140 --> 00:24:26,280 In this case. 546 00:24:26,400 --> 00:24:26,900 We're just. 547 00:24:28,740 --> 00:24:30,260 We're testing out the model's ability. 548 00:24:30,460 --> 00:24:31,480 To predict the data. 549 00:24:33,340 --> 00:24:34,260 Testing to see. 550 00:24:34,320 --> 00:24:36,400 How this approach is going to be flexible. 551 00:24:36,600 --> 00:24:37,620 And not try to. 552 00:24:38,900 --> 00:24:40,380 Overfit to the data that we're passing. 553 00:24:41,620 --> 00:24:42,720 So for our single. 554 00:24:43,200 --> 00:24:44,660 One single test here. 555 00:24:44,740 --> 00:24:46,560 We actually ended up doing extremely well. 556 00:24:47,060 --> 00:24:48,620 Accuracy over 99%. 557 00:24:48,620 --> 00:24:50,240 F1 score 91. 558 00:24:50,600 --> 00:24:52,080 And you can see from the confusion matrix. 559 00:24:52,440 --> 00:24:53,480 Zero false negatives. 560 00:24:53,820 --> 00:24:54,600 Which is great. 561 00:24:55,060 --> 00:24:56,400 A few false positives. 562 00:24:56,560 --> 00:24:58,560 But nothing too crazy. 563 00:25:00,220 --> 00:25:00,780 So. 564 00:25:01,700 --> 00:25:02,400 You know. 565 00:25:02,440 --> 00:25:03,180 That's encouraging. 566 00:25:03,440 --> 00:25:05,300 But how does that scale? 567 00:25:08,900 --> 00:25:10,420 If that was just an outlier. 568 00:25:11,280 --> 00:25:12,300 Or if it's a. 569 00:25:12,540 --> 00:25:13,280 You know. 570 00:25:13,680 --> 00:25:14,740 Predictor of things to come. 571 00:25:15,940 --> 00:25:18,480 And so we ran through cross validation. 572 00:25:18,800 --> 00:25:19,540 10 separate runs. 573 00:25:20,400 --> 00:25:22,500 Very good training and test data. 574 00:25:22,780 --> 00:25:24,520 And ended up with actually. 575 00:25:24,560 --> 00:25:25,560 Very similar results. 576 00:25:26,780 --> 00:25:28,420 Accuracy was over 99. 577 00:25:28,760 --> 00:25:30,380 And F1 score was over 90. 578 00:25:31,580 --> 00:25:32,740 The confusion matrix. 579 00:25:32,840 --> 00:25:33,900 Looked about the same. 580 00:25:34,500 --> 00:25:35,680 So I think that. 581 00:25:36,020 --> 00:25:36,620 You know. 582 00:25:39,960 --> 00:25:41,280 The approach to the problem. 583 00:25:41,460 --> 00:25:41,680 That we're taking. 584 00:25:43,780 --> 00:25:45,520 Just some graph data here. 585 00:25:45,660 --> 00:25:47,600 To provide you a better representation. 586 00:25:47,640 --> 00:25:48,580 Of what we're looking at. 587 00:25:49,540 --> 00:25:50,360 As I said. 588 00:25:50,380 --> 00:25:51,160 Not a data scientist. 589 00:25:51,540 --> 00:25:52,180 But it's good. 590 00:25:54,200 --> 00:25:56,020 So breaking things out. 591 00:25:56,080 --> 00:25:57,700 Into the other components. 592 00:25:58,080 --> 00:25:58,960 And the framework. 593 00:25:59,620 --> 00:26:00,660 With the event listener. 594 00:26:00,800 --> 00:26:02,780 We do need to monitor file change events. 595 00:26:02,980 --> 00:26:04,580 We're looking at all processes. 596 00:26:04,720 --> 00:26:05,820 That are active on a host. 597 00:26:08,900 --> 00:26:09,740 In a specific process. 598 00:26:10,340 --> 00:26:12,120 And focus specifically. 599 00:26:12,300 --> 00:26:14,260 On file creates in our case. 600 00:26:15,120 --> 00:26:16,280 There's a few approaches. 601 00:26:16,380 --> 00:26:16,920 That you can take. 602 00:26:17,040 --> 00:26:18,880 To getting this data. 603 00:26:19,980 --> 00:26:20,540 Including. 604 00:26:21,900 --> 00:26:23,460 Using Python watcher. 605 00:26:23,580 --> 00:26:25,200 But as I said before. 606 00:26:25,400 --> 00:26:27,320 The most important thing that we need here. 607 00:26:27,480 --> 00:26:28,220 Is we need a. 608 00:26:28,840 --> 00:26:31,520 We need the type of file event. 609 00:26:31,720 --> 00:26:33,620 We need the type of. 610 00:26:35,300 --> 00:26:35,860 Sorry. 611 00:26:35,960 --> 00:26:36,760 The process. 612 00:26:38,900 --> 00:26:40,060 For the particular event. 613 00:26:40,220 --> 00:26:41,380 And we need the file path. 614 00:26:41,740 --> 00:26:43,140 So Python watcher in this case. 615 00:26:43,280 --> 00:26:45,940 Is based off of the read directory changes API. 616 00:26:46,840 --> 00:26:48,260 Windows API that I believe. 617 00:26:49,280 --> 00:26:50,360 Doesn't actually return. 618 00:26:50,600 --> 00:26:51,980 Any sort of source process data. 619 00:26:52,380 --> 00:26:53,240 So in our case. 620 00:26:53,480 --> 00:26:55,100 That's not going to help. 621 00:26:55,280 --> 00:26:57,440 So alternative approaches to that. 622 00:26:57,620 --> 00:26:59,060 You could go through event logs. 623 00:26:59,380 --> 00:27:00,960 Or you could write your own file. 624 00:27:01,040 --> 00:27:01,860 When you filter your driver. 625 00:27:02,960 --> 00:27:04,020 Both of those. 626 00:27:05,000 --> 00:27:05,880 Would work. 627 00:27:08,900 --> 00:27:10,160 It would take way too much work. 628 00:27:10,420 --> 00:27:11,880 That you would want to do for this project. 629 00:27:13,960 --> 00:27:14,400 So. 630 00:27:15,300 --> 00:27:16,600 For our case here. 631 00:27:16,760 --> 00:27:18,200 What I ended up wanting to do. 632 00:27:18,340 --> 00:27:20,440 Was leverage something that's going to be prebuilt. 633 00:27:20,800 --> 00:27:22,780 And see if I can kind of sift through. 634 00:27:22,840 --> 00:27:24,180 Event log data for that. 635 00:27:24,660 --> 00:27:26,640 To get our file events. 636 00:27:26,860 --> 00:27:27,760 In real time. 637 00:27:28,200 --> 00:27:29,940 And so for my case. 638 00:27:30,040 --> 00:27:31,760 I was able to leverage Sysmon. 639 00:27:32,320 --> 00:27:33,740 If you're not familiar with Sysmon. 640 00:27:33,820 --> 00:27:35,860 It's just a tool that's. 641 00:27:36,680 --> 00:27:37,980 Used for monitoring. 642 00:27:39,220 --> 00:27:40,720 Event data on. 643 00:27:41,160 --> 00:27:42,080 On Windows. 644 00:27:42,300 --> 00:27:43,840 And so there's a specific. 645 00:27:44,160 --> 00:27:45,640 File create event actually. 646 00:27:45,760 --> 00:27:46,660 Event ID 11. 647 00:27:47,160 --> 00:27:49,380 That's perfect for our purposes. 648 00:27:49,640 --> 00:27:50,740 So we don't have to worry about. 649 00:27:51,360 --> 00:27:52,940 Distinguishing between different types. 650 00:27:53,020 --> 00:27:54,500 Of file change events. 651 00:27:54,660 --> 00:27:56,120 We only have one type of event. 652 00:27:56,960 --> 00:27:57,860 For us here. 653 00:27:58,020 --> 00:27:58,840 It's just create. 654 00:28:00,100 --> 00:28:01,820 Very simple configuration file. 655 00:28:01,960 --> 00:28:02,780 That I came up with. 656 00:28:02,780 --> 00:28:03,620 And then I posted. 657 00:28:03,880 --> 00:28:06,400 To the git repository for this project. 658 00:28:07,540 --> 00:28:08,920 We're limiting things. 659 00:28:09,000 --> 00:28:11,100 Just to .txt files. 660 00:28:11,320 --> 00:28:12,640 As I previously mentioned. 661 00:28:13,120 --> 00:28:14,360 And just trying to. 662 00:28:14,420 --> 00:28:15,540 Sift out other data. 663 00:28:15,660 --> 00:28:16,820 So we're not trying to. 664 00:28:18,300 --> 00:28:19,860 Crowd the event logs. 665 00:28:21,760 --> 00:28:23,040 There's a registry key. 666 00:28:23,160 --> 00:28:23,760 That you have to add. 667 00:28:23,900 --> 00:28:26,780 In order to properly allow. 668 00:28:27,100 --> 00:28:28,520 The event log to be queried. 669 00:28:28,640 --> 00:28:29,520 In real time. 670 00:28:29,840 --> 00:28:30,820 So that's there. 671 00:28:33,120 --> 00:28:34,380 And so basically. 672 00:28:34,460 --> 00:28:35,960 What we're trying to do in this case. 673 00:28:36,080 --> 00:28:36,880 Is we're going to pull. 674 00:28:38,100 --> 00:28:39,340 The event log. 675 00:28:39,560 --> 00:28:40,140 And we're going to use. 676 00:28:40,460 --> 00:28:41,860 The WMI query language. 677 00:28:42,420 --> 00:28:43,800 And we're essentially just going to be. 678 00:28:43,860 --> 00:28:45,100 Pulling every 10 milliseconds. 679 00:28:45,640 --> 00:28:46,840 In order to try to get updates. 680 00:28:47,180 --> 00:28:48,620 Of new file change events. 681 00:28:48,680 --> 00:28:49,240 That are coming in. 682 00:28:49,340 --> 00:28:50,140 In real time. 683 00:28:50,980 --> 00:28:52,300 So we need to limit the size. 684 00:28:52,440 --> 00:28:54,380 Of the result set that we're getting. 685 00:28:54,820 --> 00:28:56,280 And we're parsing. 686 00:29:02,780 --> 00:29:03,460 So that's what the query. 687 00:29:03,600 --> 00:29:04,580 Essentially looks like. 688 00:29:06,040 --> 00:29:07,500 Pretty self explanatory there. 689 00:29:08,880 --> 00:29:10,180 And for the actual. 690 00:29:11,140 --> 00:29:12,540 Approach for process mitigation. 691 00:29:13,000 --> 00:29:14,200 Very straight forward here. 692 00:29:14,380 --> 00:29:15,420 All we need to determine. 693 00:29:17,400 --> 00:29:18,960 Is that process. 694 00:29:19,180 --> 00:29:19,840 Currently active. 695 00:29:20,100 --> 00:29:22,400 With that ID and process name. 696 00:29:22,900 --> 00:29:23,920 If it is active. 697 00:29:24,060 --> 00:29:24,780 We'll suspend it. 698 00:29:24,920 --> 00:29:26,360 And we need to alert the user. 699 00:29:26,520 --> 00:29:28,320 That there was this activity on their host. 700 00:29:28,680 --> 00:29:30,280 And give them a choice. 701 00:29:32,780 --> 00:29:33,280 To close the process. 702 00:29:35,060 --> 00:29:35,620 Alright. 703 00:29:35,720 --> 00:29:37,580 So we're going to try a live demo here. 704 00:29:37,800 --> 00:29:39,280 So let's see what happens. 705 00:29:43,280 --> 00:29:43,840 Okay. 706 00:29:43,880 --> 00:29:45,380 So I have the framework here. 707 00:29:45,480 --> 00:29:47,540 Running in a single Python file. 708 00:29:48,180 --> 00:29:50,160 I have process monitors set up. 709 00:29:50,260 --> 00:29:51,740 With a couple filters. 710 00:29:52,500 --> 00:29:55,100 We're looking at volcano.exe. 711 00:29:55,140 --> 00:29:57,220 Volcano is a common ransomware family. 712 00:29:57,860 --> 00:30:00,180 And I renamed the executable. 713 00:30:00,240 --> 00:30:01,280 To volcano.exe. 714 00:30:01,300 --> 00:30:02,220 To make this more simple. 715 00:30:02,780 --> 00:30:03,940 And we're going to use. 716 00:30:04,740 --> 00:30:05,720 We're just going to. 717 00:30:06,000 --> 00:30:08,840 Look strictly at write file events. 718 00:30:08,920 --> 00:30:10,600 For a process with that name. 719 00:30:12,920 --> 00:30:13,920 So as you can see. 720 00:30:13,980 --> 00:30:14,940 No events at the moment. 721 00:30:16,180 --> 00:30:18,640 And here is my volcano.exe. 722 00:30:19,420 --> 00:30:20,800 And I will execute that. 723 00:30:23,580 --> 00:30:24,760 And we get our popup. 724 00:30:26,240 --> 00:30:28,940 So it provides us with a specific file path. 725 00:30:29,640 --> 00:30:31,140 To the text file. 726 00:30:31,280 --> 00:30:32,760 That it determined to be a ransom note. 727 00:30:32,780 --> 00:30:35,000 And it went ahead and suspended. 728 00:30:36,620 --> 00:30:37,620 Volcano.exe. 729 00:30:37,720 --> 00:30:39,320 With that specific PID. 730 00:30:39,440 --> 00:30:40,920 And if we go back to here. 731 00:30:41,960 --> 00:30:43,240 In process explorer. 732 00:30:43,380 --> 00:30:44,060 We can verify. 733 00:30:44,220 --> 00:30:45,880 That that process has been suspended. 734 00:30:47,680 --> 00:30:49,600 And if we go through here. 735 00:30:49,860 --> 00:30:51,060 We can kind of look through. 736 00:30:51,320 --> 00:30:51,820 How. 737 00:30:53,020 --> 00:30:54,040 You know the progression. 738 00:30:54,220 --> 00:30:55,720 Of the ransomware. 739 00:30:56,100 --> 00:30:57,500 As it's writing files to disk. 740 00:30:58,680 --> 00:31:00,700 Looks like at 540.22. 741 00:31:00,800 --> 00:31:01,860 That was the first activity. 742 00:31:02,780 --> 00:31:03,240 And. 743 00:31:04,600 --> 00:31:06,700 Let's see around 540.25. 744 00:31:06,820 --> 00:31:07,760 Is when it was. 745 00:31:08,240 --> 00:31:09,480 When the process suspended. 746 00:31:09,840 --> 00:31:11,480 And there was no further events. 747 00:31:12,680 --> 00:31:14,400 So detection time within. 748 00:31:14,820 --> 00:31:16,160 Three seconds or so. 749 00:31:16,480 --> 00:31:18,480 But we have to like for our purposes. 750 00:31:18,620 --> 00:31:20,360 Actually since we're not keying off. 751 00:31:20,420 --> 00:31:22,540 Of any other files. 752 00:31:22,900 --> 00:31:24,160 What we're only keying off of. 753 00:31:24,280 --> 00:31:25,580 Is the text files. 754 00:31:25,700 --> 00:31:27,180 So we can go through the process monitor. 755 00:31:27,880 --> 00:31:28,400 And. 756 00:31:30,620 --> 00:31:31,680 Sift through the data. 757 00:31:32,780 --> 00:31:33,100 And the text files. 758 00:31:33,340 --> 00:31:34,720 To get a better idea. 759 00:31:35,220 --> 00:31:37,340 Of how long it took for us to. 760 00:31:38,300 --> 00:31:39,320 Detect the ransomware. 761 00:32:00,240 --> 00:32:01,960 That actually ends with. 762 00:32:02,780 --> 00:32:02,900 The file. 763 00:32:05,760 --> 00:32:06,680 And so here. 764 00:32:06,840 --> 00:32:08,200 What we can see is that. 765 00:32:08,620 --> 00:32:09,960 There are multiple ransom notes. 766 00:32:10,040 --> 00:32:10,620 That are written to disk. 767 00:32:10,660 --> 00:32:11,740 As I mentioned before. 768 00:32:13,660 --> 00:32:15,120 Ransomware is typically pretty noisy. 769 00:32:15,200 --> 00:32:15,880 With how they're distributing. 770 00:32:16,020 --> 00:32:16,980 Ransom notes on disk. 771 00:32:17,180 --> 00:32:18,440 So in this case. 772 00:32:18,500 --> 00:32:19,220 We actually have. 773 00:32:20,020 --> 00:32:21,960 22 of the same file. 774 00:32:22,160 --> 00:32:23,720 That's going to be written out. 775 00:32:24,580 --> 00:32:25,020 Well. 776 00:32:26,600 --> 00:32:27,740 Actually I think we're only looking. 777 00:32:33,440 --> 00:32:34,080 For the ransomware. 778 00:32:34,080 --> 00:32:35,940 But that gives you an idea of. 779 00:32:36,460 --> 00:32:38,160 Just how noisy the ransomware was. 780 00:32:39,040 --> 00:32:40,840 So we still have that process suspended. 781 00:32:41,160 --> 00:32:42,100 And we can go ahead. 782 00:32:42,220 --> 00:32:43,100 And click terminate. 783 00:32:45,320 --> 00:32:46,400 And as we'll see here. 784 00:32:46,480 --> 00:32:47,080 The process is done. 785 00:32:56,640 --> 00:32:58,300 Okay so getting into. 786 00:32:59,040 --> 00:33:00,360 You know some more testing. 787 00:33:00,460 --> 00:33:01,420 That I did at the framework. 788 00:33:02,780 --> 00:33:03,640 I was able to test. 789 00:33:05,060 --> 00:33:06,880 Against nine samples. 790 00:33:06,980 --> 00:33:08,680 That were essentially holdouts. 791 00:33:08,740 --> 00:33:09,780 Because the ransom notes. 792 00:33:10,120 --> 00:33:12,080 Weren't part of our training or test data set. 793 00:33:12,720 --> 00:33:13,800 So we were able to. 794 00:33:14,420 --> 00:33:16,540 Detect those nine specific samples. 795 00:33:16,880 --> 00:33:17,900 From those families. 796 00:33:18,580 --> 00:33:19,920 And as well as. 797 00:33:19,940 --> 00:33:21,020 Three samples I tested. 798 00:33:21,240 --> 00:33:23,180 That already had notes in the training set. 799 00:33:23,380 --> 00:33:23,960 From earlier. 800 00:33:26,040 --> 00:33:27,220 So in order to get some. 801 00:33:27,720 --> 00:33:29,000 You know a better idea. 802 00:33:29,040 --> 00:33:31,000 Of how successful this approach is. 803 00:33:32,780 --> 00:33:33,880 You know what's currently out there. 804 00:33:34,220 --> 00:33:35,260 And so. 805 00:33:36,180 --> 00:33:37,240 For our cases. 806 00:33:37,660 --> 00:33:38,780 For our case for this. 807 00:33:38,920 --> 00:33:41,160 We just wanted to do testing against. 808 00:33:41,280 --> 00:33:42,680 Anything that was free or trial based. 809 00:33:43,700 --> 00:33:45,360 You know I didn't want to show out any money. 810 00:33:45,460 --> 00:33:46,760 For testing here. 811 00:33:47,440 --> 00:33:48,880 And we wanted to break it out. 812 00:33:48,940 --> 00:33:50,220 For two different tests. 813 00:33:50,540 --> 00:33:53,220 Does it detect the sample. 814 00:33:54,080 --> 00:33:55,220 And if it does. 815 00:33:55,500 --> 00:33:57,000 Can we run it side by side. 816 00:33:57,020 --> 00:33:58,060 With the classifier framework. 817 00:33:58,180 --> 00:33:59,040 That we just came up with. 818 00:34:02,780 --> 00:34:02,920 Or is it just an estimate. 819 00:34:03,060 --> 00:34:05,420 Of what the detection speed looks like. 820 00:34:06,000 --> 00:34:08,060 There's definitely potential complicating factors. 821 00:34:08,360 --> 00:34:08,900 In that. 822 00:34:10,340 --> 00:34:12,000 For that particular test case. 823 00:34:12,220 --> 00:34:14,240 Because things like driver altitude. 824 00:34:14,520 --> 00:34:15,680 Can definitely affect. 825 00:34:15,860 --> 00:34:18,220 How the two products. 826 00:34:18,320 --> 00:34:19,460 Are running side by side. 827 00:34:20,040 --> 00:34:21,180 But you know. 828 00:34:21,200 --> 00:34:23,300 Just a way to get a rough idea. 829 00:34:23,380 --> 00:34:24,180 Of how the performance. 830 00:34:25,140 --> 00:34:26,540 Compares to actual. 831 00:34:27,280 --> 00:34:28,940 Stuff that's currently available for download. 832 00:34:30,180 --> 00:34:31,000 And so. 833 00:34:32,780 --> 00:34:33,580 We did it extremely well. 834 00:34:35,380 --> 00:34:36,540 Kept things very generic. 835 00:34:36,600 --> 00:34:38,300 I don't want to call out any specific vendors. 836 00:34:38,500 --> 00:34:39,120 Or anything like that. 837 00:34:39,760 --> 00:34:40,860 But in our case. 838 00:34:40,980 --> 00:34:43,100 There was one specific product. 839 00:34:43,200 --> 00:34:45,160 That did perform very well. 840 00:34:45,380 --> 00:34:47,040 And was typically faster in detection. 841 00:34:48,200 --> 00:34:50,260 Than the classifier framework that I developed. 842 00:34:50,880 --> 00:34:51,360 And. 843 00:34:52,980 --> 00:34:54,000 That being said. 844 00:34:54,120 --> 00:34:55,220 The detections. 845 00:34:57,300 --> 00:34:58,620 Where product P. 846 00:34:58,620 --> 00:35:00,260 Did perform better. 847 00:35:01,000 --> 00:35:02,080 The framework was. 848 00:35:02,780 --> 00:35:04,480 Still close in performance. 849 00:35:04,600 --> 00:35:05,840 And lagged behind. 850 00:35:05,900 --> 00:35:07,300 By a couple of seconds or so. 851 00:35:08,520 --> 00:35:09,480 But surprisingly. 852 00:35:10,380 --> 00:35:11,440 There were two products. 853 00:35:11,560 --> 00:35:15,220 That were very easily outperformed. 854 00:35:15,560 --> 00:35:16,920 By the classifier framework. 855 00:35:17,720 --> 00:35:18,520 And I mean. 856 00:35:18,580 --> 00:35:19,840 If you even look at the. 857 00:35:19,920 --> 00:35:20,900 A1 and A2. 858 00:35:22,800 --> 00:35:23,280 The. 859 00:35:25,500 --> 00:35:26,700 While it detects. 860 00:35:26,700 --> 00:35:27,880 Pretty much all of the time. 861 00:35:28,300 --> 00:35:29,800 For the U12 samples. 862 00:35:29,900 --> 00:35:30,400 That we saw. 863 00:35:32,780 --> 00:35:34,760 I think this unable to run a test. 864 00:35:34,860 --> 00:35:36,560 For one of the samples. 865 00:35:36,740 --> 00:35:38,960 But it was outperformed. 866 00:35:39,080 --> 00:35:40,380 Nearly all the time. 867 00:35:40,400 --> 00:35:41,340 By our framework. 868 00:35:41,500 --> 00:35:42,820 And that's actually pretty amazing. 869 00:35:43,200 --> 00:35:46,420 Considering the sort of. 870 00:35:47,180 --> 00:35:48,580 Ad hoc approach that we took. 871 00:35:48,800 --> 00:35:50,960 With sifting through event logs. 872 00:35:51,040 --> 00:35:51,400 For data. 873 00:35:52,380 --> 00:35:54,560 And then doing all this classification. 874 00:35:55,180 --> 00:35:56,160 At run time. 875 00:35:56,580 --> 00:35:58,440 And doing it all in Python. 876 00:36:00,280 --> 00:36:01,740 Essentially going head to head. 877 00:36:01,800 --> 00:36:02,580 With something that's running. 878 00:36:02,780 --> 00:36:03,860 Native code. 879 00:36:04,140 --> 00:36:06,260 And probably leveraging minifilter driver. 880 00:36:06,340 --> 00:36:08,900 To obtain their input. 881 00:36:09,160 --> 00:36:10,520 So definitely. 882 00:36:11,400 --> 00:36:12,720 Validates the approach that we took. 883 00:36:13,720 --> 00:36:15,080 So that being said. 884 00:36:15,320 --> 00:36:16,480 Those results are great. 885 00:36:16,740 --> 00:36:18,420 But there are definitely limitations. 886 00:36:18,840 --> 00:36:19,700 With this approach. 887 00:36:20,080 --> 00:36:22,340 There are plenty of ransomware samples. 888 00:36:22,540 --> 00:36:25,160 That don't drop .txt ransom notes. 889 00:36:25,620 --> 00:36:26,220 Some. 890 00:36:26,320 --> 00:36:27,840 Don't even drop notes at all. 891 00:36:28,260 --> 00:36:30,660 Some try to convey their ransom message. 892 00:36:31,400 --> 00:36:32,580 Just in a. 893 00:36:32,780 --> 00:36:33,540 Custom file extension. 894 00:36:33,720 --> 00:36:36,180 That they apply to every single file. 895 00:36:37,640 --> 00:36:38,480 Some samples. 896 00:36:38,560 --> 00:36:39,460 Drop ransom notes. 897 00:36:39,520 --> 00:36:40,480 Much later in the game. 898 00:36:41,120 --> 00:36:42,380 After all the files have been encrypted. 899 00:36:43,100 --> 00:36:44,820 And then there's also samples that. 900 00:36:46,880 --> 00:36:47,980 Leverage some sort of persistence. 901 00:36:48,340 --> 00:36:49,260 And typically respond. 902 00:36:49,540 --> 00:36:51,300 Even if you suspend the process. 903 00:36:51,400 --> 00:36:51,880 Terminate it. 904 00:36:51,920 --> 00:36:52,140 Whatever. 905 00:36:53,380 --> 00:36:54,840 Yeah we might be able to detect it. 906 00:36:54,940 --> 00:36:56,140 But it's going to just keep going. 907 00:36:56,200 --> 00:36:56,820 Over and over. 908 00:37:04,480 --> 00:37:05,860 To deny users. 909 00:37:06,040 --> 00:37:06,880 Access to their data. 910 00:37:07,160 --> 00:37:08,100 NPR modifications. 911 00:37:08,540 --> 00:37:09,600 Anything for raw disk. 912 00:37:09,960 --> 00:37:11,720 Or just simple screen markers. 913 00:37:12,440 --> 00:37:13,740 And of course as we mentioned. 914 00:37:13,820 --> 00:37:14,460 Going in. 915 00:37:14,500 --> 00:37:15,780 Or sticking only to English. 916 00:37:16,680 --> 00:37:17,740 So future work. 917 00:37:18,040 --> 00:37:20,060 We'd like to improve the data sets. 918 00:37:20,840 --> 00:37:22,400 Definitely more ransom notes. 919 00:37:22,680 --> 00:37:25,120 Less synthetic data. 920 00:37:25,200 --> 00:37:26,000 Would be nice as well. 921 00:37:27,120 --> 00:37:29,180 As well as new ransom notes. 922 00:37:29,340 --> 00:37:31,140 As new ransomware families. 923 00:37:32,780 --> 00:37:33,580 That are made aware of. 924 00:37:34,060 --> 00:37:35,760 And we'd also like to build out. 925 00:37:35,780 --> 00:37:37,660 A more representative 9-text data set. 926 00:37:38,200 --> 00:37:39,440 More log files. 927 00:37:39,800 --> 00:37:40,600 More installer files. 928 00:37:41,280 --> 00:37:42,220 Things of that nature. 929 00:37:42,740 --> 00:37:44,720 If we could port our code base. 930 00:37:44,900 --> 00:37:46,060 To a lower level language. 931 00:37:46,340 --> 00:37:47,460 That would be great. 932 00:37:47,640 --> 00:37:50,300 And lead to very significant performance improvements. 933 00:37:50,680 --> 00:37:51,640 And we'd be able to. 934 00:37:51,780 --> 00:37:53,440 Improve our detection time as well. 935 00:37:54,740 --> 00:37:56,480 It would be nice to support. 936 00:37:57,340 --> 00:37:58,460 Other file types. 937 00:37:59,100 --> 00:38:00,020 For the. 938 00:38:02,780 --> 00:38:03,180 As we mentioned before. 939 00:38:03,540 --> 00:38:05,140 As well as images. 940 00:38:05,480 --> 00:38:07,400 Doing OCR to extract text. 941 00:38:08,280 --> 00:38:09,660 Hispanic language support. 942 00:38:09,800 --> 00:38:10,900 Would be nice as well. 943 00:38:11,680 --> 00:38:13,340 As well as experimenting. 944 00:38:13,860 --> 00:38:15,040 With the actual. 945 00:38:15,720 --> 00:38:16,720 Approach to the classification. 946 00:38:18,220 --> 00:38:19,540 So to wrap things up. 947 00:38:20,520 --> 00:38:21,920 Clustering gave us a. 948 00:38:22,320 --> 00:38:24,500 Good idea of the data being suitable. 949 00:38:24,760 --> 00:38:25,320 For classification. 950 00:38:25,940 --> 00:38:27,100 And we saw that. 951 00:38:27,140 --> 00:38:28,980 Ransom notes do share enough features. 952 00:38:29,480 --> 00:38:30,860 For a solution to be viable. 953 00:38:33,220 --> 00:38:34,240 And going into this. 954 00:38:34,340 --> 00:38:35,360 We do realize. 955 00:38:35,660 --> 00:38:37,380 This isn't going to catch all ransomware. 956 00:38:37,500 --> 00:38:39,320 But it could be a very integral piece. 957 00:38:39,400 --> 00:38:40,560 Of a layer detection approach. 958 00:38:40,740 --> 00:38:43,520 With a static classifier as well. 959 00:38:44,280 --> 00:38:44,880 So yeah. 960 00:38:45,000 --> 00:38:46,640 The proof of concept did work. 961 00:38:46,840 --> 00:38:48,860 But there are definitely many improvements to be made. 962 00:38:50,580 --> 00:38:51,000 Alright. 963 00:38:51,560 --> 00:38:52,360 Thank you very much.