WEBVTT

00:04.000 --> 00:05.600
All right.

00:05.600 --> 00:08.180
Thank you so much for coming to my talk, everyone.

00:08.340 --> 00:13.580
Not only am I a first-time speaker, but it's also my first time attending DEF CON.

00:13.580 --> 00:16.560
So I'm really excited to be... yeah, that's right.

00:17.680 --> 00:19.080
Thank you.

00:19.400 --> 00:20.020
Yeah.

00:20.020 --> 00:24.240
So I'm excited to be here and give you my talk, C4.

00:26.180 --> 00:33.240
As a quick disclaimer, this is given on my personal behalf and does not reflect my current employer, Sony Corporation.

00:34.720 --> 00:35.320
All right.

00:35.320 --> 00:40.840
So like I said, I'm Scott Taylor, and I'm part of Sony's internal red team.

00:41.260 --> 00:44.540
Prior to Sony, I've done red team work with T.

00:44.540 --> 00:46.940
Rowe Price and the MITRE Corporation.

00:47.060 --> 00:56.120
But before all of the offensive security work, I started as a Linux system administrator, because you have to learn how to build before you break things.

00:57.020 --> 00:59.540
Additionally, I have a couple of certs and degrees.

01:00.280 --> 01:07.060
So for today, I'm going to be talking about a tool that I wrote called C4, the cross-compatible command and control.

01:07.520 --> 01:15.200
And this tool heavily relies on the commonly known technique in the red team world called external C2 or external command and control .

01:15.700 --> 01:26.920
So in your typical red team operation, as usual, you're going to drop malware onto the blue team's monitor computers, and that malware is going to reach out to your red team command and control server.

01:27.220 --> 01:40.020
Now, some of the more advanced teams, instead of directly communicating from your malware to the team server, you're going to instead use a trusted third party website to perform your message communication.

01:40.240 --> 01:49.960
So there's been instances of using like GitHub and AWS, various trusted websites that typical users in your enterprise are going to browse to.

01:49.960 --> 01:57.500
But instead, as offensive security folks, we are going to send our malicious messages through these same trusted websites.

01:58.560 --> 02:05.340
So earlier this year, there was a really cool project that was released called the LOLC2 or living off the land C2.

02:05.340 --> 02:11.160
And this documented numerous websites that were compatible with external C2.

02:11.160 --> 02:24.480
So security researchers managed to figure out how to do this communication over very popular websites like Microsoft OneDrive, Google Calendar, and even some fun ones like over a counter strike server.

02:25.500 --> 02:37.720
So security researchers are certainly using this in the wild and doing a lot of creative research in this space, but also threat actors or the bad guys are also getting in on this.

02:38.080 --> 02:45.770
So as you can see, I have a screen shot of the MITRE attack framework, because of course, as a former MITRE employee, I have to rep the attack framework.

02:46.290 --> 02:54.230
And you see there's a couple of examples like Google Drive, Dropbox, and all these trusted websites being used in the wild.

02:54.550 --> 03:00.830
Now one thing to note is in this attack framework, this technique was actually added all the way back in 2017.

03:01.250 --> 03:05.110
So it's certainly not a new development in the red team space.

03:05.110 --> 03:08.710
So you might be wondering, well, why are you coming to DEF CON and talking about it?

03:09.970 --> 03:24.670
Well, I started thinking about external C2, and I was like, well, there's all these C2 frameworks out there, but when you actually start using them, there's only a handful of external C2 options available for each one.

03:24.930 --> 03:29.630
So in Cobblestrike, you see a couple of the interesting C2 profiles.

03:29.630 --> 03:38.190
Personally, I'm a mythic C2 person, and there's a handful there, but in the previous screen shot, you saw loads of examples.

03:38.650 --> 03:49.890
So, you know, I started looking at it, and I'm like, well, yeah, it's challenging to take some of these really custom C2 profiles that are specific to a framework and port it to other frameworks.

03:50.050 --> 03:57.950
So today I'm going to talk about my tool C4, and how I aim to tackle this issue of portability of external C2.

03:59.930 --> 04:10.090
So, like I mentioned, I'm a mythic C2 fan, and with this framework, it's quite simple to develop your C2 profiles.

