00:00:00.100,00:00:04.905 >>Alright! Aloha and welcome to my talk. Uh today we’re going to be talking about Harnessing 00:00:04.905,00:00:09.910 Weapons of Mac Destruction. My name is Patrick. I am a security researcher at Jamf. Uh 00:00:11.912,00:00:18.151 previously I was a co-founder at Digita Security. And I’m also the creator of the Mac security 00:00:18.151,00:00:24.658 website and tool suite Objective-See. So today we’re gonna be talking about 00:00:24.658,00:00:30.731 repurposing other people's malware for our own surreptitious purposes. We’ll 00:00:30.731,00:00:36.737 start by showing why this is rather an excellent idea and then show exactly how to 00:00:36.737,00:00:41.742 repurpose various Mac malware samples. Of course we want our repurposed samples to remain 00:00:44.411,00:00:49.950 undetected both by Apple’s built-in malware mitigations and third party AV products. So 00:00:49.950,00:00:54.955 we’ll address that as well. Finally, we’ll end by covering various generic may, methods to 00:00:57.391,00:01:02.963 detect these repurposed uh creations because really our ultimate goal is to ensure that 00:01:02.963,00:01:07.968 Mac users remain protected. So let’s dive in. So here we have a diagrammatic overview that 00:01:12.406,00:01:17.411 conceptually explains the repurposing process. So imagine that spy A has developed some 00:01:19.479,00:01:25.285 neat uh sophisticated uh fully featured malware and has deployed it to various targets, 00:01:25.285,00:01:31.258 right? Infected various systems around the world. Spy B somehow captures this malware. Uhh 00:01:31.258,00:01:37.431 perhaps either in transit or pulls it off an infected system. Spy B then will take this 00:01:37.431,00:01:42.235 malware sample to her lab and then repurpose it. So what do we mean when we talk about 00:01:42.235,00:01:47.040 repurposing? Well we’ll get into this more shortly but basically we’re talking about 00:01:47.040,00:01:52.412 reconfiguring a piece of existing malware so that you can use it for your own 00:01:52.412,00:01:58.552 surreptitious purposes. So for example we can see on the slide once spy B has repurposed the 00:01:58.552,00:02:03.857 malware, she can now redeploy that against new targets and instead of beaconing back to spy 00:02:03.857,00:02:10.197 A’s infrastructure for tasking, it’ll talk to her new infrastructure instead. Now you 00:02:10.197,00:02:15.035 might be thinking, okay, this seems like a reasonably neat idea, but why? And we’ll talk 00:02:15.035,00:02:20.807 about two reasons that hopefully show that we should really be asking, why not? So first, there 00:02:20.807,00:02:25.812 are incredibly well funded uh incredibly well resourced uh very motivated hackers, APT 00:02:27.814,00:02:32.886 groups and three lever, three letter government agencies that are creating some incredible 00:02:32.886,00:02:37.991 malware. Uh this malware is fully featured and has the benefit of being fully tested. A 00:02:37.991,00:02:43.130 lot of times already even tested in the wild. Now I’m rather lazy. I would rather be sleeping 00:02:43.130,00:02:48.568 on the beach or surfing or doing yoga so I figured why not let these groups create this 00:02:48.568,00:02:55.042 incredible malware and then we can just repurpose it for our own missions. The idea is to let 00:02:55.042,00:03:01.882 those with more time, resources and money do all the hard work. Secondly if our repurposed 00:03:01.882,00:03:07.320 creations that we redeploy get captured, it’s very likely that they will be misattributed back 00:03:07.320,00:03:13.727 to the original authors, not to us. This is great. Now you might be thinking, okay Patrick, if 00:03:13.727,00:03:18.398 this is such an amazing idea why aren't people already doing this? Well and the answer is, 00:03:18.398,00:03:25.072 they are. Now I can't comment specifically on this but leaked slide, uh slides appear to inda, 00:03:25.072,00:03:31.278 indicate that the NSA has had this capability for awhile. Also recent reporting from the New 00:03:31.278,00:03:37.818 York Times claims that the Chinese are doing this as well. Now to these well resourced 00:03:37.818,00:03:44.524 agencies the benefit of using repurposed malware is twofold. First, it allows them to deploy 00:03:44.524,00:03:51.465 other countries’ malware into risky environments. For example, perhaps a target where another 00:03:51.465,00:03:56.770 agency, another country, another APT group already exists. So imagine you're in the NSA, you 00:03:56.770,00:04:01.108 ta, you hack a high value target, you find out, well, someone else is already there. 00:04:01.108,00:04:05.412 Obviously you don’t wanna put your primary implants on that system. So, if you have a 00:04:05.412,00:04:09.883 repurposed implant that you can use, might as well put that down. Also we already talked 00:04:09.883,00:04:14.321 about attribution. These agencies don’t like people to know what they’re up to, so if 00:04:14.321,00:04:20.727 they can use repurposed malware, perhaps this muddles the attribution picture. Now of 00:04:20.727,00:04:24.498 course there's gonna be challenges to repurposing malware, if there weren't, we 00:04:24.498,00:04:29.536 wouldn’t be talking about it today. But we’ll see these challenges are not 00:04:29.536,00:04:35.142 insurmountable. So, first, generally speaking, if we capture a piece of malware to 00:04:35.142,00:04:39.079 repurpose we’re not going to have the source code for the malware. We’re just gonna have a 00:04:39.079,00:04:45.819 binary image, so we’ll have to reverse engineer the malware at the binary level. This is kinda 00:04:45.819,00:04:50.524 the analysis stage, I like to call it, and what we’re doing is we’re trying to figure out and 00:04:50.524,00:04:55.362 gain an understanding of what the malware does. Answering questions such as, how does it 00:04:55.362,00:05:00.267 persist? How does it install? And what its capabilities are. And of course what command and 00:05:00.267,00:05:05.539 control servers it talks to. Then with such an understanding we have to figure out exactly 00:05:05.539,00:05:10.277 how to patch the malware. Again, usually we don’t have a source code the, so this involves 00:05:10.277,00:05:16.416 patching at the binary level. Now if the malware talks to a remote command and control 00:05:16.416,00:05:20.821 server, which most do, we will have to figure out how the malware determines where to get 00:05:20.821,00:05:26.059 the address of that server. And then also understand the protocol so we can create our 00:05:26.059,00:05:31.665 own command and control server, so when we redeploy the repurposed malware we can 00:05:31.665,00:05:36.903 communicate with our new infected systems. And then finally since we are repurposing 00:05:36.903,00:05:42.409 general known, generally know malware, it’s likely that Apple or AV products already have 00:05:42.409,00:05:46.346 detection signatures for this. So we have to co, we have to talk and we have to figure out 00:05:46.346,00:05:51.484 how to get around that because obviously, it would be rather unfortunate if you deployed some 00:05:51.484,00:05:57.490 repurposed malware only to have it detected. Now I want to reiterate that it’s very 00:05:57.490,00:06:02.028 important to take these challenges seriously and get them right because if not, 00:06:02.028,00:06:07.334 relatively bad things can happen. Here for example we’ve attempted to comprehensively 00:06:07.334,00:06:13.473 repurpose a piece of Mac malware but it turns out that we forgot to modify, or patch out, the 00:06:13.473,00:06:19.646 addresses of the backup command and control servers. This means if we deploy what we believe to 00:06:19.646,00:06:25.018 be a fully repurposed piece of malware, at some point it may beacon back to the original 00:06:25.018,00:06:30.624 hacker’s infrastructure, giving him or her access to our infected targets. So obviously 00:06:30.624,00:06:34.894 this is something we want to be very aware of and make sure when we are repurposing these 00:06:34.894,00:06:41.835 samples, we’re doing it comprehensively. So now let’s talk about exactly how to 00:06:41.835,00:06:46.840 repurpose Mac malware, with the goal of making their malware, ours. So the first step is to 00:06:50.677,00:06:56.783 select a malware specimen. And that is the sample you want to repurpose. This is usually based 00:06:56.783,00:07:02.088 on two criteria. First you decide what you need the malware to do. Right? Are you looking 00:07:02.088,00:07:08.428 for an interactive back door? Uh perhaps a piece of RAM somewhere? Cryptocurrency miner? 00:07:08.428,00:07:12.866 Take your pick. And then maybe attribution is important to you. Right? Do you want your 00:07:12.866,00:07:18.805 repurposed sample to originally belong to a three letter agency? A Russian hacking group? So, 00:07:18.805,00:07:24.544 again, if it get, gets caught it’ll be likely misattributed to them. So on my website, 00:07:24.544,00:07:29.416 Objective-See dot com, I have a very comprehensive collection of Mac malware. So that’s a great 00:07:29.416,00:07:34.387 place to start. And all the samples we’re talking about today, that will repurpose, the 00:07:34.387,00:07:39.392 original specimens are available for download. Now, once you’ve selected your malware sample, 00:07:41.795,00:07:46.800 it’s time to analyze it. [inaudible] The main goal is to figure out things like uh, if it 00:07:53.973,00:07:58.745 has any remote access, right? If it’s talking to your remote command and control server, we 00:07:58.745,00:08:03.683 want to know what that server is so that in the malware we can modify it to instead talk to us. 00:08:05.752,00:08:10.390 If the malware does talk to our remand, uh, remote command and control server, we also need to 00:08:10.390,00:08:16.296 understand the protocol so that we can task it when it connects back to us. And, of course, you 00:08:16.296,00:08:21.034 want to fully understand the malware’s capability. Both locally, how does it persist? 00:08:21.034,00:08:26.239 How does it interact with the system? And then also, remotely. What commands can we remotely 00:08:26.239,00:08:31.244 task the malware with? So once you have a comprehensive understanding of the malware, 00:08:33.513,00:08:39.219 it’s time to actually reconfigure or repurpose it. Generally this means we’ll have 00:08:39.219,00:08:44.391 to patch the malware at the binary level. So here, for example, as we can see on the 00:08:44.391,00:08:49.062 slide, we’ve located the addresses of the malware’s remote command and control 00:08:49.062,00:08:55.835 servers directly imbedded in the malware’s binary. We can simply modify these bytes, for example 00:08:55.835,00:09:02.041 in a Hex editor, to change that address to point to our own command and control server. This 00:09:02.041,00:09:07.046 means now when we take this malware and redeploy it, the malware will beacon, connect 00:09:07.046,00:09:12.051 back to our infrastructure, and be ready for tasking. Now as I mentioned, if the malware is a 00:09:15.155,00:09:20.160 back door or an implant, uh, and expects to talk to a command and control server, well if we’re 00:09:22.162,00:09:27.233 repurposing it, we’re gonna have to write our own custom command and control server as well. This 00:09:27.233,00:09:31.504 will obviously ensure that when the malware checks in and connects back to us, we can give 00:09:31.504,00:09:37.310 it tasking and fully exploit it’s remote capabilities. Now such a custom command and 00:09:37.310,00:09:42.182 control server really doesn’t have to be anything incredibly fancy, usually whip up a simple 00:09:42.182,00:09:47.153 python script. But if you’re planning on deploying these repurposed malware samples to 00:09:47.153,00:09:52.525 many targets you might want something more comprehensively. Uh at a previous DefConwe talked 00:09:52.525,00:09:58.998 about one such custom command and control server with the goal of analyzing a sample. Now 00:09:58.998,00:10:03.403 obviously each specimen you repurpose is going to be different in the sense that it 00:10:03.403,00:10:08.608 likely has a different protocol and thus will need a custom command and control server for 00:10:08.608,00:10:15.014 that specimen, but that paper is kind of a good place to start. Alright so now let’s walk 00:10:15.014,00:10:19.686 through some actual examples repurposing some Mac malware. And we’re gonna start with a 00:10:19.686,00:10:26.559 sample called FruitFly. FruitFly is a rather unique piece of Mac malware. It was originally 00:10:26.559,00:10:31.965 developed over fifteen years ago uh remaining in the wild and only very recently became 00:10:31.965,00:10:38.872 detected. It’s a fully featured back door, which supports a myriad of remotely taskable 00:10:38.872,00:10:45.645 capabilities which really makes it the perfect candidate for us to repurpose. As we’ll see we 00:10:45.645,00:10:51.551 can very trivially repurpose this malware, and then that gives us access to a proven, 00:10:51.551,00:10:58.291 fully featured back door that we can utilize for our own subversive purposes. FruitFly is 00:10:58.291,00:11:03.730 actually written as a perl script. Though it’s highly obfuscated, if we take a peek at 00:11:03.730,00:11:09.068 the back door, we can see logic that processes command line arguments. That is to say the 00:11:09.068,00:11:14.574 script will check if it’s been invoked with certain command line arguments, parameters or 00:11:14.574,00:11:20.980 flags. Turns out it’s looking for a port or a port and IP combo of the command and control 00:11:20.980,00:11:25.752 server to connect to. So this means if we specify our own via the command line then we don’t 00:11:25.752,00:11:31.758 actually have to modify the perl script or the malware binary itself. So what we can do is we 00:11:31.758,00:11:38.197 can persist this, this malware, FruitFly, uh as a launch agent. As we can see on the slide we 00:11:38.197,00:11:45.038 can pass in our address of our command and control server. So this means we can trivially 00:11:45.038,00:11:49.509 repurpose this back door to connect to our custom command and control server. Right? 00:11:49.509,00:11:53.346 Because we can specify in the command line, we can now push that out, give the address of 00:11:53.346,00:11:57.383 our own server and the malware, when it runs, will connect directly back to us instead of 00:11:57.383,00:12:03.890 the hacker’s original servers. But to deploy this we need an installer. Good news, previously 00:12:03.890,00:12:09.195 I wrote one that’s available on pace/bin. As we can see, it's just a few lines of code which 00:12:09.195,00:12:14.334 persistently installs the malware in a manner that matches how it was uncovered in the 00:12:14.334,00:12:20.006 wild. Finally, as I had previously written the custom command and control server to 00:12:20.006,00:12:25.511 analyze the sample we can just review this. So, we’re gonna do a live demo now. Live demos are 00:12:25.511,00:12:30.416 always risky. And actually we’re gonna run this on my laptop. This is my own personal 00:12:30.416,00:12:34.754 developer laptop. Not gonna run this in a VM. Because again, I wanna show you the power of this 00:12:34.754,00:12:38.491 repurposed malware and once we’ve repurposed it, it’s essentially trustworthy. So 00:12:38.491,00:12:43.496 let’s see this in action. So the first thing we’re gonna do is we’re gonna run the command and 00:12:45.999,00:12:50.403 control server. This is listening for connections. And then we are going to execute the 00:12:50.403,00:12:55.041 malware uh specifically via the installer, passing in the address of our command and 00:12:55.041,00:12:59.679 control server. When we run this, we can see that the malware now has connected to our 00:12:59.679,00:13:04.384 command and control server on the right. And we see there’s a myriad of capabilities that we 00:13:04.384,00:13:09.756 can now task this malware. Again this is running on my own personal box. So for example if 00:13:09.756,00:13:14.994 we execute command number thirteen, this will tell us where the malware is installed. 00:13:14.994,00:13:20.733 We can see it’s running out of users/patrick/fpsaud. We can also do things like take a 00:13:20.733,00:13:26.939 screenshot, that is command number two. Execute that, we gave it a parameter of zero 00:13:26.939,00:13:32.211 saying we want a full screen capture. And this will tell the malware, which has been deployed 00:13:32.211,00:13:36.416 to my personal system now, to please take a screenshot and send it back to the commanding 00:13:36.416,00:13:43.322 control server. So we can kill the server. And we can open the screenshot. And we can see, yea, 00:13:43.322,00:13:48.327 it took an entire screenshot of the desktop. Okay so that’s FruitFly. Now let’s talk about 00:13:53.800,00:13:58.471 repurposing a cryptocurrency miner because maybe you wanna make a lot of money mining 00:13:58.471,00:14:03.076 cryptocurrency on other people’s computers but you don’t have the skills, time or resources to 00:14:03.076,00:14:09.982 write your own. So our target is called CreativeUpdate. This cryptocurrency miner was spread 00:14:09.982,00:14:14.921 via tojan, trojanized applications and then spread via the popular third party 00:14:14.921,00:14:21.828 application website Mac update dot com. If we mount the malicious disk image that 00:14:21.828,00:14:27.333 contains one of these trojanized applications, and reverse engineer the application’s main 00:14:27.333,00:14:33.906 binary, we can see it invoking a method called execute script with privs. And if we look at 00:14:33.906,00:14:39.345 what this method does in a decompiler or disesembler, we can see it simply executes a 00:14:39.345,00:14:45.318 file named script out of the application’s resource directory. So if we take a peek 00:14:45.318,00:14:51.290 at this script, we can see it first launches the real pristine copy of the application that it 00:14:51.290,00:14:56.028 had trojanized. For example, Firefox. Uh and this is so the user who has downloaded this 00:14:56.028,00:15:02.635 infected, trojanized application doesn’t think anything is amiss. We can then see in the script it 00:15:02.635,00:15:07.907 beac, beacons out or connects out to a download server to download a zip archive named 00:15:07.907,00:15:13.946 mdworker dot zip. It then extracts this archive and persistently installs something 00:15:13.946,00:15:18.951 named mdworker. If we look at the launch agent P list that persists the malware we can see 00:15:21.487,00:15:27.360 the path to the persistent binary, which is that mdworker binary we just discussed. Also 00:15:27.360,00:15:32.899 we can see some command line arguments that are passed into this binary. If we execute this 00:15:32.899,00:15:38.037 mdworker binary, it turns out it’s a legitimate cryptocurrency miner belonging to a company 00:15:38.037,00:15:44.977 named Miner Gate. The command line arguments therefore specify the miner account. That is where 00:15:44.977,00:15:49.982 to send the mining results and the type of cryptocurrency to mine. So, similar to FruitFly, 00:15:53.119,00:15:59.058 since the relevant parameters are passed via the command line, as say opposed to, directly 00:15:59.058,00:16:04.997 embedded in the malware’s binary, it’s trivial to repurpose this sample. So first 00:16:04.997,00:16:11.971 we simply modify the property list, the P list, to specify our own miner account. And then zip 00:16:11.971,00:16:17.210 up the malware’s components. Now instead of having the malware download that zip from a 00:16:17.210,00:16:22.715 download server we just add the archive to the applications bundle. This is far more simpler 00:16:22.715,00:16:26.686 and self-contained. It means we don’t actually need to set up a remote download server to host 00:16:26.686,00:16:28.988 this second piece. Next we tweak the script so instead it utilizes the zip archive we just 00:16:28.988,00:16:33.993 added. Finally we repackaged everything, ope! And we’re ready to go. So, we’re gonna do live 00:16:40.766,00:16:45.771 demo number two. Just bring up finder window. First I wanna show you the repurposed malware, 00:16:52.511,00:16:57.149 it’s kind of application bundle. We can see this is an app and within the app there is this 00:16:57.149,00:17:00.820 script file. There’s the original FireFox, this is the one that’s signed by mo, 00:17:00.820,00:17:06.859 Mozilla. Uh if we pop over here though, we’ll see that this is what the user downloads and 00:17:06.859,00:17:10.663 expects to run. So what we’re gonna do is we’re gonna run this. This has been 00:17:10.663,00:17:14.533 reconfigured. Again, I am running this on my own personal system. I figured, while I’m up 00:17:14.533,00:17:20.973 on stage I might as well be mining some cryptocurrency. So we’re gonna run this. FireFox 00:17:20.973,00:17:25.978 pops up, everything looks great, the user is stoked they’ve got this great browser. And now if 00:17:25.978,00:17:31.617 we pop back to a terminal window, behind the screens, I’m gonna make this a little bigger. 00:17:31.617,00:17:36.289 We can see that the malware has persistently installed itself. And again if we look at the 00:17:36.289,00:17:41.794 program arguments, we can see that it’s gonna execute the miner named mdworker, but we 00:17:41.794,00:17:47.533 have repurposed it so instead it’s gonna send all the results of the cryptocurrency mining 00:17:47.533,00:17:52.538 operations to me. Sweet. Awesome. Alright, well, since we’re talking about making 00:17:57.677,00:18:02.448 money, right? We all love to do that. Uh perhaps you want to deploy some ransomware without 00:18:02.448,00:18:07.420 spending time writing your own. So now we’ll walk through it, exactly how to repurpose 00:18:07.420,00:18:12.425 KeRanger. KeRanger was the first fully functional, in the wild ransomware targeting Mac OS. 00:18:14.594,00:18:21.200 Hackers infected the popular BitTorrent client transmission on the legitimate application’s 00:18:21.200,00:18:25.705 website. This means that if users went to the transmission website to download the 00:18:25.705,00:18:31.777 BitTorrent client, inadvertently they would get the malicious, infected, trojanized version and 00:18:31.777,00:18:38.751 become infected. Looking at the malware’s binary code we can see it executing something named 00:18:38.751,00:18:44.991 general dot RTF out of the application bundle. Though it appears to be a document, if we 00:18:44.991,00:18:49.295 examine that file a little closer, turns out it’s not a document it’s really a Mach-O 00:18:49.295,00:18:56.102 binary. So what this Mach-O binary does is first sleeps for a few days and then it connects 00:18:56.102,00:19:02.742 out to the attacker’s command and control server, expecting a response consisting of an public 00:19:02.742,00:19:09.048 RSA encryption key and then decryption instructions. It then uses that encryption key to 00:19:09.048,00:19:15.087 encrypt the users files and then displays the decryption instructions that demand a 00:19:15.087,00:19:21.827 ransom. Pretty standard ransom, ransomware functionality. So let’s talk about repurposing 00:19:21.827,00:19:26.966 this ransomware. First we’re gonna wait for three days. We’re kind of in a rush to start 00:19:26.966,00:19:31.270 encrypting people’s files. So what we can do is we can just patch out, nop out the call to 00:19:31.270,00:19:36.709 the sleep function. Pretty easy to do. Then we’re gonna modify the addresses of the servers 00:19:36.709,00:19:43.683 that the ransomware contacts for the public uh RSA encryption key and the decryption instructions. 00:19:43.683,00:19:49.388 As we can see on the slide these addresses are directly embedded in the malware’s binary, so it’s 00:19:49.388,00:19:56.228 pretty easy for us to hop into a Hex editor and change them to the address of our server. Uh, 00:19:56.228,00:20:00.599 pretty easy, right? And here for testing purposes we just set them to local host. One twenty 00:20:00.599,00:20:06.205 seven dot zero dot zero dot one. Now we, we also need a server because the ransomware’s gonna 00:20:06.205,00:20:10.109 connect out when it’s run. expecting that encryption key and decryption instructions. 00:20:10.109,00:20:16.982 Turns out this is really easy to do. We can just take our own public uh RSA key and decryption 00:20:16.982,00:20:23.622 instructions and package that up to, in a text file and then serve that up via netcap. So 00:20:23.622,00:20:29.528 here’s a demo of KeRanger that’s now been repurposed. We’ll see in the terminal window, this is 00:20:29.528,00:20:33.732 our server, again it’s just a netcap serving up the encryption key and the decryption 00:20:33.732,00:20:38.037 instructions. The malware has been repurposed though to talk to this command and control 00:20:38.037,00:20:42.508 server and not the attacker’s original one. And then we’ll start seeing the ransomware 00:20:42.508,00:20:49.348 immediately start encrypting all the files on the desktop. Once the malware has done this, again 00:20:49.348,00:20:52.852 it’s launched when the user launched the transmission application, they’re not gonna 00:20:52.852,00:20:57.323 be privy to anything going on. Uh you know the encryption happens in the background 00:20:57.323,00:21:01.994 although they might see all their files being encrypted. So now when the files are 00:21:01.994,00:21:06.098 encrypted, the user’s gonna be like, crap, this sucks, how’d I get my files decrypted? They’re 00:21:06.098,00:21:11.270 gonna open the read me dot decrypt file and you can now see, we provided our own 00:21:11.270,00:21:16.308 decryption instructions. So here I’ve said hey! You know, sorry about losing all your files, 00:21:16.308,00:21:21.380 send me buckets of money and I will decrypt them for you. It’s actually kind of mean, you know, 00:21:21.380,00:21:27.052 maybe don’t do that. [speaker laughs] Uh the last step that I wanna talk about repurposing is 00:21:27.052,00:21:32.057 called windtail. Now windtail is a lovely back door written by a rather sophisticated APT group. 00:21:34.160,00:21:40.166 Here we’ll repurpose both their exploit and their own back door to use for our own missions, our 00:21:40.166,00:21:46.839 offensive cyber surreptitious processes. Now one of the most interesting piece of this attack 00:21:46.839,00:21:52.077 was the malware’s infection vector. And the way it was able to infect fully patched Mac 00:21:52.077,00:21:57.349 systems, while it was, by leveraging a legitimate functionality of Mac OS by 00:21:57.349,00:22:03.155 abusing something called custom URL schemes. Now I’ve written a long detailed blog that really 00:22:03.155,00:22:09.395 dives into the technical underpinnings of this but in a nutshell on Mac OS as soon as an 00:22:09.395,00:22:15.501 application in saved to the file system, even before the user has run it, Mac OS parses that 00:22:15.501,00:22:21.106 application. And if that application supports custom URL handlers, Mac OS will 00:22:21.106,00:22:28.047 automatically register it. Once these custom URL handlers or the app has been registered you can, 00:22:28.047,00:22:34.420 for example, from a webpage make a request to that custom URL which Mac OS will be happy to 00:22:34.420,00:22:40.759 now launch. The exploit is realized in JavaScript uh basically they have some code to 00:22:40.759,00:22:45.631 first download a malicious application that contains a custom URL scheme. Mac OS 00:22:45.631,00:22:51.003 registers that and then they have some second piece of JavaScrip which makes a request 00:22:51.003,00:22:57.076 to that now registered custom URL scheme to launch the malicious application. In terms 00:22:57.076,00:23:03.148 of the back door, again this is the payload of the exploit, they persist a login item that 00:23:03.148,00:23:08.587 supports capabilities such as file collection and exfiltration. So we fire up a 00:23:08.587,00:23:13.492 process monitor, as we can see on the slide, we can observe what the malware does once it 00:23:13.492,00:23:18.897 successfully infects the system. For example we can see it invoking the built in zip 00:23:18.897,00:23:25.170 utility. Uh to compress the files that it has collected for exfiltration. And then via the 00:23:25.170,00:23:32.011 built in curl command, it sends them to the attacker’s remote command and control server. The 00:23:32.011,00:23:37.016 back door also supports a file download capability. So if we look at the SDF method, a 00:23:39.184,00:23:44.657 disassembler or decompiler, we can see it decrypts the addresses of some embedded 00:23:44.657,00:23:50.362 command and control servers. Then it makes a initial request to get a name for a downloaded 00:23:50.362,00:23:55.467 file and then makes a second request to get the actual file contents from the attacker’s 00:23:55.467,00:24:02.074 command and control server. If we use a network monitor we can see this happening live and as 00:24:02.074,00:24:07.279 we note on the slide, the address of the command and control server is flux two key 00:24:07.279,00:24:12.518 dot com and just remember this because we’ll get back to this in a second. Now once the 00:24:12.518,00:24:18.157 malware has downloaded the file from the attacker’s uh remote command and control server if we 00:24:18.157,00:24:23.429 look at more disassembly we can see that it then executes this. So this is done within the same 00:24:23.429,00:24:29.835 SDF method. We can see that it unzips the file it gets from the attacker’s remote server via the 00:24:29.835,00:24:34.840 built, built in ditto command and it executes it via the NS task API. So, pretty standard 00:24:37.743,00:24:42.748 built in download and execute capabilities. Finally the back door can be remotely uninstalled 00:24:44.850,00:24:50.522 via self delete logic. So everytime the malware starts up, it connects to the attackers 00:24:50.522,00:24:55.661 command and control infrastructure and basically says, should I delete myself? If 00:24:55.661,00:25:01.867 the command and control server responds back with a one, the malware will first delete, 00:25:01.867,00:25:06.538 uninstall itself and then terminate. It’s kind of a neat capability that allows an 00:25:06.538,00:25:11.543 attacker to remotely disinfect targets. Alright so now it’s time to coerce this lovely back 00:25:14.012,00:25:20.786 door to do our own bidding. So, first let’s talk about repurposing the exploit. It’s 00:25:20.786,00:25:26.225 pretty simple to create a malicious web page that auto downloads a zip file containing 00:25:26.225,00:25:32.030 a malicious application. As we mentioned, a safari by de, default will auto expand zip 00:25:32.030,00:25:38.470 archives so if we place a malicious application in that archive that implements some 00:25:38.470,00:25:44.877 custom URL handlers, Mac OS will automatically register that even before the user has run the 00:25:44.877,00:25:49.882 application. The malicious web page can then make a request to that now registered custom URL 00:25:52.951,00:25:58.590 which will cause the application to be launched. Now, there will be a pop up or two, but the 00:25:58.590,00:26:05.030 average user probably is gonna click through these. So here’s a demo of the repurposed exploit 00:26:05.030,00:26:11.203 that will drop and persist uh windtail. We can see the page has downloaded the application 00:26:11.203,00:26:15.841 and then we made that second request. There was a pop up. Again, if the user clicks 00:26:15.841,00:26:20.345 through, which some percentage of users will fall for, we can see that now the malware has 00:26:20.345,00:26:25.184 been automatically and persistently installed. Again, since this is a logic flaw, 00:26:25.184,00:26:31.857 there’s nothing really for Apple to patch. So this still works on the latest version of Mac OS. So 00:26:31.857,00:26:36.094 now we’ve repurposed the exploit, let’s talk about repurposing the malware. 00:26:36.094,00:26:40.432 Because, doesn’t really help us if we are sparing their original malware that still beacons back 00:26:40.432,00:26:47.372 to the attacker’s command and control servers. So step one, we need to modify the embedded 00:26:47.372,00:26:52.611 command and control server addresses so that when the malware is deployed via our 00:26:52.611,00:26:58.617 repurposed exploit, it connects to our server so that we can task it. Unfortunately the 00:26:58.617,00:27:03.922 embedded addresses of the malware’s command and control servers are encrypted. Not to 00:27:03.922,00:27:10.128 worry. What we can do is we can coerce the malware to always load a dynamic library and then 00:27:10.128,00:27:15.133 once our library is running in the process address space of the malware, we can basically modify 00:27:17.703,00:27:23.308 uh the malware at runtime to intercept the decrypted addresses of the command and 00:27:23.308,00:27:28.480 control server before the malware uses them to connect out. So let’s look a little 00:27:28.480,00:27:34.086 closer about how we accomplish this. Again the goal is for us to specify our own command and 00:27:34.086,00:27:40.592 control servers so that the malware connects back to our infrastructure. So our dynamic 00:27:40.592,00:27:45.464 library has now been loaded into the address space of the malware. What we can do is we 00:27:45.464,00:27:52.037 can swizzle or swap out the malware’s decryption routine, it’s a method named yoop. This 00:27:52.037,00:27:58.744 is accomplished via the rather powerful method exchange implementations API. As we see 00:27:58.744,00:28:03.982 on the slide, once the decryption function has been swizzled or swapped out, 00:28:03.982,00:28:09.488 whenever the malware invokes the decryption function, transparently the Objective-See 00:28:09.488,00:28:15.761 runtime will actually now call our method in our library. What our method now does is calls 00:28:15.761,00:28:20.933 into the original decryption routine, and I have no idea what the decryption algorithm is or 00:28:20.933,00:28:27.005 how it works, and frankly I don’t care, but what I can do is since it’s swizzled and passing 00:28:27.005,00:28:32.344 through us, I can see the results of that encryption. So if the original decryption 00:28:32.344,00:28:38.150 method returns the decrypted addresses of the command and control servers, I can just 00:28:38.150,00:28:42.854 return my own command and control server back into the malware’s logic. So this 00:28:42.854,00:28:48.093 dynamically gives us the ability to transparently swap out the decrypted command and control 00:28:48.093,00:28:53.098 servers with our own. And the malware is none the wiser. Now I added some debug messages to the 00:28:55.167,00:29:01.073 library so if we, if we execute this now repurposed malware, we can see and watch this at 00:29:01.073,00:29:06.378 runtime and view the addresses of the command and control servers being swapped out. So at 00:29:06.378,00:29:11.216 the bottom of the screen, uh in the terminal output, you can see that our library which is called 00:29:11.216,00:29:16.154 through to the original decryption method has detected that that response is the 00:29:16.154,00:29:20.859 command and control server that’s now decrypted. We don’t want to return that to the logic 00:29:20.859,00:29:25.564 and the malware that’s trying to connect out so we basically just drop that and return our own. 00:29:25.564,00:29:30.369 Again this ensures now that the back door will always communicate with our servers 00:29:30.369,00:29:35.907 instead of the original APT group’s. Now we still have to write a command and control 00:29:35.907,00:29:40.312 server. Uh because the malware will now be connecting back to us. But we have to be able to 00:29:40.312,00:29:45.317 talk the protocol so that we can correctly task it. Now the main feature of the windtail back 00:29:47.486,00:29:52.724 door is to collect and exfiltrate files. So let’s add this first to our custom command 00:29:52.724,00:29:58.797 and control server. Files are exfiltrated via post requests. So we simply write a few lines 00:29:58.797,00:30:04.169 of code in python to handle this, saving off each file the malware sends to us from the 00:30:04.169,00:30:10.075 infected host. So here’s a demo now of our custom command and control server receiving 00:30:10.075,00:30:15.080 exfiltrated files from the attacker. On the left you can see the network requests coming 00:30:15.080,00:30:19.618 in and on the right all our command and control server does is write these out to the file 00:30:19.618,00:30:25.524 system. This means we now support the ability to respond to the malware as it exfiltrates 00:30:25.524,00:30:30.529 all sorts of files off infected hosts. Let’s also extend our custom com, command and control 00:30:33.165,00:30:38.937 server for this windtail implant to support the download and execute capability. So we noted 00:30:38.937,00:30:45.010 the malware makes two requests for this. The first is a request where the expected response is 00:30:45.010,00:30:49.948 for the name of the downloaded file and then the second request we need to respond with the 00:30:49.948,00:30:55.320 actual bytes of the file we want to download. The malware will then save that to the file we 00:30:55.320,00:31:01.827 specify, and then unzip that, and execute that. Now again, we only need a few lines of code in 00:31:01.827,00:31:06.565 python. We can leverage a lot of built in python libraries to do this. Um and once we do that we 00:31:06.565,00:31:11.636 then have the ability to task the implant. So let’s watch this in action. We’re gonna see the 00:31:11.636,00:31:15.741 malware connecting out to our command and control servers cause we’ve swapped out those 00:31:15.741,00:31:20.145 addresses and what we’ll do is we’ll have it download and execute. You, ubiquitous 00:31:20.145,00:31:26.618 calculator dot app. So here comes the connections, we’re giving it calculator dot app, 00:31:26.618,00:31:31.056 this could be any binary. And then the malware will unzip that, and execute that. Now, 00:31:31.056,00:31:36.661 armed with this remote download and execute capability, this means we can install other tools 00:31:36.661,00:31:42.167 or even second pieces of malware. So it really makes this repurposed implant kind of 00:31:42.167,00:31:47.172 infinitely uh extensible. Finally let’s add the ability uh to our custom command and 00:31:49.307,00:31:54.279 control servers so we can support the self delete command. Ah because at some point, you 00:31:54.279,00:31:58.850 know, the FBI comes knocking on your door, might be really nice to just press a button and have 00:31:58.850,00:32:03.121 all these infected systems uninstall themselves. It’s trivial to support this 00:32:03.121,00:32:08.393 functionality. Basically when the malware connects out, checks in with our server and asks, 00:32:08.393,00:32:14.633 should I self delete? We just respond with one. This will tell the malware to delete and fully 00:32:14.633,00:32:20.305 uninstall itself. This is another demo showing this in action. We can see the 00:32:20.305,00:32:25.911 persistently installed implant. It’s that orange logo uh, the application originally tries to 00:32:25.911,00:32:30.348 mimic a PowerPoint documentation. Uh kinda sticks out, but this is in kind of a, a 00:32:30.348,00:32:34.986 hidden system directory. Uh, what’s gonna happen is the malware’s going to connect out 00:32:34.986,00:32:41.426 to us, make the should I self delete command a request, we’re gonna respond with one which 00:32:41.426,00:32:47.098 will cause the implant to uninstall itself, and then terminate. So we can see it 00:32:47.098,00:32:52.103 disappear and then it stops beaconing because obviously it's just self deleted. Alright so 00:32:54.439,00:32:59.978 we’ve showed exactly how to repurpose a myriad of Mac malware. We talked about back 00:32:59.978,00:33:05.016 doors, ransomware, cryptocurrency miners. Although, we still need to talk about how 00:33:05.016,00:33:10.355 to remain undetected. As, generally speaking, we’re repurposing known malware which 00:33:10.355,00:33:16.628 means both Mac OS and third party AV products likely will block or detect these. Unless we 00:33:16.628,00:33:22.400 do something about it. So first up, let’s talk about Mac OS’s built in malware mitigations 00:33:22.400,00:33:29.074 such as XProtect, the malware removal tool, and code signing certif, certificate checks. Now 00:33:29.074,00:33:35.981 at first glance these might seem somewhat problematic as they may generically block our repurposed 00:33:35.981,00:33:41.419 malware on any, or rather, on all Macs. Again we really need to talk about bypassing these 00:33:41.419,00:33:47.792 because if we went to deploy a nicely repurposed piece of malware and Apple blocked it, ah 00:33:47.792,00:33:53.665 that would, that would kinda suck. So let’s start with XProtect. XProtect is a simple 00:33:53.665,00:34:00.005 signature AV, simple signature based uh AV scanner that’s built in to all recent versions of Mac 00:34:00.005,00:34:04.676 OS. Somewhat limited, it only scans files downloaded by the user the first time they’re 00:34:04.676,00:34:10.849 executed. If we look at their signatures they’re in a file named XProtect dot yara. We can 00:34:10.849,00:34:16.554 see various yara signatures to detect common pieces of Mac malware. Uh for example 00:34:16.554,00:34:22.327 KeRanger, the malware we just talked about repurposing. Now at Digita we wrote a simple utility 00:34:22.327,00:34:27.332 called UXProtect that allows you to explore these signatures via the UI as well as at any time uh 00:34:30.302,00:34:36.708 basically scan arbitrary files against these built in signatures. Now, since XProtect 00:34:36.708,00:34:43.114 is purely a signature based protection mechanism, it is incredibly trivial to bypass. So 00:34:43.114,00:34:48.553 let’s take a closer look at the signature for KeRanger. We can see it maps to a group of 00:34:48.553,00:34:53.558 instructions in the malware. Knowing this, to bypass the signature, we can simply reorder 00:34:56.194,00:35:01.766 or modify any of these instructions. This will change various bytes which’ll of course 00:35:01.766,00:35:07.272 cause the signature to no longer match. So here, for example, we simply change the number of 00:35:07.272,00:35:14.179 bytes that may be written to a buffer from 0X400 to 0X300. Now this doesn’t impact the 00:35:14.179,00:35:19.684 malware’s functionality at all, but as we’ve changed the bytes that the signature is looking to 00:35:19.684,00:35:26.291 match on, we’ve completely thwarted the XProtect signature. Demo time. Uh here we have two 00:35:26.291,00:35:32.998 instances of KeRanger, again it was distributed in this infected transmission bittorrent client. 00:35:32.998,00:35:37.535 On the left we have the original sample, this is the hacker’s sample, and on the right we have 00:35:37.535,00:35:42.040 the repurposed sample that’s gonna talk to our own command and control servers to get the 00:35:42.040,00:35:48.380 encryption key. And then also it has that one byte modification to bypass XProtect. So we’re 00:35:48.380,00:35:52.784 gonna launch both of them. We’re gonna see the original one as detected by XProtect and 00:35:52.784,00:35:57.622 blocked. There’s no option to run it, the user has to click cancel. If we execute the second 00:35:57.622,00:36:00.625 one, that’s gonna say hey we downloaded this from the internet are you sure you wanna 00:36:00.625,00:36:06.231 run that? User clicks yes, the ransomware is now able to persistently install on the 00:36:06.231,00:36:11.236 user’s system and immediately starts encrypting all their files. Woo [speaker laughs, 00:36:14.472,00:36:18.343 audience applause] But wait, there’s more. [applause continues] Next up we have code 00:36:18.343,00:36:24.349 signing checks. So most binaries on Mac OS are code signed. Signed binaries are not blocked 00:36:24.349,00:36:30.555 by gatekeeper thus a lot of Mac malware is now code signed. The downside from the malware’s 00:36:30.555,00:36:36.494 point of view is once this malware is detected, Apple can simply revoke the code signing 00:36:36.494,00:36:41.499 certificate, and this means the malware will not be able to execute on any other Mac. So 00:36:41.499,00:36:46.771 here for example we can see we have windtail’s, the windtail binary, and the original code 00:36:46.771,00:36:51.776 signing certificate has been revoked by Apple Proper. This means even if we repurpose this 00:36:51.776,00:36:56.781 in attempt to redeploy this to new systems it won’t be allowed to run. Well, the problem is 00:36:59.217,00:37:04.389 really the revoked certificate. It’s not the malware per say so we can simply remove the code 00:37:04.389,00:37:10.361 signing certificate. And then either distribute the repurposed malware unsigned or resign it 00:37:10.361,00:37:15.734 with another legit developer code signing certificate. Which is pretty easy to get. So to 00:37:15.734,00:37:21.072 unsign it, Apple actually provides a utility called codesign that is an undocumented 00:37:21.072,00:37:26.211 flag dash remove signature. So if you execute this and point it at the malware, Apple’s utility 00:37:26.211,00:37:30.548 will nicely strip off the uh revoked code signing certificate. And then as I 00:37:30.548,00:37:34.853 mentioned we can just deploy it as is on the side or if we wanna get a little more fancy we can 00:37:34.853,00:37:40.492 resign it again using the codesign utility passing in the dash S flag. This means the 00:37:40.492,00:37:46.231 resigned windtail will not no longer be blocked by Mac OS. [speaker sniffs] Finally we have 00:37:46.231,00:37:52.837 MRT. This is Apple’s malware re, removal tool. It’s another built in AV like tool that ships with 00:37:52.837,00:37:59.244 all versions of Mac OS. It’s similar to XProtect but scans malware that may be already on 00:37:59.244,00:38:04.682 the system. And if it detects it it’ll automatically removes it. Now, unlike XProtect, it’s 00:38:04.682,00:38:09.621 signatures are directly embedded in it’s binary. Kind of interesting. And as an 00:38:09.621,00:38:16.194 interesting side Apple also uses MRT to remove legitimate software it deems unsafe. Such 00:38:16.194,00:38:20.165 as the recent uh zoom application that had some vulnerable components so. Giving 00:38:20.165,00:38:26.337 a lot of power to Apple here for them to arbitrary remove uh files from your system. Now 00:38:26.337,00:38:32.610 since MRT, like XProtect uses signatures, its equally trivial to bypass. If we dump the MRT 00:38:32.610,00:38:37.282 binary, because again the signatures are embedded directly in that binary, we can see all 00:38:37.282,00:38:43.221 the signatures including one for FruitFly. Which makes us wonder is this going to detect our 00:38:43.221,00:38:48.226 repurposed FruitFly malware? Well if we examine the embedded MRT FruitFly signature we can 00:38:50.495,00:38:56.367 see it’s detecting FruitFly based on both the path of the malware and it’s launch agent P 00:38:56.367,00:39:01.773 list. This means as long as we change either the path or the name of the malware it’s not 00:39:01.773,00:39:06.778 going to detect it. Like I said, trivial. Now, I also wanna briefly mention bypassing third 00:39:09.447,00:39:14.686 party antivirus products because you might run into a system where the user you’re targeting 00:39:14.686,00:39:19.557 has an antivirus product installed. Now there’s been a lot of talk about this so I’m 00:39:19.557,00:39:24.295 not gonna dive into it a ton, but suffice to say, uh traditional AV products that 00:39:24.295,00:39:29.400 largely rely on signatures, which is pretty much the norm especially on Mac OS, are 00:39:29.400,00:39:35.940 equally trivial to bypass. For example I took FruitFly, recall it’s a perl script, I ran it 00:39:35.940,00:39:40.511 through a free online perl obfuscator which caused detections on virus total to 00:39:40.511,00:39:45.984 drop all the way to zero. Now, that works, but you might want to use more sophisticated 00:39:45.984,00:39:51.789 capabilities uh especially for the binary based malware. So you can do things like pack them, 00:39:51.789,00:39:57.495 use a custom encrypter, or even in memory execution. I gave a talk at Black Hat a few years 00:39:57.495,00:40:01.899 ago about these techniques uh ch, recommend checking that out because that can ensure that 00:40:01.899,00:40:07.071 even if the user has a third party AV product installed on their system it’ll be unlikely 00:40:07.071,00:40:13.111 to detect your repurposed malware creation. [speaker sniffs] Now for Mac users, this 00:40:13.111,00:40:19.017 kinda sucks. Right? We showed that advanced adversaries are already using repurposed malware 00:40:19.017,00:40:23.421 samples and that it's actually not that difficult to do. Often times we just have to switch a 00:40:23.421,00:40:27.659 few bytes or change the command line arguments and now, ya know, power to the people, we have the 00:40:27.659,00:40:32.297 ability to take these very sophisticated threats and redeploy them for our own 00:40:32.297,00:40:39.203 surreptitious processes. Also the majority of detections, those built into Mac OS or those 00:40:39.203,00:40:45.443 provided by third party AV products fail to detect these repurposed threats. This in my 00:40:45.443,00:40:50.048 opinion is rather la, lame because if you think about it, this repurposed malware is 00:40:50.048,00:40:54.686 basically an exact copy of the original known malware. We really just slightly 00:40:54.686,00:40:59.324 reconfigured it. So I wanna end this talk, kinda switch gears. We’ll put on our white hats now 00:40:59.324,00:41:05.229 and talk about how to generically detect such, such threats. So first, and this is a 00:41:05.229,00:41:09.667 well known fact, that I hopefully just illustrated, uh detecting malware based on 00:41:09.667,00:41:16.474 signatures, bound to fail. So instead what we need to do is look for unusual or malicious 00:41:16.474,00:41:23.448 behaviors. By definition malware does unusual or abnormal things. So let’s leverage this fact to 00:41:23.448,00:41:29.520 discuss generically detecting even repurposed threats. Because again, as we just stated, if we 00:41:29.520,00:41:34.792 are an attacker, repurpose a known piece of malware the underlying functionality is it’s 00:41:34.792,00:41:39.864 behaviors and capabilities aren’t going to change. That is to say even a repurposed piece 00:41:39.864,00:41:44.402 of ransomware is still going to encrypt all your files. Uh a repurposed back door is going to 00:41:44.402,00:41:49.640 persist and then start exfiltrating your files to a remote server. So here on the 00:41:49.640,00:41:56.247 slide, I’ve kind of listed some um capabilities or some actions or events that are good to look 00:41:56.247,00:42:01.953 for and monitor because they may provide insight into generically detecting even repurposed 00:42:01.953,00:42:07.792 malware. So let’s start by talking about persistence. What I mean by persistence is the way 00:42:07.792,00:42:12.797 that malware installs itself so that it’s automatically restarted every time the system 00:42:12.797,00:42:17.702 is rebooted. This is something the majority of malware, both on Windows and Mac, strives to 00:42:17.702,00:42:23.708 achieve. So what we can do is we can simply monitor the file system, specifically observing 00:42:23.708,00:42:30.081 persistence locations and then if anything modifies those we can alert the user or assist 00:42:30.081,00:42:35.086 admin and say hey look something just persisted, maybe you wanna take a closer look at it. So 00:42:35.086,00:42:40.558 here for example we can now alert and generically detect when windtail, either the 00:42:40.558,00:42:45.563 original or repurposed item persists. Next up is mic and webcam access. A lot of Mac 00:42:48.733,00:42:53.738 malware accesses the webcam or the mic to enspy, to spy on the users of an infected system. So 00:42:55.907,00:43:02.747 to detect this subversive activity, we can register with Mac OS, it turns out there is a 00:43:02.747,00:43:08.653 callback you can register that anytime anybody accesses either the mic or the webcam, you will 00:43:08.653,00:43:13.291 programmatically get notification of that fact. So this will allow us to detect 00:43:13.291,00:43:19.397 malware, even something like FruitFly which we’ve repurposed, or an exploit like zoom uh 00:43:19.397,00:43:24.402 anytime it accesses the mic or the camera. Next up we have keylogger detection. A malware 00:43:26.471,00:43:31.542 often times tried to capture your keystrokes uh to steal things like passwords and credit 00:43:31.542,00:43:37.281 card information. On Mac OS the easiest way to capture keystrokes is by registering 00:43:37.281,00:43:43.754 something called an event tap. What we can do is we can generically detect these taps by 00:43:43.754,00:43:50.561 again registering for a dispatch notification that will be kindly invoked by the operating system 00:43:50.561,00:43:56.901 any time a new event tap is installed. This allows us to very trivially detect keyloggers 00:43:56.901,00:44:03.708 even if they have been repurposed. We talked alot about FruitFly this is one of the more 00:44:03.708,00:44:08.613 sophisticated, feature complete malware. One of the neat features it has is the ability 00:44:08.613,00:44:14.285 to remotely interact with the UI via synthetic or programmatic mouse and keyboard events. So 00:44:14.285,00:44:19.524 the attacker can move the mouse, click on buttons or even send programmatic keyboard events to 00:44:19.524,00:44:25.196 an infected system. So this is something we want to detect because this isn’t something 00:44:25.196,00:44:29.333 that should normally be happening on a Mac system. Luckily it’s pretty easy to 00:44:29.333,00:44:35.973 detect. We can install our own event tap and monitor for mouse activity. When a mouse click is 00:44:35.973,00:44:42.880 generated, we can then examine a variable, a state variable, which Mac OS sets to one, if the 00:44:42.880,00:44:48.486 mouse event, the click or the move, has been programmatically generated. So this allows us to 00:44:48.486,00:44:55.426 now generically detect synthetic clicks even in repurposed malware. Now at the start of the 00:44:55.426,00:44:59.864 talk I mentioned uh I was the creator of Objective-See. It’s my kind of personal Mac security 00:44:59.864,00:45:05.169 web page. But the main goal of Objective-See is to provide free and largely open source security 00:45:05.169,00:45:10.241 tools for any users who are using Macs. Uh many of the detections we talked about are 00:45:10.241,00:45:15.913 realized in tools on this site so if you’re interested in that hop over to Objective-See dot 00:45:15.913,00:45:22.320 com. Now, a downside of these tools is they’re all separate, right? There’s an individual 00:45:22.320,00:45:26.791 keylogger detector, there’s an individual firewall, there’s not like an all in one solution. So 00:45:26.791,00:45:33.631 when I started working at Digita we decided to combine these into a single all in one tool. Uh and 00:45:33.631,00:45:38.636 the idea was to monitor the system and then create rules to detect unusual behavior. We then 00:45:40.805,00:45:46.811 took both those pieces and fed them into Apple’s built in game logic engine, which would do all 00:45:46.811,00:45:53.017 the hard work for us, and would evaluate our rules on top of our data and spit out a result for 00:45:53.017,00:45:57.855 us. So now let’s talk about some of these behavior based detection rules. And it’s 00:45:57.855,00:46:02.159 important to know you can use these in other security tools as well so this is not specific to 00:46:02.159,00:46:07.164 our product per say. So using this system we can generically and rather trivially detect all 00:46:09.367,00:46:15.373 the repurposed malware we talked about today. Uh so for example, windtail. We can detect it’s 00:46:15.373,00:46:21.212 exploitation vector by observing the fact that safari downloads and then auto extracts an 00:46:21.212,00:46:27.385 application. That same application then triggers the registration of a custom URL 00:46:27.385,00:46:33.090 handler. And finally, then that same application is started automatically via custom URL 00:46:33.090,00:46:38.796 requests from a website. So detecting the combination of those events gives us a generic 00:46:38.796,00:46:44.335 capability. Both against windtail or any other malware that utilizes this same 00:46:44.335,00:46:49.340 infection vector. Similarly we can detect FruitFly at install time by observing various events 00:46:52.143,00:46:58.482 that cumulatively indicate something is suspicious or at least amiss. So here for example 00:46:58.482,00:47:04.221 we observe the fact that a hidden non-Apple binary has persisted as a launch item. 00:47:04.221,00:47:09.794 There’s no legitimate reason that this should ever happen. So that’s really shady. Now imagine 00:47:09.794,00:47:15.833 that FruitFly is already running on the system uh we can also detect this by observing runtime 00:47:15.833,00:47:20.905 behaviors. For example, FruitFly does things that are really shady and suspicious. For 00:47:20.905,00:47:25.609 example, as we mentioned, persisting and running a hidden process. This hidden process in 00:47:25.609,00:47:32.483 some scenarios will drop an em, embedded unsigned binary to the temp directory, execute that and 00:47:32.483,00:47:37.254 then start capturing or generating synthetic events. Clearly this is incredibly 00:47:37.254,00:47:43.394 shady. Now of course we don’t have to trigger when all these events occur. Uh we can look at 00:47:43.394,00:47:47.298 them either cumulatively, we see one or two we might wanna take a closer look at the system 00:47:47.298,00:47:52.670 because something might be amiss. So hopefully I’ve illustrated that by using these 00:47:52.670,00:47:59.443 behavioral heuristics we can generically detect even sophisticated Mac uh threats, 00:47:59.443,00:48:06.016 even those that have been repurposed by advanced adversaries or by Patrick. Now 00:48:06.016,00:48:11.155 before I end this talk I’m really excited to announce Objective by the Sea version 00:48:11.155,00:48:16.761 three point 0. So if you are aware, uh Objective by the Sea is a Mac security conference uh 00:48:16.761,00:48:22.733 that I organize each year. Uh this year it’ll be back in Hawaii so if you want an excuse 00:48:22.733,00:48:29.206 for your company to send you to Hawaii in February, go to Objective-See dot com. Well that 00:48:29.206,00:48:34.445 is a wrap uh I wanna thank you all so much for attending my talk. We have about two minutes 00:48:34.445,00:48:38.516 for questions and then I will also be off the side of the stage if you wanna come up and 00:48:38.516,00:48:41.852 chat, talk nerdy about Mac stuff. So again, thank you though for real, attending, I 00:48:41.852,00:48:46.857 really appreciate it. [audience applause]