1 00:00:00,000 --> 00:00:02,480 Right. These are the hardcore people, right? 2 00:00:03,600 --> 00:00:06,140 You guys are here at 5 o'clock to come hear this. 3 00:00:06,180 --> 00:00:06,880 This is really cool. 4 00:00:07,520 --> 00:00:08,440 Is it 6? 5 00:00:09,380 --> 00:00:11,520 No. It's 6.20? 6 00:00:13,540 --> 00:00:15,100 This is what happens. 7 00:00:16,380 --> 00:00:17,900 So anyways, we have... 8 00:00:17,900 --> 00:00:20,520 Okay, I'm going to butcher his name, but... 9 00:00:20,520 --> 00:00:20,980 Do it! 10 00:00:24,380 --> 00:00:26,360 I have to look it up again. 11 00:00:29,140 --> 00:00:30,860 And I'm still going to do it wrong. 12 00:00:37,640 --> 00:00:39,000 Rick Van June. 13 00:00:39,960 --> 00:00:41,040 That's wrong, I know. 14 00:00:41,100 --> 00:00:43,120 He's told me that's the American version of it. 15 00:00:43,440 --> 00:00:45,440 So, he thinks so. 16 00:00:47,180 --> 00:00:50,900 He and Leandro Velasco are going to talk about... 17 00:00:50,900 --> 00:00:51,760 See, I got that one right. 18 00:00:54,040 --> 00:00:55,900 Come on, guys. That was easier, right? 19 00:00:56,620 --> 00:01:00,100 We are going to talk about endpoint monitoring with free and open source software. 20 00:01:00,280 --> 00:01:02,020 This is going to be a great talk. I'm looking forward to this. 21 00:01:06,280 --> 00:01:07,540 So, hi, guys. 22 00:01:09,560 --> 00:01:09,960 Thanks. 23 00:01:13,160 --> 00:01:18,220 So, welcome to our talk on endpoint monitoring using free and open source software. 24 00:01:19,940 --> 00:01:22,300 As discussed before, my name is Rick Van Duin, 25 00:01:22,820 --> 00:01:26,340 which is way different, but for American purposes, I'm Van June. 26 00:01:26,360 --> 00:01:30,600 Now, I work as a pen tester. I'm that dude. 27 00:01:30,980 --> 00:01:32,400 And a security researcher. 28 00:01:32,820 --> 00:01:34,520 We work at a company called Darebytes. 29 00:01:34,820 --> 00:01:41,320 And we do everything from pen testing up until policy, monitoring, firewall management, 30 00:01:41,580 --> 00:01:44,140 just IT security in the broadest sense of the word. 31 00:01:44,440 --> 00:01:48,660 I give this presentation together with my colleague, Leandro Velasco, 32 00:01:49,360 --> 00:01:53,100 which is very easily pronounceable for English speakers. 33 00:01:54,060 --> 00:01:56,340 He's, according to our HR department, 34 00:01:56,360 --> 00:01:59,720 he's a threat intel analyst and a security researcher 35 00:01:59,720 --> 00:02:01,640 and does not have a profile picture. 36 00:02:03,320 --> 00:02:05,660 So, why do we need endpoint monitoring? 37 00:02:06,080 --> 00:02:09,580 I would like to give a short introduction on the use of it 38 00:02:09,580 --> 00:02:13,960 and some reasons why you need to be thinking about your endpoint monitoring 39 00:02:13,960 --> 00:02:15,880 before somebody else does. 40 00:02:17,380 --> 00:02:20,280 So, antivirus is currently being bypassed left and right. 41 00:02:20,500 --> 00:02:25,920 It's getting increasingly more easy to infect the system without antivirus being, 42 00:02:26,600 --> 00:02:27,560 you know, annoying to us. 43 00:02:28,440 --> 00:02:31,140 There's lots of EDR mumbo-jumbo passing around. 44 00:02:31,400 --> 00:02:35,560 So, service managers, product managers, and sales dudes are looking at Gartner. 45 00:02:35,820 --> 00:02:38,020 So, you need to think about it before they do. 46 00:02:38,960 --> 00:02:42,600 And network monitoring is getting increasingly more difficult. 47 00:02:42,860 --> 00:02:45,100 It's great that encrypt is very popular, 48 00:02:45,300 --> 00:02:47,940 meaning that most of the traffic nowadays is encrypted. 49 00:02:48,300 --> 00:02:52,100 That also means that if you're just doing network monitoring, 50 00:02:52,300 --> 00:02:53,620 you'll see less and less and less, 51 00:02:53,740 --> 00:02:56,280 or you need to rely on a lot of threat intel. 52 00:02:56,360 --> 00:02:58,880 Which is easily bypassable. 53 00:02:59,120 --> 00:03:01,360 As discussed before in the MITRE talk, 54 00:03:01,580 --> 00:03:03,240 you've seen that the Pyramid of Pain, 55 00:03:03,400 --> 00:03:06,420 like tracking just domains and IPs, 56 00:03:06,460 --> 00:03:08,420 might be not so effective. 57 00:03:10,020 --> 00:03:13,400 So, we also think we're currently boring a lot of analysts to death 58 00:03:13,400 --> 00:03:15,140 with contextless alerts. 59 00:03:15,480 --> 00:03:19,780 So, there's lots of blinky boxes doing, saying there's an alert, 60 00:03:19,920 --> 00:03:22,820 there's something going wrong, and there's no real context there. 61 00:03:23,220 --> 00:03:26,040 Sometimes they put like one packet, and so this is the packet, 62 00:03:26,040 --> 00:03:30,000 the alert fired on, and that's it. 63 00:03:30,180 --> 00:03:32,400 So, that's not that much to go on, 64 00:03:32,420 --> 00:03:34,240 and it's really hard to then determine, 65 00:03:34,400 --> 00:03:36,480 okay, is this something, and what's the context? 66 00:03:38,660 --> 00:03:41,940 So, I think that's the motivation for us to be doing this. 67 00:03:42,560 --> 00:03:44,320 And we were thinking, we were sitting in a room, 68 00:03:44,400 --> 00:03:47,000 and we were thinking, okay, is there a product there? 69 00:03:47,240 --> 00:03:48,320 Do we build something? 70 00:03:49,040 --> 00:03:52,140 The thing is, like, we're engineers, 71 00:03:52,280 --> 00:03:53,920 so we like to build things, so we thought, 72 00:03:54,000 --> 00:03:55,940 okay, we're building something, we need to, 73 00:03:55,940 --> 00:03:58,580 we need to have some data, we need to figure out something. 74 00:03:59,340 --> 00:04:01,220 And then Leandro started complaining, 75 00:04:01,460 --> 00:04:03,140 because we needed requirements. 76 00:04:04,300 --> 00:04:07,240 So, then requirements, we, yeah, 77 00:04:07,620 --> 00:04:10,380 I just said we need this, but that doesn't count, 78 00:04:10,460 --> 00:04:13,180 according to the academic approach Leo has. 79 00:04:14,620 --> 00:04:16,060 So, we had some requirements. 80 00:04:16,240 --> 00:04:17,460 So, one of the first things was, 81 00:04:17,560 --> 00:04:20,420 okay, we need a way to gather system activity data. 82 00:04:20,820 --> 00:04:24,680 So, we needed a way to gather data from the system, 83 00:04:24,740 --> 00:04:25,840 and see something. 84 00:04:25,840 --> 00:04:28,100 And then some of the system activity, 85 00:04:28,420 --> 00:04:31,100 user activity, commands being run. 86 00:04:32,120 --> 00:04:34,780 So, we looked at PowerShell script log logging, 87 00:04:34,900 --> 00:04:37,560 which allows you to, if your version of PowerShell 88 00:04:37,560 --> 00:04:40,300 is new enough, allows you to actually log 89 00:04:40,300 --> 00:04:42,220 all PowerShell commands that are being executed, 90 00:04:42,860 --> 00:04:46,860 which is really great, because you will see lots and lots. 91 00:04:47,160 --> 00:04:49,920 It also has a downside, you will see lots and lots. 92 00:04:51,240 --> 00:04:53,440 And next to the whole PowerShell thing, 93 00:04:53,640 --> 00:04:55,740 we decided to go with Sysmon, 94 00:04:55,740 --> 00:04:58,160 which will allow you to log things like 95 00:04:58,160 --> 00:05:02,780 registry key creation, WMI event filters being created, 96 00:05:03,860 --> 00:05:04,840 DLLs being loaded. 97 00:05:05,020 --> 00:05:09,260 You can actually view almost anything happening on a system, 98 00:05:09,400 --> 00:05:10,820 which is pretty amazing. 99 00:05:11,020 --> 00:05:13,520 However, in order to do that, 100 00:05:13,660 --> 00:05:17,360 you actually want to have a good config, 101 00:05:17,600 --> 00:05:19,920 in order to know what you're logging. 102 00:05:20,120 --> 00:05:22,540 Because you could literally log anything, 103 00:05:23,240 --> 00:05:25,660 but that would, like, if you're using like a, 104 00:05:25,740 --> 00:05:27,660 a traditional CMIT, you would probably kill it 105 00:05:27,660 --> 00:05:28,400 with a couple of hosts. 106 00:05:29,280 --> 00:05:32,740 Next to that, not all data is as relevant as the next. 107 00:05:33,060 --> 00:05:37,600 So there's two major projects currently in development. 108 00:05:38,740 --> 00:05:41,360 There's the Swift on security config, 109 00:05:41,640 --> 00:05:43,560 which is pretty great to start with. 110 00:05:43,740 --> 00:05:45,880 It's based on, like, a lot of events, 111 00:05:46,000 --> 00:05:48,660 or new research, or threats being disclosed. 112 00:05:48,820 --> 00:05:51,660 And then they update the config to log the new things. 113 00:05:52,400 --> 00:05:54,340 And it logs things in a very broad sense. 114 00:05:54,340 --> 00:05:56,880 So you get some more data, which is really good, 115 00:05:56,980 --> 00:05:57,860 because you can see a lot. 116 00:05:58,640 --> 00:06:02,780 For those of you who are stuck with a solution that, 117 00:06:03,400 --> 00:06:05,720 yeah, that you need to pay per event, 118 00:06:05,840 --> 00:06:07,580 or you need to pay per megabyte stored, 119 00:06:08,280 --> 00:06:09,880 you might want to look at the project 120 00:06:09,880 --> 00:06:10,940 Olaf Hartong is doing. 121 00:06:11,160 --> 00:06:13,960 He's a Dutch dude, and he's been working 122 00:06:14,500 --> 00:06:17,340 on a modular Sysmon config that allows you to 123 00:06:18,360 --> 00:06:21,000 only log what you already think is, like, evil. 124 00:06:21,120 --> 00:06:24,260 So it scales down the amount of events, 125 00:06:24,260 --> 00:06:27,220 you have, it will also maybe limit you 126 00:06:27,220 --> 00:06:29,140 in looking back in the past, obviously. 127 00:06:29,620 --> 00:06:33,040 But for those of us that have to pay per megabyte 128 00:06:33,660 --> 00:06:36,940 parsed in our system, it's a very interesting project. 129 00:06:37,280 --> 00:06:40,600 But, as I said before, we chose to go with Swift. 130 00:06:40,840 --> 00:06:44,000 Thank you, thank you, Swift, for this great configuration. 131 00:06:45,140 --> 00:06:46,760 We modified it a little bit. 132 00:06:47,480 --> 00:06:49,300 We're logging some other things. 133 00:06:49,440 --> 00:06:50,480 We've added some things. 134 00:06:50,640 --> 00:06:53,560 And we'll be submitting a pull request to the project. 135 00:06:54,260 --> 00:06:55,600 And hope to improve it. 136 00:06:56,060 --> 00:06:57,500 That's one of our goals. 137 00:06:58,760 --> 00:07:02,680 So, as I've said before, we gather system data. 138 00:07:02,800 --> 00:07:04,280 But gathering data is not enough. 139 00:07:04,460 --> 00:07:07,480 So we need to have the ability to actually collect that 140 00:07:07,480 --> 00:07:10,420 and parse and store that centrally. 141 00:07:11,720 --> 00:07:15,060 So, one of the things many people think about 142 00:07:15,060 --> 00:07:17,460 when talking about open source would be Elastic. 143 00:07:17,640 --> 00:07:19,580 So we're just using Elastic in this case. 144 00:07:20,160 --> 00:07:23,940 We're using WinlogBeat to gather all the data. 145 00:07:24,620 --> 00:07:27,040 We're using Logstash to ingest it, 146 00:07:27,180 --> 00:07:29,540 put it into Elastic and Kibana to look at it. 147 00:07:30,500 --> 00:07:33,240 We had some great feedback by our friend Eric. 148 00:07:33,500 --> 00:07:35,360 Eric's not here right now, but thank you, Eric. 149 00:07:36,720 --> 00:07:38,680 To use the Windows Event Forwarder. 150 00:07:39,300 --> 00:07:40,860 We haven't actually played with that. 151 00:07:41,040 --> 00:07:43,880 But for those of you working in a corporate environment, 152 00:07:44,140 --> 00:07:44,720 it might be nice. 153 00:07:44,920 --> 00:07:46,940 So, using the Windows Event Forwarder 154 00:07:46,940 --> 00:07:49,980 will allow you to use a GPO to push all your data 155 00:07:49,980 --> 00:07:51,080 to one central system. 156 00:07:52,180 --> 00:07:54,240 Install WinlogBeat there, and it will help you 157 00:07:54,240 --> 00:07:55,660 ingest it into your Elastic stack, 158 00:07:56,580 --> 00:07:59,540 which is one less agent to run on all of your hosts. 159 00:07:59,780 --> 00:08:00,840 So that might be nice. 160 00:08:01,040 --> 00:08:03,700 For our project, just installing WinlogBeat everywhere 161 00:08:03,700 --> 00:08:05,380 wasn't really an issue. 162 00:08:06,280 --> 00:08:08,740 So, I will now give the mic to my friend. 163 00:08:11,300 --> 00:08:12,660 Okay, thank you very much, Rick. 164 00:08:13,680 --> 00:08:17,240 So, up until now, we had like a nice pipeline. 165 00:08:17,500 --> 00:08:19,600 We are gathering information from the systems 166 00:08:19,600 --> 00:08:21,320 using Sysmon and Skidplug login. 167 00:08:21,540 --> 00:08:23,600 We are shipping the data to our central location. 168 00:08:24,240 --> 00:08:26,420 And in that location, we are parsing, 169 00:08:26,560 --> 00:08:28,220 we are like enriching the data, 170 00:08:28,340 --> 00:08:30,220 and we can display it using Kibana. 171 00:08:30,520 --> 00:08:32,620 But, so we can do threat hunting, 172 00:08:32,800 --> 00:08:34,360 because we have nice context. 173 00:08:34,980 --> 00:08:36,720 We have the means to query, 174 00:08:36,960 --> 00:08:39,380 we have the means to visualize using nice dashboards. 175 00:08:39,560 --> 00:08:42,080 But we don't want to do that manually all the time. 176 00:08:42,240 --> 00:08:43,840 We want to provide some means 177 00:08:43,840 --> 00:08:46,080 to automate certain scenarios. 178 00:08:46,280 --> 00:08:50,880 Let's say, like, after an analyst finds a nice scenario, 179 00:08:51,100 --> 00:08:53,580 like a threat or a particular, 180 00:08:54,540 --> 00:08:57,060 say, okay, this is nice, this is a query to find it, 181 00:08:57,140 --> 00:08:59,760 but I don't want to do it every time, the same query. 182 00:08:59,880 --> 00:09:02,300 I want to have, like, a way to have an alarm. 183 00:09:03,380 --> 00:09:04,160 Yeah, that's it. 184 00:09:05,400 --> 00:09:07,440 So, there are ways to implement that, 185 00:09:07,600 --> 00:09:10,820 and Elastic provides one, but we chose a different one. 186 00:09:11,020 --> 00:09:13,520 We chose to use ElastAlert, because it's free. 187 00:09:14,320 --> 00:09:16,780 It's really powerful, and it's quite flexible and simple. 188 00:09:17,700 --> 00:09:20,420 Basically, it allows us to do, like, alerts 189 00:09:20,940 --> 00:09:23,240 based on pattern matching, so when certain query 190 00:09:23,240 --> 00:09:27,840 is found or it triggers or give us a match in Elasticsearch, 191 00:09:28,020 --> 00:09:28,920 it will create an alarm. 192 00:09:29,420 --> 00:09:33,780 But also, it allows us to do more advanced alarms 193 00:09:33,780 --> 00:09:35,560 based on frequency, for example, 194 00:09:35,620 --> 00:09:38,840 or when different events happen in the same host 195 00:09:38,840 --> 00:09:41,960 or using the same domain or using the same user, for example. 196 00:09:42,200 --> 00:09:46,360 So, it allows us to do pretty much anything that we need. 197 00:09:47,420 --> 00:09:52,040 As I mentioned before, Elastic provides a means to do that. 198 00:09:52,140 --> 00:09:53,200 It's called WAPT. 199 00:09:53,240 --> 00:09:54,940 It was called Watcher, now it's called XPAC, 200 00:09:55,060 --> 00:09:56,760 but you need to pay for that. 201 00:09:56,960 --> 00:09:59,540 So, this is a nice alternative for that system. 202 00:10:02,180 --> 00:10:04,140 Then, we have a way to trigger alarms, 203 00:10:04,340 --> 00:10:07,480 but we want to write the rules in a way that we can share 204 00:10:07,480 --> 00:10:09,460 with the rest of the community, because it's great, 205 00:10:09,660 --> 00:10:13,020 but if you want to, every time we are building nice rules, 206 00:10:13,160 --> 00:10:16,800 we identify a lot of use cases or different interesting scenarios, 207 00:10:17,060 --> 00:10:19,840 and we want to share with our colleagues or whatever, 208 00:10:20,360 --> 00:10:22,100 we don't want to transform us 209 00:10:22,100 --> 00:10:23,220 into another user. 210 00:10:24,920 --> 00:10:28,440 We don't want to reprocess the data or do it from scratch. 211 00:10:28,720 --> 00:10:31,920 So, we need to find a way that is standard and shareable. 212 00:10:32,100 --> 00:10:33,820 So, for that, we're using Sigma. 213 00:10:34,520 --> 00:10:37,640 Sigma is a really cool project made by Florian Roth. 214 00:10:37,860 --> 00:10:38,560 Thank you, man. 215 00:10:40,160 --> 00:10:44,340 Basically, you write files in YAML, and it's really easy. 216 00:10:44,480 --> 00:10:45,420 It's human readable. 217 00:10:45,700 --> 00:10:48,840 It has a simple schema that you need to follow, 218 00:10:49,000 --> 00:10:52,020 and it allows us to transform from that schema 219 00:10:52,020 --> 00:10:55,200 into different systems, such as ArcSight, 220 00:10:55,380 --> 00:10:57,180 and I will show you a picture later. 221 00:10:58,100 --> 00:11:02,000 Also, one of the biggest benefits of this repository 222 00:11:02,000 --> 00:11:05,280 is that a lot of people already contribute a lot of rules 223 00:11:05,280 --> 00:11:09,640 based on the Mitre attack that you may have here. 224 00:11:09,800 --> 00:11:10,820 It's a really nice framework. 225 00:11:10,980 --> 00:11:14,160 It provides a lot of insight into techniques and procedures 226 00:11:14,160 --> 00:11:15,340 that attackers are using. 227 00:11:15,540 --> 00:11:17,140 So, if you build a rule based on that, 228 00:11:17,300 --> 00:11:20,680 you're going for not just a simple detection. 229 00:11:20,900 --> 00:11:22,000 You're going for a detection of, like, 230 00:11:22,020 --> 00:11:22,280 a technique. 231 00:11:22,460 --> 00:11:23,320 It's something more advanced, 232 00:11:23,520 --> 00:11:25,860 and a lot of people already build some rules, 233 00:11:26,000 --> 00:11:28,280 and those are published in the Sigma repository. 234 00:11:28,980 --> 00:11:31,660 So, as I was mentioning before, we have Sigma. 235 00:11:31,760 --> 00:11:35,260 From Sigma, we can compile the rules into different platforms. 236 00:11:35,680 --> 00:11:39,260 We are using ElastAlert, but you can do that to Kibana, 237 00:11:39,360 --> 00:11:41,800 QRudder, ArcSight, Splunk, and there are a few more. 238 00:11:43,340 --> 00:11:45,420 Okay. So, now we have alarms. 239 00:11:45,800 --> 00:11:46,660 We have the rules. 240 00:11:46,920 --> 00:11:48,520 We have a way to share the rules 241 00:11:48,520 --> 00:11:49,660 with the rest of the community, 242 00:11:49,800 --> 00:11:52,000 and a way to transform those rules. 243 00:11:52,020 --> 00:11:53,540 You can change the rules into whatever you're using. 244 00:11:53,880 --> 00:11:55,340 But we want to test that. 245 00:11:55,520 --> 00:11:56,520 How can we test that? 246 00:11:56,620 --> 00:11:59,320 How can we test that after we modify a rule, 247 00:11:59,560 --> 00:12:01,340 we don't break it and it still works? 248 00:12:01,460 --> 00:12:04,060 So, we need to have a way to do automatic unit tests. 249 00:12:04,420 --> 00:12:06,440 So, for that, we're using Red Team Automation. 250 00:12:06,980 --> 00:12:09,620 In this case, we're using RTA from the Endgame Company. 251 00:12:09,840 --> 00:12:10,680 It's a really nice one. 252 00:12:11,080 --> 00:12:13,560 Fred Canary also provides a framework such as this one, 253 00:12:13,960 --> 00:12:15,860 but we chose Red Team Automation 254 00:12:15,860 --> 00:12:17,100 because it's a bit more simplistic. 255 00:12:17,560 --> 00:12:21,560 It's based on Python, so you have, like, small scripts 256 00:12:21,560 --> 00:12:23,320 that they are trying to emulate certain attacks, 257 00:12:23,720 --> 00:12:26,160 and you can build them as complex as you want 258 00:12:26,160 --> 00:12:27,100 or as simple as you want. 259 00:12:27,220 --> 00:12:29,700 So, for our framework, it works really well. 260 00:12:31,040 --> 00:12:33,340 And another reason is that Red Team Automation 261 00:12:33,340 --> 00:12:34,660 is so hard right now, right? 262 00:12:36,480 --> 00:12:38,340 Okay. Here we have the complete system. 263 00:12:38,660 --> 00:12:40,480 As we were talking about the different components, 264 00:12:40,640 --> 00:12:42,200 but before moving forward, 265 00:12:42,300 --> 00:12:43,640 I want to give you, like, a refresh 266 00:12:43,640 --> 00:12:45,660 because we have been talking a lot. 267 00:12:45,800 --> 00:12:48,040 So, for Red Team Automation, with Red Team Automation, 268 00:12:48,120 --> 00:12:51,300 we emulate and we create events in the system. 269 00:12:51,560 --> 00:12:54,620 With Sysmon, we parse this event or we actually monitor, 270 00:12:54,900 --> 00:12:58,620 we generate events that will be gathered by Build-A-Bit, 271 00:12:58,680 --> 00:12:59,920 shipped to Loftash. 272 00:13:00,060 --> 00:13:02,540 Loftash will parse them and reach them 273 00:13:02,540 --> 00:13:05,000 and store in Elasticsearch. 274 00:13:05,540 --> 00:13:07,620 Then we have the Sigma rules here 275 00:13:07,620 --> 00:13:10,520 that will be compiled into ElastAlert rules, 276 00:13:10,680 --> 00:13:13,420 and ElastAlert will be querying constantly Elasticsearch 277 00:13:13,420 --> 00:13:16,140 and looking for certain scenarios to trigger, right? 278 00:13:16,280 --> 00:13:18,580 Those alarms will be displayed by Kibana, 279 00:13:18,640 --> 00:13:21,100 and Kibana also allows us to do threat hunting. 280 00:13:21,100 --> 00:13:21,840 Basically, manually. 281 00:13:22,800 --> 00:13:24,000 But enough of talk. 282 00:13:24,120 --> 00:13:26,000 Let's do some demos because we don't want to bore you. 283 00:13:27,180 --> 00:13:31,540 So, the way we plan the demos, 284 00:13:31,600 --> 00:13:32,960 we have three different case studies. 285 00:13:33,220 --> 00:13:35,200 We're going to analyze different threats. 286 00:13:36,260 --> 00:13:38,400 The first one is Emotestation. 287 00:13:38,640 --> 00:13:42,420 Basically, this Emotestation is like a station for Emotet 288 00:13:42,880 --> 00:13:44,020 that is based on Word. 289 00:13:44,200 --> 00:13:47,840 This Word has a macro that will spawn CMD. 290 00:13:47,900 --> 00:13:49,420 CMD will spawn a PowerShell. 291 00:13:49,560 --> 00:13:51,080 This PowerShell will download this 292 00:13:51,100 --> 00:13:53,940 Trojan from Internet and execute it directly from memory. 293 00:14:00,100 --> 00:14:02,560 So, the idea is to first infect us, 294 00:14:02,680 --> 00:14:06,040 then analyze the sample or analyze the threat 295 00:14:06,040 --> 00:14:09,220 in our system and show that the alarm works. 296 00:14:09,560 --> 00:14:14,100 So, for the first one, we have, okay, let's hope it works. 297 00:14:18,580 --> 00:14:19,100 Okay. 298 00:14:19,100 --> 00:14:22,300 So, because I already accept the editing of macro, 299 00:14:22,500 --> 00:14:23,900 you don't see the banner here. 300 00:14:25,500 --> 00:14:27,160 But trust me, it did work. 301 00:14:28,060 --> 00:14:28,760 You hope. 302 00:14:29,060 --> 00:14:29,400 Yeah. 303 00:14:31,320 --> 00:14:31,760 Okay. 304 00:14:31,980 --> 00:14:32,720 It's not working. 305 00:14:33,260 --> 00:14:33,940 There you are. 306 00:14:34,080 --> 00:14:34,740 No, no, it's working. 307 00:14:34,840 --> 00:14:35,700 Sorry, just kidding, just kidding. 308 00:14:36,160 --> 00:14:36,760 All right. 309 00:14:36,840 --> 00:14:37,220 Don't do it like that. 310 00:14:38,460 --> 00:14:39,340 All right. 311 00:14:40,420 --> 00:14:43,640 So, basically, because of Sysmon, 312 00:14:43,700 --> 00:14:46,720 we can see the entire process creation or process tree. 313 00:14:46,880 --> 00:14:49,080 So, on this side, we have a process tree. 314 00:14:49,100 --> 00:14:52,520 For you, it will be like the left-hand side. 315 00:14:52,680 --> 00:14:53,560 We have the parent. 316 00:14:53,840 --> 00:14:57,420 On the right-hand side, we have the child. 317 00:14:57,860 --> 00:15:04,000 So, here we can see how WinWard executes a CMD. 318 00:15:04,640 --> 00:15:07,200 Also, I want you to look at this CMD 319 00:15:07,200 --> 00:15:09,840 and see what's going on here. 320 00:15:10,820 --> 00:15:12,680 You can see there is a lot of obfuscation, right? 321 00:15:14,260 --> 00:15:16,660 So, what happened here is that somebody used, 322 00:15:17,100 --> 00:15:18,700 invoked this obfuscation from, 323 00:15:19,100 --> 00:15:19,740 Daniel Bohannon. 324 00:15:20,080 --> 00:15:22,420 This is a really cool, okay, 325 00:15:22,540 --> 00:15:24,500 cool for the red team perspective, right? 326 00:15:26,080 --> 00:15:27,780 It's a script that allows you to, 327 00:15:27,840 --> 00:15:31,040 you give like a remote creation or you give like a command line 328 00:15:31,040 --> 00:15:33,060 and it obfuscated like this. 329 00:15:33,580 --> 00:15:35,920 And we talked with Daniel and he confirmed 330 00:15:35,920 --> 00:15:38,300 that this is 100% invoked as obfuscation. 331 00:15:39,280 --> 00:15:40,060 It's quite cool. 332 00:15:40,200 --> 00:15:43,260 This is the first time this is seen in the wild 333 00:15:43,260 --> 00:15:47,340 because it's not that far since he published his research. 334 00:15:48,780 --> 00:15:50,760 But how can we detect this, right? 335 00:15:51,040 --> 00:15:52,300 Because it's hard. 336 00:15:52,840 --> 00:15:55,520 So, for this, because it's the first case study, 337 00:15:55,740 --> 00:15:58,120 we're going to use a simple approach 338 00:15:58,120 --> 00:16:02,480 and that is why WinWard is actually calling CMD. 339 00:16:02,660 --> 00:16:03,860 I mean, that's not normal. 340 00:16:04,040 --> 00:16:05,160 I mean, why is it doing that, right? 341 00:16:05,640 --> 00:16:09,280 So, let me show you how we create the sigma rule 342 00:16:09,280 --> 00:16:12,340 so you get into our mindset. 343 00:16:12,560 --> 00:16:13,640 So, this is sigma. 344 00:16:14,000 --> 00:16:14,880 It's a jumbo file. 345 00:16:15,060 --> 00:16:16,020 You can see it's easy. 346 00:16:16,180 --> 00:16:17,080 It's human readable. 347 00:16:18,540 --> 00:16:19,740 Here we have some documentation. 348 00:16:20,540 --> 00:16:23,640 The most important thing here is we need to give some fields. 349 00:16:23,780 --> 00:16:25,500 In this case, it's event ID one. 350 00:16:25,660 --> 00:16:26,780 This means process creation. 351 00:16:27,040 --> 00:16:29,220 So, we are instructing the next one. 352 00:16:29,280 --> 00:16:31,020 Say, like, look at this event ID. 353 00:16:31,200 --> 00:16:32,740 Then we provide the parent images. 354 00:16:33,240 --> 00:16:35,580 In this case, we are giving like the office to it 355 00:16:35,580 --> 00:16:38,180 because it's not only work that we are interested in 356 00:16:38,180 --> 00:16:40,820 but we are also interested in like Excel, PowerPoint, whatever 357 00:16:41,260 --> 00:16:44,140 because none of those should spawn any of these. 358 00:16:44,500 --> 00:16:46,880 Here we have some suspicious binaries. 359 00:16:46,880 --> 00:16:52,100 I mean, why Windward should be calling C or 32, right? 360 00:16:53,560 --> 00:16:54,440 Thank you very much. 361 00:16:57,140 --> 00:16:57,580 Okay. 362 00:16:58,040 --> 00:17:01,000 So, after we compile this, and it's not much fun to show you 363 00:17:01,000 --> 00:17:02,620 the compiled version because it's hard to read, 364 00:17:03,420 --> 00:17:07,340 we load that into ElastAlert and we hope that it works. 365 00:17:07,420 --> 00:17:08,900 And, yeah, it did work. 366 00:17:09,980 --> 00:17:13,760 So, what is interesting here is that it did trigger 367 00:17:13,760 --> 00:17:16,780 when this event happened, but also we have another rule 368 00:17:16,880 --> 00:17:19,120 that triggers when CMD calls PowerShell. 369 00:17:19,360 --> 00:17:21,840 That's not a really strong indication, 370 00:17:22,160 --> 00:17:25,540 but together with the Windward calling CMD 371 00:17:25,540 --> 00:17:27,100 and CMD calling PowerShell, 372 00:17:27,180 --> 00:17:28,580 that becomes something more interesting. 373 00:17:28,760 --> 00:17:31,280 So, the idea here, like, if an analyst sees this tool, 374 00:17:31,440 --> 00:17:33,240 he's like, hmm, something fishy is going on, right? 375 00:17:34,060 --> 00:17:37,700 Okay. Let me move you to the next case study. 376 00:17:39,340 --> 00:17:41,660 Okay, now we are going to talk about Unicorn Stager. 377 00:17:41,880 --> 00:17:44,880 This Unicorn Stager is a tool to generate stagers 378 00:17:45,380 --> 00:17:46,320 based on PowerShell. 379 00:17:46,960 --> 00:17:50,220 And the interesting thing of this one is that it takes 380 00:17:50,220 --> 00:17:54,720 different type of payloads, such as CrowdStrike, Empire, 381 00:17:55,140 --> 00:18:00,000 Metaprter, and embeds that into a series of PowerShell commands, 382 00:18:00,760 --> 00:18:03,200 heavily authenticated, encoded in B64, 383 00:18:03,500 --> 00:18:05,720 and the payload never touched the disk. 384 00:18:05,920 --> 00:18:10,420 It goes directly into memory and Unicorn started directly from it. 385 00:18:10,560 --> 00:18:14,380 So, what is important is that we can expect that in a certain 386 00:18:14,380 --> 00:18:16,060 moment PowerShell will be executed. 387 00:18:17,460 --> 00:18:20,100 Because that's the way to place things in memory, right? 388 00:18:21,320 --> 00:18:25,820 Okay, let me get infected so we can analyze. 389 00:18:27,100 --> 00:18:30,460 So, something interesting about Unicorn is that it allows 390 00:18:31,380 --> 00:18:33,160 different delivery methodologies. 391 00:18:33,300 --> 00:18:36,400 So, one is HTA, but you can also embed this into macro, 392 00:18:36,580 --> 00:18:38,440 DDE, or different ones. 393 00:18:38,640 --> 00:18:40,220 It's ongoing work. 394 00:18:40,300 --> 00:18:41,100 It's really amazing. 395 00:18:42,780 --> 00:18:45,080 So, here you can see that it is working. 396 00:18:45,260 --> 00:18:46,040 Some PowerShell. 397 00:18:46,060 --> 00:18:47,180 PowerShell happening, and that's it. 398 00:18:48,700 --> 00:18:49,100 Okay. 399 00:18:51,900 --> 00:18:53,920 So, again, here we have our system. 400 00:18:54,400 --> 00:18:56,860 And we can see the process creation. 401 00:18:58,700 --> 00:19:06,060 So, here we can see MSTA calling, okay, calling PowerShell. 402 00:19:06,500 --> 00:19:09,280 And, again, we see a lot of obfuscation and encoded commands. 403 00:19:09,440 --> 00:19:12,180 So, from this alone, it's hard to determine what's going on. 404 00:19:13,060 --> 00:19:15,600 We might have some indication that something fishy is going 405 00:19:15,600 --> 00:19:15,780 on. 406 00:19:16,060 --> 00:19:17,780 Because it's not normal to have, like, so many PowerShells 407 00:19:17,780 --> 00:19:19,100 calling each other. 408 00:19:19,380 --> 00:19:21,720 But also, please take a look at this. 409 00:19:22,340 --> 00:19:23,320 This is strange. 410 00:19:23,560 --> 00:19:25,920 Basically, what's happening here is that PowerShell is 411 00:19:25,920 --> 00:19:29,340 trying to avoid calling PowerShell using the argument 412 00:19:29,340 --> 00:19:30,060 encoded. 413 00:19:30,060 --> 00:19:33,300 Because a lot of tools are looking for that in particular. 414 00:19:33,480 --> 00:19:36,400 So, the way it's doing it is by setting value, that's why we 415 00:19:36,400 --> 00:19:40,140 have SV, and get value somewhere here, here. 416 00:19:40,660 --> 00:19:44,960 And it's constructing, on memory, the PowerShell encoded 417 00:19:44,960 --> 00:19:45,280 command. 418 00:19:46,300 --> 00:19:49,680 So, this is one way to detect such a thread will be like, hey, 419 00:19:50,300 --> 00:19:50,920 look at this. 420 00:19:50,960 --> 00:19:51,640 This is quite unique. 421 00:19:51,760 --> 00:19:54,180 I mean, it's not that common to see this in a PowerShell 422 00:19:54,560 --> 00:19:54,920 execution. 423 00:19:55,900 --> 00:19:58,360 But the problem with that approach is that it's quite 424 00:19:58,360 --> 00:19:59,140 simplistic to bypass. 425 00:19:59,500 --> 00:20:02,500 You just need to add a comma or another caret or whatever, and 426 00:20:02,880 --> 00:20:04,060 your rule doesn't work anymore. 427 00:20:04,320 --> 00:20:06,320 So, this rule is simple. 428 00:20:06,480 --> 00:20:08,600 It works really well for that specific version. 429 00:20:08,900 --> 00:20:10,100 But it's easy to bypass. 430 00:20:10,340 --> 00:20:12,400 So, we need to think of something better. 431 00:20:12,560 --> 00:20:16,040 How can we, I mean, what is the underlying tactic that we need to 432 00:20:16,060 --> 00:20:16,420 do? 433 00:20:16,420 --> 00:20:18,900 What is the attacker trying to do, really? 434 00:20:19,080 --> 00:20:22,600 So, as I mentioned before, it's trying to place some content 435 00:20:22,600 --> 00:20:24,640 into memory and execute it directly from there. 436 00:20:25,340 --> 00:20:28,400 The problem is that Sysmon doesn't allow us to see this 437 00:20:28,400 --> 00:20:28,680 information. 438 00:20:29,080 --> 00:20:32,160 Likely, as Rick mentioned before, we have a PowerShell 439 00:20:32,160 --> 00:20:35,900 script lock log in, and we can see way more with that. 440 00:20:38,600 --> 00:20:40,180 So, this is what we can see. 441 00:20:40,340 --> 00:20:42,340 This is basically what PowerShell is trying to do. 442 00:20:42,420 --> 00:20:45,220 One of those encoded commands end up executing this. 443 00:20:46,060 --> 00:20:49,560 One of the interesting things here is that it's loading manually the 444 00:20:49,560 --> 00:20:54,020 kernel32 DLL, and it's calling functions directly from this DLL, 445 00:20:54,220 --> 00:20:56,900 such as virtual log, create thread, and memset. 446 00:20:57,200 --> 00:21:01,140 So, if we create a rule that is looking for these keywords, we 447 00:21:01,140 --> 00:21:02,160 have a detection, right? 448 00:21:03,040 --> 00:21:07,540 What is important to make it clear for you is that PowerShell is 449 00:21:07,540 --> 00:21:08,700 calling that as a command. 450 00:21:08,900 --> 00:21:11,360 It's not PowerShell as a process calling this function. 451 00:21:11,540 --> 00:21:13,920 It's literally the commands in the command line. 452 00:21:15,080 --> 00:21:16,040 So, let's see. 453 00:21:16,060 --> 00:21:17,500 Let me show you the rule here. 454 00:21:17,980 --> 00:21:20,500 So, in this case, we're using event one. 455 00:21:20,680 --> 00:21:21,680 That's for Sysmon. 456 00:21:21,880 --> 00:21:24,020 We're using 4104. 457 00:21:24,160 --> 00:21:26,200 That's for remote execution. 458 00:21:26,720 --> 00:21:30,360 And we have a bunch of functions of keywords. 459 00:21:31,020 --> 00:21:34,520 We extract these keywords from Maitre, different empires, 460 00:21:34,680 --> 00:21:39,100 different suites that do like post-exploitation, such as 461 00:21:39,100 --> 00:21:43,060 power exploit, and the idea that they all share this idea of 462 00:21:43,620 --> 00:21:45,380 injecting things in memory and executing it. 463 00:21:46,220 --> 00:21:51,960 So, when we see that a PowerShell engine is up, there is a PowerShell 464 00:21:51,960 --> 00:21:56,040 script that is calling these functions directly, we might have 465 00:21:56,040 --> 00:21:56,520 a trigger. 466 00:21:56,820 --> 00:22:02,280 In this case, we create this, we compile it, and here you can see 467 00:22:02,280 --> 00:22:03,320 that it is working. 468 00:22:03,540 --> 00:22:05,060 So, we call it the memory injection command. 469 00:22:05,380 --> 00:22:09,680 Again, we have a Unicorn-specific version, and if we take a look at 470 00:22:09,680 --> 00:22:12,240 these two, we're like, hmm, this is really fishy. 471 00:22:13,120 --> 00:22:13,600 Okay. 472 00:22:13,960 --> 00:22:16,040 Let me show you the last one. 473 00:22:17,980 --> 00:22:21,580 This is a bit, it's quite interesting, and we want to have 474 00:22:21,580 --> 00:22:26,360 like a spin-off, we modify part of this demo today, thanks to Matt 475 00:22:26,360 --> 00:22:27,000 Grebo. 476 00:22:27,840 --> 00:22:31,660 So, the idea that we were analyzing a miner, it's called 477 00:22:31,660 --> 00:22:34,640 GhostMiner, and the interesting thing of this GhostMiner is that 478 00:22:34,640 --> 00:22:38,920 it achieves persistency using WMI objects. 479 00:22:39,080 --> 00:22:43,540 So, basically what it does, it creates a WMI filter that will 480 00:22:43,540 --> 00:22:45,680 be looking for a particular event in the system. 481 00:22:46,380 --> 00:22:50,600 And when that event happens, it will trigger a WMI consumer. 482 00:22:50,980 --> 00:22:55,320 This consumer has pre-programmed an action such as call CMD or 483 00:22:55,320 --> 00:22:58,540 start PowerShell or even execute this JavaScript. 484 00:22:59,600 --> 00:23:03,960 And when it calls a different command, it will do it via this 485 00:23:03,960 --> 00:23:04,400 process. 486 00:23:04,720 --> 00:23:10,600 So, also, if you execute a remote command using WMIC, this 487 00:23:10,600 --> 00:23:13,140 process will be in charge of executing such a command. 488 00:23:13,400 --> 00:23:16,040 So, we will monitor this. 489 00:23:16,060 --> 00:23:17,640 And we will monitor this event. 490 00:23:20,680 --> 00:23:25,120 So, for that, we create a batch file. 491 00:23:26,300 --> 00:23:29,720 So, what's happening at the moment is first we are setting, 492 00:23:29,860 --> 00:23:31,200 we are creating these objects. 493 00:23:31,760 --> 00:23:34,980 We create the filter that will be looking for the task 494 00:23:34,980 --> 00:23:35,280 manager. 495 00:23:35,580 --> 00:23:39,520 That's why we triggered this event because we want to show 496 00:23:39,520 --> 00:23:41,500 you that it's working. 497 00:23:41,960 --> 00:23:45,120 And the consumer is instructed to call notepad. 498 00:23:45,260 --> 00:23:46,040 And as you can see, it's working. 499 00:23:46,060 --> 00:23:48,760 It's actually working here because we started the task 500 00:23:48,760 --> 00:23:49,040 manager. 501 00:23:50,960 --> 00:23:54,220 And then, how can we detect that? 502 00:23:54,420 --> 00:23:54,660 Right? 503 00:23:54,900 --> 00:23:59,320 So, we have a bunch of dashboards here. 504 00:24:00,520 --> 00:24:06,760 So, what we did first was to modify the sysmon configuration 505 00:24:06,760 --> 00:24:09,860 file because the one provided by system security doesn't allow 506 00:24:09,860 --> 00:24:12,200 us to do WMI monitoring. 507 00:24:12,520 --> 00:24:13,580 So, we modified that. 508 00:24:13,660 --> 00:24:15,480 And now we can see the creation of objects. 509 00:24:15,620 --> 00:24:15,800 So. 510 00:24:16,060 --> 00:24:17,420 First one, we see this one. 511 00:24:17,460 --> 00:24:20,000 This is the most interesting one because, like, okay, why this 512 00:24:20,580 --> 00:24:24,040 consumer is trying to call CMD and then call PowerShell with an 513 00:24:24,040 --> 00:24:24,540 encoded command? 514 00:24:26,280 --> 00:24:26,680 Okay. 515 00:24:27,440 --> 00:24:29,540 Here we can see the filter that I was talking about. 516 00:24:29,740 --> 00:24:33,700 So, basically, it's waiting for the task manager creation. 517 00:24:35,360 --> 00:24:39,220 So, this is one approach, but in alone, it's not that strong 518 00:24:39,220 --> 00:24:42,440 because it could be something that is happening normally in 519 00:24:42,440 --> 00:24:42,840 the system. 520 00:24:43,240 --> 00:24:44,480 This is a little bit strange. 521 00:24:44,480 --> 00:24:46,620 But that's a different approach. 522 00:24:47,380 --> 00:24:50,400 Also, we want to monitor this process because this process 523 00:24:50,400 --> 00:24:52,500 will be calling something suspicious. 524 00:24:52,760 --> 00:24:56,000 In this case, this process is calling CMD that will call 525 00:24:56,000 --> 00:24:57,680 PowerShell that will call notepad. 526 00:24:58,800 --> 00:25:02,200 So, what we did was to create those two alarms. 527 00:25:02,380 --> 00:25:04,120 And let me show you one of those. 528 00:25:08,420 --> 00:25:11,720 So, here we are monitoring what this process is calling. 529 00:25:11,920 --> 00:25:13,980 And when this process is calling one of these, 530 00:25:14,940 --> 00:25:16,660 binaries, we trigger an alarm. 531 00:25:18,000 --> 00:25:22,580 In this case, we monitor when event 20 that is the creation of 532 00:25:22,580 --> 00:25:26,760 WMI object has as a target, so this is the destination of the 533 00:25:27,340 --> 00:25:29,960 consumer calling something, one of these. 534 00:25:32,320 --> 00:25:36,160 So, as you can expect, it works because we test this several 535 00:25:36,160 --> 00:25:36,360 times. 536 00:25:36,740 --> 00:25:42,300 So, here we have the system and we might call a suspicious 537 00:25:42,300 --> 00:25:42,680 program. 538 00:25:43,780 --> 00:25:44,260 Okay. 539 00:25:44,840 --> 00:25:48,500 So, I will give the voice back to Rick. 540 00:25:55,260 --> 00:25:59,260 So, as shown before, we have the technology to actually do this. 541 00:25:59,340 --> 00:26:02,120 However, just having a system that does this for you does not 542 00:26:02,120 --> 00:26:04,280 mean that you don't have to do anything. 543 00:26:04,500 --> 00:26:07,700 I think the most important part of having the ability to see all 544 00:26:07,700 --> 00:26:11,500 this is having a process and a team behind it that's actually 545 00:26:11,500 --> 00:26:14,460 capable of translating threats to the system. 546 00:26:14,460 --> 00:26:15,220 To actual work. 547 00:26:15,640 --> 00:26:19,260 There's, like, the WMI event consumer, that's a trick to 548 00:26:19,260 --> 00:26:19,840 describe the miner. 549 00:26:20,100 --> 00:26:20,620 That's fun. 550 00:26:20,840 --> 00:26:24,180 But you need to translate that to an actual detection rule so you 551 00:26:24,180 --> 00:26:25,060 can do something with it. 552 00:26:25,440 --> 00:26:28,080 So, we had a couple of discussions internally. 553 00:26:28,320 --> 00:26:31,920 And we had many, many different flowcharts. 554 00:26:32,420 --> 00:26:35,680 And then we decided to not have a big one here. 555 00:26:36,380 --> 00:26:38,120 To not try and not annoy you. 556 00:26:38,320 --> 00:26:43,920 So, how would this actually work in the, yeah, if you implement this? 557 00:26:44,040 --> 00:26:44,440 Okay. 558 00:26:44,460 --> 00:26:54,420 I would say you wait for some InfoSec news, an incident happening at your company, new information being released, a report on some APT group. 559 00:26:54,740 --> 00:26:57,820 And the first thing you do is you try to understand what's actually happening. 560 00:26:58,120 --> 00:27:03,420 The moment you do, you can start searching back in your own network, have I ever seen this before? 561 00:27:03,640 --> 00:27:05,720 Because that might also be interesting to know. 562 00:27:06,060 --> 00:27:10,940 And if you don't, you can go and look for a way on how to emulate it. 563 00:27:11,020 --> 00:27:13,820 So make your own way of emulating the threat. 564 00:27:14,460 --> 00:27:17,280 Or maybe get a sample, execute it, see what's happening. 565 00:27:17,640 --> 00:27:20,740 So that could help create at least a hunt. 566 00:27:20,900 --> 00:27:28,360 And if you get a really great hunt, you can let that evolve and eventually create a nice detection rule. 567 00:27:29,240 --> 00:27:36,640 And in the end, have something implemented which will allow you to automatically detect a specific threat. 568 00:27:36,920 --> 00:27:39,620 So it's not like something you put in immediately. 569 00:27:39,700 --> 00:27:41,660 It's something that has to evolve. 570 00:27:42,600 --> 00:27:44,440 So for those of you who don't like flowcharts, 571 00:27:44,460 --> 00:27:46,800 we made another one, but done with pictures. 572 00:27:48,640 --> 00:27:54,340 So the thing how it will actually work, so let's say you found something, your hunt's perfect, 573 00:27:54,580 --> 00:28:00,540 and you made a nice, I hope, Sigma rule, because we can all benefit from that. 574 00:28:00,940 --> 00:28:05,820 The first thing you do is you generate rules for your platform, which in our case is like ElastAlert, 575 00:28:05,900 --> 00:28:09,580 but it could also be Splunk, or, I don't know, ArcSight or something. 576 00:28:10,020 --> 00:28:13,970 That will put any, that will be keep searching on our Elastic stack. 577 00:28:15,700 --> 00:28:23,240 You can then automate or do a unit test of all your rules using Retium Automation. 578 00:28:23,800 --> 00:28:30,180 And any, well, that will obviously generate some logging, the logging will be put into the Elastic stack. 579 00:28:30,780 --> 00:28:37,100 ElastAlert will hopefully find whatever you are trying to do, and put that into the alarms index, 580 00:28:37,340 --> 00:28:39,760 so you will be able to review that alarm. 581 00:28:40,820 --> 00:28:43,680 So, how would we actually, how would this actually work? 582 00:28:43,840 --> 00:28:44,440 So let's say, 583 00:28:44,440 --> 00:28:50,540 you wake up one morning, and Matt Graber thinks of another thing, and you have to handle it. 584 00:28:50,700 --> 00:28:58,340 So this was, while we were doing this research, this was a tweet by Matt Graber describing an application whitelisting bypass 585 00:28:59,280 --> 00:29:03,640 that would allow you to execute commands using some signed Windows binary. 586 00:29:04,060 --> 00:29:09,760 So the great thing of this research was actually that only 20% of the blog focused on exploitation, 587 00:29:10,120 --> 00:29:12,720 and about 80% focused on defense. 588 00:29:13,020 --> 00:29:14,300 So that already does, 589 00:29:14,300 --> 00:29:16,200 it does a lot of work for you, so that's lucky. 590 00:29:16,440 --> 00:29:17,720 That's also lucky for the demo. 591 00:29:19,140 --> 00:29:26,880 So it describes a way to actually execute and bypass the application whitelisting. 592 00:29:27,220 --> 00:29:31,580 And it also came with a nice POC, so a nice proof of concept. 593 00:29:31,840 --> 00:29:37,320 In this case, I think it executed something like calc, or at least it does in our demo. 594 00:29:38,020 --> 00:29:43,940 So what we did is we actually created a Retium Automation script for this, which will allow 595 00:29:43,940 --> 00:29:47,780 us to execute squibbley foo, because that's the name. 596 00:29:49,000 --> 00:29:58,520 Which, what it does, it drops a XSL file, and then tries to execute that using winrm.vbs. 597 00:29:59,320 --> 00:30:06,580 The thing is, there's like four ways to call it, and there's two different files you can 598 00:30:06,580 --> 00:30:08,320 actually use to exploit this. 599 00:30:08,800 --> 00:30:10,980 So there's now eight calcs being popped up. 600 00:30:11,140 --> 00:30:13,920 For those of you who are very interested, I can show you later how it works. 601 00:30:17,140 --> 00:30:17,820 Sorry. 602 00:30:21,020 --> 00:30:23,620 So first thing, there's two files. 603 00:30:24,300 --> 00:30:34,100 There's the WSM-TXT and WSM-PTY.xsl, which need to be created in order to have the file. 604 00:30:34,240 --> 00:30:40,740 It's an XML-ish format, which has, which you can embed some JavaScript in there, or 605 00:30:40,740 --> 00:30:42,800 VBScript, which will allow you to execute. 606 00:30:42,800 --> 00:30:45,460 However, that on its own wouldn't be enough. 607 00:30:45,640 --> 00:30:52,860 So you need to actually see something, because just alerting on the existence of like an 608 00:30:52,860 --> 00:30:54,800 XSL file would be a bit silly. 609 00:30:55,140 --> 00:30:59,760 So the thing is, there's actually a pretty particular way you need to call this. 610 00:31:00,040 --> 00:31:04,500 So the winrm.vbs needs to be in the command line, because we can't modify that file. 611 00:31:04,800 --> 00:31:10,460 And as you can see, you can see cscript.exe slash winword.exe. 612 00:31:10,460 --> 00:31:17,780 So the winrm.script verifies if cscript.exe is somewhere in its command line. 613 00:31:18,060 --> 00:31:20,260 But it doesn't have to be the binary that calls it. 614 00:31:20,380 --> 00:31:24,880 So if you would just look at the binary name, you would actually get bypassed. 615 00:31:24,880 --> 00:31:26,400 And the same goes for all these formats. 616 00:31:26,880 --> 00:31:29,240 There's like four different ways to call it. 617 00:31:29,920 --> 00:31:32,840 So the RTA file helped us actually figure that out. 618 00:31:33,680 --> 00:31:37,420 So what would be nice is to have the ability to actually correlate these two events. 619 00:31:37,660 --> 00:31:39,000 So we have two loose alarms. 620 00:31:39,240 --> 00:31:39,540 And... 621 00:31:40,460 --> 00:31:44,540 You could use a human to do that, but then you get very bored analysts, and that's not 622 00:31:44,540 --> 00:31:44,940 so nice. 623 00:31:45,280 --> 00:31:51,000 So what we did is we created something for this, because Elasticsearch does not allow 624 00:31:51,000 --> 00:31:51,820 for correlation. 625 00:31:53,340 --> 00:31:55,340 ElastAlert also does not allow for correlation. 626 00:31:55,720 --> 00:32:02,580 So we invented something called ghetto correlation, which is correlation for people who don't 627 00:32:02,580 --> 00:32:03,680 have fancy systems. 628 00:32:04,380 --> 00:32:06,520 What we actually did is we use... 629 00:32:06,520 --> 00:32:08,360 We look at our own alerts index. 630 00:32:08,940 --> 00:32:10,300 And we use the frequency. 631 00:32:10,300 --> 00:32:15,980 And we use the frequency function within ElastAlert to see, okay, can we get two Scribbly-Foo 632 00:32:15,980 --> 00:32:21,240 related alarms on the same system within X period of time? 633 00:32:21,520 --> 00:32:23,980 And then you would be able to actually correlate. 634 00:32:24,180 --> 00:32:29,060 Which is great, because as mentioned earlier by Leandro, there are some events that are 635 00:32:29,060 --> 00:32:31,440 suspicious but not enough to actually alert on. 636 00:32:31,900 --> 00:32:36,380 But you could actually add like a suspicious tag and have like, okay, there's multiple 637 00:32:36,380 --> 00:32:40,280 suspicious events on the same system within an hour or one minute. 638 00:32:40,300 --> 00:32:41,100 It doesn't really matter. 639 00:32:41,340 --> 00:32:47,100 So you could actually like gain something from all those like quirky things that are 640 00:32:47,100 --> 00:32:50,340 not necessarily bad, but you might want to do something about. 641 00:32:51,230 --> 00:32:53,420 So ghetto correlation might be for you. 642 00:32:56,220 --> 00:33:03,260 Well, and the funny thing was this morning we woke up and Matt Graber and I think Lee 643 00:33:03,260 --> 00:33:08,320 Holmes published their slides on supporting sysmon, which actually kind of defeats the 644 00:33:08,320 --> 00:33:09,740 purpose of the whole thing. 645 00:33:10,400 --> 00:33:14,540 So we were looking at that, and it's actually pretty cool, because they were actually pretty 646 00:33:14,540 --> 00:33:16,280 good at subverting it. 647 00:33:17,200 --> 00:33:20,420 So we didn't make a full demo of this, and it might fail. 648 00:33:21,620 --> 00:33:24,940 But the thing is, it turns out that sysmon, oh, sorry, dude. 649 00:33:25,780 --> 00:33:27,120 So this was this tweet. 650 00:33:27,220 --> 00:33:28,240 I woke up to this thing. 651 00:33:28,380 --> 00:33:29,420 It's not very nice. 652 00:33:31,120 --> 00:33:33,440 And then we looked at the slides. 653 00:33:33,520 --> 00:33:35,140 There are multiple ways of subverting sysmon. 654 00:33:35,220 --> 00:33:37,980 There's also a lot of ways to subvert like PowerShell script log logging. 655 00:33:38,340 --> 00:33:39,360 But the fun thing is. 656 00:33:39,360 --> 00:33:45,180 You can actually look for the subversion attempts, which also are a regular user is not going 657 00:33:45,180 --> 00:33:47,720 to try and subvert sysmon or PowerShell script log logging. 658 00:33:47,780 --> 00:33:48,100 That's weird. 659 00:33:48,520 --> 00:33:50,240 So what we did is we looked at it. 660 00:33:50,560 --> 00:33:57,120 So what happens is the way sysmon logs the event consumers and the event filters and 661 00:33:57,120 --> 00:34:01,640 all the things is actually by looking at one specific namespace. 662 00:34:01,920 --> 00:34:07,460 So what the guys did was actually create a script that adds another namespace, and that 663 00:34:07,460 --> 00:34:09,340 hosts the active script log. 664 00:34:09,360 --> 00:34:16,460 So then the script will still like filter and execute things, but sysmon doesn't detect 665 00:34:16,460 --> 00:34:17,160 anything anymore. 666 00:34:17,580 --> 00:34:21,560 So we looked at that in order to figure out, oh, wait, yeah, there's a GitHub, too. 667 00:34:21,720 --> 00:34:26,360 So for those of you who want to play with that, where are you? 668 00:34:26,720 --> 00:34:27,880 It's not in there. 669 00:34:33,080 --> 00:34:38,180 So as we said, we just built this like an hour before the talk. 670 00:34:38,380 --> 00:34:38,440 So. 671 00:34:39,360 --> 00:34:45,680 So we're reusing their POC, and as you can see, there's like if task manager opens, WMI 672 00:34:45,680 --> 00:34:49,880 file drop.txt gets created, it's just we needed to execute something. 673 00:34:50,260 --> 00:34:53,340 We actually stole their POC, so no credit there. 674 00:34:54,600 --> 00:34:56,700 But the thing is, we started looking at that. 675 00:34:56,840 --> 00:35:00,360 So what is how could we even detect this? 676 00:35:00,500 --> 00:35:02,740 Is there any possibility of this? 677 00:35:02,960 --> 00:35:08,560 Because we checked, it doesn't log the creation of the WMI event consumer or any of those. 678 00:35:08,560 --> 00:35:11,100 So what is there? 679 00:35:11,400 --> 00:35:13,740 What's there is limited, but might be interesting. 680 00:35:14,700 --> 00:35:22,300 As you can see, there is a Windows event ID 63 message, event message, that says that 681 00:35:22,300 --> 00:35:26,220 a new provider was registered in a new namespace. 682 00:35:26,720 --> 00:35:32,440 So we looked at that, and this machine has been running for like a couple of months now. 683 00:35:32,800 --> 00:35:38,440 And if you start looking at that, and you do a Windows update, you get a hailstorm. 684 00:35:40,120 --> 00:35:42,980 So it won't work if you update systems. 685 00:35:43,840 --> 00:35:48,420 But if you get one lonely one, and we could do something with frequency there again, you 686 00:35:48,420 --> 00:35:52,080 might be able to detect the fact that something's happening on that system. 687 00:35:52,700 --> 00:35:57,640 At least it's interesting to look at the moment you see other weird events. 688 00:35:59,100 --> 00:36:04,040 But the reason we put it in there was not just to say, like, oh, the system kind of 689 00:36:04,040 --> 00:36:08,420 works on that, but more the fact that you will be able to, like, literally sit in a 690 00:36:08,440 --> 00:36:13,440 back of a room, somebody tweets something, and within an hour have something, something 691 00:36:13,440 --> 00:36:14,160 to look at. 692 00:36:14,360 --> 00:36:18,600 I'm not saying it's, like, the most robust solution, but because you can move pretty 693 00:36:18,600 --> 00:36:19,660 quickly, it's pretty nice. 694 00:36:21,600 --> 00:36:23,160 So enough positive. 695 00:36:24,940 --> 00:36:26,120 Let's talk about limitations. 696 00:36:27,980 --> 00:36:30,500 So yeah, it's all great. 697 00:36:30,680 --> 00:36:31,180 It's amazing. 698 00:36:33,100 --> 00:36:37,960 However, there are some caveats, or there are at least some things that we haven't fully 699 00:36:38,960 --> 00:36:39,480 explored. 700 00:36:39,660 --> 00:36:43,380 So there are some things that might be interesting to improve on. 701 00:36:43,980 --> 00:36:49,380 And I think the main thing would be to look at scalability and robustness of the entire 702 00:36:49,380 --> 00:36:49,820 system. 703 00:36:50,120 --> 00:36:54,140 We know the Elastic Stack can handle lots and lots of data, so that shouldn't be a 704 00:36:54,140 --> 00:36:54,440 problem. 705 00:36:54,680 --> 00:36:56,900 However, for our project, we haven't tried. 706 00:36:57,080 --> 00:36:58,820 So it might fail. 707 00:37:00,180 --> 00:37:01,320 Obfuscation is an issue. 708 00:37:01,980 --> 00:37:07,240 We showed the demo with Emotet, invoked obfuscation by Daniel Bohannon is pretty cool. 709 00:37:07,420 --> 00:37:07,940 It's pretty cool. 710 00:37:08,540 --> 00:37:10,620 Currently, the system doesn't really handle that. 711 00:37:10,760 --> 00:37:17,140 So what you could do is, at ingestion time, try to enrich your events by detecting obfuscation 712 00:37:17,640 --> 00:37:21,120 and say, like, oh, this looks obfuscated, so have a flag or something, or maybe even 713 00:37:21,120 --> 00:37:22,220 try to deobfuscate. 714 00:37:22,460 --> 00:37:28,000 I know there is a PowerShell script for the invoke obfuscation. 715 00:37:28,500 --> 00:37:29,680 That's meant for PowerShell. 716 00:37:29,760 --> 00:37:32,220 So there is an invoke deobfuscation for that. 717 00:37:32,360 --> 00:37:35,240 For the dosfuscation, however, there isn't one. 718 00:37:35,460 --> 00:37:37,420 But it might be very interesting to look at that. 719 00:37:37,420 --> 00:37:41,560 To have something that, at ingestion time, will fix that for you. 720 00:37:43,140 --> 00:37:45,720 Looking at all the commands and things are nice. 721 00:37:45,980 --> 00:37:50,280 However, what if somebody just drops a binary that executes a command and it's gone? 722 00:37:50,840 --> 00:37:52,020 That might be tricky. 723 00:37:52,660 --> 00:37:55,480 You might lose sight of what's happening, actually. 724 00:37:56,040 --> 00:38:01,580 So it might still be nice to, at ingestion time, also enrich your events with threat 725 00:38:01,580 --> 00:38:05,080 intelligence information, such as looking at simple hashes. 726 00:38:05,180 --> 00:38:06,940 I mean, if it's there, why not do it? 727 00:38:08,140 --> 00:38:13,300 Kibana has a Vega framework, which allows you to actually create your own visualizations, 728 00:38:14,300 --> 00:38:19,260 which would allow you to have fancy things for your analysts, like maybe have a process 729 00:38:19,260 --> 00:38:23,980 tree or call stack, all those things, so you could actually visualize it a bit better 730 00:38:23,980 --> 00:38:27,320 and not have to look at, like, a table with all the things in there. 731 00:38:27,480 --> 00:38:30,300 I mean, fine for me, but some people like pretty pictures. 732 00:38:32,440 --> 00:38:37,060 There's been a lot invested into sysmon config tampering. 733 00:38:37,180 --> 00:38:37,400 There's been a lot invested into sysmon config tampering. 734 00:38:37,420 --> 00:38:37,720 There's been a lot invested into sysmon config tampering. 735 00:38:37,720 --> 00:38:40,680 And PowerShell script logging evasion or disabling of it. 736 00:38:40,900 --> 00:38:43,340 I think that's actually great. 737 00:38:43,580 --> 00:38:46,520 It's very good to see that people are actually investing time into that. 738 00:38:46,920 --> 00:38:47,960 So it's good to... 739 00:38:47,960 --> 00:38:49,980 I think it means you're on the right track, right? 740 00:38:50,120 --> 00:38:53,480 All attackers and red teams are now looking into ways to subvert that. 741 00:38:54,580 --> 00:39:00,620 So I think we still need to look at the subversion attempts in order to determine that it's happening. 742 00:39:00,920 --> 00:39:05,880 And I mean, the moment they happen, you lose visibility, but the fact that somebody's trying 743 00:39:05,880 --> 00:39:06,220 to... 744 00:39:07,420 --> 00:39:11,100 Disable PowerShell script log logging might be a strong indication of something weird 745 00:39:11,100 --> 00:39:11,780 going on anyway. 746 00:39:12,920 --> 00:39:15,000 And the last thing would be bring your own land. 747 00:39:15,280 --> 00:39:21,720 There are people now, like, dropping their own run DLL 32, but named blah, blah, blah.exe, 748 00:39:21,820 --> 00:39:26,620 which kind of defeats most of those detections, because they're all based on names, and that 749 00:39:26,620 --> 00:39:27,300 doesn't work anymore. 750 00:39:28,000 --> 00:39:29,200 So that might be an issue. 751 00:39:30,220 --> 00:39:35,260 So in conclusion, I think this whole endpoint monitoring with free and open source software 752 00:39:35,260 --> 00:39:35,880 really works. 753 00:39:35,980 --> 00:39:36,280 All right. 754 00:39:37,260 --> 00:39:37,740 Wow. 755 00:39:38,380 --> 00:39:40,160 Who would have guessed I would say that? 756 00:39:41,040 --> 00:39:43,760 But it does allow for experimentation without a budget. 757 00:39:43,940 --> 00:39:45,020 It's very easy to start. 758 00:39:45,540 --> 00:39:46,760 There's no licensing cost. 759 00:39:47,000 --> 00:39:47,460 It's flexible. 760 00:39:47,700 --> 00:39:49,140 It's scalable, we think. 761 00:39:50,780 --> 00:39:56,060 And it will give you and your analyst a pretty fun time trying to figure out all the things 762 00:39:56,060 --> 00:39:56,620 that are happening. 763 00:39:57,040 --> 00:40:02,880 So you can go from an incident to a hunt to an alarm pretty quickly, as shown with the 764 00:40:03,600 --> 00:40:04,920 SysMonster version thing. 765 00:40:04,920 --> 00:40:12,400 You can give your analyst more context than the blinky box with its bad sign, and it can 766 00:40:12,400 --> 00:40:18,040 also get your analyst very enthusiastic about new red teaming attacks, because it's not 767 00:40:18,040 --> 00:40:21,980 just a new attack and you have to wait for an update so your system really detects something, 768 00:40:22,240 --> 00:40:24,700 but you would have the ability to actually do something. 769 00:40:24,880 --> 00:40:29,180 So figure out what it does, figure out how it works, and then try and stop it. 770 00:40:29,740 --> 00:40:31,780 And that makes for happy and skilled analysts. 771 00:40:31,780 --> 00:40:35,260 So that's our presentation. 772 00:40:36,120 --> 00:40:41,780 If any of you would want to do anything with this, we uploaded all our Pocs, the configs, 773 00:40:41,800 --> 00:40:43,580 the Sigma things to GitHub. 774 00:40:44,460 --> 00:40:45,860 Just trust the QR code. 775 00:40:47,880 --> 00:40:50,560 There's no goatee there, I promise you. 776 00:40:51,300 --> 00:40:55,860 You can also read our paper, because this is all based on a paper called Fileless Threats, 777 00:40:55,860 --> 00:40:57,200 Analysis and Detection. 778 00:40:58,240 --> 00:40:59,180 Just review it. 779 00:40:59,260 --> 00:41:01,760 If you have any questions or any comments like, you fucked up here. 780 00:41:01,780 --> 00:41:02,600 Or you did this wrong. 781 00:41:02,740 --> 00:41:04,760 Or I have done it better. 782 00:41:05,260 --> 00:41:06,160 Please let us know. 783 00:41:06,240 --> 00:41:06,900 We want to learn. 784 00:41:07,660 --> 00:41:09,740 So does anybody have any questions? 785 00:41:12,400 --> 00:41:13,300 Dude in the back. 786 00:41:21,540 --> 00:41:25,260 So we actually tried, and we had like 40 megs a day. 787 00:41:25,440 --> 00:41:30,980 But it might be worse if you're using like a server or a terminal server, a domain controller. 788 00:41:30,980 --> 00:41:33,280 That might be way more. 789 00:41:35,800 --> 00:41:36,840 Any other questions? 790 00:41:46,880 --> 00:41:49,580 That's Olaf's blog, I guess. 791 00:41:49,760 --> 00:41:50,880 Is it recent blog series? 792 00:41:55,260 --> 00:41:56,000 I don't know. 793 00:41:56,080 --> 00:41:57,480 Might be the one by Olaf. 794 00:41:57,600 --> 00:41:59,880 He focused a lot on tuning it down. 795 00:41:59,880 --> 00:42:05,140 So if you have a system that like you have to pay per event or you just don't have the 796 00:42:05,140 --> 00:42:07,520 ability to store too much, look at his config. 797 00:42:07,780 --> 00:42:08,720 It's really nice. 798 00:42:08,900 --> 00:42:10,800 And it like narrows things down. 799 00:42:10,960 --> 00:42:14,800 And he made like an entire blog series on it on how to do that and how to work with 800 00:42:14,800 --> 00:42:14,920 it. 801 00:42:15,000 --> 00:42:17,520 And he made a nice Splunk app to hunt and stuff. 802 00:42:18,300 --> 00:42:19,060 It's really good. 803 00:42:21,240 --> 00:42:22,760 Any other questions? 804 00:42:24,380 --> 00:42:24,780 Nope. 805 00:42:24,840 --> 00:42:25,180 Okay. 806 00:42:25,240 --> 00:42:25,840 Thank you, guys. 807 00:42:26,120 --> 00:42:26,200 Oh. 808 00:42:26,680 --> 00:42:27,260 Sorry, dude. 809 00:42:29,920 --> 00:42:29,980 Bye.