Latest / CyberCode Academy / Course 6 - Network Traffic Analysis for Incident Response | Episode 7: Network Data Analysis Toolkit: Tools, Techniques and Threat Signature
Transcript
- 0:00Speaker 1: All right, so you've done it. You successfully tap the network.
- 0:03Speaker 2: You collected all the road traffic pckps, the flows, the logs,
- 0:07Speaker 2: all of it exactly.
- 0:08Speaker 1: And you might be thinking, hew, the hard part's over,
- 0:11Speaker 1: But honestly, that was just step one.
- 0:13Speaker 2: Oh. Absolutely, the real fight, the real work is just
- 0:16Speaker 2: beginning right now.
- 0:17Speaker 1: You've got to turn this sheer volume of data into
- 0:20Speaker 1: something you can actually use into clear actionable security intelligence.
- 0:25Speaker 2: It's a mountain of information and the tools out there,
- 0:28Speaker 2: they span a huge spectrum. You can go for these
- 0:31Speaker 2: fully automated commercial.
- 0:32Speaker 1: Solutions expensive easy buttons.
- 0:35Speaker 2: Easy buttons, Yeah, they abstract away the complexity. Or you
- 0:39Speaker 2: can go the other way and build your own bespoke
- 0:43Speaker 2: analysis frameworks from scratch.
- 0:46Speaker 1: And that's our mission for this deep dive. We need
- 0:48Speaker 1: to map out that tool, look at the key methodologies.
- 0:50Speaker 1: I think there are three right connections, statistical and event
- 0:54Speaker 1: based analysis. Those are big three, and we need to
- 0:56Speaker 1: match them with the right instruments because you have to
- 0:59Speaker 1: know the right tool for the right job to get
- 1:01Speaker 1: answers fast. You really do, Okay, let's start with that.
- 1:04Speaker 1: Build your own philosophy, the real basics, the command line utilities.
- 1:10Speaker 1: These things are often built right into the OS, but
- 1:12Speaker 1: they're deceptively powerful.
- 1:15Speaker 2: They really are. We're talking about the classics, you know,
- 1:17Speaker 2: things like GP for just quick searching, essentials the absolute essentials,
- 1:23Speaker 2: and then OK for complex pattern processing, and CUT for
- 1:27Speaker 2: just making the output clean. Individually, they're simple, but you
- 1:30Speaker 2: combine them, that's where the magic is. The real insight
- 1:33Speaker 2: here is speed. By piping these together, you know, connecting
- 1:37Speaker 2: the output of one tool right into the input of
- 1:39Speaker 2: the next, you can create a really specialized filter or
- 1:43Speaker 2: analysis tool in minutes.
- 1:45Speaker 1: It sounds like the ultimate security hack, you know, just
- 1:48Speaker 1: quickly scripting something for an incident that just happened. But
- 1:51Speaker 1: isn't that a bit brittle? I mean, if a log
- 1:53Speaker 1: format change is just a little your whole hack breaks.
- 1:55Speaker 2: That's the critical point they are. They're inherently disposable and
- 1:59Speaker 2: very specific. They're for quick tactical winds, not long term stability.
- 2:03Speaker 2: But their modularity means they are perfect for basic automation.
- 2:08Speaker 2: On a Linux system. You can link these little shell
- 2:10Speaker 2: scripts right into something like kron for scheduled runs, or
- 2:14Speaker 2: push the results to syslog for central reporting.
- 2:17Speaker 1: So you can bootstrap a monitoring system really.
- 2:19Speaker 2: Really easy sockingly easy. Yeah.
- 2:21Speaker 1: So if the command line tools are the tactical building blocks,
- 2:25Speaker 1: then scripting languages like Python and r they're more like
- 2:30Speaker 1: the architecture.
- 2:31Speaker 2: A great way to put it. They offer much more power,
- 2:33Speaker 2: but you know, with a bit more overhead.
- 2:34Speaker 1: And in the security world, Python seems to have the edge.
- 2:38Speaker 2: It has the clear edge, mainly because of packages built
- 2:40Speaker 2: specifically for this. The big one is skapy scapey. Yeah.
- 2:44Speaker 2: Skapy is purpose built to read and parse PCP data.
- 2:48Speaker 2: So it takes the dense, you know, chaotic binary structure
- 2:51Speaker 2: of a packet, the ethernet layer, the IP, the TCP
- 2:54Speaker 2: and it just translates it all into these clean, accessible fields.
- 2:58Speaker 1: So instead of fighting with raw bites, we just get
- 3:00Speaker 1: attributes we can call in the code that's the key.
- 3:02Speaker 2: The packet becomes an object, so you can write logic
- 3:05Speaker 2: tests directly on its content. You can, for instance, check
- 3:08Speaker 2: if the raw payload starts with the bytes for ant
- 3:12Speaker 2: get request.
- 3:13Speaker 1: Well that's powerful.
- 3:14Speaker 2: Or if you just need the source IP address, you
- 3:17Speaker 2: just call packetip dot src. It's that simple, and that
- 3:21Speaker 2: efficiency is why skapy is used for more than just analysis.
- 3:25Speaker 2: People use it to actively craft malicious packets. For testing
- 3:28Speaker 2: their own defenses.
- 3:29Speaker 1: That custom framework gives you so much control. So okay,
- 3:33Speaker 1: we have the data flowing. Where do we start the analysis?
- 3:35Speaker 1: You said connection analysis is the necessary first step. What
- 3:39Speaker 1: is this simple approach actually looking for.
- 3:42Speaker 2: It's the low hanging fruit. It focuses only on the
- 3:44Speaker 2: existing connections between machines. The fundamental question is just who
- 3:48Speaker 2: is talking to whom and on what port.
- 3:50Speaker 1: It sounds simple, but I bet that uncovers a ton
- 3:53Speaker 1: of risk during like an audit.
- 3:55Speaker 2: It really does. It gives you three immediate security wins. First,
- 3:58Speaker 2: you can spot unauthorized serve, you know as a machine
- 4:01Speaker 2: that should only be a client suddenly listening on Port
- 4:03Speaker 2: eighty acting like a web server. That's a red flag. Second,
- 4:07Speaker 2: lateral movement, if an attacker gets a foothold and starts
- 4:10Speaker 2: moving inside your network, you'll see strange internal SSH traffic
- 4:14Speaker 2: between machines that have no business talking to each other.
- 4:17Speaker 2: And the third compliance you can quickly verify that your
- 4:21Speaker 2: sensitive database ports are only talking to approved application servers
- 4:25Speaker 2: and nothing else.
- 4:27Speaker 1: And the classic tool for this is netstat.
- 4:29Speaker 2: Absolutely, netstat is everywhere. It's a command line tool and
- 4:33Speaker 2: its real diagnostic power is showing you the state of
- 4:35Speaker 2: those connections. The state tells you everything, okay, so give.
- 4:39Speaker 1: Us the most important states for say, incident.
- 4:42Speaker 2: Response, you want to focus on three. Listening That means
- 4:46Speaker 2: the port is open, it's just waiting for a connection.
- 4:48Speaker 2: It's a perfect snapshot of what services are running.
- 4:51Speaker 1: Okay.
- 4:51Speaker 2: Then there's established, which is an active live data flow,
- 4:55Speaker 2: and critically.
- 4:56Speaker 1: Timewaight time waste. What's that?
- 4:58Speaker 2: That means the connection is closing, but the socket is
- 5:00Speaker 2: waiting around for a bit to make sure no last
- 5:02Speaker 2: minute packets get lost. If you see tons of connections
- 5:05Speaker 2: stuck in weird states or a huge number in time weight,
- 5:09Speaker 2: it can signal a big problem before an attack or
- 5:11Speaker 2: even gets data out.
- 5:12Speaker 1: Connection analysis feels very concrete, but statistical analysis that's a
- 5:17Speaker 1: step back, more of a macro view. And this is
- 5:19Speaker 1: where it gets really interesting because now we're trying to
- 5:22Speaker 1: define what normal even looks like on a network.
- 5:24Speaker 2: Right. Statistical analysis is all about defining that norm, that
- 5:28Speaker 2: baseline over time and then just aggressively searching for deviations
- 5:33Speaker 2: from it anomalies.
- 5:34Speaker 1: The assumption being an attack will look different exactly.
- 5:37Speaker 2: The core assumption is that any attack, malware and insider
- 5:41Speaker 2: threat whatever, it's going to cause a noticeable, measurable blip
- 5:44Speaker 2: that's different from the baseline. This is where machine learning
- 5:49Speaker 2: and AI really shine because they can constantly refine that
- 5:52Speaker 2: understanding of normal.
- 5:54Speaker 1: Can this approach help with malware families that are constantly changing?
- 5:58Speaker 2: It's excellent for that. Let's take the ghost rap malware family.
- 6:01Speaker 2: A new variant might be tagged ghost or LURK zero
- 6:04Speaker 2: or version twenty twelve.
- 6:05Speaker 1: The names change, but the behavior the.
- 6:09Speaker 2: Command and control communication structure is almost identical. So statistical
- 6:13Speaker 2: classifiers can cluster these traffic samples together based on those
- 6:16Speaker 2: deep structural similarities. This lets you spot a brand new
- 6:21Speaker 2: zero day ghost GRAT variant just because it's network traffic
- 6:24Speaker 2: looks too much like the bad stuff you already know about.
- 6:26Speaker 1: That's for grouping threats, but what about just finding one
- 6:30Speaker 1: single bad connection hidden in millions of good ones.
- 6:34Speaker 2: For that, you use a technique called steck counting. You
- 6:37Speaker 2: groop all your traffic by some feature, let's say destination port,
- 6:40Speaker 2: and then you sort by count. Okay, now, when you
- 6:43Speaker 2: analyze it, you do something counterintuitive. You intentionally ignore the
- 6:46Speaker 2: high count.
- 6:47Speaker 1: You ignore port eighty four forty.
- 6:49Speaker 2: Three, all of it all the common stuff. You focus
- 6:51Speaker 2: intensely on the bins with very low.
- 6:53Speaker 1: Counts because the common traffic is just noise. But one
- 6:56Speaker 1: single hit on a weird port that's the signal, precisely.
- 7:00Speaker 2: I remember one case where this exact technique revealed a
- 7:03Speaker 2: single connection to port twenty one FTP. That one anomaly
- 7:07Speaker 2: led us to an unauthorized internal file server. It had
- 7:11Speaker 2: been running for three months, totally invisible in all the
- 7:13Speaker 2: normal web traffic. A single connection on some unassigned port
- 7:17Speaker 2: like twenty two to sixty six, that's highly suspicious.
- 7:20Speaker 1: To do this at enterprise scale, you must need a
- 7:23Speaker 1: specialized tool.
- 7:24Speaker 2: You do, you need something like silk. Silk operates at
- 7:26Speaker 2: the flow level, which is a higher level summary than
- 7:29Speaker 2: individual packets.
- 7:30Speaker 1: So with silk you're trading off the ability to read
- 7:33Speaker 1: the actual content of the packet you are, but what
- 7:35Speaker 1: you gain is the speed you need to map millions
- 7:38Speaker 1: of connections. Is that the trade off?
- 7:40Speaker 2: That's exactly the trade off. You sacrifice detail for processing
- 7:43Speaker 2: speed and storage efficiency. Silk can filter, sort, and summarize
- 7:48Speaker 2: huge amounts of flow data very very quickly. It's essential
- 7:51Speaker 2: for that macro level view.
- 7:52Speaker 1: Okay, so that's the opposite of our next method. In
- 7:55Speaker 1: contrast to statistical analysis, hunting for the unknown event based
- 7:58Speaker 1: analysis is microfl focused. It's signature driven. Here you have
- 8:03Speaker 1: to know exactly what you're looking for.
- 8:04Speaker 2: That is the critical distinction. Yes, in this methodology, the
- 8:08Speaker 2: analyst has to define the specific signature of a known threat,
- 8:12Speaker 2: the exact pattern of a piece of ransomware or a
- 8:15Speaker 2: unique C two channel.
- 8:17Speaker 1: The advantage being it's super fast and effective if you
- 8:21Speaker 1: know the threat. That's how antivirus works, right, It's.
- 8:24Speaker 2: The operational model for most AV and IPS systems.
- 8:27Speaker 1: But the flaw is obvious. If the threat is brand new,
- 8:31Speaker 1: a true zero day, your signature detection fails instantly. There's
- 8:36Speaker 1: nothing to match against.
- 8:37Speaker 2: That is the fundamental drawback and we rely on two
- 8:40Speaker 2: main tools here. The first is Yara Signatures. Yah Jara
- 8:43Speaker 2: is this very versatile rule based language. It's used everywhere
- 8:46Speaker 2: in malware analysis and it works just as well on
- 8:48Speaker 2: network traffic data as it does on files.
- 8:50Speaker 1: And how does that rule structure help you, catch, say,
- 8:53Speaker 1: multiple variants of the same malware family.
- 8:55Speaker 2: A Yar rule lets you define specific strings, text, hex values,
- 8:58Speaker 2: complex regular expression, and then you combine them with boolean
- 9:01Speaker 2: logic ads and ors. So you can easily write a
- 9:05Speaker 2: rule that matches any ghost rat variant by just saying
- 9:08Speaker 2: match the tag lurk zero or r V twenty ten.
- 9:12Speaker 2: Or you can catch multi stage malware by creating a
- 9:14Speaker 2: rule that requires matching multiple malicious host names like margot
- 9:18Speaker 2: c dot JP and is standbull dot net.
- 9:21Speaker 1: Very cool. And the second tool is snort, the cornerstone
- 9:25Speaker 1: of network specific signatures.
- 9:27Speaker 2: Right. Snort rules are incredibly robust. The syntags is really
- 9:31Speaker 2: concise and action oriented. You just specify the action alert,
- 9:35Speaker 2: log block, the protocol source and destination info, and then
- 9:38Speaker 2: you get into very detailed content options.
- 9:40Speaker 1: Give me a really technical example, maybe one that only
- 9:42Speaker 1: uses the TCP packet flags.
- 9:44Speaker 2: Sure, you can use snort to detect stealthy port scans
- 9:47Speaker 2: like a Christmas scan. The scan uses a really unusual
- 9:50Speaker 2: combination of TCP flags to try and sneak past firewalls. Okay,
- 9:53Speaker 2: the snort rule is simple. It just alerts anytime it
- 9:56Speaker 2: sees the simultaneous combination of the FBN PUSHH and urgent flag.
- 10:00Speaker 2: Some people call it the fpn U combo. Another great
- 10:03Speaker 2: use is logging clear text password leaks. You can just
- 10:05Speaker 2: look for the specific content string authentication succeeded being sent
- 10:08Speaker 2: over Port twenty five, the unencrypted SMTP.
- 10:11Speaker 1: Port, and this is where skapey comes back in right.
- 10:13Speaker 1: It completes the circle absolutely.
- 10:15Speaker 2: Skapy is crucial for testing those SNORT rules. If you
- 10:18Speaker 2: have a rule that seems like it's failing, sometimes you
- 10:21Speaker 2: can take a live PC tape use Skapey to surgically
- 10:24Speaker 2: change things like change a source IP or tweak a flag,
- 10:28Speaker 2: and then you replay that traffic.
- 10:30Speaker 1: To make sure your rule is robust enough for the
- 10:32Speaker 1: real world.
- 10:33Speaker 2: Exactly to make sure it holds up against all the
- 10:35Speaker 2: weird variations you'll actually see.
- 10:37Speaker 1: This really brings a whole thing together. We've covered three
- 10:39Speaker 1: distinct but essential approaches. Connection analysis tells us who's talking.
- 10:45Speaker 2: To whom right the basics.
- 10:47Speaker 1: Statistical analysis tells us what looks abnormal, what deviates from
- 10:50Speaker 1: the norm. And event based analysis tells us what looks
- 10:54Speaker 1: exactly like a known threat.
- 10:55Speaker 2: And you need all three. Effective security intelligence comes from
- 10:59Speaker 2: using a combination of all of them all at the
- 11:01Speaker 2: same time.
- 11:02Speaker 1: A holistic view is essential.
- 11:03Speaker 2: It is and connecting this to the bigger picture, you
- 11:06Speaker 2: always have to remember the strategic importance of scope. Don't
- 11:10Speaker 2: waste your time and storage running incredibly detailed packet level
- 11:13Speaker 2: analysis with Skapy and snort. If simple flow data which
- 11:19Speaker 2: Silk handles and seconds gives you the answer you.
- 11:21Speaker 1: Need, choose the right tool for the job.
- 11:24Speaker 2: Choosing the appropriate data, fidelity, and the right tool. That's
- 11:28Speaker 2: the single biggest thing that determines success in this field.
- 11:31Speaker 2: It saves you massive amounts of time.
- 11:33Speaker 1: A vital point about efficiency. So here's something for you
- 11:36Speaker 1: to maybe chew.
- 11:37Speaker 2: On after this, a little thought experiment.
- 11:39Speaker 1: Yeah, exactly. Let's say an attacker is using a totally
- 11:42Speaker 1: standard encrypted connection port four four three, just regular HTTPS
- 11:46Speaker 1: for their command.
- 11:47Speaker 2: And control, something you'd see a million times a day.
- 11:49Speaker 1: Right, So, which are the three techniques we talked about today, connection,
- 11:53Speaker 1: statistical or event based, which one would be the least
- 11:56Speaker 1: effective against that? And more importantly, why.
- 11:59Speaker 2: It really comes down onto what encryption does, what it
- 12:01Speaker 2: fundamentally hides from you.
- 12:03Speaker 1: So to think about