Latest / CyberSecurity Summary / Hands-On AWS Penetration Testing with Kali Linux: Set up a virtual lab and pentest major AWS services, including EC2, S3, Lambda
Transcript
- 0:00Speaker 1: You know, usually in cloud architecture, you're building a fortress.
- 0:04Speaker 1: You can figure your keys, you lock down all the
- 0:06Speaker 1: ingress rules, and the security engineer just kind of points
- 0:09Speaker 1: at the architecture and says, there it is impenetrable.
- 0:12Speaker 2: Right, that's the standard goal. You want to keep everyone
- 0:14Speaker 2: out exactly.
- 0:16Speaker 1: But today we are taking the exact opposite approach. We're
- 0:19Speaker 1: deliberately building a house of cards. We are looking at
- 0:22Speaker 1: excerpts from the book hands on AWS Penetration Testing with
- 0:27Speaker 1: Caulli Linux by Carl Gilbert Benjamin Caddle.
- 0:30Speaker 2: Yeah, and it's a really fascinating text because it flips
- 0:32Speaker 2: the script.
- 0:33Speaker 1: It really does. The mission for this deep dive is
- 0:36Speaker 1: to demystify how cybersecurity professionals practice their craft. We are
- 0:41Speaker 1: going to guide you through the exact blueprint for building
- 0:44Speaker 1: a personal quarantine hacking laboratory entirely in the Amazon Web
- 0:49Speaker 1: Services cloud.
- 0:50Speaker 2: Because you know, abstract theory only gets you so far, right, So.
- 0:53Speaker 1: Instead of learning how to build secure servers today, we
- 0:55Speaker 1: are intentionally building incredibly vulnerable ones. Okay, let's impact it.
- 1:00Speaker 1: Why why would anyone pay Amazon to host a server
- 1:05Speaker 1: that is basically begging to be hacked?
- 1:07Speaker 2: Well, because you can't meaningfully patch a vulnerability if you
- 1:11Speaker 2: have never watched it being exploited in real time.
- 1:13Speaker 1: Oh sure that makes sense.
- 1:15Speaker 2: Yeah, I mean to really understand the mechanics of an attack,
- 1:18Speaker 2: you need a controlled, completely isolated environment, somewhere you can
- 1:22Speaker 2: launch live exploits without the risk of bringing down your
- 1:26Speaker 2: company's actual production database. You need infrastructure that is meant
- 1:30Speaker 2: to be compromised, which.
- 1:31Speaker 1: Means before you can practice those exploits, you need something
- 1:34Speaker 1: to actually hack. You have to meticulously construct the crash
- 1:38Speaker 1: test dummies basically exactly.
- 1:41Speaker 2: And the blueprint we're following starts with provisioning two highly
- 1:44Speaker 2: vulnerable target machines. Right in AWS, we start with a
- 1:48Speaker 2: Linux machine specifically and one to sixteen point zero four.
- 1:52Speaker 1: Instance, which is pretty outdated, right.
- 1:54Speaker 2: Very outdated, and that gives us a fragile foundation. But
- 1:57Speaker 2: the real focal point is the application layer design calls
- 2:00Speaker 2: for downloading a specific heavily backdoored FTP server directly from
- 2:04Speaker 2: a gehabripo. It's called VSFTPD. Doatch two point three point
- 2:09Speaker 2: four infected dot get.
- 2:10Speaker 1: Man the two point three point four version of VSFTPD
- 2:14Speaker 1: that is like legendary and offensive security sort of absolutely
- 2:17Speaker 1: for anyone who hasn't encountered it. This is the infamous
- 2:20Speaker 1: smiley face backdoor from way back in twenty eleven. Basically,
- 2:24Speaker 1: if an attacker tries to log into the FTP server
- 2:27Speaker 1: and just adds a smiley face like a colon and
- 2:31Speaker 1: a parenthesis to the end of their username, the malicious
- 2:34Speaker 1: code intercepts that strength.
- 2:35Speaker 2: And it silently forks a root shell on port sixty
- 2:38Speaker 2: two hundred.
- 2:39Speaker 1: Yes, it is a literal wink to the attacker. It's crazy.
- 2:43Speaker 2: It is brilliantly simple. But getting that infected code to
- 2:45Speaker 2: actually run on our modern lab instance, that requires some
- 2:49Speaker 2: bizarre reverse engineering.
- 2:51Speaker 1: Because you aren't just downloading a package, right, You're building
- 2:53Speaker 1: this malware from the raw.
- 2:55Speaker 2: Source code, right, And the raw code for this specific
- 2:58Speaker 2: back door is actually, well, it's a bit. If you
- 3:00Speaker 2: just run the standard make command to compile it, the
- 3:03Speaker 2: compilation completely fails.
- 3:04Speaker 1: Yeah, you have to open the make file and manually
- 3:06Speaker 1: append a dollar crypt linker flag before compiling it.
- 3:10Speaker 2: What's fascinating here is the deliberate precision required to be insecure.
- 3:14Speaker 2: I love that phrase, right, because that doacwork flag. It
- 3:18Speaker 2: tells the compiler to link the operating system's cryptography libraries
- 3:22Speaker 2: into the FTP executable. The back door needs to intersect
- 3:26Speaker 2: the authentication process, which means it has to interface with
- 3:29Speaker 2: the system's password hashing mechanisms.
- 3:31Speaker 1: And without that flag, it just breaks.
- 3:33Speaker 2: Exactly Without it, the malware throws a segmentation FAULL and crashes.
- 3:38Speaker 2: So you're basically debugging the attacker's malware to ensure it
- 3:42Speaker 2: successfully compromises your own system.
- 3:44Speaker 1: That is so wild. It's like building a custom escape room,
- 3:47Speaker 1: but instead of trying to break out, you are intentionally
- 3:49Speaker 1: planting flaws so you can practice breaking in.
- 3:52Speaker 2: That's a perfect analogy.
- 3:53Speaker 1: And we don't stop there. The text says we have
- 3:55Speaker 1: to create a system user named nobody and a directory
- 3:59Speaker 1: named empty.
- 4:00Speaker 2: Right, you're carefully satisfying all the environmental prerequisites the damon expects,
- 4:04Speaker 2: just so the back door can run silently in the background.
- 4:06Speaker 1: Yeah. And then finally we edit the vsftpd dot com
- 4:10Speaker 1: file to explicitly enable local user logins.
- 4:14Speaker 2: Which ensures the authentication mechanism is fully active and ready
- 4:17Speaker 2: to process that smiley faced trigger. It really moves vulnerability
- 4:21Speaker 2: from a theoretical concept into very specific lines of compiled
- 4:25Speaker 2: code running in memory.
- 4:27Speaker 1: Right, So, okay, we have our network level backdoor in
- 4:29Speaker 1: the Linux dummy, but we also need to observe application
- 4:32Speaker 1: layer flaws, which brings us to the Windows target.
- 4:35Speaker 2: Ah, yes, the Windows target.
- 4:37Speaker 1: Yeah. If the Linux machine is an old workhorse, this
- 4:39Speaker 1: Windows target is a total relic. We are provisioning a
- 4:42Speaker 1: Windows Server two thousand and three instance straight from the
- 4:45Speaker 1: AWS marketplace.
- 4:46Speaker 2: Which is wild because Server two thousand and three lacks
- 4:49Speaker 2: address base layout randomization and like most modern execution protections.
- 4:53Speaker 1: But getting into this instance in the cloud introduces a
- 4:57Speaker 1: really unique AWS workflow.
- 4:59Speaker 2: Right it does. AWS strongly discourages password authentication, but since
- 5:02Speaker 2: we're using Remote Desktop Protocol to access the Windows GUI,
- 5:05Speaker 2: we actually need a password.
- 5:07Speaker 1: And AWS doesn't just email you the administrator credentials that
- 5:11Speaker 1: would be too easy. When the EC two instance books up,
- 5:15Speaker 1: it generates a random password, encrypts that password using the
- 5:17Speaker 1: public rsakey you assigned at launch, and then dumps that
- 5:20Speaker 1: ciphertext into the system log via the EC two metadata service.
- 5:25Speaker 2: It's actually a very elegant way to handle credentials without
- 5:28Speaker 2: the hypervisor or AWS itself ever knowing your actual plain
- 5:32Speaker 2: text password.
- 5:33Speaker 1: So to get in you have to download that encrypted
- 5:35Speaker 1: payload from the console and process it locally with your
- 5:38Speaker 1: private RSA key.
- 5:40Speaker 2: Exactly, your local machine decrypts the log, revealing the plaintext passwords.
- 5:45Speaker 1: Piece of cryptography. But once we use that password to
- 5:48Speaker 1: RDP into the box, we just completely ruin the neighborhood.
- 5:51Speaker 2: Oh totally.
- 5:51Speaker 1: We install an old bundled version of xampp so that's
- 5:55Speaker 1: a patchy myseqel and PHP, and drop a vulnerable web app,
- 5:58Speaker 1: specifically a SQL injection demo called Shindarth Sickle injection demo
- 6:03Speaker 1: directly into the c stocks folder.
- 6:05Speaker 2: We even log into FEASTPMI admin to manually import the
- 6:08Speaker 2: database dot spl file.
- 6:09Speaker 1: Just bypassing every modern web application firewall and serving up
- 6:13Speaker 1: a brittle database architecture on a silver platter YEP, handing
- 6:17Speaker 1: it right to them.
- 6:17Speaker 2: Okay, here's where it gets really interesting. You've just created
- 6:21Speaker 2: digital biohazards on the public Internet. If we don't immediately
- 6:25Speaker 2: lock them down, real malicious actors will find and compromise
- 6:29Speaker 2: them before we even start.
- 6:30Speaker 1: Exactly, So we have to talk about quarantining these biohazards
- 6:34Speaker 1: using AWS, virtual Private clouds or vpcs.
- 6:38Speaker 2: Right, and a VPC can hold up to what four
- 6:41Speaker 2: ninety six internal IP addresses, but by default AWS blocks
- 6:46Speaker 2: them from talking to each other.
- 6:48Speaker 1: Yeah, it's zero trust out of the box. To allow
- 6:50Speaker 1: the lab machines to communicate. The text tells us to
- 6:53Speaker 1: manually capture the private IP of your attack machine and
- 6:56Speaker 1: edit the inbound rules in the AWS security.
- 6:59Speaker 2: Groups, and you change those rules to allow all traffic
- 7:01Speaker 2: exclusively from that one specific IP, right, effectively cutting off
- 7:05Speaker 2: the rest.
- 7:05Speaker 1: Of the world precisely.
- 7:06Speaker 2: But wait, we are putting incredibly vulnerable machines on the
- 7:09Speaker 2: largest public cloud in the world and relying entirely on
- 7:12Speaker 2: a virtual firewall rule to keep the bad guys out?
- 7:15Speaker 2: Isn't that inherently risky? I mean, it sounds reckless, it
- 7:18Speaker 2: really does. But this is the ultimate lesson in cloud
- 7:21Speaker 2: access control. You have to understand that security groups are
- 7:25Speaker 2: the fundamental perimeter defense in AWS.
- 7:27Speaker 1: Okay, so it's not like a normal firewall, right.
- 7:29Speaker 2: It's not a traditional operating system firewall like IPTA BOWLS
- 7:33Speaker 2: or Windows firewall. It operates independently at the hypervisor layer.
- 7:37Speaker 2: Understanding how to strictly define a loud praffic Essentially, whitelisting
- 7:42Speaker 2: is a non negotiable skill for any cloud engineer.
- 7:45Speaker 1: I see, so the hypervisor acts as the bouncer before
- 7:48Speaker 1: traffic even gets near the operating system.
- 7:50Speaker 2: Exactly.
- 7:51Speaker 1: Okay, so the biohzards are quarantined safely inside the sandbox.
- 7:54Speaker 1: But now you need to sneak your own attack machine
- 7:57Speaker 1: inside that sandbox.
- 7:58Speaker 2: Right, you need to build the attacker's cock pit. The
- 8:01Speaker 2: blueprint specifies deploying the Calli Linux Amazon Machine image, specifically
- 8:05Speaker 2: an older twenty eighteen point one build running on a
- 8:09Speaker 2: T two dot medium instance.
- 8:10Speaker 1: And that T two dot medium gives you two virtual
- 8:13Speaker 1: cores and four gigabytes of RAM, which is super important
- 8:16Speaker 1: because penetration testing tools will just chew through memory.
- 8:18Speaker 2: Oh they absolutely will.
- 8:19Speaker 1: Yeah.
- 8:20Speaker 2: But deploying Collie in the cloud introduces a major access dilemma.
- 8:24Speaker 1: Because AWS requires secure key based authentication by default. But
- 8:29Speaker 1: the book shows how to configure the machine for easy
- 8:32Speaker 1: mobile or browser access.
- 8:33Speaker 2: Right, yes, And to do that you have to alter
- 8:36Speaker 2: the aescetrous config file to change permit root log in
- 8:40Speaker 2: and password authentication to yes.
- 8:43Speaker 1: Wow.
- 8:43Speaker 2: Yeah, this raises an important question. You are actively reducing
- 8:48Speaker 2: your security stance to enable root password logins. It highlights
- 8:52Speaker 2: this eternal tug of war and tech between ultimate security,
- 8:55Speaker 2: so key based limited users and ultimate convenience, which is
- 8:59Speaker 2: browser based root access.
- 9:01Speaker 1: Right, and we get that convenience by installing a patch Guacamole.
- 9:04Speaker 1: I like to think of Guacamole as having a high
- 9:06Speaker 1: tech remote control that lets you pilot your attack ship
- 9:08Speaker 1: from a coffee shop using just a web browser.
- 9:10Speaker 2: That's exactly what it is. But to set it up
- 9:12Speaker 2: you need specific hardening steps because you just open up
- 9:15Speaker 2: your SSH canfig right.
- 9:17Speaker 1: You don't want someone else stealing your attack.
- 9:18Speaker 2: Ship exactly, So you install it too the uncomplicated firewall
- 9:22Speaker 2: and fail to banning to stop root force attacks. Then
- 9:24Speaker 2: you open port twenty two for SSH and port five
- 9:27Speaker 2: five five five five for Guacamole.
- 9:29Speaker 1: Yeah, and the book details changing the Tomcat eight server
- 9:32Speaker 1: port to five five five five five, installing XRDP for
- 9:35Speaker 1: the remote desktop, and setting up the userbambing dot xml file.
- 9:39Speaker 2: That user dash mapping dot xml file is critical because
- 9:43Speaker 2: it tells Guacamole how to connect the browser session to
- 9:46Speaker 2: the local XRDT service.
- 9:47Speaker 1: It's an amazing setup. So, Okay, you are sitting in
- 9:50Speaker 1: the cockpit, you have the controls, but right now you
- 9:53Speaker 1: are flying blind. Before you attack you need to map
- 9:56Speaker 1: out the vulnerabilities of your.
- 9:57Speaker 2: Targets because you need to know exactly what you're dealing with,
- 10:00Speaker 2: which means installing nessa's a really popular automated vulnerability scanner.
- 10:03Speaker 1: Right, But there are logistics involved. The text mentions you
- 10:07Speaker 1: have to download the dot deb package from tenable and
- 10:09Speaker 1: use a tool like win SCP to securely transfer it
- 10:12Speaker 1: to the KALIEC two INSI.
- 10:13Speaker 2: Yeah, and then you install it via the dpkg command.
- 10:16Speaker 2: But here is the final trick. NESSUS runs its own
- 10:19Speaker 2: local web interface.
- 10:21Speaker 1: And you can't just open a browser on a headless server.
- 10:23Speaker 2: Exactly To securely view it on your local computer, you
- 10:26Speaker 2: must create an SSH tunnel. You forward Colley's port eight
- 10:29Speaker 2: eight three four back to your local one two seven
- 10:31Speaker 2: by zero point one point eight eight three four.
- 10:34Speaker 1: Oh that is so clever. So once you do that,
- 10:37Speaker 1: you just open your local browser, register a home license,
- 10:40Speaker 1: and initialize the scanner data.
- 10:41Speaker 2: Yep, it pipes the interface securely over SSH right to
- 10:45Speaker 2: your screen.
- 10:46Speaker 1: So what does this all mean for our toolkit? It's
- 10:48Speaker 1: basically like turning on the targeting radar in a fighter jet.
- 10:52Speaker 1: It automates all the heavy lifting of finding exactly where
- 10:55Speaker 1: the armor is weak.
- 10:56Speaker 2: It really is, and running these NESSA scans mimics the
- 10:59Speaker 2: exact to automated reconnaissance that malicious spots perform constantly across
- 11:04Speaker 2: the entire Internet. By seeing the output of the scan
- 11:07Speaker 2: on your intentional vulnerabilities, you learn exactly what the enemy
- 11:10Speaker 2: sees when they look at a poorly configured network.
- 11:13Speaker 1: Wow. Okay, so let's summarize where we are. We've taken
- 11:15Speaker 1: you from a completely empty AWS account to a fully functioning,
- 11:19Speaker 1: quarantined cyber warfare.
- 11:21Speaker 2: Lab a pretty dangerous one too.
- 11:23Speaker 1: Yeah, no kidding. You've got an infected Linux server and
- 11:26Speaker 1: Arcaic Windows SQL injection target, and a browser controlled Kali
- 11:30Speaker 1: Linux attack box armed with.
- 11:31Speaker 2: A nessa's radar, all running in the cloud.
- 11:33Speaker 1: Right. And this matters because the cloud isn't just for
- 11:37Speaker 1: hosting websites. It is a highly dynamic, disposable learning environment
- 11:42Speaker 1: where you can build and destroy complex networks for pennies
- 11:45Speaker 1: an hour.
- 11:46Speaker 2: It's an incredible resource for cybersecurity professionals, it really is.
- 11:50Speaker 1: But I want to leave you with a final kind
- 11:51Speaker 1: of lingering question to ponder. We just saw how fast
- 11:55Speaker 1: and easy it is to spin up intentionally vulnerable infrastructure
- 11:59Speaker 1: using pre configure AMIS and code.
- 12:01Speaker 2: From GitHub literally just a few minutes, right.
- 12:04Speaker 1: So, if it's this easy to automate the deployment of
- 12:07Speaker 1: vulnerabilities on purpose, what does that mean for real companies?
- 12:11Speaker 1: Companies whose automated deployment scripts, infrastructure is code might contain
- 12:16Speaker 1: a single, tiny misconfiguration.
- 12:18Speaker 2: Oh that is a terrifying thought.
- 12:20Speaker 1: How many accidental crash test dunies are out there on
- 12:22Speaker 1: the real Internet right now, just waiting for someone's radar
- 12:25Speaker 1: to ping them