Latest / CyberCode Academy / Course 6 - Network Traffic Analysis for Incident Response | Episode 6: Investigating RATs, Worms, Fileless, and Multi-Stage Malware Variants
Transcript
- 0:00Speaker 1: Welcome to the deep dive. Today. We're taking you right
- 0:03Speaker 1: into the engine room of cybersecurity.
- 0:06Speaker 2: Yeah, we're going to be looking at the digital footprints
- 0:09Speaker 2: malware leaves behind on a network.
- 0:11Speaker 1: It's basically like reading a network's digital diary to find
- 0:14Speaker 1: out exactly what the bad guys are up to, what
- 0:16Speaker 1: they're stealing, or you know, what instructions they're getting.
- 0:19Speaker 2: That's the thing. Every piece of malware, I mean, from
- 0:21Speaker 2: a simple remote access trojan to a really sophisticated multi
- 0:25Speaker 2: stage threat, it has to communicate. It needs that command
- 0:29Speaker 2: and control channel or see two to do anything. So
- 0:33Speaker 2: our goal here looking at these captures is to spot
- 0:36Speaker 2: those signs, the clumsy mistakes, and even the really clever
- 0:39Speaker 2: tricks that show an intrusion is happening.
- 0:42Speaker 1: And we're going to look at several real world examples,
- 0:44Speaker 1: from the surprisingly basic stuff all the way to the
- 0:48Speaker 1: heavily disguised techniques. The idea is to give you the
- 0:51Speaker 1: knowledge to spot these things yourself.
- 0:53Speaker 2: Let's start with maybe the simplest one, the plain text beacon.
- 0:58Speaker 2: What's amazing is that you know, with all the encryption
- 1:00Speaker 2: available today, a lot of malur authors still use really basic,
- 1:04Speaker 2: sometimes totally transparent communications for that first call home like what. Well,
- 1:10Speaker 2: we saw this perfectly with a variant called WSHRT. It's
- 1:14Speaker 2: designed to beacon home, which just means it sends these frequent,
- 1:18Speaker 2: outgoing check in messages to its server.
- 1:21Speaker 1: And the communication itself was almost funny, wasn't it. We
- 1:25Speaker 1: saw it sending an HTTP POSD request where the URL
- 1:29Speaker 1: path was literally just the words.
- 1:30Speaker 2: Is ready, Yeah, is ready. It's like shouting across a
- 1:33Speaker 2: crowded room.
- 1:34Speaker 1: Hey I'm here, so obvious. But the actual data theft
- 1:37Speaker 1: was a lot smarter.
- 1:38Speaker 2: Exactly. They weren't just checking in. They were immediately sending
- 1:41Speaker 2: back a ton of host information. But and this is
- 1:44Speaker 2: the clever part, they didn't put it in the body
- 1:46Speaker 2: of the POC request, where a firewall might look.
- 1:49Speaker 1: Where did they put it?
- 1:50Speaker 2: They embedded it right into the standard HGTP user agent. Feel.
- 1:53Speaker 1: Oh, that is a great hiding spot. I mean, the
- 1:56Speaker 1: user agent is usually just boring stuff about your browser
- 1:59Speaker 1: and OS.
- 1:59Speaker 2: Right. Wow, that's so brilliant because basic network filters almost
- 2:02Speaker 2: never look there. They're not configured to inspect or log
- 2:06Speaker 2: the entire contents of a user agent string. They just
- 2:09Speaker 2: assume its normal metadata.
- 2:10Speaker 1: But in this case, it was a gold mine.
- 2:13Speaker 2: Everything's in there. The traffic capture showed the name of
- 2:15Speaker 2: the rat rusher RAT, a unique machine ID, the computer name,
- 2:19Speaker 2: the username admin in this case, and even a note
- 2:22Speaker 2: that JavaScript had to be installed.
- 2:24Speaker 1: So that initial beacon is all you need for forensics.
- 2:27Speaker 1: It confirms the infection and gives you triage details right away.
- 2:31Speaker 2: Absolutely, and in this case, the C two server acknowledged
- 2:34Speaker 2: it but never sent back any actual commands. So the
- 2:36Speaker 2: attack might installed, but it doesn't matter. The beacon itself
- 2:39Speaker 2: confirms the breach.
- 2:40Speaker 1: Okay, So let's contrast that with another one NJR. That
- 2:43Speaker 1: one was a bit more ambitious.
- 2:45Speaker 2: Oh yeah, this one was collecting system information on an
- 2:48Speaker 2: industrial scale. It wasn't just basic details.
- 2:51Speaker 1: What was it grabbing.
- 2:52Speaker 2: We saw the Windows XP version, the CPU model and
- 2:55Speaker 2: Intel Core I seven, the username Laura, machine details like
- 2:58Speaker 2: Dell xt and it was actively looking for the location
- 3:01Speaker 2: of svcchost dot ex.
- 3:04Speaker 1: Which suggests it's getting ready for a much deeper attack
- 3:07Speaker 1: like process injection.
- 3:09Speaker 2: Precisely, and this data wasn't just hidden in a standard field.
- 3:12Speaker 2: This is where we start to see custom communication protocols.
- 3:16Speaker 1: How could you tell, well.
- 3:17Speaker 2: When we looked at the raw TCP stream, It didn't
- 3:20Speaker 2: look like any standard protocol. It was just these chunks
- 3:23Speaker 2: of binary data. But here's the giveaway. Each chunk was
- 3:27Speaker 2: preceded by a tiny four by number, and that number
- 3:31Speaker 2: was it appeared to be the exact length of the
- 3:33Speaker 2: data payload that came right after it.
- 3:35Speaker 1: So they built their own language, basically a custom way
- 3:38Speaker 1: of framing the data to talk.
- 3:39Speaker 2: To their servers exactly. It's a custom C two protocol
- 3:43Speaker 2: and that makes analysis much harder because unless you can
- 3:45Speaker 2: reverse engineer that protocol, you have no idea what the
- 3:48Speaker 2: commands mean. It definitely escalates the investigation.
- 3:51Speaker 1: Okay, so let's pivot from custom protocols to pure stealth.
- 3:55Speaker 1: This brings us to files malware. The goal is simple,
- 3:59Speaker 1: don't write anything to the hard drive, and.
- 4:00Speaker 2: If you don't write to the disc, you bypass a
- 4:03Speaker 2: lot of host based security tools. This is where network
- 4:06Speaker 2: analysis becomes well non negotiable. It's the only place to
- 4:09Speaker 2: find the evidence.
- 4:10Speaker 1: A perfect example of this was the Anger exploit kit.
- 4:14Speaker 1: It used this really fascinating trick to hide its malicious
- 4:17Speaker 1: code during the download.
- 4:19Speaker 2: It was incredible camouflage the malicious traffic. It contained these
- 4:23Speaker 2: HTML responses that were clearly structured to full automated scanners.
- 4:27Speaker 2: How so they would mix in these big blocks of
- 4:31Speaker 2: totally benign content. We're talking actual quotes from literature with
- 4:34Speaker 2: blocks of heavily obfuscated code.
- 4:37Speaker 1: So a simple filter sees, you know, call me Ishmael
- 4:39Speaker 1: and just moves on totally missing the malicious script right next.
- 4:43Speaker 2: To it exactly. But if you dig into the data
- 4:46Speaker 2: streams you see patterns. In this case, we saw a
- 4:49Speaker 2: lot of XOR encoding. It's a simple way to scramble
- 4:52Speaker 2: a payload, but you need a key to unscramble it.
- 4:55Speaker 1: And since we had the traffic, we could piece it
- 4:57Speaker 1: all back together. We saw these suspicious file transfers, a
- 5:00Speaker 1: flash file and these big octet stream files with weird.
- 5:04Speaker 2: Names right, and once we isolated those octet streams, we
- 5:07Speaker 2: could analyze the repeating xor pattern. It's often pretty straightforward
- 5:10Speaker 2: to figure out the key they used.
- 5:12Speaker 1: So what'd you find when you decoded it?
- 5:13Speaker 2: This is the really cool part. It wasn't one file,
- 5:16Speaker 2: It was two distinct file stitched together. First you had
- 5:19Speaker 2: a small piece of what's called shell code, and then
- 5:21Speaker 2: right after it a Windows executable a DLL file.
- 5:25Speaker 1: Can you just quickly explain what shell code does here?
- 5:27Speaker 2: Sure? Shell code is just a tiny, efficient piece of
- 5:30Speaker 2: code designed to do one specific thing. In this case,
- 5:34Speaker 2: it was an injector. Its whole job was to take
- 5:36Speaker 2: that DLL, the real malware, and inject it into an
- 5:39Speaker 2: existing running process like your web browser.
- 5:41Speaker 1: So the malware never gets saved to the disc. It
- 5:43Speaker 1: just runs in memory.
- 5:45Speaker 2: That's how it achieves file A status. But the entire
- 5:48Speaker 2: blueprint for the attack, every piece of it, was sitting
- 5:50Speaker 2: right there in the network traffic.
- 5:52Speaker 1: Okay, let's switch gears to something with a very different
- 5:54Speaker 1: trapping pattern. Network worms. These things are all about spreading fast, right.
- 6:00Speaker 2: And their network signature is loud. Method one is direct exploitation.
- 6:05Speaker 2: You know, think back to Wanacry. It used the eternal
- 6:08Speaker 2: Blue exploit against the SMB protocol on port four to
- 6:11Speaker 2: forty five.
- 6:12Speaker 1: So what's the signature? What does that look like on
- 6:14Speaker 1: the network?
- 6:14Speaker 2: It's unmistakable. You see one machine sending massive amounts of
- 6:18Speaker 2: connection request to the exact same port four to forty
- 6:21Speaker 2: five across tons of different internal IP addresses. It's like
- 6:24Speaker 2: a port scanner pointed at its own neighbors. A huge
- 6:27Speaker 2: red flat. But if it succeeds, the traffic pattern changes.
- 6:30Speaker 2: You see a heavy data transfer as the worm uploads itself,
- 6:33Speaker 2: often followed by a protocol error like invalid parameter. That error,
- 6:37Speaker 2: ironically it can be a sign that the malicious code
- 6:39Speaker 2: was successfully executed.
- 6:41Speaker 1: Okay, and the second method is more social engineering. Right mailers.
- 6:44Speaker 2: Yep. We even saw the mydoom worm, which is ancient
- 6:47Speaker 2: from two thousand and four, trying to spread. In a
- 6:49Speaker 2: capture from late twenty eighteen, Midom just spams itself out
- 6:52Speaker 2: using SMTP port twenty five. So if you look at
- 6:55Speaker 2: your traffic stats you just see these huge, usually one
- 6:58Speaker 2: way data transfers on s some tt ports. A bulk
- 7:01Speaker 2: mailing operation is underway.
- 7:03Speaker 1: And the evasion trick, while old with pretty clever for
- 7:06Speaker 1: its time, it targeted the user right.
- 7:07Speaker 2: It attached itself as a VIP file with an executable inside,
- 7:11Speaker 2: but the filename was designed to deceive you. It would
- 7:13Speaker 2: be something like mail dot txt then a bunch of
- 7:16Speaker 2: spaces than three dots, than dot exe.
- 7:19Speaker 1: So if you had file extensions hidden, which many people did,
- 7:22Speaker 1: you'd just see mail dot txt and think it was.
- 7:25Speaker 2: A text file exactly, and you have to ask Why
- 7:28Speaker 2: are they still using fourteen year old malware?
- 7:30Speaker 1: Is it just laziness or maybe strategic They know some
- 7:33Speaker 1: systems are never patched, so it's a low effort way
- 7:36Speaker 1: to find that one vulnerable machine.
- 7:38Speaker 2: It's probably a bit of both. Luckily, in the sample
- 7:41Speaker 2: we saw modern security blocked every single attempt. But the
- 7:45Speaker 2: lesson is the traffic patterns, the mass scanning or mass emailing.
- 7:49Speaker 2: They always give the game away.
- 7:51Speaker 1: Okay, let's tackle the most complex scenario, the multi stage
- 7:55Speaker 1: attack chain. This is where one piece of malware downloads
- 7:58Speaker 1: the next like a relay race.
- 8:00Speaker 2: We tracked one that started with a simple DNS request
- 8:02Speaker 2: followed by an HTTP request that had an ID value
- 8:05Speaker 2: in it. And that ID value is immediately suspicious because
- 8:08Speaker 2: it was base sixty.
- 8:09Speaker 1: Four encoded and when you decoded it, it.
- 8:11Speaker 2: Revealed PII personally identifiable information and actual email address Reggie Cage.
- 8:16Speaker 2: That's a huge privacy red flag. Right at stage one,
- 8:19Speaker 2: a confirmed data leak. Then the machine checked its own
- 8:22Speaker 2: public IP reconnaissance complete.
- 8:24Speaker 1: Then came stage two.
- 8:26Speaker 2: Stage two was a download a Microsoft word file almost
- 8:29Speaker 2: certainly containing malicious macros to axs as the dropper, and
- 8:33Speaker 2: right after that a PS frequest went out to a
- 8:36Speaker 2: domain known to be used by the Pony Downloader malware.
- 8:39Speaker 1: And what wasn't that second post request.
- 8:41Speaker 2: More data detailed host metadata, this time a GUID which
- 8:46Speaker 2: is a unique system ID, the OS build number, and
- 8:49Speaker 2: it confirmed the victim's identity with the full name Reginald Cage.
- 8:53Speaker 1: So now the attackers fully mapped their target. They know
- 8:56Speaker 1: who it is, what system they're on.
- 8:57Speaker 2: Everything, yes, and stage three is where the downloader gets
- 9:00Speaker 2: to work. The malware started contacting multiple suspicious domains. Some
- 9:05Speaker 2: of the C two traffic was encrypted, but we still
- 9:07Speaker 2: found these revealing Base sixty four encoded responses.
- 9:10Speaker 1: What was so revealing about them.
- 9:11Speaker 2: The structure the Base sixty four data had these specific markers.
- 9:15Speaker 2: It would start with sequences like MQA one and always
- 9:18Speaker 2: end with a hex bite of seven. That's not random.
- 9:20Speaker 2: That regularity tells you there's a highly structured command protocol
- 9:23Speaker 2: at play.
- 9:23Speaker 1: So putting it all together.
- 9:25Speaker 2: You have a clear chain. The initial word doc was
- 9:28Speaker 2: the lure that installed the Pony downloader, which then fetched
- 9:32Speaker 2: the final encrypted malware payloads. But that entire breadcrumb trail.
- 9:37Speaker 2: Let's an incident responder immediately block the attacker's entire infrastructure.
- 9:41Speaker 1: So we've covered this huge spectrum today, from simple data
- 9:45Speaker 1: hidden in a user agent field to file as injection
- 9:49Speaker 1: and these complex multi stage attacks.
- 9:51Speaker 2: And through it all, the one constant is that every
- 9:53Speaker 2: single one of these threats left an unmistakable signature in
- 9:56Speaker 2: the network traffic.
- 9:58Speaker 1: That really is the key takeaway is it.
- 10:00Speaker 2: Is the value of looking beyond the file system is immense.
- 10:04Speaker 2: Attackers spends so much time trying to hide on the host,
- 10:07Speaker 2: but they can't hide their communications the initial steps, the
- 10:10Speaker 2: scanning the system, reporting the downloads. They almost always leave
- 10:13Speaker 2: these visible clues in the network capture.
- 10:16Speaker 1: To really drive this home, here's a final question for
- 10:17Speaker 1: you to think about. We talked about the wshr at
- 10:21Speaker 1: hiding data in an unusual spot. So if you were
- 10:24Speaker 1: monitoring traffic and saw a large post request where the
- 10:27Speaker 1: data was clearly encoded but not encrypted, which specific often
- 10:31Speaker 1: overlooked HTTP field, should you check first for that hidden
- 10:34Speaker 1: reconnaissance data.
- 10:36Speaker 2: Keep exploring, keep analyzing, and just remember the network logs
- 10:39Speaker 2: never lie.