1 00:00:02,159 --> 00:00:04,680 good morning good evening and good 2 00:00:04,680 --> 00:00:07,560 afternoon to those at Defcon I am Danny 3 00:00:07,560 --> 00:00:11,519 Henderson I go by bandito or Bandit zero 4 00:00:11,519 --> 00:00:14,519 I am part of a forensics team and we're 5 00:00:14,519 --> 00:00:16,260 going to learn how to use chainsaw to 6 00:00:16,260 --> 00:00:18,779 identify malicious activity 7 00:00:18,779 --> 00:00:21,840 now what is chainsaw you ask 8 00:00:21,840 --> 00:00:24,779 well we're gonna go over that 9 00:00:24,779 --> 00:00:26,640 this is going to be a quick the slides 10 00:00:26,640 --> 00:00:27,960 are going to be quick because we're 11 00:00:27,960 --> 00:00:29,699 going to get right into the action but 12 00:00:29,699 --> 00:00:32,579 to give an overview of Chainsaw it is an 13 00:00:32,579 --> 00:00:36,239 incident response tool that can that you 14 00:00:36,239 --> 00:00:38,940 can use to quickly gather the data from 15 00:00:38,940 --> 00:00:41,579 the windows event logs is a command line 16 00:00:41,579 --> 00:00:43,680 tool that uses a sigma rule detection 17 00:00:43,680 --> 00:00:45,719 logic 18 00:00:45,719 --> 00:00:48,300 you can either search by keyword regex 19 00:00:48,300 --> 00:00:52,800 or just specific IDs or you can hunt 20 00:00:52,800 --> 00:00:57,180 using its built-in tools or Sigma rules 21 00:00:57,180 --> 00:00:59,280 the useful thing about it is that you 22 00:00:59,280 --> 00:01:02,039 can export the data to text files or 23 00:01:02,039 --> 00:01:04,619 csvs to put in a spreadsheet so you want 24 00:01:04,619 --> 00:01:06,420 to carve more information 25 00:01:06,420 --> 00:01:09,600 out so let's get right into it 26 00:01:09,600 --> 00:01:11,580 Sigma rule 27 00:01:11,580 --> 00:01:15,180 now this is a generic signature for Sims 28 00:01:15,180 --> 00:01:17,040 that is like I said targeted Windows 29 00:01:17,040 --> 00:01:19,799 events so it is to event logs as Yara is 30 00:01:19,799 --> 00:01:21,180 the malware 31 00:01:21,180 --> 00:01:24,060 and we have an example here from integer 32 00:01:24,060 --> 00:01:25,979 in fact 33 00:01:25,979 --> 00:01:28,320 of how you would generally set up a 34 00:01:28,320 --> 00:01:31,039 sigma rule 35 00:01:31,439 --> 00:01:34,500 now without further ado 36 00:01:34,500 --> 00:01:37,939 let's Let It Rip 37 00:01:37,979 --> 00:01:40,640 foreign 38 00:01:42,840 --> 00:01:45,060 so the first thing we want to do is go 39 00:01:45,060 --> 00:01:48,180 just pull up chainsaw itself 40 00:01:48,180 --> 00:01:53,240 you get the nice view of the console 41 00:01:53,340 --> 00:01:55,380 with the use with the instructions of 42 00:01:55,380 --> 00:01:57,000 how to use it 43 00:01:57,000 --> 00:02:01,159 so let's take a look at the help 44 00:02:01,740 --> 00:02:05,219 same thing inversion 45 00:02:05,219 --> 00:02:09,500 which is already on the screen but 46 00:02:10,560 --> 00:02:14,700 oh thanks yeah there we go 47 00:02:14,700 --> 00:02:18,900 so that's it we want to go to various 48 00:02:18,900 --> 00:02:20,900 each part so 49 00:02:20,900 --> 00:02:24,300 let's go we're gonna go for two things 50 00:02:24,300 --> 00:02:25,560 there's two things that we're going to 51 00:02:25,560 --> 00:02:27,720 use throughout the event so let me clear 52 00:02:27,720 --> 00:02:30,620 this log right quick 53 00:02:30,720 --> 00:02:33,180 there's two aspects that we're gonna go 54 00:02:33,180 --> 00:02:35,700 for search is gonna be our first one 55 00:02:35,700 --> 00:02:37,739 search and Hunt are the ones that we use 56 00:02:37,739 --> 00:02:38,819 the most 57 00:02:38,819 --> 00:02:41,400 Now searching as I mentioned in the 58 00:02:41,400 --> 00:02:43,800 first slide in one slides that you can 59 00:02:43,800 --> 00:02:46,980 search through the event IDs or keywords 60 00:02:46,980 --> 00:02:49,980 or even use regex The Hunt is where 61 00:02:49,980 --> 00:02:52,080 you're going to be doing it's a little 62 00:02:52,080 --> 00:02:54,540 more automated 63 00:02:54,540 --> 00:02:59,120 so let's go through the search First 64 00:03:04,560 --> 00:03:08,780 so you want to look into the search help 65 00:03:08,819 --> 00:03:12,239 so we're doing this case uh step by step 66 00:03:12,239 --> 00:03:15,060 now the flags here you can put the 67 00:03:15,060 --> 00:03:16,739 search for 68 00:03:16,739 --> 00:03:19,379 case insensitive 69 00:03:19,379 --> 00:03:21,780 now this is only usable for string 70 00:03:21,780 --> 00:03:23,760 search because I've attempted this with 71 00:03:23,760 --> 00:03:27,060 the regex and that's not going to work 72 00:03:27,060 --> 00:03:30,720 now we can use the flags for either the 73 00:03:30,720 --> 00:03:32,700 events 74 00:03:32,700 --> 00:03:35,640 regex and strings and we may want to 75 00:03:35,640 --> 00:03:38,220 make an output of it so let's begin on 76 00:03:38,220 --> 00:03:39,659 that 77 00:03:39,659 --> 00:03:44,760 so we uh so this for the obsidian 78 00:03:44,760 --> 00:03:48,720 event we have kill chain one and three 79 00:03:48,720 --> 00:03:52,080 we're gonna start with kill chain three 80 00:03:52,080 --> 00:03:55,379 for the search aspects so we got two 81 00:03:55,379 --> 00:03:57,720 holes that was part of the compromise so 82 00:03:57,720 --> 00:03:59,760 we're gonna use that for the example of 83 00:03:59,760 --> 00:04:02,220 how regex can help you identify what's 84 00:04:02,220 --> 00:04:03,900 going on 85 00:04:03,900 --> 00:04:07,760 so what we're going to do here 86 00:04:19,680 --> 00:04:22,560 we're going to use the event id4104 87 00:04:22,560 --> 00:04:26,300 which is associated with the Powershell 88 00:04:31,800 --> 00:04:34,460 foreign 89 00:04:43,080 --> 00:04:46,860 so let's scroll up for just a bit let's 90 00:04:46,860 --> 00:04:50,880 scroll up as much as we can 91 00:04:50,880 --> 00:04:55,159 because things happen very fast 92 00:04:56,220 --> 00:04:58,740 and it may actually be better 93 00:04:58,740 --> 00:05:01,440 if we just did a more 94 00:05:01,440 --> 00:05:04,759 let's Let It Go slowly 95 00:05:06,780 --> 00:05:09,919 now note it searched through 96 00:05:09,919 --> 00:05:13,698 311 logs 97 00:05:13,979 --> 00:05:16,380 and this is part of the output that it 98 00:05:16,380 --> 00:05:18,620 found 99 00:05:18,720 --> 00:05:21,960 you have many attributes such as the 100 00:05:21,960 --> 00:05:27,960 event data the paths what that text is 101 00:05:27,960 --> 00:05:30,720 and for this is a big chunk 102 00:05:30,720 --> 00:05:33,320 foreign 103 00:05:35,699 --> 00:05:37,740 now next 104 00:05:37,740 --> 00:05:40,620 we're going to do the strings next 105 00:05:40,620 --> 00:05:42,360 so there's two things that we could do 106 00:05:42,360 --> 00:05:45,199 with for the strings 107 00:05:45,840 --> 00:05:48,600 we're going to go with the 108 00:05:48,600 --> 00:05:50,759 we're going to remove the insensitive 109 00:05:50,759 --> 00:05:52,560 one we're not going to use that one we 110 00:05:52,560 --> 00:05:56,120 will instead just use 111 00:05:59,100 --> 00:06:00,780 as is 112 00:06:00,780 --> 00:06:04,080 you will find in this example 113 00:06:04,080 --> 00:06:07,520 this actually did work 114 00:06:11,639 --> 00:06:16,620 so in this case you see signs of 115 00:06:16,620 --> 00:06:19,639 Kerber roasting 116 00:06:20,819 --> 00:06:23,400 so only one event was found which is 117 00:06:23,400 --> 00:06:27,780 part of the windows event logs 118 00:06:27,780 --> 00:06:29,940 and this is pulled from the Powershell 119 00:06:29,940 --> 00:06:32,900 operational log 120 00:06:36,120 --> 00:06:38,580 it's one two three 121 00:06:38,580 --> 00:06:42,258 so we found that aspect 122 00:06:43,139 --> 00:06:45,000 now we're going to do something 123 00:06:45,000 --> 00:06:48,660 different we're going to do a regex 124 00:06:48,660 --> 00:06:50,220 now this 125 00:06:50,220 --> 00:06:52,080 as I mentioned before it's also able to 126 00:06:52,080 --> 00:06:54,740 do regex 127 00:06:58,080 --> 00:07:01,199 this time we're going to do another 128 00:07:01,199 --> 00:07:03,780 uh device which was the domain 129 00:07:03,780 --> 00:07:06,318 controller 130 00:07:11,520 --> 00:07:13,940 oh 131 00:07:40,440 --> 00:07:43,340 what was that 132 00:07:43,860 --> 00:07:45,960 now the reason why 133 00:07:45,960 --> 00:07:47,300 um 134 00:07:47,300 --> 00:07:50,099 let's get one moment 135 00:07:50,099 --> 00:07:53,300 oops that's why 136 00:07:59,099 --> 00:08:01,919 now here we do have 137 00:08:01,919 --> 00:08:04,560 this gone fast so first we're going to 138 00:08:04,560 --> 00:08:06,120 do two things we're going to do more 139 00:08:06,120 --> 00:08:09,560 just to go through it slowly 140 00:08:12,599 --> 00:08:18,000 so here we can see PS exec service or Ps 141 00:08:18,000 --> 00:08:21,080 executive service 142 00:08:25,759 --> 00:08:29,599 the create keys 143 00:08:31,199 --> 00:08:34,159 system on 144 00:08:38,458 --> 00:08:43,458 we have the service here from the sysmon 145 00:08:47,540 --> 00:08:50,940 now let's do this 146 00:08:50,940 --> 00:08:53,519 just to show you another way of seeing 147 00:08:53,519 --> 00:08:56,779 how how much did we grab 148 00:09:06,920 --> 00:09:10,500 so most of this has been part of the 149 00:09:10,500 --> 00:09:13,040 service 150 00:09:24,060 --> 00:09:26,839 next up 151 00:09:27,240 --> 00:09:30,899 now we want to do oh and here we 152 00:09:30,899 --> 00:09:33,839 actually have PS exec with one of the 153 00:09:33,839 --> 00:09:35,100 keys 154 00:09:35,100 --> 00:09:37,200 so that's another example of what we 155 00:09:37,200 --> 00:09:40,019 have of a different one so the regex was 156 00:09:40,019 --> 00:09:41,640 used to find 157 00:09:41,640 --> 00:09:45,660 the service as well as the PPS exec 158 00:09:45,660 --> 00:09:47,880 which we found with the RDP key 159 00:09:47,880 --> 00:09:50,339 associated 160 00:09:50,339 --> 00:09:52,980 and now we want to save it to an output 161 00:09:52,980 --> 00:09:55,980 so 162 00:10:15,959 --> 00:10:18,800 there we go 163 00:10:24,000 --> 00:10:27,360 on one hand we do have it as an output 164 00:10:27,360 --> 00:10:29,100 on here on the other hand it doesn't 165 00:10:29,100 --> 00:10:30,959 look the greatest 166 00:10:30,959 --> 00:10:33,600 but hey you do have a weight of 167 00:10:33,600 --> 00:10:36,180 putting it on here 168 00:10:36,180 --> 00:10:38,399 and even more 169 00:10:38,399 --> 00:10:40,380 let's take a look at 170 00:10:40,380 --> 00:10:43,399 the downloads 171 00:10:56,459 --> 00:11:00,000 okay now back to the next part so we're 172 00:11:00,000 --> 00:11:02,600 going to move on to the other capability 173 00:11:02,600 --> 00:11:05,880 of Chainsaw 174 00:11:05,880 --> 00:11:08,459 now this is the other aspect called The 175 00:11:08,459 --> 00:11:09,660 Hunt 176 00:11:09,660 --> 00:11:12,360 this we can use the built-in tools of 177 00:11:12,360 --> 00:11:17,180 hunt so we're gonna go with 178 00:11:17,220 --> 00:11:18,839 actually 179 00:11:18,839 --> 00:11:21,980 do some cleanup here 180 00:11:25,140 --> 00:11:26,339 okay 181 00:11:26,339 --> 00:11:29,000 clean up done 182 00:11:33,860 --> 00:11:35,700 first we're going to take a look at the 183 00:11:35,700 --> 00:11:37,740 help 184 00:11:37,740 --> 00:11:40,920 now there's very there are various Flags 185 00:11:40,920 --> 00:11:44,459 we can it we can save it as a c as the 186 00:11:44,459 --> 00:11:47,339 individual CSV files 187 00:11:47,339 --> 00:11:49,620 we can ask it to not use the built-in 188 00:11:49,620 --> 00:11:52,860 tools Go full which 189 00:11:52,860 --> 00:11:54,779 this can be useful for the Powershell 190 00:11:54,779 --> 00:11:58,740 because some of it's going to truncate 191 00:11:58,740 --> 00:12:02,700 we can also leverage the lateral all 192 00:12:02,700 --> 00:12:06,860 so let's do this one first 193 00:12:08,220 --> 00:12:10,320 run check on one of the workstations 194 00:12:10,320 --> 00:12:12,660 this one's going to be with the built-in 195 00:12:12,660 --> 00:12:15,079 tools 196 00:12:19,380 --> 00:12:21,920 foreign 197 00:12:36,779 --> 00:12:40,339 so we're going to do a hunt 198 00:12:41,180 --> 00:12:43,980 we didn't add anything new to it but we 199 00:12:43,980 --> 00:12:47,600 do have a nice output out of this 200 00:12:49,800 --> 00:12:52,740 now we also see that it takes everything 201 00:12:52,740 --> 00:12:53,820 out 202 00:12:53,820 --> 00:12:56,279 so here we at least have some activity 203 00:12:56,279 --> 00:12:59,700 from the built-in logic such as the 204 00:12:59,700 --> 00:13:03,320 security audit being cleared 205 00:13:03,839 --> 00:13:07,740 at 0.35 206 00:13:08,339 --> 00:13:11,959 we also have 207 00:13:12,120 --> 00:13:16,279 users added to the local group 208 00:13:19,200 --> 00:13:21,180 four we have indications of brute 209 00:13:21,180 --> 00:13:23,599 forcing 210 00:13:24,320 --> 00:13:25,980 foreign 211 00:13:25,980 --> 00:13:29,639 now we're going to 212 00:13:29,639 --> 00:13:32,639 let's actually go to workstation 2. then 213 00:13:32,639 --> 00:13:36,980 we're going to add lateral all to 214 00:13:37,980 --> 00:13:39,480 if there's indications of lateral 215 00:13:39,480 --> 00:13:41,839 movement 216 00:13:49,920 --> 00:13:52,320 now here you have potential activity 217 00:13:52,320 --> 00:13:54,899 related with lateral movement 218 00:13:54,899 --> 00:13:57,540 such as the user added into the local 219 00:13:57,540 --> 00:13:59,839 group 220 00:14:03,959 --> 00:14:06,480 as well the system locks being cleared 221 00:14:06,480 --> 00:14:09,380 and the 222 00:14:09,380 --> 00:14:13,320 4624 successful connections 223 00:14:13,320 --> 00:14:15,120 where you see a lot of connections on to 224 00:14:15,120 --> 00:14:16,800 workstation 2. 225 00:14:16,800 --> 00:14:19,620 whereas others you see a system 226 00:14:19,620 --> 00:14:22,699 associated with it 227 00:14:27,480 --> 00:14:30,600 now what we want to do next is use the 228 00:14:30,600 --> 00:14:33,320 sigma rules 229 00:14:35,160 --> 00:14:37,320 so this one's handled differently you 230 00:14:37,320 --> 00:14:39,959 have to in order to use the sigma rule 231 00:14:39,959 --> 00:14:41,940 you have to add 232 00:14:41,940 --> 00:14:45,959 a certain you have to add multiple Flags 233 00:14:45,959 --> 00:14:50,239 to it so we're going to put rules 234 00:14:55,139 --> 00:14:57,480 so we've added the signal rules and then 235 00:14:57,480 --> 00:15:00,139 mapping 236 00:15:15,839 --> 00:15:18,600 uh let's do more just to not have it 237 00:15:18,600 --> 00:15:21,420 take everything at once 238 00:15:21,420 --> 00:15:24,000 so no no one screens are scrolled on 239 00:15:24,000 --> 00:15:26,180 here 240 00:15:27,180 --> 00:15:31,979 now this one is going through 835 241 00:15:32,339 --> 00:15:36,660 detection rules out of the 311 event 242 00:15:36,660 --> 00:15:39,439 logs 243 00:15:39,740 --> 00:15:42,240 of those detection rules we see 90 of 244 00:15:42,240 --> 00:15:44,399 them were not loaded 245 00:15:44,399 --> 00:15:48,360 so here we see activity that was not 246 00:15:48,360 --> 00:15:51,420 associated with the built-in logic 247 00:15:51,420 --> 00:15:54,779 so Powershell indications 248 00:15:54,779 --> 00:15:59,720 now when I mentioned about the full 249 00:15:59,759 --> 00:16:01,620 this part here is where it talks about 250 00:16:01,620 --> 00:16:04,560 the use the full flag to show all 251 00:16:04,560 --> 00:16:05,820 content 252 00:16:05,820 --> 00:16:07,560 so we're probably going to do that on 253 00:16:07,560 --> 00:16:10,219 the next go 254 00:16:12,060 --> 00:16:14,660 foreign 255 00:16:21,600 --> 00:16:24,899 and this time we're going to build this 256 00:16:24,899 --> 00:16:27,380 fully 257 00:16:27,540 --> 00:16:29,399 also we can scroll up and see the other 258 00:16:29,399 --> 00:16:31,440 events that happens at once 259 00:16:31,440 --> 00:16:34,579 it'd be easier that way 260 00:16:36,660 --> 00:16:38,639 so we're letting it letting the chainsaw 261 00:16:38,639 --> 00:16:41,779 rip through once more 262 00:16:42,600 --> 00:16:44,639 the nice thing about this is that it can 263 00:16:44,639 --> 00:16:45,899 go through 264 00:16:45,899 --> 00:16:49,399 the logs very quickly 265 00:16:51,000 --> 00:16:53,820 now we see indications of the user being 266 00:16:53,820 --> 00:16:56,300 added 267 00:16:56,459 --> 00:16:59,540 security audit and as I mentioned before 268 00:16:59,540 --> 00:17:03,420 more suspicious activity now sometimes 269 00:17:03,420 --> 00:17:06,480 these may be noise itself the suspicious 270 00:17:06,480 --> 00:17:09,119 file creation these may be more noise 271 00:17:09,119 --> 00:17:12,599 but what this allows you to do 272 00:17:12,599 --> 00:17:16,199 is it gives you a opportunity to analyze 273 00:17:16,199 --> 00:17:18,720 it so despite the automation behind it 274 00:17:18,720 --> 00:17:21,119 you still have to be part of you still 275 00:17:21,119 --> 00:17:23,240 have to have the analyst behind it to 276 00:17:23,240 --> 00:17:26,660 decipher what's going on 277 00:17:29,640 --> 00:17:32,760 and mentioned earlier we're going to add 278 00:17:32,760 --> 00:17:36,080 the CSV flag 279 00:17:55,460 --> 00:17:58,860 now you see that it for here it created 280 00:17:58,860 --> 00:18:01,679 multiple files on CSV files 281 00:18:01,679 --> 00:18:05,120 one is based off of the external rules 282 00:18:05,120 --> 00:18:08,760 and then also the built-in logic 283 00:18:08,760 --> 00:18:11,220 so it separates them 284 00:18:11,220 --> 00:18:14,520 so let's open this back up and take a 285 00:18:14,520 --> 00:18:17,039 look at the 286 00:18:17,039 --> 00:18:20,120 CSV itself 287 00:18:25,980 --> 00:18:28,020 Yep this folder 288 00:18:28,020 --> 00:18:30,840 and we're going to open up the external 289 00:18:30,840 --> 00:18:33,439 rule here 290 00:18:34,799 --> 00:18:37,520 yep 291 00:18:42,539 --> 00:18:45,059 so it'll use the system time of the 292 00:18:45,059 --> 00:18:46,080 activity 293 00:18:46,080 --> 00:18:48,960 as well as the ID the event ID 294 00:18:48,960 --> 00:18:53,240 Associated detection rules 295 00:18:55,320 --> 00:18:58,520 and the data 296 00:19:04,260 --> 00:19:06,059 and let's take a look at the file 297 00:19:06,059 --> 00:19:09,260 suspicious file loading 298 00:19:13,260 --> 00:19:15,600 so you see indications of suspicious 299 00:19:15,600 --> 00:19:17,640 modules that's worth investigating to 300 00:19:17,640 --> 00:19:20,940 rule out if this was malicious or not 301 00:19:20,940 --> 00:19:23,880 but the thing about the tool is that it 302 00:19:23,880 --> 00:19:26,520 gives you a faster way to analyze the 303 00:19:26,520 --> 00:19:28,260 data 304 00:19:28,260 --> 00:19:30,600 to create it as a collector a triage 305 00:19:30,600 --> 00:19:31,980 collector 306 00:19:31,980 --> 00:19:35,360 that's important thing about this 307 00:19:36,660 --> 00:19:38,700 and we're just going to open it with 308 00:19:38,700 --> 00:19:40,980 pluma just to see the 309 00:19:40,980 --> 00:19:44,480 at your CSV itself 310 00:19:51,419 --> 00:19:55,700 and that is actually the way of 311 00:19:58,320 --> 00:20:01,100 chainsaw 312 00:20:02,400 --> 00:20:05,280 now if you want to use chainsaw for your 313 00:20:05,280 --> 00:20:08,120 own investigations 314 00:20:31,740 --> 00:20:34,440 you can grab it and get the GitHub 315 00:20:34,440 --> 00:20:36,600 just remember the installation side 316 00:20:36,600 --> 00:20:39,900 remember to tag the 317 00:20:39,900 --> 00:20:43,080 sub modules to re recurse 318 00:20:43,080 --> 00:20:45,120 because if you don't 319 00:20:45,120 --> 00:20:47,280 you will not have access to the attack 320 00:20:47,280 --> 00:20:51,559 samples order Sigma rules to work with 321 00:20:55,919 --> 00:20:59,720 I'll leave you all with one final note 322 00:21:02,220 --> 00:21:06,600 chainsaw has been a great tool to 323 00:21:06,600 --> 00:21:08,159 which has helped us with the 324 00:21:08,159 --> 00:21:11,159 investigation for the obsidian project 325 00:21:11,159 --> 00:21:13,500 we recommend everyone and I personally 326 00:21:13,500 --> 00:21:15,539 recommend everyone having this in their 327 00:21:15,539 --> 00:21:17,400 Library when they're doing their own 328 00:21:17,400 --> 00:21:18,780 even 329 00:21:18,780 --> 00:21:22,140 their own incident investigation 330 00:21:22,140 --> 00:21:24,360 so penny for the questions 331 00:21:24,360 --> 00:21:28,039 I will see you all later