Latest / CyberCode Academy / Course 27 - Hacking Web Applications, Penetration Testing, CTF | Episode 15: Mastering Metasploitable 2: A Comprehensive Pentesting Guide
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. I want to start
- 0:03Speaker 1: today with a mental image.
- 0:05Speaker 2: Okay, I'm listening.
- 0:06Speaker 1: Picture a punching bag, you know, the heavy leather kind
- 0:09Speaker 1: hanging in a boxing gym. Right. It exists for one reason,
- 0:13Speaker 1: and that's to get beaten up. Boxers hit it until
- 0:16Speaker 1: their knuckles bleed so that when they finally get in
- 0:18Speaker 1: the ring with a real opponent, they actually know how
- 0:21Speaker 1: to throw a hook.
- 0:22Speaker 2: It's a classic training tool, conditioning through repetition.
- 0:25Speaker 1: Exactly. Now, I want you to imagine a digital version
- 0:29Speaker 1: of that, a computer server that exists solely to be destroyed,
- 0:33Speaker 1: a machine that literally begs you to break into it.
- 0:35Speaker 2: Which is a very specific and honestly somewhat paradoxical corner
- 0:41Speaker 2: of the cybersecurity world. Yeah, I mean, usually we build
- 0:44Speaker 2: servers to keep people.
- 0:45Speaker 1: Out right, And that brings me to the big question
- 0:48Speaker 1: for this deep dive. Where can you legally practice being
- 0:52Speaker 1: a hacker? Because usually if you try to break into
- 0:54Speaker 1: a server, even just to see if you can, you're
- 0:56Speaker 1: committing a felony.
- 0:57Speaker 2: Yeah, you don't get a pat on the back, You
- 0:58Speaker 2: get a subpoena.
- 0:59Speaker 1: Or a knock the door. And that is exactly why
- 1:02Speaker 1: we have metasploitable too.
- 1:03Speaker 2: Metasploitable two.
- 1:04Speaker 1: It sounds like an eighties action movie sequel, it really does.
- 1:08Speaker 2: But essentially what it is, it's a virtual machine, a VM,
- 1:11Speaker 2: running an older version of a Buntu Linux. But the
- 1:14Speaker 2: developers didn't secure it. In fact, they did the exact opposite.
- 1:18Speaker 2: They deliberately filled it with holes, outdated software, misconfigurations, and
- 1:23Speaker 2: just terrible weak passwords.
- 1:26Speaker 1: It's a safe haven for penetration testing exactly.
- 1:29Speaker 2: It is a capture of the flag environment explicitly designed
- 1:32Speaker 2: to be compromised.
- 1:33Speaker 1: It's the Swiss Cheese of servers, and our mission today
- 1:36Speaker 1: is to walk through the kill chain on this specific machine.
- 1:40Speaker 1: We aren't just going to rattle off a list of
- 1:41Speaker 1: tools for you to memorize.
- 1:43Speaker 2: Well, that wouldn't be very helpful.
- 1:44Speaker 1: We are going to look at why these exploits work
- 1:46Speaker 1: from every angle. We've got back doors hidden in source code,
- 1:49Speaker 1: we've got lazy administrators leaving keys in the door, and
- 1:53Speaker 1: web apps that just let you rewrite their own instructions,
- 1:56Speaker 1: and that distinction is vital.
- 1:58Speaker 2: It's not enough to just know how to run a script.
- 2:01Speaker 2: If you want to be a professional, you need to
- 2:03Speaker 2: understand the underlying architectural failure that let the script work
- 2:06Speaker 2: in the first place.
- 2:07Speaker 1: So before we put on our hoodies and start aggressively
- 2:10Speaker 1: typing on our keyboards, we need to set the stage
- 2:13Speaker 1: the setup. Right, you download this as a compressed file,
- 2:16Speaker 1: you unzip it, and you load it into something like
- 2:19Speaker 1: VMware or virtual box. But and this is a massive
- 2:23Speaker 1: flashing red warning light, we need to talk about the
- 2:26Speaker 1: network setup.
- 2:27Speaker 2: This part is non negotiable. When you can figure the
- 2:30Speaker 2: network settings for a virtual machine, you usually have a
- 2:33Speaker 2: choice between that and bridge mode.
- 2:36Speaker 1: Bridge mode is the dangerous one here.
- 2:38Speaker 2: Very if you choose bridge mode, you were telling the
- 2:42Speaker 2: vm to act like a completely separate physical device on
- 2:45Speaker 2: your actual local network, so.
- 2:46Speaker 1: It pulls its own IP address directly from your router,
- 2:49Speaker 1: just like your laptop or your smartphone.
- 2:51Speaker 2: Was exactly and since metasploitable two is designed to be
- 2:54Speaker 2: hacked by literally anyone. If you put it on bridge
- 2:57Speaker 2: mode and you happen to be on public Wi Fi,
- 2:59Speaker 2: oh wow. Or even if your home network just has
- 3:01Speaker 2: one compromised device like say a cheap smart ball, right,
- 3:05Speaker 2: that vulnerability is now totally exposed to the network.
- 3:08Speaker 1: So you're basically inviting the call to come from inside
- 3:11Speaker 1: the house.
- 3:11Speaker 2: Precisely, you have to keep it on host only or
- 3:14Speaker 2: GNAT networking, keep it isolated. Treat this thing like a
- 3:17Speaker 2: live grenade. You don't pull the pin in a crowded room.
- 3:20Speaker 1: Message received. Safety first, so let's assume we've booted it
- 3:25Speaker 1: up safely isolated from the world. The login screen stares
- 3:29Speaker 1: at you, and this brings us to our first lesson
- 3:32Speaker 1: in security by obscurity or I guess the total lack thereof.
- 3:36Speaker 2: The default credentials.
- 3:37Speaker 1: Yeah, the login meant for the admin is using name
- 3:40Speaker 1: msfadmin and the password is Drummroll ms fadmin, which.
- 3:44Speaker 2: Is convenient for getting into the system console. So we
- 3:46Speaker 2: log in. We wrote the ifcnfit command to get our
- 3:49Speaker 2: IP address, and then we switch rolls.
- 3:51Speaker 1: We put on the black hat.
- 3:52Speaker 2: Right, we were no longer the admin. We're now the attacker,
- 3:55Speaker 2: sitting on a different machine, usually running Collie Linux, just
- 3:58Speaker 2: staring at that IP address.
- 3:59Speaker 1: We found there's a reconnaissance phase, so we know the
- 4:02Speaker 1: IP and we've discovered the surface area. I want to
- 4:04Speaker 1: start with the stuff that really freaks me out, the
- 4:06Speaker 1: supply chain attacks.
- 4:08Speaker 2: Well, these are fascinating.
- 4:09Speaker 1: Because this isn't about a user making a silly mistake.
- 4:12Speaker 1: This is about the software itself being poisoned at the
- 4:14Speaker 1: factory before you even install it.
- 4:17Speaker 2: These are arguably the most insidious vulnerabilities because you, as
- 4:21Speaker 2: a system administrator, you can do everything perfectly right, follow
- 4:24Speaker 2: all the best practices, and still lose. Let's like at
- 4:27Speaker 2: port twenty one.
- 4:28Speaker 1: P twenty one is usually FTP right file Transfer Protocol correct.
- 4:32Speaker 2: On this machine, it is running a specific piece of
- 4:34Speaker 2: software called VSFTPD, which actually stands for Very Secure ftpdmon.
- 4:40Speaker 1: That name aged poorly.
- 4:41Speaker 2: It really did. Specifically, this is version two point three
- 4:44Speaker 2: point four. Now here's the wild history behind this. Back
- 4:48Speaker 2: between June and July of twenty eleven, for just a
- 4:51Speaker 2: couple of days, the official download site for vsftpd was compromised. Okay,
- 4:55Speaker 2: hackers got in and replaced the legitimate source code with
- 4:58Speaker 2: a modified version.
- 5:00Speaker 1: So, if I was just a diligent IT professional doing
- 5:02Speaker 1: my job updating my server software on July first, twenty eleven,
- 5:06Speaker 1: I literally downloaded and installed the back door myself.
- 5:09Speaker 2: You did, and the mechanism they used is fascinatingly simple.
- 5:12Speaker 2: The attackers modified the specific block of code that checks
- 5:15Speaker 2: your username when you try to log in, so they
- 5:18Speaker 2: edit a conditional statement, a basic if clause that looked
- 5:20Speaker 2: for a very specific sequence of characters in the username field, like.
- 5:23Speaker 1: A secret handshake, like a smiley face. Wait stop it
- 5:26Speaker 1: a literal colon and a parenthesis.
- 5:28Speaker 2: Yes, a literal smiley face. If the username contained a
- 5:32Speaker 2: smiley face. The code silently triggered a function in the
- 5:36Speaker 2: background that opened a command shell on port sixty two hundred.
- 5:40Speaker 1: It didn't even check the password.
- 5:42Speaker 2: It didn't care if the password was wrong, It didn't
- 5:44Speaker 2: care what the password was. It just saw the smiley
- 5:46Speaker 2: face and said, come on in route.
- 5:48Speaker 1: That feels like they were mocking the users. Smile you've
- 5:51Speaker 1: been hacked. So to exploit this on our end today,
- 5:54Speaker 1: we just need to trigger that exact code exactly.
- 5:57Speaker 2: Now. We could do it manually by connecting and typing
- 5:59Speaker 2: a smile face username, but we usually use metasploit to
- 6:02Speaker 2: automate the process.
- 6:04Speaker 1: The penetration testing framework right.
- 6:06Speaker 2: Phase one is detection. We scan the poor with n map.
- 6:09Speaker 2: We use version detection and we see VSFTPD two point
- 6:13Speaker 2: three point four.
- 6:14Speaker 1: And the moment we see that version number, we know
- 6:16Speaker 1: the back doors there.
- 6:17Speaker 2: We do or you can use metasploits built in auxiliary
- 6:20Speaker 2: scanner for FTP versions either way. Once you spot it,
- 6:23Speaker 2: we move to phase two execution.
- 6:26Speaker 1: So in metasplit we aren't hacking in the Hollywood sense
- 6:29Speaker 1: of green text and cracking passwords. We're just searching for
- 6:33Speaker 1: that vsftpdxploit and selecting the back door module.
- 6:35Speaker 2: Right, you set the RHO stay the target IPA address,
- 6:38Speaker 2: you hit exploit, and metasploit handles the handshake for you.
- 6:41Speaker 2: It sends the smiley face, automatically connects to port sixty
- 6:44Speaker 2: two hundred and just hands you a terminal.
- 6:46Speaker 1: A command shell opens, and if we type wam me,
- 6:50Speaker 1: it returns route game over total control via a compromised
- 6:55Speaker 1: update that is truly terrifying. Okay, let's look at another
- 6:59Speaker 1: one in this supply chain category. Port sixty six sixty seven.
- 7:02Speaker 1: This is IRC right.
- 7:03Speaker 2: Internet Relay Chap. Yes, before slack, before discord, before all
- 7:07Speaker 2: of that, the entire tech community basically lived on IRC.
- 7:10Speaker 1: It was huge, and metasplatable two is running a server
- 7:13Speaker 1: called unreal IRCd exactly, and.
- 7:15Speaker 2: This one had a very similar factory defect. In November
- 7:18Speaker 2: two thousand and nine, a back door was inserted into
- 7:20Speaker 2: its source code.
- 7:21Speaker 1: Another smiley face.
- 7:22Speaker 2: Now this one was disguised much better. It was hidden
- 7:24Speaker 2: inside what looked like a debug statement.
- 7:26Speaker 1: So just look like a harmless testing code left behind
- 7:28Speaker 1: by the developers exactly.
- 7:30Speaker 2: It just looked like a standard macro meant for debugging
- 7:33Speaker 2: the software. But if you sent a specific crafted packet
- 7:36Speaker 2: to the server, that debug code would take whatever input
- 7:39Speaker 2: you gave it and execute it as a system command.
- 7:42Speaker 1: It's the exact same story. You trust the vendor and
- 7:44Speaker 1: you get burned, and.
- 7:45Speaker 2: The exploit path is nearly identical for us. As the attacker,
- 7:49Speaker 2: you use n map to identify the service version on
- 7:51Speaker 2: port sixty six sixty seven, you fire up metasploit search
- 7:55Speaker 2: for unreal IRCd, configure your target IP and launch.
- 7:59Speaker 1: The tool sends the malicious packet.
- 8:01Speaker 2: The server interprets it as a command, and boom, another
- 8:03Speaker 2: command shell opens his root.
- 8:04Speaker 1: Okay, so that covers the sort of James Bond stuff
- 8:07Speaker 1: spies planting bugs in the source code. But I feel
- 8:10Speaker 1: like the vast majority of real world hacks aren't nearly
- 8:13Speaker 1: that sophisticated at all. They're usually just human error.
- 8:16Speaker 2: Absolutely. We call this the low hanging fruit This is
- 8:19Speaker 2: where we transition from blaming the code to blaming what
- 8:23Speaker 2: we call the lazy administrator.
- 8:24Speaker 1: Vulnerability is caused by weak passwords or choosing convenience over
- 8:28Speaker 1: actual security exactly.
- 8:30Speaker 2: Let's look at port twenty one to twenty one. This
- 8:32Speaker 2: is running another FTP server called pra ftpd.
- 8:36Speaker 1: Okay, so unlike the last FTP server, the software itself
- 8:39Speaker 1: is fine.
- 8:40Speaker 2: Here the software is totally fine, no back doors. The
- 8:43Speaker 2: problem is the configuration. The admins set it up with
- 8:47Speaker 2: incredibly weak credentials. They left default or simple passwords active,
- 8:52Speaker 2: like what like username, user, password, user or admin and admin. Seriously,
- 8:57Speaker 2: it happens constantly in the real world. To exploit this,
- 9:00Speaker 2: you can just log in manually via the FTP command.
- 9:03Speaker 1: Line, where you could automate it right right.
- 9:04Speaker 2: You use metaploids ft plogin auxiliary scanner. You feed it
- 9:08Speaker 2: a list of common user names and passwords a brute
- 9:11Speaker 2: force dictionary, and it just tries them all until it
- 9:13Speaker 2: gets a hit.
- 9:14Speaker 1: That is painfully simple. But I saw in the outline
- 9:17Speaker 1: that the database is even worse.
- 9:18Speaker 2: My sqel oh the database is left wide open.
- 9:21Speaker 1: How can it be worse than user slash user.
- 9:23Speaker 2: How about logging in as the root database user with
- 9:26Speaker 2: absolutely no password.
- 9:27Speaker 1: At all, a blank password for the database.
- 9:30Speaker 2: Yep, you can literally log in manually by typing my
- 9:33Speaker 2: squale dash you root dash h and the IP address.
- 9:37Speaker 2: Or if you want to use metasoid, you use the
- 9:39Speaker 2: mice qualm can scanner and just set the blank passwords
- 9:41Speaker 2: option to true. It just walks right in instant access
- 9:44Speaker 2: to the data.
- 9:45Speaker 1: So why do system administrators actually do this? Is it
- 9:48Speaker 1: just pure laziness sometimes?
- 9:51Speaker 2: But often it's fear or convenience. You know. They think
- 9:54Speaker 2: if I change the default database password, I might break
- 9:57Speaker 2: the automated script that runs the backups at three am.
- 10:00Speaker 2: Ah see, So they tell themselves they'll leave it default
- 10:02Speaker 2: just for now, and then they forget and just for
- 10:05Speaker 2: now becomes forever.
- 10:06Speaker 1: And that inertia is what gets you hacked. Oh all right,
- 10:08Speaker 1: I want to talk about something else in this Leezyadamin
- 10:11Speaker 1: category that blew my mind. The remote execution service on
- 10:15Speaker 1: port five thirteen are a log in.
- 10:17Speaker 2: Oh yes, I noticed.
- 10:19Speaker 1: That this vulnerability has a CVSS score of ten. That is,
- 10:23Speaker 1: the absolute maximum severity score of vulnerability can get perfect ten.
- 10:27Speaker 1: What makes it so catastrophic? Is it some incredibly complex
- 10:31Speaker 1: memory corruption.
- 10:32Speaker 2: No, it's friendship.
- 10:33Speaker 1: Friendship, what do you mean?
- 10:34Speaker 2: Well, our log in is a very old legacy protocol
- 10:37Speaker 2: from the days when the Internet was essentially a small, trusted,
- 10:40Speaker 2: academic neighborhood. It allowed users on one trusted machine to
- 10:44Speaker 2: log into another trusted machine without ever typing a password.
- 10:46Speaker 1: How did it know who to trust?
- 10:48Speaker 2: It relied on a configuration file that basically acted as
- 10:52Speaker 2: a VIP list, a list of friends of the server.
- 10:55Speaker 1: So if my machine is on the friends list, I
- 10:57Speaker 1: just bypassed the bouncer and walk right in exactly.
- 11:00Speaker 2: But the flaw here in metasplitable two is that this
- 11:03Speaker 2: service is configured to trust pretty.
- 11:06Speaker 1: Much everyone, so the exploit.
- 11:07Speaker 2: The exploit isn't a script at all. You literally just
- 11:10Speaker 2: open your terminal and type arlog and dash l root
- 11:13Speaker 2: and the target IP address.
- 11:14Speaker 1: You type log me on his root and it just
- 11:16Speaker 1: lets you.
- 11:16Speaker 2: It says welcome route, no password prompt, no verification. You
- 11:21Speaker 2: are instantly the superuser.
- 11:23Speaker 1: That is mind blowing. It's literally leaving your front door
- 11:25Speaker 1: wide open because you assume only your nice neighbors ever
- 11:28Speaker 1: walk down your street.
- 11:30Speaker 2: And speaking of open doors, this leads us perfectly to
- 11:33Speaker 2: the other massive open door on the system. Quote fifteen
- 11:36Speaker 2: twenty four. We call this the rogue shell.
- 11:39Speaker 1: Right. I saw this listed as the ingress lock port.
- 11:42Speaker 1: What exactly is ingriss law.
- 11:43Speaker 2: Historically it was a legitimate database locking service, but in
- 11:47Speaker 2: this context the name is just a misnomer. What's actually
- 11:51Speaker 2: happening is that someone, maybe a developer testing something, or
- 11:55Speaker 2: maybe a previous attacker who compromised the system, has left
- 11:59Speaker 2: a command actively listening on this high port, a listening shell.
- 12:04Speaker 2: Think of it like a telephone that automatically answers the
- 12:06Speaker 2: second it rings yeah, and instead of a person saying hello,
- 12:09Speaker 2: it connects you directly into the operating system's brain with
- 12:12Speaker 2: root privileges.
- 12:13Speaker 1: So how do we connect to it?
- 12:14Speaker 2: You don't even need metasploid. You can detect it with enmap,
- 12:17Speaker 2: and then you just use telnet directly to port fifteen
- 12:20Speaker 2: twenty four.
- 12:21Speaker 1: Tell Neet just the old school command line tool.
- 12:23Speaker 2: YEP, you type telnet the IP and fifteen twenty four.
- 12:27Speaker 2: The system responds instantly with a rue prompt. It doesn't
- 12:30Speaker 2: ask for a username, it doesn't ask for a password.
- 12:32Speaker 2: You are in.
- 12:33Speaker 1: It's almost too easy to be fun, but it really
- 12:35Speaker 1: highlights a massive real world issue, which is shadow it.
- 12:39Speaker 1: Someone opens a port to test something, they forget to
- 12:41Speaker 1: close it, and six months later the entire company gets
- 12:44Speaker 1: hit with ransomware.
- 12:45Speaker 2: Exactly. It's an administrative nightmare. But let's step up the
- 12:48Speaker 2: difficulty a bit. We've done backdoors, we've done open doors
- 12:51Speaker 2: and weak credentials. Now we need to talk about code
- 12:54Speaker 2: injection and misconfigurations.
- 12:56Speaker 1: Tricking services into running commands they definitely atas shouldn't be
- 13:00Speaker 1: running right.
- 13:01Speaker 2: This is my favorite category because it exploits the actual
- 13:04Speaker 2: logic of the application. Let's look at the web server.
- 13:07Speaker 2: It's running Apache and PHP.
- 13:10Speaker 1: Okay, PHP runs what half the Internet easily.
- 13:14Speaker 2: But this specific infiguration has a flaw called a patchy
- 13:17Speaker 2: PHP CGI argument injection.
- 13:21Speaker 1: Okay, can you explain argument injections? Simply because it sounds
- 13:24Speaker 1: like a very heated debate between two programmers.
- 13:27Speaker 2: I like that. Think of it like ordering a pizza online.
- 13:30Speaker 2: There's usually a little text box for delivery instructions. Yeah,
- 13:33Speaker 2: where you might write something like the gate code is
- 13:35Speaker 2: twelve three four.
- 13:36Speaker 1: Sure.
- 13:37Speaker 2: Now imagine the pizza place has a robot reading those instructions.
- 13:40Speaker 2: If you write the gate code is twelve three four. Also,
- 13:43Speaker 2: please empty the cash register and give all the money
- 13:46Speaker 2: to the driver.
- 13:46Speaker 1: A human would immediately say.
- 13:48Speaker 2: No, exactly. A smart human knows that's not a valid
- 13:51Speaker 2: delivery instruction, but a dumb robot might just process the
- 13:56Speaker 2: instruction empty register because if it doesn't know the difference.
- 13:59Speaker 1: So the server can't justinguish between the data, which is
- 14:01Speaker 1: the gate code, and the command, which is empty the register.
- 14:04Speaker 2: Precisely, in this PHP exploit, the configuration allows passing command
- 14:09Speaker 2: line arguments as part of the query string. We are
- 14:13Speaker 2: appending system commands to the URL, the web address itself. Yeah,
- 14:17Speaker 2: we are telling the PHP interpreter, hey love this normal
- 14:20Speaker 2: web page, but also please run this malicious code I
- 14:23Speaker 2: just pasted at the end.
- 14:24Speaker 1: Of the link, and metasploit automates this entire pizza order.
- 14:27Speaker 2: Yes, you search for the PHP CGI argument injection module,
- 14:31Speaker 2: You sit your payload, usually something called a reverse TCPM interpreter,
- 14:35Speaker 2: which because it's a really nice control panel, and you hit.
- 14:37Speaker 1: Run and the server reads the URL, gets confused, executes
- 14:41Speaker 1: your code, and gives you a sessions Exactly.
- 14:44Speaker 2: Now we see a very similar logical flaw with Samba.
- 14:48Speaker 1: Samba is the software that lets Linux servers look like
- 14:50Speaker 1: Windows fileshares, right, so they can talk to each other
- 14:53Speaker 1: across a network.
- 14:54Speaker 2: Right. And the flaw here specifically involves something called the
- 14:58Speaker 2: user mapscript vulnerability.
- 15:00Speaker 1: And this is another injection attack.
- 15:01Speaker 2: Yes, it's another case of poor input sanitization. You can
- 15:05Speaker 2: define a script in Samba to map usernames from one
- 15:07Speaker 2: system to another. But if you put actual shell commands
- 15:11Speaker 2: inside the username field, Samba doesn't filter them out, It
- 15:14Speaker 2: just executes them.
- 15:16Speaker 1: It seems like a massive recurring theme here. The application
- 15:19Speaker 1: just blindly trusts the input we hand it. You can
- 15:22Speaker 1: figure the module in metasploit, set the target, and Samba
- 15:26Speaker 1: gives you a Rootshell.
- 15:27Speaker 2: That blind trust is the root of almost all injection attacks,
- 15:31Speaker 2: and honestly, nowhere is that trust more abused than in
- 15:33Speaker 2: a service called DISTCCCC.
- 15:37Speaker 1: The distributed C compiler. Let's talk about that.
- 15:39Speaker 2: So, compiling code from text into a running program is
- 15:42Speaker 2: heavy work. It takes a lot of CPU power. So
- 15:45Speaker 2: development teams use this sc to contribute the computing load
- 15:48Speaker 2: across multiple machines on a network.
- 15:50Speaker 1: Like all compile this chunk, you compile that chunk, and
- 15:52Speaker 1: we'll combine them at the end.
- 15:53Speaker 2: Exactly. It is highly efficient for teams, but by design,
- 15:56Speaker 2: DOCC trusts his clients completely. By default, it assumes if
- 16:01Speaker 2: you are on the internal network you must be a
- 16:03Speaker 2: fellow developer helping with the work.
- 16:05Speaker 1: It has no authentication, no ID check at the door, none.
- 16:08Speaker 2: So we use a metaspolit module to connect to port
- 16:11Speaker 2: three six thirty two and essentially say hey, I have
- 16:13Speaker 2: a compiled job for you. But the job isn't compile
- 16:16Speaker 2: this c code.
- 16:17Speaker 1: The job is give me a command show right.
- 16:19Speaker 2: We abuse that trust to execute arbitrary commands, and the
- 16:22Speaker 2: just ccdmon just says, sure thing, boss, and execute it.
- 16:25Speaker 1: It's tragic, really, It's a tool built entirely for teamwork
- 16:29Speaker 1: and cooperation being used for absolute betrayal.
- 16:32Speaker 2: That is surprisingly poetic. But yes, that's exactly what it is.
- 16:35Speaker 1: Now, there's one more in this misconfiguration category. I want
- 16:37Speaker 1: to touch on the Java RMI server on port ten
- 16:40Speaker 1: ninety nine.
- 16:41Speaker 2: Ah, yes, remote method invocation.
- 16:44Speaker 1: What's the flaw here?
- 16:45Speaker 2: It's another insecure default configuration. Java RMI is meant to
- 16:49Speaker 2: allow Java objects on one machine to invoke methods on
- 16:52Speaker 2: an object running on another machine, but the default setup
- 16:55Speaker 2: allows unauthenticated attackers to just execute code.
- 16:58Speaker 1: So no password require again, right, use.
- 17:01Speaker 2: NMP to spot the Java RMI service. Then you load
- 17:05Speaker 2: up the Java mighta server exploit in metasploit, send over
- 17:08Speaker 2: Java interpreter payload, and you compromise the system.
- 17:11Speaker 1: Okay, we are moving fast. We're at the final stage now,
- 17:14Speaker 1: the application layer. We've been hitting the network and the
- 17:17Speaker 1: OS services. But now let's hit a web application directly.
- 17:20Speaker 2: Well, we have the stacks, right.
- 17:22Speaker 1: Let's talk about apatche Tomcat.
- 17:23Speaker 2: Tomcat is an absolute beast in the enterprise world. It's
- 17:27Speaker 2: a Java application server and on metasportable two. It's running
- 17:31Speaker 2: on port eighty one eighty.
- 17:32Speaker 1: Now, in all the previous examples, we usually just ran
- 17:35Speaker 1: one exploit module or typed one command and we were in.
- 17:38Speaker 1: But this one feels a bit more like a heist.
- 17:40Speaker 1: It has distinct phases it does.
- 17:42Speaker 2: It requires a bit of a kill chain. Step one
- 17:45Speaker 2: is discovery. We use enmap with the service version flag
- 17:48Speaker 2: to find Tomcat running on that specific port.
- 17:50Speaker 1: Okay, step one complete. What's step two?
- 17:52Speaker 2: Step two is credential hunting. We can't just exploit a
- 17:56Speaker 2: codebug here. We actually need to log into the Tomcat
- 17:58Speaker 2: manager application.
- 18:00Speaker 1: We're back to guessing passwords we are.
- 18:02Speaker 2: We use an auxiliary scanner in Metaspoid called tomcat growl
- 18:06Speaker 2: log in. It hammers the manager login paid with a
- 18:09Speaker 2: list of common default credentials.
- 18:11Speaker 1: And what does it find? Let me guess.
- 18:13Speaker 2: I bet you can guess. The username is tomcat and
- 18:16Speaker 2: the password is tomcat.
- 18:17Speaker 1: Incredible. Okay, so we are logged in as the manager.
- 18:20Speaker 1: But logging into a web dashboard isn't the same as
- 18:23Speaker 1: having a command shell on the server. How do we
- 18:26Speaker 1: escalate that into total control? Step three?
- 18:30Speaker 2: This is the really cool part. Tomcat's whole purpose is
- 18:33Speaker 2: to allow managers to upload and run Java applications. These
- 18:37Speaker 2: web apps are packaged in files called war files web
- 18:40Speaker 2: application archives.
- 18:41Speaker 1: Okay, so we just upload our own app exactly.
- 18:44Speaker 2: We use the tomcat ropeload exploit module. It uses those
- 18:48Speaker 2: valid credentials we just found to create and upload a
- 18:51Speaker 2: malicious trojan horse application.
- 18:53Speaker 1: An app that looks valid to the server but contains
- 18:55Speaker 1: our Java interpreter payload.
- 18:57Speaker 2: Right, Tomcat sees a perfectly valid upload coming from a
- 19:00Speaker 2: valid manager account, so it automatically deploys it. It runs
- 19:02Speaker 2: our app, and the very moment that malicious app starts,
- 19:05Speaker 2: it connects back.
- 19:06Speaker 1: To us and interpreter session opens. We're in. But wait,
- 19:10Speaker 1: I remember from the outline that when we do this,
- 19:12Speaker 1: we aren't rout right. If we run Wollma, it says
- 19:15Speaker 1: the user is Tomcat fifty five.
- 19:16Speaker 2: That is a very sharp observation, and it's a crucial
- 19:19Speaker 2: difference to understand. When you exploit the kernel or root
- 19:23Speaker 2: service like that VSFTPD back door, Yeah, you are practically
- 19:26Speaker 2: god on that machine, but when you exploit a web application,
- 19:30Speaker 2: you're usually just a peasant. You only have the permissions
- 19:33Speaker 2: assigned to that specific web app user account, in this
- 19:36Speaker 2: case tomcab fifty five.
- 19:38Speaker 1: So I can trash the website, I can mess with
- 19:40Speaker 1: the database connections the app uses, but I can't necessarily
- 19:44Speaker 1: wipe the server's hard drive or read the shadow password files.
- 19:47Speaker 2: Not immediately. No, your next step in the real world
- 19:50Speaker 2: would be privileged escalation. Yeah, you'd have to find a
- 19:53Speaker 2: secondary vulnerability to jump from the Tomcat user up to root,
- 19:56Speaker 2: but honestly, that is a whole other deep dive for
- 19:59Speaker 2: another day.
- 19:59Speaker 1: Yeah, we have already covered a staggering amount of ground today.
- 20:02Speaker 1: We've broken into this machine via FTP backdoors, IRCd bug flaws,
- 20:07Speaker 1: legacy SSH alternatives like or log in, open databases and
- 20:11Speaker 1: Java application servers.
- 20:12Speaker 2: And we used exactly the same framework metasploid for almost
- 20:15Speaker 2: all of it.
- 20:15Speaker 1: It really emphasizes just how incredibly powerful these tools are.
- 20:20Speaker 1: But before we wrap up today, I want to put
- 20:23Speaker 1: you the listener on the spot oh pop quiz exactly.
- 20:27Speaker 1: I want to see if you've been paying attention to
- 20:28Speaker 1: the mechanics of what we discussed, not just memorizing the
- 20:31Speaker 1: tool names. I'm going to ask three questions. The question one,
- 20:35Speaker 1: early on, we talked about a backdoor that was triggered
- 20:38Speaker 1: by a specific character sequence in the username field. It
- 20:42Speaker 1: wasn't a complex script, it was just a symbol. What
- 20:45Speaker 1: was that symbol?
- 20:46Speaker 2: I'll give you second to think it was the smiley face,
- 20:49Speaker 2: a colon and a parenthesis in the VSFTPD server.
- 20:53Speaker 1: Question two, we discussed an argument injection attack against PHP
- 20:57Speaker 1: and to explain it, we used an analogy about food.
- 21:00Speaker 1: What was that analogy?
- 21:01Speaker 2: That was the pizza delivery robot. The server couldn't tell
- 21:05Speaker 2: the difference between the data, the gate code, and the
- 21:07Speaker 2: malicious command to empty the cash register.
- 21:09Speaker 1: Perfect. Last one, and this is a big conceptual one.
- 21:12Speaker 1: Why was the DISTCC compiler vulnerable to giving us a
- 21:15Speaker 1: command show was it a buffer overflow or was it
- 21:18Speaker 1: something else?
- 21:18Speaker 2: Entirely, it was a trust issue. It had zero authentication
- 21:22Speaker 2: because it was designed to assume that everyone on the
- 21:24Speaker 2: internal network was a trusted friend.
- 21:26Speaker 1: If you got those right, then you aren't just memorizing commands.
- 21:30Speaker 1: You are actually understanding how security works at an architectural level.
- 21:34Speaker 2: And that brings me to my final thought for this
- 21:36Speaker 2: deep dive. If you look at this entire list of
- 21:39Speaker 2: targets VSFTPD, Tomcat, my sequel, disley CC, what is the
- 21:45Speaker 2: common thread running through all of.
- 21:46Speaker 1: Them that they were all ultimately vulnerable.
- 21:48Speaker 2: That they were all defaults, default code from a vendor
- 21:52Speaker 2: that wasn't audited, default passwords left unchanged, default trust configuration.
- 21:57Speaker 1: Oh yeah.
- 21:58Speaker 2: Security is rarely about fighting a genius hagger in a
- 22:01Speaker 2: dark room wearing a hoodie. It is almost always about
- 22:04Speaker 2: changing the defaults.
- 22:05Speaker 1: The very moment you unbox a server or spin up
- 22:07Speaker 1: a VM, the clock starts ticking to change those default
- 22:10Speaker 1: settings exactly.
- 22:12Speaker 2: The most powerful security tool you have isn't a million
- 22:14Speaker 2: dollar firewall. It's a solid setup checklist.
- 22:17Speaker 1: I absolutely love that well that wraps up our dissection
- 22:19Speaker 1: of metaspolitable two. If you want to try this yourself,
- 22:22Speaker 1: you can find the VM online, but remember put it
- 22:25Speaker 1: on a host only network.
- 22:27Speaker 2: Do not bridge it to your Wi Fi.
- 22:28Speaker 1: Seriously, don't do it. Keep it safe and see if
- 22:31Speaker 1: you can find the smiley face back door yourself. Happy ending,
- 22:35Speaker 1: thanks for listening to the Deep Dive. We'll see you
- 22:38Speaker 1: next time.