Latest / CyberCode Academy / Course 6 - Network Traffic Analysis for Incident Response | Episode 4: Mapping, Decoding, and Decrypting Network Traffic Intelligence
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. Today, we're going to
- 0:03Speaker 1: put aside the basics of network analysis. We're not talking
- 0:06Speaker 1: about just analyzing normal traffic. Our mission is to go deeper.
- 0:11Speaker 1: We're going to explore how analysts, programmers, you know, ethical hackers,
- 0:17Speaker 1: how they move beyond those simple packet lists and start
- 0:20Speaker 1: pulling out the real.
- 0:21Speaker 2: Secrets exactly, the malicious payloads, the hidden commands.
- 0:24Speaker 1: That's it. How do they turn this overwhelming stream of
- 0:28Speaker 1: data from a network capture a pcap it is something
- 0:32Speaker 1: actually useful.
- 0:34Speaker 2: That's the whole game. We want to turn raw packets
- 0:37Speaker 2: into actionable insights, especially when the data is deliberately hidden
- 0:41Speaker 2: or encrypted.
- 0:42Speaker 1: Because the bad actors know we're.
- 0:43Speaker 2: Watching, of course, so they try to hide their tracks.
- 0:46Speaker 2: But here's the thing. Advanced analysis isn't about finding a
- 0:48Speaker 2: normal web request. It's about spotting the weird stuff, the anomalies,
- 0:52Speaker 2: and figuring out what they're trying to hide.
- 0:55Speaker 1: Okay, so let's break this down. It sounds like we
- 0:56Speaker 1: have a clear path. First we map out the environment,
- 1:00Speaker 1: get the lay of the land, Then we learn how
- 1:02Speaker 1: to decode some of the easier secrets, and finally we
- 1:05Speaker 1: tackle the really hard stuff. Modern encryption sounds like a plan.
- 1:11Speaker 2: Let's start with mapping. So you open up a huge
- 1:13Speaker 2: Kiskap file in a tool like wireshark. What do you see?
- 1:16Speaker 1: A wall of text, just thousands and thousands of lines
- 1:21Speaker 1: of data, all in order exactly.
- 1:23Speaker 2: It's dense, it's linear, and it's almost impossible for a
- 1:26Speaker 2: human brain to see the relationships in that kind of list.
- 1:29Speaker 1: It's the definition of information overload. So what's the shortcut?
- 1:33Speaker 1: How does an analyst get a handle on this fast visualization?
- 1:36Speaker 2: You have to visualize that. We use tools, A lot
- 1:39Speaker 2: of them are open source and Python based, like peacap,
- 1:41Speaker 2: viz and others in that category.
- 1:43Speaker 1: And they just take the raw data and what draw picture.
- 1:46Speaker 2: Pretty much, they generate a visual map of all the
- 1:49Speaker 2: communication paths. So instead of a list, you see dots
- 1:52Speaker 2: in line, you see connections. It gives you instant context
- 1:54Speaker 2: before you even look at a single packet.
- 1:56Speaker 1: And I'm guessing you can change what that map shows you.
- 1:59Speaker 2: You can. You can configure it by network layer. So
- 2:01Speaker 2: if you look at layer three, you're seeing IP addresses.
- 2:04Speaker 1: So which computers are talking to which computers.
- 2:07Speaker 2: Precisely, and that can instantly show you, say an infected
- 2:11Speaker 2: machine inside your network talking to some unknown server on
- 2:15Speaker 2: the Internet, and layer four that shows you the TCP
- 2:18Speaker 2: and UDP ports. So now you're not just seeing which computers,
- 2:21Speaker 2: but which applications are talking to each other.
- 2:24Speaker 1: And that's the real AHA moment, isn't it.
- 2:26Speaker 2: It is because a quick glance at that map lets
- 2:29Speaker 2: you separate the normal from the suspicious.
- 2:31Speaker 1: Right, you'd expect to see a lot of traffic on
- 2:33Speaker 1: port fifty three for DNS or four four three for HTTPS,
- 2:38Speaker 1: that's just noise.
- 2:39Speaker 2: But if you suddenly see a clear line of communication
- 2:42Speaker 2: happening on some weird, nonstandard port, let's say Port nine hundred.
- 2:47Speaker 1: It immediately stands out as probably a commanding control server
- 2:50Speaker 1: a C two.
- 2:51Speaker 2: It screams C two, and just like that, the map
- 2:54Speaker 2: is filtered out ninety nine percent of the noise for you.
- 2:56Speaker 2: It takes hundreds of thousands of packets and points you
- 2:59Speaker 2: to two or three suspicious connections that need a closer look.
- 3:02Speaker 1: Of course, there's a limitation here.
- 3:03Speaker 2: Always the map can only show you what you've captured.
- 3:06Speaker 2: It can't show you connections that weren't being monitored when
- 3:08Speaker 2: the PCPU is taken.
- 3:09Speaker 1: Okay, that makes sense. So that leads us to the
- 3:12Speaker 1: next step. We found the suspicious line on the map.
- 3:15Speaker 1: Now we need to read the data.
- 3:17Speaker 2: And this is where it gets interesting because attackers often
- 3:19Speaker 2: don't use like military grade.
- 3:22Speaker 1: Encryption, the simpler stuff obfuscation.
- 3:25Speaker 2: Yeah, simple encoding or weak obfuscation. A lot of the
- 3:28Speaker 2: time it's just frankly laziness. They want to hide the data,
- 3:32Speaker 2: but they don't want the headache of managing complex keys.
- 3:35Speaker 1: So let's talk techniques. First. Up XOR encoding. How on
- 3:39Speaker 1: earth do you spot that in a stream of random
- 3:42Speaker 1: looking data the key is repetition.
- 3:44Speaker 2: It's actually a dead giveaway when you're looking at the
- 3:47Speaker 2: raw hecks of the traffic. If you see the exact
- 3:50Speaker 2: same series of bites repeating over and over and over,
- 3:53Speaker 2: that's almost certainly xor.
- 3:55Speaker 1: Wait hold on, So the attacker's own attempt to hide
- 3:57Speaker 1: the data gives you the key to unlock.
- 3:59Speaker 2: It's that's the poetic justice of it. Yes, their effort
- 4:02Speaker 2: to conceal actually creates a massive vulnerability. This usually happens
- 4:06Speaker 2: when the malware's key, maybe a simple four character password
- 4:09Speaker 2: like MLVR, is xord against a big chunk of zeros.
- 4:12Speaker 1: And the output is just the key repeating.
- 4:13Speaker 2: Itself over and over, so an analyst can just look
- 4:16Speaker 2: at that pattern, figure out the key, and reverse the
- 4:18Speaker 2: whole thing. We've seen real samples where reversing the xor
- 4:23Speaker 2: revealed the header for a second stage Windows executable, plain
- 4:26Speaker 2: as day.
- 4:27Speaker 1: This brings up a really critical concept, then, which is entropy.
- 4:30Speaker 1: When you see that pattern, that repetition, that's low entropy exactly.
- 4:34Speaker 2: Low entropy means the data is predictable, its patterned. High
- 4:38Speaker 2: entropy looks random and low entropy is a huge sign
- 4:42Speaker 2: of simple encoding. Or our next technique, Base sixty.
- 4:45Speaker 1: Four right B sixty four is everywhere, So how do
- 4:48Speaker 1: we recognize that one? In a capture?
- 4:49Speaker 2: Base sixty four has a very distinct look. The data
- 4:52Speaker 2: is mostly going to be alphanumeric characters, both upper and
- 4:55Speaker 2: lower case. You'll also see plus signs and forward slashes.
- 4:59Speaker 1: And the giveaway at the end, the big one.
- 5:00Speaker 2: It often ends with one or two equal signs. That's
- 5:03Speaker 2: the padding you see that. You can be pretty sure
- 5:05Speaker 2: you're looking at base sixty four.
- 5:07Speaker 1: And we see this all the time in protocols like
- 5:09Speaker 1: HTTP to sneak commands past basic filters. The old Onion
- 5:13Speaker 1: Duke malware was famous for this.
- 5:14Speaker 2: But again, and this distinction is everything. It's just encoding,
- 5:17Speaker 2: not encryption.
- 5:18Speaker 1: What's the practical difference for an analyst.
- 5:20Speaker 2: Well, you decode the basicxty four. If you get readable
- 5:23Speaker 2: text back, great, But if you decode it and you're
- 5:26Speaker 2: still looking at a bunch.
- 5:27Speaker 1: Of random junk, it's high entropy.
- 5:28Speaker 2: It's still high entropy. Yeah, and that's your clue that
- 5:31Speaker 2: the basicsty four was just a rapper for a second,
- 5:33Speaker 2: much stronger layer of encryption, something like RC four, And
- 5:37Speaker 2: at that point your nealysis stops unless you can find
- 5:39Speaker 2: the key.
- 5:40Speaker 1: Okay, let's pivot from malicious hiding to just accidental leaking
- 5:47Speaker 1: the low hanging fruit.
- 5:48Speaker 2: Clear text credentials.
- 5:50Speaker 1: This really drives home why TLS transport layer security is
- 5:54Speaker 1: just non negotiable today.
- 5:55Speaker 2: Absolutely. If you're using an old clear text protocol that
- 5:58Speaker 2: needs a log in, you're basically shouting your password across
- 6:00Speaker 2: the network.
- 6:01Speaker 1: Let's start with telmet.
- 6:02Speaker 2: It's like SSH, but but horribly horribly insecure.
- 6:05Speaker 1: Yes, So in a tailneate capture, the username and password.
- 6:08Speaker 2: Are right there in plain sight. You just follow the
- 6:11Speaker 2: TCP stream and you'll see the login prompt and then
- 6:14Speaker 2: the credentials being typed in. Same for old email protocols
- 6:17Speaker 2: like IME, the log in is just clear text.
- 6:20Speaker 1: Now SMTP for sending email, it tries a little harder,
- 6:23Speaker 1: doesn't it, Yeah, a tiny bit harder.
- 6:26Speaker 2: It makes a minor attempt to hide things. SMTP often
- 6:29Speaker 2: uses base sixty four to encode the username and password
- 6:32Speaker 2: during authentication.
- 6:34Speaker 1: But because the protocol itself is so predictable and analyst
- 6:37Speaker 1: knows exactly where to.
- 6:37Speaker 2: Look exactly you see the server's request for credentials, it's
- 6:41Speaker 2: always the same, like a status code three three four.
- 6:43Speaker 2: Then you just grab the next packet from the client,
- 6:45Speaker 2: pull out the base sixty four string, which is.
- 6:48Speaker 1: Low entropy patterned, easy to.
- 6:50Speaker 2: Spot, and you decode it. We've seen captured examples from
- 6:53Speaker 2: public malur reports with credentials like group our tap and
- 6:56Speaker 2: password punjab at one two three just sitting there.
- 6:59Speaker 1: It's perfect example. Encoding is not security Without real encryption,
- 7:05Speaker 1: the credentials might as well be on a billboard.
- 7:06Speaker 2: Yep. So what happens when we finally do run into
- 7:10Speaker 2: proper encryption HTTPS, TLSSSL. This is the real challenge.
- 7:15Speaker 1: Take it case by case. What if we get lucky
- 7:17Speaker 1: and it's an older system.
- 7:18Speaker 2: If we're really fortunate the system is using a static
- 7:21Speaker 2: key exchange like RSA. In that case, if the analysts
- 7:24Speaker 2: can get their hands on the server's RSA private key file,
- 7:27Speaker 2: maybe from a server backup or something.
- 7:29Speaker 1: They could decrypt the whole conversation, the.
- 7:31Speaker 2: Entire session retroactively. You just load that private key into
- 7:35Speaker 2: wireshark and it does the magic.
- 7:37Speaker 1: And suddenly all that high entropy gibberish turns back into
- 7:40Speaker 1: readable HTTP, headers, HTML, all the good stuff.
- 7:44Speaker 2: That transformation is the goal. But and this is a
- 7:47Speaker 2: big butt, the vast majority of modern web traffic doesn't
- 7:50Speaker 2: use static RSA anymore. It uses ephemeral keys.
- 7:54Speaker 1: You're talking about ECDH, elliptic curve, diffy, Hellman ephemeral, that's
- 7:58Speaker 1: the one.
- 7:59Speaker 2: It's a mouth.
- 8:00Speaker 1: And why is that so much harder to crack?
- 8:02Speaker 2: Because the keys are well ephemeral, they're one time use.
- 8:06Speaker 2: The key used to encrypt the session is generated on
- 8:09Speaker 2: the fly and then thrown away.
- 8:11Speaker 1: So even if you have the server's main private key,
- 8:13Speaker 1: it doesn't help.
- 8:14Speaker 2: It's not enough. If you weren't there to capture that
- 8:17Speaker 2: initial handshake where the session key was created, you can't
- 8:19Speaker 2: decrypt it later. It's pretty much impossible retroactively.
- 8:22Speaker 1: So what's the move. If you're an analyst and you
- 8:24Speaker 1: control the client machine, how do you beat it?
- 8:27Speaker 2: Ah, If you control the client you have an in
- 8:29Speaker 2: you can set a special environment variable in SSL key
- 8:32Speaker 2: log file.
- 8:33Speaker 1: Then what does that do?
- 8:34Speaker 2: It forces the web browser on that machine to dump
- 8:37Speaker 2: all those ephemeral secrets like the pre master secret, into
- 8:40Speaker 2: a simple text.
- 8:41Speaker 1: File and then wire shark can just read that file exactly.
- 8:44Speaker 2: Wire shark ingusts that log file and can then decrypt
- 8:47Speaker 2: the traffic in real time. Even with ECDAG, that's incredibly powerful.
- 8:52Speaker 1: But trying to collect those key log files from every
- 8:56Speaker 1: machine in a big company that sounds like a security nightmare.
- 9:00Speaker 1: You'd have files full of secret keys sitting everywhere.
- 9:03Speaker 2: It's a massive risk. It just doesn't scale, and that's
- 9:05Speaker 2: why most large organizations don't do that. They turn to
- 9:08Speaker 2: something else for what we call deep packet inspection or DPIDPI.
- 9:12Speaker 1: So the ability to actually look inside the encrypted traffic. Right.
- 9:16Speaker 2: They use corporate web proxyes.
- 9:17Speaker 1: So instead of managing keys on every single computer, you
- 9:20Speaker 1: force all the traffic through one central point that can
- 9:22Speaker 1: inspect it. A man in the middle.
- 9:24Speaker 2: That's the setup the client. Your computer makes a secure
- 9:27Speaker 2: connection to the proxy. Then the proxy makes a second
- 9:30Speaker 2: secure connection to the real destination like your bank's website.
- 9:33Speaker 1: And the proxy sits in the middle, seeing all the
- 9:35Speaker 1: decrypted data as it passes through.
- 9:37Speaker 2: It sees everything in clear text.
- 9:39Speaker 1: We wait a minute. My browser would freak out right
- 9:42Speaker 1: If I try to go to Google, which uses security
- 9:45Speaker 1: like HSTS, and it gets a certificate from some corporate
- 9:48Speaker 1: proxy instead of from Google, it should throw up a
- 9:51Speaker 1: huge warning.
- 9:52Speaker 2: It absolutely should. And that's the final critical step for
- 9:55Speaker 2: this to work. The organization has to install the proxy's
- 9:59Speaker 2: own self signed certificate authority it's ca as a trusted
- 10:03Speaker 2: root authority on every single client machine.
- 10:07Speaker 1: Oh so you're basically telling every computer in the company, hey,
- 10:11Speaker 1: trust any certificate that this proxy signs, no matter what.
- 10:14Speaker 2: You are tricking the client into trusting the proxy implicitly.
- 10:18Speaker 1: This feels like a huge problem if we're trying to
- 10:20Speaker 1: build a zero trust network, This man in the middle
- 10:23Speaker 1: approach seems to completely undermine the entire trust model. You're
- 10:27Speaker 1: deliberately breaking the chain of trust, and that is.
- 10:30Speaker 2: The core tension. The benefit is clear. You get centralized,
- 10:33Speaker 2: scalable inspection for malware that's hiding an encrypted traffic.
- 10:36Speaker 1: But the downside seems massive.
- 10:38Speaker 2: They are first, that proxy is now a single point
- 10:41Speaker 2: of failure. It holds all the unencrypted traffic. If it
- 10:45Speaker 2: gets compromised, your entire organization's encryption is worthless.
- 10:49Speaker 1: And from the user side, their browser can never actually
- 10:52Speaker 1: verify the real certificate from the server they're trying to
- 10:55Speaker 1: connect to it.
- 10:55Speaker 2: They can't, which raises huge security and ethical questions. It's
- 10:59Speaker 2: this constant battle between the need for enterprise security and
- 11:04Speaker 2: what that does to client trust and user privacy.
- 11:07Speaker 1: So we've really gone on a journey here from just
- 11:10Speaker 1: looking at a list of packets to actively mapping traffic,
- 11:13Speaker 1: decoding simple seekers, and then fighting our way through modern tls.
- 11:17Speaker 2: It really covers the fundamental skill set. You're either exploiting
- 11:20Speaker 2: in attackers predictable low entropy patterns, or you're exploiting your
- 11:24Speaker 2: own control over the network to intercept and decrypt.
- 11:27Speaker 1: So let's leave you with one final thought as we
- 11:29Speaker 1: wrap up this deep dive. We learned that simple encoding
- 11:31Speaker 1: creates low entropy repetitive patterns, while strong encryption creates high entropy,
- 11:36Speaker 1: random looking data. So for you, the listener, think about this.
- 11:40Speaker 1: If you find a suspicious block of data in a
- 11:42Speaker 1: network capture, why is figuring out that entropy level distinguishing
- 11:45Speaker 1: simple base sixty four from strong encryption the absolute most
- 11:49Speaker 1: critical factor in deciding what you do next.