04:10.090 --> 04:19.590
Mythic deploys in multiple docker containers, and the actual C2 portion of the framework runs in its own docker container.

04:19.590 --> 04:33.290
So what I did was I developed the server side in Python, and this is published on GitHub, and not, you know, granted I'm exploiting GitHub, but in this case, it's actually published on GitHub.

04:33.490 --> 04:37.810
And on the client side, this is where mythic is a little bit more unique.

04:38.170 --> 04:45.290
Commonly in C2 frameworks, you have one agent for one C2 framework, so you might have, for example, beacon for Cobalt Strike.

04:45.290 --> 04:48.570
In mythic, there's multiple agents that exist.

04:48.570 --> 04:59.030
So for myself, I decided to develop this for the Athena agent, which is an agent run by check commander, and this agent is written in the dot net framework.

04:59.410 --> 05:12.890
So with dot net, I was able to find a dot net library out there to very easily interact with GitHub, and this is quite specific developed for this agent.

05:15.090 --> 05:18.250
Now, the cool thing is, yeah, this worked great.

05:18.250 --> 05:35.230
I was able to do my, you know, GitHub C2 using the Athena agent in the mythic C2 framework, but some of the other agent developers for this framework were like, well, I want to get in on the fun, but it's a little more challenging to take what I developed in dot net and port it to all these other languages .

05:35.730 --> 05:40.790
You know, all you malware developers out there, I'm sure you all have your preferred languages that you like to write in.

05:41.250 --> 05:45.170
You know, even in this case, I have a table of all the different agents, just some of them.

05:45.170 --> 05:46.210
There are more than this.

05:46.410 --> 05:49.970
And, you know, it ranges from all over the place.

05:50.230 --> 05:54.730
There's even like a JavaScript agent that acts as a malicious Visual Studio code extension.

05:54.810 --> 06:08.150
So, really cool stuff, but again, I wanted to find a way to take these external C2 profiles that I'm developing and make it more accessible for malware developers regardless of language of choice.

06:08.810 --> 06:17.510
So, this started my security research endeavor and I ended up stumbling upon WebAssembly.

06:19.070 --> 06:25.550
So, for WebAssembly, I went into this thinking, well, this is more of like a browser technology thing.

06:25.550 --> 06:27.730
And, you know, this is partly true.

06:27.790 --> 06:34.810
For WebAssembly, this is a compiled format, so you end up with a bunch of dot WASM files.

06:35.170 --> 06:41.250
And these WASM files, or WASM modules, I should say, they run at near native speed.

06:41.250 --> 06:43.350
So, for web developers, they love it.

06:43.350 --> 06:53.950
For example, the folks that develop Photoshop took that really intensive program, compiled it down to a WebAssembly module, loaded it in the browser, and now you can do Photoshop in the browser.

06:53.970 --> 06:55.990
So, really cool advancements.

06:56.030 --> 07:03.370
But the problem is, for WebAssembly, you know, this instance, this is all in the browser.

07:03.370 --> 07:06.730
But us red team operators, we're on the operating system.

07:06.790 --> 07:16.770
So, I needed to figure out how I could take all this really cool WebAssembly stuff and end up using it on the real host that we're trying to hack into.

07:16.990 --> 07:27.990
Now, for WebAssembly, again, popular in the web browser, however, there are WASM, or WebAssembly run times, outside of the browser.

07:28.550 --> 07:36.030
And further down the rabbit hole, this led me to discovering WASI, the WebAssembly system interface.

07:36.330 --> 07:44.910
Now, this is exactly what I was looking for, because this allows your WebAssembly modules to actually interact directly with the operating system.

07:44.910 --> 07:49.010
This is the bridge for the WebAssembly modules to your computer.

07:49.370 --> 07:59.850
So, with WASI enabled, you're able to interact with the file system, so you can read, write, delete files, you can read the system time, and you can interact with sockets.

07:59.870 --> 08:02.050
So, you can start making network requests.

08:02.470 --> 08:05.990
So, for what I was trying to do, this is looking very promising.

