Latest / CyberCode Academy / Course 27 - Hacking Web Applications, Penetration Testing, CTF | Episode 17: Common Network and Web Application Vulnerabilities
Transcript
- 0:00Speaker 1: You know, there's this really fascinating paradox in cybersecurity. We
- 0:04Speaker 1: call it the complexity paradox.
- 0:06Speaker 2: Oh right, the idea that more security creates more holes exactly.
- 0:10Speaker 1: I mean, we spend millions on next generation firewalls, AI
- 0:15Speaker 1: driven threat detection and these encrypted tunnels that would make
- 0:19Speaker 1: a military general jealous. We build these massive digital fort knoxes, but.
- 0:24Speaker 2: The data breaches just aren't slowing down.
- 0:26Speaker 1: No, they're actually accelerating. And it's usually not because the
- 0:30Speaker 1: attacker use some you know, quantum computing mission impossible style
- 0:35Speaker 1: exploit to crack the encryption.
- 0:38Speaker 2: No, it's it's usually because someone left the digital equivalent
- 0:41Speaker 2: of the back door unlocked. Yeah, or they hid the
- 0:44Speaker 2: key end of the welcome map because it was just
- 0:46Speaker 2: more convenient for the staff, right.
- 0:48Speaker 1: And that's exactly what we're unpacking in this deep dive today.
- 0:51Speaker 1: We are looking at the low hanging fruit. I've been
- 0:53Speaker 1: going through all this material on common vulnerabilities, network flaws,
- 0:56Speaker 1: web ap injections, logic gaps, and these are statistically the
- 0:59Speaker 1: most common ways attackers actually get in.
- 1:01Speaker 2: They are the bread and butter of penetration testing.
- 1:04Speaker 1: But our mission today isn't just to list them off.
- 1:07Speaker 1: I want us to understand the actual mechanics of why
- 1:09Speaker 1: they work. We're going to visualize the invisible digital mechanics
- 1:12Speaker 1: step by step.
- 1:13Speaker 2: That is the perfect goal. We really need to move
- 1:15Speaker 2: past the what and get to the how and why,
- 1:18Speaker 2: because if you understand the mechanics of the exploit, the
- 1:21Speaker 2: defense just becomes obvious. It stops being a checklist item
- 1:24Speaker 2: and starts being a mindset.
- 1:26Speaker 1: So let's start at the perimeter the network. Now, most
- 1:29Speaker 1: of you listening probably know what a port is. It's
- 1:32Speaker 1: a communication endpoint. But simply having an open port isn't
- 1:36Speaker 1: a vulnerability in itself, right.
- 1:37Speaker 2: An open port is just a door. The vulnerability is
- 1:40Speaker 2: about what is listening behind.
- 1:42Speaker 1: That door exactly. So let's look at FTP file transfer
- 1:45Speaker 1: protocol that's typically on port twenty one. We know it's
- 1:48Speaker 1: an ancient protocol, but is the risk just that it's unencrypted?
- 1:52Speaker 2: That's a part of it. But the real low hanging
- 1:54Speaker 2: fruit with FTP is misconfiguration, specifically a feature called anonymous.
- 1:59Speaker 1: Ft which sounds exactly like what.
- 2:01Speaker 2: It is pretty much. It's this legacy feature that lets
- 2:04Speaker 2: a user log in with the username anonymous and then
- 2:07Speaker 2: they can use just an email address or honestly literally
- 2:11Speaker 2: anything as the password.
- 2:12Speaker 1: But surely companies lock that down to read only access.
- 2:15Speaker 1: I mean, letting strangers read public files is one thing,
- 2:18Speaker 1: but letting them write files to your server.
- 2:20Speaker 2: You would be shocked. This is where the concept of
- 2:23Speaker 2: chaining comes in. Imagine an admin sets up an FTP
- 2:26Speaker 2: server so clients can easily upload documents. They allow anonymous
- 2:30Speaker 2: uploads just for convenience, but they accidentally map that FTP
- 2:34Speaker 2: folder to the exact same directory that the web server
- 2:37Speaker 2: uses to host the website.
- 2:38Speaker 1: Oh, I see where this is going. If I can
- 2:40Speaker 1: upload a file via.
- 2:41Speaker 2: FTP and then just request that same file via your
- 2:43Speaker 2: web browser, you have remote code execution. An attacker uploads
- 2:47Speaker 2: what's called a webshell, just a tiny script usually written
- 2:51Speaker 2: in PHP, and then navigates to company dot com slash
- 2:54Speaker 2: shell dot php.
- 2:56Speaker 1: Suddenly they aren't just uploading files.
- 2:58Speaker 2: No, they have a live command terminal on.
- 3:00Speaker 1: That's a terrifying escalation, going from file storage to full
- 3:04Speaker 1: server control in two steps. And it's not just FTP.
- 3:06Speaker 1: What about SMB server message block.
- 3:08Speaker 2: Oh. SMB is a classic. It's used for sharing files
- 3:12Speaker 2: and printers across a network. The danger there is guest
- 3:14Speaker 2: access admins sometimes leave entire file shares open to anyone
- 3:18Speaker 2: on the network without requiring a password, so.
- 3:21Speaker 1: An attacker just browses the network and reads.
- 3:23Speaker 2: The hr file exactly, or the IT team's backup scripts,
- 3:27Speaker 2: which often contain hard coded passwords.
- 3:29Speaker 1: Speaking of databases, attackers aren't just blindly knocking on these doors,
- 3:33Speaker 1: are they like, they look for specific database ports.
- 3:35Speaker 2: Yeah, they map the attack service. They know that port
- 3:38Speaker 2: three three oh six is usually mice SQL or Maria dB,
- 3:41Speaker 2: port five four three two is Postgres School, and port's
- 3:44Speaker 2: fourteen thirty three or fourteen thirty four are Microsoft SQL server.
- 3:48Speaker 2: Finding those ports is step one, and then.
- 3:50Speaker 1: There's the Bash history oversight. This is one I feel
- 3:52Speaker 1: personally victimized by because I've absolutely done it.
- 3:54Speaker 2: Ah the dot Bash underscore history file the diary of
- 3:57Speaker 2: the Linux.
- 3:58Speaker 1: User right for those who don't and their lives in
- 4:00Speaker 1: a terminal. This is a hidden file in your home
- 4:03Speaker 1: directory on Unix systems. It literally records the last few
- 4:06Speaker 1: hundred commands you typed. And I've definitely typed my sql
- 4:09Speaker 1: dash you admin dash P followed by my super secret
- 4:13Speaker 1: password directly into the command line because I was Russian.
- 4:16Speaker 2: Oh we all have. But the specific risk is that
- 4:19Speaker 2: that command password and all is now sitting there in
- 4:22Speaker 2: plain text in that history file.
- 4:24Speaker 1: Yea.
- 4:24Speaker 2: If an attacker gets even low level access to the system,
- 4:27Speaker 2: the very first thing they do is read that file.
- 4:29Speaker 1: It's essentially a treasure map.
- 4:31Speaker 2: It really is. They searching for words like password, key token.
- 4:35Speaker 2: It's an easy win. The fix is simple. You just
- 4:37Speaker 2: configure the system to ignore commands that start with the space.
- 4:40Speaker 2: But it's amazing how often admins forget to do that.
- 4:43Speaker 1: It highlights that human error is still our biggest vulnerability. Now,
- 4:46Speaker 1: before we leave the network layer, we got a touch
- 4:48Speaker 1: on sniffing traffic. You mentioned.
- 4:50Speaker 2: FTP is encrypted, right, It sends data in clear text,
- 4:54Speaker 2: same with older protocols like Telnet HGTP and POP three
- 4:57Speaker 2: for email.
- 4:58Speaker 1: So if I'm on a public Wi Fi coffee shop.
- 5:01Speaker 2: Or if an attacker is already lurking on your corporate network,
- 5:05Speaker 2: they can use tools like wire shark, t shark or TCP.
- 5:08Speaker 1: Don't wire Shark is incredibly powerful for those visualizing this.
- 5:11Speaker 1: It essentially captures the data packets flying through the air
- 5:14Speaker 1: and lays them out on your screen.
- 5:16Speaker 2: It turns invisible network graphic into a highly readable stream.
- 5:20Speaker 2: If you log into a tailnet server, I can see
- 5:23Speaker 2: the packet containing your username, then the packet with your password.
- 5:27Speaker 2: I can pluck your credentials right out of the thin air.
- 5:29Speaker 2: That's why each TTPs isn't just a nice to have.
- 5:32Speaker 2: It encrypts that traffic, so to a sniffer, it just
- 5:35Speaker 2: looks like garbage noise.
- 5:36Speaker 1: Okay, so that's the network infrastructure. Let's move up the
- 5:39Speaker 1: stack to the web application layer. This is where things
- 5:41Speaker 1: get really creative. I want to dive into injection attacks.
- 5:45Speaker 1: The concept seems simple, you trick the computer into running
- 5:47Speaker 1: code instead of just reading data. But how does that
- 5:50Speaker 1: actually work mechanically. Let's start with the heavyweight SEQL injection
- 5:53Speaker 1: or sql.
- 5:55Speaker 2: SQL is the absolute classic. It happens when user input
- 5:58Speaker 2: is concatenated directly into a database query without any sanitization.
- 6:02Speaker 1: Sanitization being the keyword. So normally the back end code
- 6:05Speaker 1: says something like select user where name equals and then
- 6:09Speaker 1: it pastes in whatever you typed in the log in box.
- 6:12Speaker 2: Right, Let's visualize the bypass. Imagine a log inbox on
- 6:16Speaker 2: your screen. Instead of your name, you type admin followed
- 6:20Speaker 2: by a single quote a space and two.
- 6:22Speaker 1: Dashes admin quote dash dash. Why does that work? How
- 6:26Speaker 1: can typing that destroy or bypass a database?
- 6:29Speaker 2: Think about the mechanics. The single quote you typed actually
- 6:33Speaker 2: closes the data field that the developer created. You're telling
- 6:36Speaker 2: the database the username is admin. Now stop reading the name.
- 6:39Speaker 1: You've broken out of the data input and entered the
- 6:41Speaker 1: actual command structure.
- 6:42Speaker 2: Yes, and the two dashes in SQL two dashes signify
- 6:46Speaker 2: a comment. It tells the database to just ignore everything
- 6:49Speaker 2: that comes after it. So the part of the code
- 6:51Speaker 2: that normally checks your password gets completely commented out.
- 6:55Speaker 1: Wow. So the database just reads select user where name
- 6:58Speaker 1: is admin, finds the admin account, and logs you in
- 7:00Speaker 1: without even asking for the password.
- 7:02Speaker 2: Exactly. But there's also the boolean trick.
- 7:04Speaker 1: Oh, the or statement.
- 7:06Speaker 2: Right, you'd have a single quote, then the word or
- 7:08Speaker 2: than forty one equals.
- 7:09Speaker 1: One because forty one doesn't equal one. Wait, sorry, the
- 7:12Speaker 1: logic evaluates too true.
- 7:14Speaker 2: Right, Well, actually the classic is one equals one. But
- 7:16Speaker 2: any true statement works. If you use rr forty one
- 7:19Speaker 2: equals forty one. The database evaluates the math. Since forty
- 7:23Speaker 2: one always equals forty one, the statement is true and
- 7:26Speaker 2: it grants you access. Attackers use automated tools like sql
- 7:30Speaker 2: map or broop suitet pro to test thousands of these
- 7:33Speaker 2: variations in seconds.
- 7:34Speaker 1: That is wild. No, there's a variant of this that
- 7:36Speaker 1: targets the server's operating system itself, not just the database OS.
- 7:40Speaker 2: Command injection also known as shell injection. This is arguably
- 7:44Speaker 2: more dangerous. Imagine a web tool that lets you ping
- 7:46Speaker 2: an IP address to check if the server's online. The
- 7:49Speaker 2: back end code is probably just taking your input and
- 7:51Speaker 2: passing it directly to the system's underlying ping command.
- 7:54Speaker 1: So if I type an IP address, it runs the
- 7:56Speaker 1: pin command. But how do I exploit that?
- 7:58Speaker 2: By using the chaining technique we talked about earlier. In
- 8:01Speaker 2: Linux and Windows, you can run multiple commands on a
- 8:03Speaker 2: single line using separators. In Linux, a semicolon, a pipe,
- 8:07Speaker 2: or double ampersands act as command separator.
- 8:10Speaker 1: So in that pingbox, I type the IP address, then
- 8:12Speaker 1: a semicolon, and then the word womme exactly.
- 8:15Speaker 2: The server pings the IP finished that task, seize the
- 8:18Speaker 2: semicolon and then immediately runs woomi, which is a command
- 8:22Speaker 2: that reveals the user identity of the server. You're tricking
- 8:25Speaker 2: the web page into running system level commands.
- 8:27Speaker 1: It's the ultimate breach of trust. Speaking of trust, let's
- 8:30Speaker 1: talk about XSS cross site scripting. I feel like this
- 8:34Speaker 1: one is often misunderstood. With SQL and command injection, we
- 8:38Speaker 1: are attacking the server, but in XSS we're attacking other users.
- 8:41Speaker 2: Right, That is the critical distinction. In XSS, you inject
- 8:45Speaker 2: client side scripts, usually JavaScript, into web pages. The server
- 8:50Speaker 2: is just the delivery mechanism. The actual victim is the
- 8:53Speaker 2: person viewing the page.
- 8:54Speaker 1: And there are two main types. Storry about, reflected and stored.
- 8:57Speaker 2: Right. Reflected is when the payload is in the URL.
- 9:00Speaker 2: If I trick you into clicking a malicious link, your
- 9:02Speaker 2: browser runs the script, but STOREDXSS is much nastier. Imagine
- 9:06Speaker 2: a comment section on a blog. I leave a comment
- 9:08Speaker 2: that contains hidden malicious JavaScript.
- 9:11Speaker 1: And the server stores that comment in its database.
- 9:13Speaker 2: Yes, now, anyone who' used that blog post, their browser
- 9:17Speaker 2: loads my comment and silently runs my script. I could
- 9:20Speaker 2: steal the session cookies of every single person who reads
- 9:23Speaker 2: that page.
- 9:24Speaker 1: So valid users are getting hacked just by reading a
- 9:27Speaker 1: website because their browser trusts the site exactly.
- 9:30Speaker 2: It assumes code delivered by the website is safe.
- 9:32Speaker 1: Okay, I want to pivot to a category that I
- 9:34Speaker 1: found surprisingly deep when researching this file inclusion vulnerabilities LFI
- 9:39Speaker 1: local file inclusion and RFI remote file inclusion. This really
- 9:44Speaker 1: gets into the weeds of how web servers handle files.
- 9:46Speaker 2: It comes down to dynamic loading. A website might use
- 9:49Speaker 2: a URL parameter to load a page picture URL that
- 9:52Speaker 2: ends in question mark page equals contact dot php.
- 9:55Speaker 1: Right. Very The vulnerability is when the attacker changes content
- 10:00Speaker 1: php to a system filepath, like changing it to slash
- 10:03Speaker 1: et cetera slash pass route, which is the user file
- 10:05Speaker 1: on Linux.
- 10:06Speaker 2: But they usually have to use the dot dot slash technique.
- 10:08Speaker 2: Right Yeah, directory traversal.
- 10:10Speaker 1: Yes, you type dot dot slash, dot dot slash to
- 10:13Speaker 1: move up and out of the public web folder and
- 10:15Speaker 1: down into the system route to access those hidden files.
- 10:18Speaker 1: But wait, if the original code automatically adds dot php
- 10:22Speaker 1: to the end of whatever you type, wouldn't it look
- 10:25Speaker 1: for password dot php which doesn't exist, so the attack
- 10:28Speaker 1: would fail in modern systems.
- 10:30Speaker 2: Yes, but there's a classic evation technique called the null
- 10:34Speaker 2: meta character or null byte injection.
- 10:36Speaker 1: Oh, adding percent zero zero to the end of the
- 10:39Speaker 1: string exactly.
- 10:40Speaker 2: It exploits how different programming languages talk to each other,
- 10:43Speaker 2: when you add percent zero zero, it acts as a
- 10:46Speaker 2: stop sign. It tells the underlying system to cut off
- 10:49Speaker 2: the string right there, effectively hiding the dot php requirement. Now,
- 10:53Speaker 2: that was patched in PHP five point three, but the
- 10:56Speaker 2: concept of manipulating how data is parsed.
- 10:59Speaker 1: Is still highly And what if you don't want to
- 11:01Speaker 1: execute a file, but you just want to read the
- 11:03Speaker 1: source code of the application itself, like to find hard
- 11:06Speaker 1: coded passwords.
- 11:07Speaker 2: That's where PHP wrappers come in. You can use a
- 11:08Speaker 2: filter to tell the server, hey, don't run this file,
- 11:11Speaker 2: just encode its contents in base sixty four and hand
- 11:13Speaker 2: it to me. Then you decode it on your own
- 11:15Speaker 2: machine and read the raw source code.
- 11:17Speaker 1: That's incredibly clever. And then RFI remote file inclusion is
- 11:22Speaker 1: just pointing that same parameter to a malicious file hosted
- 11:25Speaker 1: on your own external server.
- 11:27Speaker 2: Right you change the URL to point to attacker dot com,
- 11:30Speaker 2: slash malware dot php, and the victim server reaches out,
- 11:35Speaker 2: downloads it, and runs it.
- 11:36Speaker 1: You're forcing the server to infect itself. Okay, we've covered
- 11:39Speaker 1: a lot of technical execution, but I want to end
- 11:42Speaker 1: on authentication and logic flaws. These often don't require any
- 11:46Speaker 1: coding knowledge at all. Let's talk about credential attacks. Obviously,
- 11:50Speaker 1: credential reuse is a massive problem.
- 11:52Speaker 2: Using the same password for your email, your bank, and
- 11:55Speaker 2: your FTP server. Once one is breached, they all.
- 11:57Speaker 1: Are But how do attackers test them? I mean brute
- 12:00Speaker 1: force versus password spring.
- 12:02Speaker 2: Brute Force is trying a million different passwords on one
- 12:05Speaker 2: single account, but that's loud. It triggers lockouts and alarms.
- 12:09Speaker 1: It's like banging on the front door with a sledgehammer exactly.
- 12:12Speaker 2: So attackers use password spring, which is a reverse brute Force,
- 12:14Speaker 2: and take one highly common password like winter twenty twenty
- 12:17Speaker 2: four exclamation mark, and you try it against every single
- 12:20Speaker 2: account in the company.
- 12:21Speaker 1: It's so sneaky because no single account gets locked out.
- 12:25Speaker 2: But statistically, someone in the marketing department definitely used the
- 12:29Speaker 2: season in the year as their password.
- 12:31Speaker 1: And once you're logged in, you might find logic flaws.
- 12:34Speaker 1: My favorite example is the price change hack because it
- 12:36Speaker 1: literally feels like digital shoplifting.
- 12:39Speaker 2: It really does. You add a laptop to your cart
- 12:41Speaker 2: for one thousand dollars. When you hit check out, your
- 12:43Speaker 2: browser sends a request to the server saying buy this
- 12:46Speaker 2: item for one thousand dollars.
- 12:48Speaker 1: But you don't let that request go straight to the server.
- 12:50Speaker 2: You intercept it right using a proxy tool like burp suite.
- 12:54Speaker 2: You catch the request midair, change the price parameter from
- 12:57Speaker 2: one thousand to one dollar, and then forward it to
- 12:59Speaker 2: the server.
- 13:00Speaker 1: And if the server actually relies on client side validation,
- 13:03Speaker 1: meaning it trusts the browser to check the rules, you
- 13:06Speaker 1: just bought a laptop for a dollar.
- 13:08Speaker 2: Never trust the client ever, the server must validate everything.
- 13:12Speaker 1: There are other ways trust is abused too, like open redirects.
- 13:15Speaker 2: H Phisher's dream a trusted site redirecting to a malicious one.
- 13:20Speaker 1: So a user clicks a link from a brand they trust,
- 13:23Speaker 1: but a parameter at the end quietly forwards them to
- 13:26Speaker 1: a fake login.
- 13:26Speaker 2: Page exactly and similarly open mail relays. If a company's
- 13:31Speaker 2: email server is misconfigured, an attacker can use it to
- 13:34Speaker 2: send out spam or phishing emails that legitimately originate from
- 13:38Speaker 2: the CEO's actual email address.
- 13:40Speaker 1: Because it's coming from the real server, it bypasses spam filters. Oh,
- 13:44Speaker 1: I have one last vulnerability before we wrap up verbose
- 13:47Speaker 1: error messages. We've all seen a website crash and spit
- 13:51Speaker 1: out a page full of gibberish code. Why is that
- 13:53Speaker 1: a security risk?
- 13:54Speaker 2: That gibberish is usually a stack trace or a debug
- 13:57Speaker 2: true output. It gives attackers file names, line numbers, server paths.
- 14:01Speaker 2: It's literally a roadmack of your code.
- 14:03Speaker 1: So when a site crashes, it shouldn't show the math.
- 14:05Speaker 1: It should just say oops, yes, keep.
- 14:07Speaker 2: Your airrors generic. Never give the attack or a blueprint
- 14:10Speaker 2: of your application.
- 14:12Speaker 1: We have covered a massive amount of ground here, from
- 14:14Speaker 1: open ports and Bash history to the nuances of SEQL
- 14:17Speaker 1: injection and logic flaws. If there is one thread tying
- 14:20Speaker 1: all this together, what is it?
- 14:22Speaker 2: It's that systems usually don't break because of highly complex
- 14:26Speaker 2: Sci Fi mathematics. They break because of logic gaps. We
- 14:30Speaker 2: trust user input, we leave default settings on, or we
- 14:33Speaker 2: fail to validate data on the server side. Security is
- 14:37Speaker 2: really a mindset of constantly questioning assumptions.
- 14:40Speaker 1: Questioning assumptions. I love that. So to help you listening
- 14:44Speaker 1: cement this mindset, let's do a quick review exercise.
- 14:47Speaker 2: Let's do it.
- 14:48Speaker 1: Okay, picture this. You are testing a log in form
- 14:51Speaker 1: on a website. You try to log in, but instead
- 14:54Speaker 1: of a username, you type the word admin followed by
- 14:57Speaker 1: a single quote and then a semicolon you hit enter.
- 15:01Speaker 1: What vulnerability are you testing for? And why does that
- 15:04Speaker 1: single quote matter?
- 15:05Speaker 2: Take a second think about the command separators in data
- 15:08Speaker 2: fields we talked about earlier. Got your answer you were
- 15:10Speaker 2: testing for SQL injection or possibly command injection. That single
- 15:15Speaker 2: quote is attempting to break out of the code's input
- 15:17Speaker 2: field to alter the database query, and the semicolon is
- 15:20Speaker 2: checking if you can chain a new command right after it.
- 15:23Speaker 1: Such simple characters, but devastating results. It really is Well,
- 15:27Speaker 1: this has been an incredible deep dive, but I want
- 15:29Speaker 1: to leave you with one final thought to Mollover. We've
- 15:32Speaker 1: talked about how these vulnerabilities stem from logic gaps and
- 15:36Speaker 1: trusting user input, but think about the very foundation of
- 15:40Speaker 1: the web. HDTP, HTML, DNS. These protocols were built decades
- 15:45Speaker 1: ago by academics who inherently trusted each other. They were
- 15:48Speaker 1: designed for sharing information, not securing it. So as we
- 15:52Speaker 1: keep building infinitely complex applications on top of this naturally
- 15:56Speaker 1: trusting foundation, are we just putting heavier doors on a
- 15:59Speaker 1: house made of paper. Maybe the future of security isn't
- 16:02Speaker 1: about patching the low hanging fruit, but entirely rethinking the
- 16:05Speaker 1: architecture of trust on the Internet.
- 16:07Speaker 2: That is a fascinating perspective to leave off.
- 16:09Speaker 1: On definitely makes you look at every log in box
- 16:11Speaker 1: with a bit more suspicion. Thanks for joining us for
- 16:13Speaker 1: this deep dive, and keep questioning those assumptions.