About the episode
Episode transcript
Download transcriptEpisode 29 - Automating Malware PCAPs with AI and Corelight
Welcome to Corelight Defenders. I'm Richard Bejtlich, strategist and author in residence at Corelight. In each episode, we explore insights from the front lines of NDR, network detection and response. Today, I'm speaking with Keith Jones, principal security researcher at Corelight. Welcome back,
Keith. Hey, thanks for having me back. I am glad you're back. You're always a great guest. You just have your hands in so many different interesting technical topics, and I had heard that you were working on another cool project.
Can you share something about it with our audience? Sure. Um, so with the advent of AI, I'm constantly looking for spots where I can automate out the painful parts of, of our job.
So for one of the things that I routinely will have to do is go find some PCAPs on the internet. And if you've ever done this task, sounds fun, but it's not, bec- because what you do is you start with probably, what, 100,000 PCAPs in some malware sandbox like Triage or VirusTotal or AnyRun or malwaretrafficanalysis.net, and then you gotta open them up and you go, "Okay, well, was, you know, was there C2 traffic, yes or no?" Yeah, if the answer is yes, then the, the question is, well, was the C2 infrastructure actually up during the time?
So was it c- the traffic actually two-way? And as you see, you gotta ask yourself a bunch of questions of these PCAPs just to figure out if they're worth spending time on.
And prior to AI, it was kinda difficult to just take a PCAP and just run it through an automated process that says, "Hey, this one might be worth looking at." But now that we have AI,
I tried to throw that into the mix to sorta, you know, pseudo put a human in the loop, you know, using AI, to do sort of the first pass look at PCAPs that I find on the internet before I have to, you know, open them up in Wireshark and, you know, do all the slow things that I just described.
So, uh, one of the tools I wrote, um, just for lack of a better name, I'm calling it PCAP Analyzer, which is an N8n automation, and that's, um, if you've never seen it before, it's actually the letter N, the number eight, and then the letter n.com.
And you can basically make flow charts, you know, giant flow charts of just different automations. But the cool thing is, is you can tie in your
AI engines, like for instance, Gemini or Claude or something like that. So what I was able to do is have it watch over a shared drive that, um, a bunch of us have access to in labs, because I shared it to them. And when you create a folder in there, you can put a
PCAP in there. So in these subdirectories, you can put your PCAP in there, but you can also put sidecar files in there, and that can be anything. It could be your text file that you opened up and just wrote some notes in. It could be, for instance, the JSON files from the Triage malware sandbox service that you download and put next to it, so that way it has, you know, um, host-based information as well as the PCAP.
And what my automation does is it watches for these new subdirectories, finds the PCAPs, looks for the sidecar files, and then sort of builds a prompt. Well, actually, first, before the prompt, it runs the PCAP through all the tools that we love. So it runs it through Zeek, it runs it through TShark, it runs it through
TCP Dump. So basically, I wrote a, just a very simple REST application that would let you hand it a PCAP, and then it would run these things and then hand it back to the automation service. So it would have that ground truth of what was actually in a
PCAP rather than, you know, for instance, trying to search online to see what people said about the PCAP. It's actually looking at the data itself, which is really neat. And so I took it one step further with that and said, "Okay, I'm gonna build these prompts, and I'm gonna say things like,
'If the Zeek data doesn't show malicious traffic, I don't care about this PCAP.' Or, 'If it shows malicious data but it's only trying to connect to a non-existent C2 server, then I probably don't care about that
PCAP.'" But if it's something like, you know, a, a scan, a port scan, for instance, which is also kind of weird connections
'cause somet- a lot of them are just aren't open, it can, you know, discern between looking at the things and going, "Oh, well, this is all benign stuff," and it can look at a whole, whole bunch of open connections and go, "Well, this is a scan."
And it knows, just because I wrote it into the prompt, to put that PCAP in my, um, you know, this is useful pile, basically.
Yeah. So, so that's, that's one tool, is to do the automated analysis. And I actually, I built in some, um, fact-checking into it where, because of hallucinations,
I will then take the output and run it back through Gemini and then also give it Zeek. Uh, so that same server that I was talking about earlier that does the rest, um,
I made it into an MCP server, so it can actually look up things. So it then goes through and checks for truth, and then it checks everything, and it can actually go back and, you know, ask questions of, you know, what was the ZCLOG for this or the
TShark thing for that. And then basically correct anything that could be wrong. And then it basically builds a report at the end. So you get, like, an MB file of the, the PCAP, and it'll say things like, uh, you know, "This is Agent Tesla," and I'm doing this from memory, so maybe I'll have the C2 wrong, but from what I recall, Agent Tesla does, um, FTP Uh,
C2. So it'll say things like, "Hey, there's a lot of benign traffic in here," but if you just narrow it down to the malicious data, we see Agent Tesla traffic running, you know, an ex- an FTP exfiltration after this malware was executed, and this is the type of stuff that was exfiltrated, like, you know, system name, username, password, and all that kind of stuff.
So that's, that's tool number one. So there's a ton there. So let me, let me just try to step back for a second. So is this the sort of thing that you would be, like you come into work and you think, "I need to write something." Like, we have a requirement to write, uh, a parser for some new protocol. So then you'll use this first tool that you've talked about to try to find traffic that would help you... That you, you would inspect that traffic with your prototype code or whatever for that new protocol. Is, is that, like, one of the problems you're trying to solve with this?
R- right now I've been... That, that is, that could be one problem, yeah. The one I, um, have been just highlighting though has just been malware detonations. So for instance, just trying to pick through PCAPs, because maybe 90 of those malware detonations are duds, and what we're trying to do is find the 10% that actually w- you know, was alive and actually had decent traffic that we could analyze.
Okay. And this, this helps automate that whole process of a human having to open up 100 different PCAPs going, "Does this thing have, you know, was it bidirectional? Nope. Okay, we'll throw this PCAP away.
Let's go to the next one." And that's sort of what the AI does now for you in the background. So, so the first problem you're trying to solve then is, I just wanna have a corpus of high-quality PCAPs that represent something truly malicious happening, and I'm not gonna worry about right now what's in them.
Uh, I mean, you, you do worry, you want them to be representative of what we're looking for, but as far as, like, trying to solve a specific issue, you just wanna have this, this set of PCAPs on hand.
Yes. Um, and that kind of dove- because it dovetails into my s- the second tool actually goes out there and finds the samples. So, um, the, the first, the first tool that I w- I was talking about first was the analyzer.
So the, the, the point of the analyzer is to just be able to handle it, hand it PCAPs and have it quickly say, "This is what's malicious in here, and then the rest of it's benign." The first tool is probably where the, the coolest portion of it lives, because it does the analysis automatically for y- for you, and puts it in a nice little markdown report that you can, you know, then search with, uh,
Google Drive, Gemini, and all your, all your tools. You could, you could basically take all these reports and just put 'em into your LLM, and then ask it even more, um, in-depth questions.
Like, I'll routinely p- go to Google Drive and say, you know, "In the last day, what is the most unique
C2 traffic?" When I'm looking for things like, um, because a lot of times C2 traffic will ha- happen over, like, FTP or SMTP or something like that. But, um, sometimes I'm looking for exfiltration just over something that we don't know what it is, and you'll get those samples where it's like something was sent over 445, but we don't know what it is, and it looks like exfiltration.
And now you can kinda do that because you can just go to Google, Google Drive's Gemini and say, "Hey, go find, you know, this type of thing," and it'll just go out there and find those samples that it's already done the analysis on. So this just became an intelligence tool, because if it's out there looking for stuff and, and you have a little standing request to say, "Hey, show me something cool," and it's like, "I got something for you today," that's re- that's really cool. Yeah. So, um, I can plug Triage.
So that's the source that I use, uh, to get new malware detonation sa- like, the PCAPs. So most people would know Triage because they're gonna go there, they're gonna take malware, they're gonna detonate it, they're gonna look at, you know, what it says was bad in it. But I use it because you get the PCAPs.
And even better is if you're a security researcher, you can get API access, and once you get API access, you can then pull samples and their JSON reports and the PCAP actually all through the API. And what I do is
I, um, will run it at a periodic schedule to get, like, it, it allows you to pull the last 200 samples, for instance. So I'll pull 200 samples, and then
I'll put criteria on it, and I'll say, you know, there has to be network evidence in there. If there's no network evidence, I don't even care about it. So that filters a bunch of them out, like, right away. And then I'll say things like, you know,
I don't really care about C2 that's not up anymore, so if the C2 isn't bidirectional, just get rid of that PCAP.
You know, and I'll go from, like, 200 down to maybe 100 samples, and then I try to rank 'em based upon how much network traffic is in each just by looking at that Triage report JSON, to just give it a score in order to be able to, you know, do a sort on it and basically say,
"Hey, take the top 30 samples, download them, and then I'll do an analysis on these 30 samples." By the way I've crafted those prompts,
I'm, I'm trying to download only samples that have relevant data in there. Because what I'm trying to do is alleviate a human having to sit down and open PCAPs manually and saying, "Well, this doesn't apply. This doesn't apply." And it's like, you know, 90, 95% of the PCAPs out there.
Just to get to those, you know, 5, 10% of the really good ones. And so, um, between the PCAP picker, which pulls it off of Triage, and then the PCAP analyzer, which then analyzes the PCAP that we just picked off of Triage,
I'm able to very quickly each day go through there and say, "Okay, well what's, what's the newest, um..." Like for instance, um, there's some malware that I was looking at recently that will go to ip-api.com, but specifically it will use the fields equals hosting. And what that does is it's saying,
"If you think I'm in a hosting environment, return true." And I'm sitting here and I'm looking at this, I'm like, well- How many times does this actually get used in, like, with real software? I, I can't think of any software I've written where
I need to know if I'm in a hosting environment or not. Yeah. And typically, that's something done for malware, because then if they see if they're in AWS or something like that, they go, "Oh, well, I'm probably running in some kind of sandbox, and I shouldn't be just, you know, giving my secrets away, and I'm just gonna ex- you know, quit." Being able to put all this stuff together, it's like you quickly cut away all that benign, you know, Microsoft Windows going and looking for certificates, you know, the usual Windows stuff every time you run anything, and you just get to those little nuggets where it's like the
A- IP-API.com with this specific call looks very specific, uh, uh, to malware. And it's like I'm, I'm trying to get the analyst as close to the relevant data as soon as possible. Are you surprised at this point that you are still finding novel things in network traffic?
No, not really, and I, I, I think it's probably gonna get worse now with probably the advent of AI 'cause, you know, the things that you and I've seen over the years has always been handcrafted or handwritten.
Yeah. And now, you know, things are written by computers. So w- w- you know, I've s- in, in my own work, I've seen just really crazy stuff that Claude will do to solve problems, and I think now that people are using these AI services to try to exploit things, we're gonna see even crazier stuff on the wire, where it's just like, wow, never would've thought of that. Are we talking about different protocols? Are we talking about covert channels, more use of encryption or different enc- different encryption?
Or what, what do you think is, is gonna happen, or what are, what are some of the things you, you've seen happen? I don't have any specific stories or scenarios that I can share with you. What I'm, uh, what
I, I'm comparing it to when I solve problems with... S- so I solve a lot of software development problems, and when I ask it to do something, sometimes I'll give it background information because I want it to s- to I want it to solve something a particular way.
Yeah. Or other times, I'll just say, "Solve this problem," because I'm curious of how it's gonna come up with something, and it's like, it's a very high percentage. It's like well over 50, 60% of the time when it comes back with a solution, I'm just like, "Wow, I didn't even know you could do this in Zeke," or you know, it just pulled something up where I have to, like, go online and check and go,
"Is this a hallucination or is this real?" And I think you're gonna start seeing stuff like that even in the offensive side, where it's like our brains as humans might not think to exploit a particular protocol a particular way, but to an AI it's unemotional. You know, it's just gonna, it's gonna just try to think of the beth- best way that it can do it, and we'll probably end up seeing stuff that, you know, humans would have never have, uh, probably come up with on their own.
Yeah. I have a, a non-cyber example of that. So several years ago, a Air Force research lab was testing AI pilots versus real pilots, and the
AI were constantly finding these edge cases to defeat the humans, and they were sort of subverting norms that human pilots, uh, would not subvert. The, the, the biggest one that I remember from this study was the AIs would love to do head-on attacks, and you generally do not do head-on combat. You d- like you- Yeah ... don't wanna o- orient your, your plane so that it is going directly at the other plane, um, in, like, a game of chicken, and yet the AIs were f- totally fine with it. Um, maybe they were confident that they could pull away at the right time after getting their kill shot or whatever. But, uh, human pilots would never do that, so the AIs were constantly trying that trick, and the humans eventually had to realize this is something that they're gonna try, so we need to avoid that. So yeah, that seems to be a, a facet of these... I mean, it's the same thing with chess, right? You s- you, you re- read these, uh, AI chess players who, uh, they're doing these crazy things that people just wouldn't think of. So I've heard some people mention that we're in the, the Script Kiddie phase of AI attacks.
So if you think about someone who has, like, no exploit, uh, uh, you know, no offensive talent, but they wanna break into a target, and they tell an AI, "I just want you to break into this target," and they don't optimize for stealth, they don't optimize for low visibility, whatever instructions you might give, uh, to try to avoid detection, and they simply wanna exfiltrate whatever data that they get access to. It's a negative in that you've given this capability to someone who p- possibly previously couldn't have taken that action.
But on the detection side, m- probably not on the prevention side, but on the detection side, if they're using all these, these sort of... Like, just as a stupid example, they don't encrypt anything.
They just say, "Well, I could steal data via HTP just as easily via HCPS, but I didn't tell the model this, so it's just gonna use HTTP." That makes it easier for us to see it. Do you have that sense as well as, as how some of these things are working?
I'm still surprised that encryption isn't a bigger priority for attackers, and maybe it doesn't need to be, but it's like I flip through there, and it's like exfiltration over FTP, and there goes the username and password to that possibly compromised server in some other country.
Hmm. And for a defender it's awesome 'cause we can see what was exfiltrated, but, you know, how much harder would it have made our jobs if they would've just switched over to, like, SCP, for instance? Yeah. But they don't. You know, it, even
2026, I'm still seeing FTP shoot across the wire, probably 'cause it's easy, and pr- you know, maybe it's because they can compromise these FTP servers out there that are, um, actual victims.
You'll remember we just had a briefing from, uh, one of our guys who worked in the Black Hat Knock, and he was talking about all the consumer-grade software for monitoring your home cameras or uploading family photos or whatever it was, and it was all done unencrypted. A lot of it was done via FTP. Like, professional photographers were using servers that- O- only provided FTP. There was no secure way to use them. So here you have people who are making money selling these applications, and they don't bother to apply the, you know, the most basic, uh, hygiene-type stuff.
So it- I'm not, I'm kinda not surprised that the, uh, the attackers don't either in some cases, right? Of the stuff you've been looking at, y- are we talking mostly Windows exploitation, or have, have you seen any, uh, you know, Linux or Mac or anything that's, you know, not Windows? In my work recently, I haven't been able to pull any Mac ones. I have pulled a handful of Linux ones, if I recall correctly. Um, like probably five or less. And then, um, the lion's share, so I have, like, hundreds and hundreds of, uh, Windows ones, and they vary from anything from, you know, rats to info stealers to I think there was some Bitcoin mining stuff.
Um, so it's, it's all over the board. And that's one of the things I was trying to, uh, describe with that ranking is another thing I rank is by family name, so I try to grab as many families as I can from when I pick those PCAPs. So it's not like... So for instance, I don't wake up in the morning and have 100 different samples of Agent
Tesla. Yeah. I wake up in the morning, and I have 100 samples. You know, three might be Agent Tesla, but then three are Amity, and three are, you know, another family and... Well, you're always working on something cool. That's why
I... We hadn't checked in in a little while, and I thought, "I'm sure Keith has got something interesting to share with the audience." So, I appreciate you being a, a return guest here and talking about all the innovation that you're doing. Oh, no problem. Appreciate it. Yeah, and if you have any questions, and I know I talk fast in a lot of this stuff, but if you hit me offline off of the, um, the podcast, I'm happy to try to walk you through some of the stuff that I really quickly talked about, like MCP servers and all that kind of stuff, too.
So happy to address any of those questions your listeners might have. All right. Sounds good. Thank you, Keith. No problem. Thanks for having me again. Thank you for joining us on The Network Defenders. podcast, sponsored by Corelight.
We will see you on the network. You've been listening to Corelight. Defenders. To stay informed with expert intelligence on today's cybersecurity challenges, please subscribe to ensure you never miss an episode.
We'll see you on the network.