08:06.410 --> 08:10.030
And WASI also advertises that it works in all kinds of places.

08:10.030 --> 08:21.790
So, you can run WebAssembly modules in the cloud, server side apps, embedded system developers really like this stuff, but what I was really interested in is the fact that it was advertised as a plug-in system.

08:22.370 --> 08:28.290
So, for myself, because I wanted to develop external C2 plug-ins, this was looking really promising.

08:29.370 --> 08:38.650
So, this all sounds great in theory, but I needed to find an actual project that I could take and really make this happen, take the theory to the practical.

08:39.170 --> 08:43.990
So, this led me to discovering a project called Xtism, which is developed by Delipso.

08:44.650 --> 08:53.950
And aside from this wicked cool logo, it advertised exactly what I was looking for, a universal WebAssembly plug-in system.

08:54.350 --> 09:01.770
It supports multiple languages, so that's exactly what I was shooting for, and there's the idea of a plug-in kit and a host kit.

09:01.910 --> 09:11.890
For plug-ins, you can write your plug-ins in multiple different languages, compile it down to WebAssembly, and then take that WebAssembly module and run it in multiple languages.

09:11.890 --> 09:13.650
So, very, very ideal.

09:13.830 --> 09:32.370
Additionally, the WebAssembly runtime that Xtism produces has a couple of nice features, such as persistent memory, host-based control, so you can specify what HTTP endpoints your WebModules can reach out to, and a couple of execution guard rails , which helps keep the WebAssembly module secure.

09:33.770 --> 09:38.030
Here's a high-level overview of what this development pipeline looks like.

09:38.330 --> 09:49.390
So, for myself, I developed my plug-ins in Rust, and Rust can sometimes scare folks, so no need to fear, you can develop your plug-ins in multiple different languages.

09:49.610 --> 10:04.490
Regardless of the language you choose, compile it down to a WASM file, and then you take that and run it and load it inside of multiple languages, and this is where the malware developers get really excited, because you can take whatever language you're writing in,

10:04.490 --> 10:09.570
and start loading this WebAssembly module, and start running this shared code very seamlessly.

10:11.530 --> 10:20.830
So, this all sounds great in theory, but it was time to actually put it to the test, and that's when I started developing my tool, C4, the cross-compatible command and control.

10:22.410 --> 10:28.570
So, in a typical crawl, walk, run fashion, we had to start with a basic hello world.

10:28.630 --> 10:38.070
Now, this is a very basic six-line Rust program to just return hello world, and then I went language by language and just tested this out.

10:38.470 --> 10:45.230
Sure enough, one by one, each of the programming languages returned my basic hello world message, so we're off to a good start.

10:47.050 --> 11:04.090
Next, we had to step it up a little bit, we had to really make sure that this thing could do reliable HTTP requests, so now my Rust program got a little bit more complex, but no need to worry, each programming language returned a status 200, indicating that your website is up and active.

11:04.310 --> 11:12.930
So, we're able to make, we're able to compile WebAssembly modules and make HTTP requests and interact with APIs and all that fun stuff.

11:13.250 --> 11:20.850
Which then leads me to my first example of the AWS S3 plugin that I developed.

11:21.010 --> 11:28.810
Now, for those that aren't familiar, AWS S3 is a cloud-based service that's very popular for file sharing and file hosting.

11:29.730 --> 11:35.910
So, in this case, I developed two actions, and this is true across all of the plugins that I developed.

11:35.910 --> 11:38.690
There is a basic send and receive function.

11:38.950 --> 11:47.070
In the context of AWS S3, you're going to send a message by uploading a file to an AWS S3 bucket.

11:47.390 --> 11:55.530
Receiving a message, you're downloading a message from AWS S3, and then I also go ahead and delete the file after retrieving the message.

11:55.550 --> 11:57.230
You know, cleaning up after ourselves.

11:58.130 --> 12:06.030
Now, in a red team operation, there's a couple of things that you need to consider when developing an operationally ready external C2 channel.

12:06.330 --> 12:11.310
First thing, you need to be able to support multiple agents simultaneously calling back.

12:11.430 --> 12:14.430
In the red team world, two is one, one is none.

