start	end	text
4000	5600	All right.
5600	8180	Thank you so much for coming to my talk, everyone.
8340	13580	Not only am I a first-time speaker, but it's also my first time attending DEF CON.
13580	16560	So I'm really excited to be... yeah, that's right.
17680	19080	Thank you.
19400	20020	Yeah.
20020	24240	So I'm excited to be here and give you my talk, C4.
26180	33240	As a quick disclaimer, this is given on my personal behalf and does not reflect my current employer, Sony Corporation.
34720	35320	All right.
35320	40840	So like I said, I'm Scott Taylor, and I'm part of Sony's internal red team.
41260	44540	Prior to Sony, I've done red team work with T.
44540	46940	Rowe Price and the MITRE Corporation.
47060	56120	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.
57020	59540	Additionally, I have a couple of certs and degrees.
60280	67060	So for today, I'm going to be talking about a tool that I wrote called C4, the cross-compatible command and control.
67520	75200	And this tool heavily relies on the commonly known technique in the red team world called external C2 or external command and control .
75700	86920	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.
87220	100020	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.
100240	109960	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.
109960	117500	But instead, as offensive security folks, we are going to send our malicious messages through these same trusted websites.
118560	125340	So earlier this year, there was a really cool project that was released called the LOLC2 or living off the land C2.
125340	131160	And this documented numerous websites that were compatible with external C2.
131160	144480	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.
145500	157720	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.
158080	165770	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.
166290	174230	And you see there's a couple of examples like Google Drive, Dropbox, and all these trusted websites being used in the wild.
174550	180830	Now one thing to note is in this attack framework, this technique was actually added all the way back in 2017.
181250	185110	So it's certainly not a new development in the red team space.
185110	188710	So you might be wondering, well, why are you coming to DEF CON and talking about it?
189970	204670	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.
204930	209630	So in Cobblestrike, you see a couple of the interesting C2 profiles.
209630	218190	Personally, I'm a mythic C2 person, and there's a handful there, but in the previous screen shot, you saw loads of examples.
218650	229890	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.
230050	237950	So today I'm going to talk about my tool C4, and how I aim to tackle this issue of portability of external C2.
239930	250090	So, like I mentioned, I'm a mythic C2 fan, and with this framework, it's quite simple to develop your C2 profiles.
250090	259590	Mythic deploys in multiple docker containers, and the actual C2 portion of the framework runs in its own docker container.
259590	273290	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.
273490	277810	And on the client side, this is where mythic is a little bit more unique.
278170	285290	Commonly in C2 frameworks, you have one agent for one C2 framework, so you might have, for example, beacon for Cobalt Strike.
285290	288570	In mythic, there's multiple agents that exist.
288570	299030	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.
299410	312890	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.
315090	318250	Now, the cool thing is, yeah, this worked great.
318250	335230	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 .
335730	340790	You know, all you malware developers out there, I'm sure you all have your preferred languages that you like to write in.
341250	345170	You know, even in this case, I have a table of all the different agents, just some of them.
345170	346210	There are more than this.
346410	349970	And, you know, it ranges from all over the place.
350230	354730	There's even like a JavaScript agent that acts as a malicious Visual Studio code extension.
354810	368150	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.
368810	377510	So, this started my security research endeavor and I ended up stumbling upon WebAssembly.
379070	385550	So, for WebAssembly, I went into this thinking, well, this is more of like a browser technology thing.
385550	387730	And, you know, this is partly true.
387790	394810	For WebAssembly, this is a compiled format, so you end up with a bunch of dot WASM files.
395170	401250	And these WASM files, or WASM modules, I should say, they run at near native speed.
401250	403350	So, for web developers, they love it.
403350	413950	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.
413970	415990	So, really cool advancements.
416030	423370	But the problem is, for WebAssembly, you know, this instance, this is all in the browser.
423370	426730	But us red team operators, we're on the operating system.
426790	436770	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.
436990	447990	Now, for WebAssembly, again, popular in the web browser, however, there are WASM, or WebAssembly run times, outside of the browser.
448550	456030	And further down the rabbit hole, this led me to discovering WASI, the WebAssembly system interface.
456330	464910	Now, this is exactly what I was looking for, because this allows your WebAssembly modules to actually interact directly with the operating system.
464910	469010	This is the bridge for the WebAssembly modules to your computer.
469370	479850	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.
479870	482050	So, you can start making network requests.
482470	485990	So, for what I was trying to do, this is looking very promising.
486410	490030	And WASI also advertises that it works in all kinds of places.
490030	501790	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.
502370	508290	So, for myself, because I wanted to develop external C2 plug-ins, this was looking really promising.
509370	518650	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.
519170	523990	So, this led me to discovering a project called Xtism, which is developed by Delipso.
524650	533950	And aside from this wicked cool logo, it advertised exactly what I was looking for, a universal WebAssembly plug-in system.
534350	541770	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.
541910	551890	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.
551890	553650	So, very, very ideal.
553830	572370	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.
573770	578030	Here's a high-level overview of what this development pipeline looks like.
578330	589390	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.
589610	604490	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,
604490	609570	and start loading this WebAssembly module, and start running this shared code very seamlessly.
611530	620830	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.
622410	628570	So, in a typical crawl, walk, run fashion, we had to start with a basic hello world.
628630	638070	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.
638470	645230	Sure enough, one by one, each of the programming languages returned my basic hello world message, so we're off to a good start.
647050	664090	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.
664310	672930	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.
673250	680850	Which then leads me to my first example of the AWS S3 plugin that I developed.
681010	688810	Now, for those that aren't familiar, AWS S3 is a cloud-based service that's very popular for file sharing and file hosting.
689730	695910	So, in this case, I developed two actions, and this is true across all of the plugins that I developed.
695910	698690	There is a basic send and receive function.
698950	707070	In the context of AWS S3, you're going to send a message by uploading a file to an AWS S3 bucket.
707390	715530	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.
715550	717230	You know, cleaning up after ourselves.
718130	726030	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.
726330	731310	First thing, you need to be able to support multiple agents simultaneously calling back.
731430	734430	In the red team world, two is one, one is none.
734430	739230	You have to make sure you have a backup agent in case one of your other agents gets burned.
739630	746950	So, in this case, I organized my messages into multiple folders, depending on which agent is sending and receiving messages.
747250	751970	So, this ensures that multiple agents can simultaneously communicate with the C2.
753190	757010	Additionally, we have to make sure the files that we're uploading don't overwrite each other.
757010	758350	They can't have the same name.
758350	765410	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.
766050	771650	And additionally, you have to make sure that large messages are compatible.
772230	783190	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.
783810	790390	So, with this, AWS S3 is a very good and viable option for external C2.
791810	798310	In the plug-in, just as we talked about earlier, these are the two actions that are existing.
798310	802390	It's your send and receive commands, and I handle all of this with JSON.
802390	807970	So, when you call your functions out of plug-ins, you're just sending a little JSON blob.
808030	822690	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.
825190	830610	So, here's an example of actually taking a plug-in and using it in Python.
831090	839630	So, for Python, to actually get this WASM or WebAssembly run time, it's just as simple as pip install XSIM.
839630	842450	You know, I'm sure the Python developers are familiar with that.
842450	858350	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,
858350	860970	you could limit it to just AWS S3.
861630	869710	Then you have to enable WASI, because we're making network connections, we're reading the system time, all that fun stuff.
869710	877750	So, we enable WASI, and then we have a loaded plug-in, and we can start actually calling it and making actions.
879330	885230	So, here's an example of actually calling this loaded plug-in that we have in Python.
885890	894850	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.
894850	902130	As you can see, we have some redacted access and secret keys, and some details about the S3 bucket that we're communicating with.
902930	912170	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.
912350	918530	So, in the context of external C2, you know, this is all you really need, right?
918530	930730	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.
932750	940910	So, with that, hopefully you're walking away from this saying, well, external C2, it doesn't have to be that hard.
941090	950770	With this, I have multiple plug-ins, I support AWS S3, Confluence, everyone's favorite documentation site, and GitHub Gist.
950770	955590	So, with that, I have tons of plans for developing more external C2 channels.
956390	961790	Additionally, WASM is a relatively new technology, I'd highly suggest checking it out.
962190	966350	It's constantly being developed, and it's just a really cool tech to keep up with.
966810	973110	So, with that, start downloading some C4 plug-ins and loading them up in your malware today.
973110	977010	If you have any questions, reach out to me at scottctaylor12 across all the socials.
977010	978490	Thank you so much for your time, everyone.