12:14.430 --> 12:19.230
You have to make sure you have a backup agent in case one of your other agents gets burned.

12:19.630 --> 12:26.950
So, in this case, I organized my messages into multiple folders, depending on which agent is sending and receiving messages.

12:27.250 --> 12:31.970
So, this ensures that multiple agents can simultaneously communicate with the C2.

12:33.190 --> 12:37.010
Additionally, we have to make sure the files that we're uploading don't overwrite each other.

12:37.010 --> 12:38.350
They can't have the same name.

12:38.350 --> 12:45.410
So, with WASI, I read the system time, and each of the files that are being uploaded are named after the time that it is.

12:46.050 --> 12:51.650
And additionally, you have to make sure that large messages are compatible.

12:52.230 --> 13:03.190
In this case, AWS S3 supports very large files, but this is really important when you go to exfiltrate or steal really large files off of a victim computer.

13:03.810 --> 13:10.390
So, with this, AWS S3 is a very good and viable option for external C2.

13:11.810 --> 13:18.310
In the plug-in, just as we talked about earlier, these are the two actions that are existing.

13:18.310 --> 13:22.390
It's your send and receive commands, and I handle all of this with JSON.

13:22.390 --> 13:27.970
So, when you call your functions out of plug-ins, you're just sending a little JSON blob.

13:28.030 --> 13:42.690
So, in this case, because we're dealing with AWS S3, the parameters are going to include AWS specific details, like your access and secret key, the bucket name that you're creating and writing files to, and the region that that bucket is located in.

13:45.190 --> 13:50.610
So, here's an example of actually taking a plug-in and using it in Python.

13:51.090 --> 13:59.630
So, for Python, to actually get this WASM or WebAssembly run time, it's just as simple as pip install XSIM.

13:59.630 --> 14:02.450
You know, I'm sure the Python developers are familiar with that.

14:02.450 --> 14:18.350
You import your XSIM package, and then inside of a manifest configuration, you have to specify that this WebAssembly module is allowed to make network connections, and in this case, I just allow it to make connections anywhere, but if you want it to be more OPSEC safe,

14:18.350 --> 14:20.970
you could limit it to just AWS S3.

14:21.630 --> 14:29.710
Then you have to enable WASI, because we're making network connections, we're reading the system time, all that fun stuff.

14:29.710 --> 14:37.750
So, we enable WASI, and then we have a loaded plug-in, and we can start actually calling it and making actions.

14:39.330 --> 14:45.230
So, here's an example of actually calling this loaded plug-in that we have in Python.

14:45.890 --> 14:54.850
So, we take our loaded plug-in, we build out our JSON message, and in this example, we're sending a message, just very basic test message.

14:54.850 --> 15:02.130
As you can see, we have some redacted access and secret keys, and some details about the S3 bucket that we're communicating with.

15:02.930 --> 15:12.170
And with that, we're very, it's very simple to continue to call these actions, and likewise with sending, you can receive just as easily.

15:12.350 --> 15:18.530
So, in the context of external C2, you know, this is all you really need, right?

15:18.530 --> 15:30.730
I look at a lot of agents on the open source side of things, and you just set up your infinite for loop, and you continue to call and receive, or send and receive messages to and from your C2 server.

15:32.750 --> 15:40.910
So, with that, hopefully you're walking away from this saying, well, external C2, it doesn't have to be that hard.

15:41.090 --> 15:50.770
With this, I have multiple plug-ins, I support AWS S3, Confluence, everyone's favorite documentation site, and GitHub Gist.

15:50.770 --> 15:55.590
So, with that, I have tons of plans for developing more external C2 channels.

15:56.390 --> 16:01.790
Additionally, WASM is a relatively new technology, I'd highly suggest checking it out.

16:02.190 --> 16:06.350
It's constantly being developed, and it's just a really cool tech to keep up with.

16:06.810 --> 16:13.110
So, with that, start downloading some C4 plug-ins and loading them up in your malware today.

16:13.110 --> 16:17.010
If you have any questions, reach out to me at scottctaylor12 across all the socials.

16:17.010 --> 16:18.490
Thank you so much for your time, everyone.

