Latest / CyberSecurity Summary / Beginner's Guide to Exploitation on ARM Vol 2
Transcript
- 0:00Speaker 1: Welcome to the deep dive. Today, we're diving into the
- 0:03Speaker 1: world of AR exploitation. Ooh exciting using Beginner's Guide to
- 0:07Speaker 1: Exploitation on Arm Volume two by Billy Ellis.
- 0:11Speaker 2: Oh yeah, I've heard of that one.
- 0:13Speaker 1: It's going to get pretty technical.
- 0:14Speaker 2: Yeah, this book gets right into it.
- 0:16Speaker 1: But even if you're not a programmer, you know, understanding
- 0:19Speaker 1: these concepts I think is absolutely super important for cybersecurity.
- 0:23Speaker 2: It is. Yeah, so like learning to think like the
- 0:25Speaker 2: enemy exactly.
- 0:26Speaker 1: Yeah, like reading the Attacker's playbook. Yeah, so this is
- 0:29Speaker 1: volume two. It builds on concepts from the first book.
- 0:33Speaker 2: Right.
- 0:33Speaker 1: It assumes that you have some basic knowledge.
- 0:36Speaker 2: Yeah, it kind of jumps right in.
- 0:37Speaker 1: Programming and memory corruption and that it does. It gives
- 0:40Speaker 1: you all these like real world code examples and exercises.
- 0:45Speaker 2: You can really get your hands dirty with this one.
- 0:46Speaker 1: Oh yeah, and I see it also mentions that you
- 0:49Speaker 1: need a jail broken arm device.
- 0:51Speaker 2: Yeah, you need a way to actually test this stuff out.
- 0:53Speaker 1: To really try out the exercises.
- 0:54Speaker 2: Right, But even if you're not going to do any
- 0:56Speaker 2: actual hacking, it's still so valuable to understand how these
- 0:59Speaker 2: things work.
- 1:00Speaker 1: Okay, so let's take a look at some of the
- 1:01Speaker 1: stuff that we're going to be covering, right, Integer overflows
- 1:04Speaker 1: off by one errors. Oh yeah, I'm a classic double
- 1:06Speaker 1: free conditions stack pivoting stackpivoty is always fun to hijack
- 1:10Speaker 1: program execution.
- 1:12Speaker 2: That's the goal, right.
- 1:13Speaker 1: It sounds intense.
- 1:15Speaker 2: It is intense, but also super fascinating.
- 1:17Speaker 1: So let's start with integer overflows. Chapter one dives right in,
- 1:20Speaker 1: as does with this program called into overflow dot C. Okay,
- 1:24Speaker 1: and it's pretty simple. It's checking if input data is
- 1:27Speaker 1: less than thirty two bytes.
- 1:28Speaker 2: Sounds simple enough, Yeah, what could go wrong?
- 1:31Speaker 1: But the problem is the data type that's used to
- 1:34Speaker 1: store the length. Ah, it's an unsigned chart, which can
- 1:38Speaker 1: only hold values from zero to two fifty five.
- 1:41Speaker 2: Right, so if you exceed that what happens? Then that's
- 1:44Speaker 2: where the fun begins.
- 1:45Speaker 1: Yeah? Does it throw an error?
- 1:46Speaker 2: Well not exactly, Okay, it causes this wrap around effect
- 1:50Speaker 2: wrack around. Yeah. If you've ever seen those old school odometers,
- 1:53Speaker 2: Oh yeah, like the ones that roll back to zero
- 1:55Speaker 2: after hitting nine hundred and ninety nine miles. Okay, it's
- 1:58Speaker 2: kind of like that.
- 2:00Speaker 1: You exceed the maximum value and then those bits.
- 2:03Speaker 2: And reset yep, leading to a really small number okay, and.
- 2:06Speaker 1: The book actually has a really cool diagram that shows
- 2:08Speaker 1: this visually.
- 2:09Speaker 2: Oh yeah, they use the eight bits of a char
- 2:11Speaker 2: to illustrate it.
- 2:11Speaker 1: It's super helpful. So this wrap around allows an attacker
- 2:16Speaker 1: to kind of bypass that size check, right because.
- 2:20Speaker 2: The program thinks the data is smaller than it actually.
- 2:22Speaker 1: Is, okay, and write more data into the buffer than intended.
- 2:26Speaker 2: Leading to you guessed it a buffer overflow.
- 2:29Speaker 1: And then the example in the book shows how this
- 2:30Speaker 1: leads to a segmentation fault.
- 2:32Speaker 2: Right, the program just crashes because it can't handle all
- 2:34Speaker 2: that extra data.
- 2:35Speaker 1: So essentially, a tiny coding mistake yep, can cause a
- 2:40Speaker 1: full blown stack buffer overflow.
- 2:42Speaker 2: Which can have some serious consequences.
- 2:44Speaker 1: Yeah, it's a little bit scary.
- 2:46Speaker 2: It is a good reminder that security starts at the
- 2:48Speaker 2: code level.
- 2:49Speaker 1: Yeah, okay, so let's move on to chapter two. Okay,
- 2:52Speaker 1: one byte overflows.
- 2:54Speaker 2: One bite overflows.
- 2:55Speaker 1: My first thought was how much damage can one byte
- 2:58Speaker 1: really do?
- 2:58Speaker 2: Right? It doesn't sound like much, but as this chapter shows, yeah,
- 3:03Speaker 2: even a single byte can be extremely dangerous. It's all
- 3:07Speaker 2: about precision and targeting.
- 3:09Speaker 1: So the example uses two strucks to store data on
- 3:12Speaker 1: the heap and I like how the book provides this
- 3:16Speaker 1: visual representation of the heat layout.
- 3:19Speaker 2: Yeah, those visuals are super helpful. Yeah, for understanding how
- 3:22Speaker 2: the exploit works.
- 3:24Speaker 1: It is.
- 3:24Speaker 2: So the vulnerability here is in this line of code
- 3:28Speaker 2: that copies data from the command line into a buffer,
- 3:32Speaker 2: and it's the loop condition. Okay, less than are equal
- 3:35Speaker 2: to sixteen, that's the problem. Okay, it ends up copying
- 3:38Speaker 2: seventeen bytes instead of sixteen.
- 3:40Speaker 1: That one extra bite. What does that overrite?
- 3:44Speaker 2: That one byte overwrites a function pointer, a function pointer,
- 3:47Speaker 2: and that's where things get really interesting.
- 3:49Speaker 1: So an attacker can like carefully craft their input to
- 3:54Speaker 1: change this pointer to point to their malicious code, and
- 3:58Speaker 1: the book shows this in action. The program's execution is
- 4:02Speaker 1: redirected to through a bunch of bees zero by forty two,
- 4:05Speaker 1: forty two four.
- 4:07Speaker 2: Yeah, b's and hexadecimal after the exploit. It's a classic
- 4:10Speaker 2: demonstration of how manipulating just one.
- 4:13Speaker 1: Bite it's pretty powerful.
- 4:15Speaker 2: You give you complete control, Yeah, over a program.
- 4:18Speaker 1: Okay, So chapter three shifts gears to double free.
- 4:22Speaker 2: Ah, double free?
- 4:23Speaker 1: What's that all about?
- 4:25Speaker 2: This is where we get into the dangers of freeing
- 4:27Speaker 2: the same block of memory twice. Okay, The book uses
- 4:30Speaker 2: some nice step by step diagrams to explain this. I
- 4:32Speaker 2: do like the diagram They're super helpful for visualizing what's
- 4:35Speaker 2: going on.
- 4:36Speaker 1: So you can see how the heap is divided into
- 4:38Speaker 1: blocks bite, and how functions like Malik and free manage memory.
- 4:42Speaker 2: Exactly, and how a double free can create this weird
- 4:45Speaker 2: situation where two pointers are pointing to the same memory location.
- 4:50Speaker 1: That's a dangling pointer, right, that's right. It's like having
- 4:52Speaker 1: a key. It is to a room that's not yours anymore.
- 4:55Speaker 2: Exactly, a key to a room that doesn't even exist anymore.
- 4:58Speaker 1: Okay, So if an attacker can put their controlled data
- 5:01Speaker 1: into that free memory, right, then they can control they.
- 5:05Speaker 2: Can control what those dangling pointers are pointing to. Okay,
- 5:08Speaker 2: so potentially leading to arbitrary code execution.
- 5:11Speaker 1: And the example program they use HEAP level three dot
- 5:13Speaker 1: C Hmmm, it has some security checks to prevent use.
- 5:18Speaker 2: After free, right, they try to make it a little
- 5:20Speaker 2: bit harder.
- 5:20Speaker 1: But there's another bug.
- 5:21Speaker 2: There's always another bug.
- 5:22Speaker 1: Related to free austraya that can be exploited.
- 5:25Speaker 2: Of course, there is.
- 5:26Speaker 1: Why is exploiting the double free in this particular program.
- 5:30Speaker 2: Yeah, so in this case, the key it's because the
- 5:33Speaker 2: attacker has to get two pointers yeah, to point to
- 5:35Speaker 2: the same memory location, which is a bit harder because
- 5:38Speaker 2: of the limited functionality of the example program.
- 5:41Speaker 1: Okay, but in the.
- 5:42Speaker 2: Real world, double free vulnerabilities can often be exploited much
- 5:47Speaker 2: more liably.
- 5:47Speaker 1: So this is like a simplified example. It is, yeah,
- 5:50Speaker 1: to illustrate the concept exactly. Okay, let's talk about stack pivoting.
- 5:54Speaker 2: Oh yes, stack pivoting.
- 5:55Speaker 1: Chapter four is all about this technique.
- 5:58Speaker 2: This is a good one.
- 5:59Speaker 1: It sounds cool, but honestly, the details are a little
- 6:01Speaker 1: fuzzy for me.
- 6:02Speaker 2: Okay. So imagine the stack like a pile of plates, okay,
- 6:05Speaker 2: with the stack pointer pointing to the top plate.
- 6:08Speaker 1: Okay.
- 6:09Speaker 2: Stack pivoting is like grabbing that whole pile of plates
- 6:12Speaker 2: and moving it to a different location that's under the
- 6:16Speaker 2: attacker's control.
- 6:17Speaker 1: So you're redirecting the program's execution flow exactly to like
- 6:22Speaker 1: their own custom stack.
- 6:23Speaker 2: That's the idea.
- 6:24Speaker 1: Okay. So why is this useful for an attacker?
- 6:27Speaker 2: So sometimes the space available on the stack is too small,
- 6:32Speaker 2: okay for them to inject their entire malicious payloads.
- 6:34Speaker 1: They need more room.
- 6:35Speaker 2: They need more.
- 6:36Speaker 1: Room, so they pivot to a different section of memory that's.
- 6:38Speaker 2: Larger exactly, and they control that memory. Okay, so they
- 6:41Speaker 2: have more space to work with.
- 6:43Speaker 1: So the book uses this challenge called ROPL level six
- 6:46Speaker 1: to illustrate this.
- 6:47Speaker 2: It's a good one.
- 6:47Speaker 1: It's a classic heat based buffer overflow. But the twist
- 6:52Speaker 1: is you only get a single gadget, a single gadget
- 6:55Speaker 1: to gain control of R fifteen PC.
- 6:58Speaker 2: Ah. Yes, the program, the key to controlling the program.
- 7:02Speaker 1: So the challenge is to find.
- 7:04Speaker 2: Find that stack pivot gadget, a stack pivot gadget. Luckily,
- 7:08Speaker 2: it's provided in the gadget library.
- 7:10Speaker 1: Okay for this example, So let's take a look at
- 7:12Speaker 1: this gadget.
- 7:13Speaker 2: All right.
- 7:13Speaker 1: It uses two instructions, two instructions MOVs spr five and
- 7:18Speaker 1: pop R four PC.
- 7:20Speaker 2: All right. So the first instruction, the mov spr five. Yeah,
- 7:24Speaker 2: that's the key to the pivot. Okay. It moves the
- 7:26Speaker 2: value of register R five into the stack pointer okay,
- 7:30Speaker 2: which effectively sets the stack pointer to the memory location
- 7:34Speaker 2: pointed to.
- 7:34Speaker 1: By R five, which is controlled by the attacker.
- 7:36Speaker 2: It's controlled by the attacker exactly.
- 7:38Speaker 1: That's the pivot.
- 7:39Speaker 2: That's the pivot.
- 7:40Speaker 1: And then the second instruction.
- 7:41Speaker 2: So the pop R four PC pops.
- 7:43Speaker 1: Two values off the stack it does. The first goes
- 7:45Speaker 1: into R four right, and the second goes into the PC.
- 7:48Speaker 2: The program counter.
- 7:50Speaker 1: So since the attacker has already set the stack to
- 7:53Speaker 1: point to their controlled memory, they can cracked these values,
- 7:57Speaker 1: and in this challenge, that popped value for the PC
- 8:01Speaker 1: leads to the execution of a secret function.
- 8:04Speaker 2: It's a classic stack pivoting technique.
- 8:07Speaker 1: It's very clever, it is, but.
- 8:09Speaker 2: It requires a lot of knowledge about the target program
- 8:12Speaker 2: and the ability to find the right gadgets.
- 8:14Speaker 1: Okay, so that's stack pivoting, that's stat pivoting. Definitely more
- 8:17Speaker 1: advanced than your typical buffer overflow. Oh yeah, this is
- 8:21Speaker 1: getting real.
- 8:22Speaker 2: This is advanced stuff. But that's what attackers use in
- 8:26Speaker 2: the real world.
- 8:26Speaker 1: All right, So let's talk about defenses.
- 8:28Speaker 2: Okay.
- 8:29Speaker 1: Chapter five introduces stack canaries.
- 8:32Speaker 2: Stack canaries.
- 8:34Speaker 1: It sounds kind of cute. It does sound cu for
- 8:36Speaker 1: such a serious security feature.
- 8:38Speaker 2: Don't let the name fool you.
- 8:39Speaker 1: So what are they all about?
- 8:40Speaker 2: So, stack canaries are designed to detect buffer overflows and
- 8:45Speaker 2: prevent arbitrary code execution. Think of it like the canary
- 8:50Speaker 2: in the coal mine.
- 8:51Speaker 1: Okay, so how do they work?
- 8:52Speaker 2: So basically they sing. They don't actually sing.
- 8:55Speaker 1: When there's an overflow.
- 8:56Speaker 2: No, but I like the way you think. It's more
- 8:58Speaker 2: like a trip wire. So a stack canary is a
- 9:01Speaker 2: random value. Okay, let's place on the stack between you
- 9:05Speaker 2: seeing a buffer and the return address.
- 9:06Speaker 1: The book has a really cool visual representation of this. Yeah,
- 9:09Speaker 1: the visual really helps to help you see how it works.
- 9:12Speaker 2: Absolutely.
- 9:12Speaker 1: So before a function returns, right, the program checks the
- 9:16Speaker 1: canary's value exactly, and if.
- 9:18Speaker 2: It's changed, then it knows something's wrong.
- 9:21Speaker 1: It means there's been a buffer overflow most likely yes,
- 9:25Speaker 1: and then the program just terminates gracefully.
- 9:28Speaker 2: Yep, instead of allowing the attacker to run their malicious code.
- 9:31Speaker 1: That's pretty clever.
- 9:32Speaker 2: It is pretty clever.
- 9:33Speaker 1: But I'm sure attackers have figured out ways to get
- 9:36Speaker 1: around this, right of course, like what well.
- 9:39Speaker 2: One common method is to try and leak the canary value.
- 9:43Speaker 1: So if they can figure out what that random value
- 9:45Speaker 1: is exactly, they can just overwrite it with the correct value.
- 9:49Speaker 2: Mm hm and make it look like nothing happened.
- 9:51Speaker 1: During their exploit.
- 9:52Speaker 2: Right.
- 9:53Speaker 1: That's sneaky.
- 9:53Speaker 2: It is sneak.
- 9:54Speaker 1: So the book walks through an example of defeating a
- 9:57Speaker 1: stack canary in this program called canary dot com.
- 10:00Speaker 2: See, yeah, they show you how an attacker would actually
- 10:03Speaker 2: do this. That's pretty interesting.
- 10:04Speaker 1: So they show how to find the instructions that are
- 10:06Speaker 1: responsible right for placing and checking the canary.
- 10:10Speaker 2: They use a debugger.
- 10:11Speaker 1: Yeah, using a debugger like GDB. So our stack canary
- 10:14Speaker 1: is useless.
- 10:15Speaker 2: Then no, not at all. Yeah, there's still a valuable
- 10:18Speaker 2: security feature.
- 10:18Speaker 1: Okay.
- 10:19Speaker 2: They make exploitations significantly.
- 10:21Speaker 1: Harder, so they raise the bar a little bit exactly
- 10:23Speaker 1: for attackers.
- 10:24Speaker 2: They forced attackers to be more sophisticated. Okay, And that's
- 10:28Speaker 2: what defense and depth is all about.
- 10:29Speaker 1: So it's just one layer of protection. It's one layer
- 10:32Speaker 1: in a well secured system exactly. Okay. So let's talk
- 10:35Speaker 1: about heap fung shoe.
- 10:37Speaker 2: Heap fung shoe.
- 10:38Speaker 1: Chapter six is all about this.
- 10:41Speaker 2: This is a fun one.
- 10:42Speaker 1: It sounds surprisingly zen.
- 10:43Speaker 2: It does right hacking technique like arranging furniture for optimal
- 10:47Speaker 2: energy flow, but in memory. But in memory exactly.
- 10:50Speaker 1: So what is heap fung shoe?
- 10:52Speaker 2: So it's all about manipulating the layout of the heap okay,
- 10:56Speaker 2: to make heap based exploits more reliable. Okay, and it
- 11:00Speaker 2: does kind of involve thinking about the arrangement.
- 11:03Speaker 1: Of things like playing tetris with memory.
- 11:05Speaker 2: Yeah, like tetris with memory, trying to get.
- 11:06Speaker 1: Things to line up.
- 11:07Speaker 2: You got it.
- 11:08Speaker 1: The book uses some diagrams.
- 11:10Speaker 2: Again, the diagrams are super helpful for visualizing this.
- 11:13Speaker 1: So they show the initial layout of the heap, and
- 11:16Speaker 1: then they.
- 11:16Speaker 2: Show and then they show how an attacker.
- 11:19Speaker 1: How an attacker can create these.
- 11:21Speaker 2: Holes by strategically allocating and deallocating blocks.
- 11:26Speaker 1: Of memory so they can get their target object allocated
- 11:30Speaker 1: into a specific hole exactly sandwich between controlled data sandwich.
- 11:34Speaker 2: I love that analogy.
- 11:35Speaker 1: And then they can use that controlled data to overwrite
- 11:38Speaker 1: important values.
- 11:40Speaker 2: Like function pointers for example.
- 11:42Speaker 1: And then they walk through an example of attacking the
- 11:44Speaker 1: program heap level three using this technique. They do so
- 11:48Speaker 1: they manipulate the program to fragment the heap.
- 11:50Speaker 2: They do a bunch of allocations and de allocations.
- 11:53Speaker 1: And then, with careful timing, right timing is key, they
- 11:57Speaker 1: allocate a string object and a device object. Okay, so
- 12:02Speaker 1: that the device object ends up between two string objects.
- 12:06Speaker 2: All right, they made their sandwich.
- 12:07Speaker 1: So they've made the sandwich. Yes, Now, how does this
- 12:09Speaker 1: lead to an exploit.
- 12:10Speaker 2: So this layout allows the attacker to overflow a nearby
- 12:15Speaker 2: string object okay, and that overflow data overwrites the function
- 12:21Speaker 2: pointer of the device object.
- 12:22Speaker 1: And then boom, they've got control and.
- 12:24Speaker 2: They control the execution flow.
- 12:26Speaker 1: It's amazing how they can set this up just right.
- 12:29Speaker 2: It's all about setting up the heap for that exploit.
- 12:31Speaker 1: So developers can actually use this knowledge to build more
- 12:35Speaker 1: robust defenses.
- 12:36Speaker 2: By understanding how attackers might manipulate the heap, you can
- 12:39Speaker 2: implement safeguards.
- 12:40Speaker 1: So that's integer overflows, one byte overflows, double free stack, pivoting,
- 12:46Speaker 1: stack canaries. We've covered a lot of ground heap fung shui.
- 12:50Speaker 2: It's amazing how much you can do with memory.
- 12:52Speaker 1: It's a lot, and it's pretty exciting.
- 12:54Speaker 2: It is. It's a fascinating area of security.
- 12:56Speaker 1: But we've only just scratched the surface we have. There's
- 12:59Speaker 1: so much more to explore, So in part two of
- 13:02Speaker 1: our deep dive, we're going to continue exploring some of
- 13:05Speaker 1: the more advanced techniques.
- 13:06Speaker 2: We're going to get into some real world stuff.
- 13:08Speaker 1: Outlined in this book, absolutely including an example of building
- 13:11Speaker 1: an ROP chain on an actual and not an actual
- 13:14Speaker 1: target system. So stay tuned and we'll be back soon.
- 13:18Speaker 2: We'll be back.
- 13:19Speaker 1: Welcome back to the deep dive.
- 13:21Speaker 2: It's great to be back.
- 13:22Speaker 1: In part one, we went through some pretty wild stuff.
- 13:25Speaker 1: Oh we did dodging buffer overflows, playing Tetris with the.
- 13:28Speaker 2: Heap stack pivoting, fun times stack pivoting.
- 13:32Speaker 1: It was like a crash course. It was in memory corruption.
- 13:35Speaker 2: Absolutely, But that was just the warm up, just the basics.
- 13:39Speaker 2: Now we're going deeper, deeper into the rabbit hole.
- 13:41Speaker 1: Into the world of return oriented programming.
- 13:44Speaker 2: Oh yes, ROP or ROP. This is where things get
- 13:48Speaker 2: really interesting.
- 13:49Speaker 1: So Chapter seven of Beginner's Guide to Exploitation on Air,
- 13:53Speaker 1: Volume two is going to be our guy roadmap. Yeah,
- 13:57Speaker 1: our roadmap for this adventure. And we're going to be
- 14:01Speaker 1: looking at how attackers build ROP chains on real.
- 14:05Speaker 2: Systems, real world stuff, targeting the kernel, the heart of
- 14:08Speaker 2: the operating side.
- 14:09Speaker 1: So before we get lost in the assembly jungle.
- 14:12Speaker 2: It can be a juggle out there, let's make sure
- 14:14Speaker 2: we're all.
- 14:14Speaker 1: On the same page. Okay, what exactly is an ROP gadget?
- 14:18Speaker 1: That's an ROP gadget and why are they so important?
- 14:21Speaker 2: Is a pre existing snippet of code? Okay, within a
- 14:25Speaker 2: program that ends with a return instructions okay, and attackers
- 14:30Speaker 2: use these gadgets to indirectly achieve their goals.
- 14:34Speaker 1: So they're not actually writing their own.
- 14:35Speaker 2: Code, right, They can't just inject their own code directly,
- 14:38Speaker 2: so they have to use what's already there.
- 14:40Speaker 1: So they're piecing together existing instructions exactly.
- 14:42Speaker 2: It's like creating a Frankenstein's Monster of code.
- 14:45Speaker 1: It's like a puzzle. It is a puzzle where they
- 14:47Speaker 1: have to find the right pieces, yeah, and.
- 14:49Speaker 2: Fit them together in just the right way to get
- 14:51Speaker 2: the desired outcome.
- 14:52Speaker 1: So why is this so powerful?
- 14:54Speaker 2: Well, because it allows attackers to bypass security mechanisms. Okay,
- 14:59Speaker 2: they try to prevent vent the execution.
- 15:01Speaker 1: Of data by essentially using legitimate code.
- 15:04Speaker 2: Exactly, they're reusing code that's already there.
- 15:06Speaker 1: It's pretty sneaky, is very sneaky, But it sounds like
- 15:09Speaker 1: you need to be pretty skilled to pull this off.
- 15:12Speaker 2: You need a deep understanding of the target system. You
- 15:15Speaker 2: need to know how memory is laid out, what gadgets
- 15:20Speaker 2: are available.
- 15:20Speaker 1: So when we talk about kernel level exploitation, that puzzle
- 15:25Speaker 1: gets even more complex.
- 15:26Speaker 2: Oh yeah, the kernel has a lot of security mechanisms
- 15:29Speaker 2: in place.
- 15:29Speaker 1: So like the iOS kernel that prevents non position independent
- 15:33Speaker 1: binaries from executing.
- 15:35Speaker 2: So attackers need to find ways around that.
- 15:37Speaker 1: Okay, So let's say we have that information, like what
- 15:39Speaker 1: we know the memory layout, where do we even begin
- 15:42Speaker 1: to look for these gadgets?
- 15:44Speaker 2: So there are a few tools and techniques that attackers use.
- 15:47Speaker 2: One common approach is to use a disassembler. A disassembler, yeah,
- 15:51Speaker 2: like Hopper or idea pro.
- 15:53Speaker 1: So they're manually looking through code.
- 15:55Speaker 2: They are, but it can be very tedious.
- 15:58Speaker 1: Especially when you're dealing with something like the iOS kernel.
- 16:00Speaker 2: Yeah, that's a lot of code to sift through.
- 16:03Speaker 1: So are there any shortcuts?
- 16:06Speaker 2: There are? Luckily rules there are tools called ROP gadget finders.
- 16:12Speaker 1: ROP gadget finders.
- 16:14Speaker 2: These tools automatically scan the binary code and extract potential gadgets.
- 16:19Speaker 1: So it makes the process a lot easier, much easier.
- 16:22Speaker 1: Are there any specific gadget finders.
- 16:25Speaker 2: There are a few out there that you would recommend.
- 16:27Speaker 2: The book Mentions one created by Jonathan sall One, Okay,
- 16:30Speaker 2: which you can find on GitHub.
- 16:32Speaker 1: So we've got our gadget finding tools, We're ready to go.
- 16:34Speaker 1: What kind of gadgets are we actually looking for?
- 16:36Speaker 2: So the specific gadgets you need.
- 16:39Speaker 1: What should we be keeping an eye out for.
- 16:41Speaker 2: Depend on your goal, okay, But some common types include
- 16:44Speaker 2: write what whear gadget right what where? These allow you
- 16:47Speaker 2: to write data to a specific memory address.
- 16:51Speaker 1: Okay, so you can control the data exactly.
- 16:53Speaker 2: You can control the target program's data.
- 16:55Speaker 1: Okay. Stack pivot gadgets we've already talked about those.
- 16:58Speaker 2: We have those. Let you redirect the stackpointer. Yeah. And
- 17:02Speaker 2: then system called gadgets.
- 17:04Speaker 1: System call gadgets.
- 17:05Speaker 2: These are very powerful.
- 17:07Speaker 1: Why are they so powerful.
- 17:08Speaker 2: Because they allow you to invoke system calls, okay, which
- 17:12Speaker 2: are functions provided by the operating system.
- 17:14Speaker 1: You can do things like read sensitive file.
- 17:17Speaker 2: You can read files, execute commands.
- 17:19Speaker 1: Have elevated privileges.
- 17:20Speaker 2: With elevated privileges, that's the danger.
- 17:22Speaker 1: It sounds dangerous, it is. So by chaining these different
- 17:26Speaker 1: gadgets together, that's the art of ROP, attackers can create.
- 17:30Speaker 2: Very powerful exploits.
- 17:32Speaker 1: So it's like a chain reaction. It is of carefully planned.
- 17:36Speaker 2: Actions, each gadget triggering.
- 17:38Speaker 1: The next, leading to the ultimate goal.
- 17:40Speaker 2: Exactly. That's a great way to put and.
- 17:42Speaker 1: I imagine domnning an ROP chain. It's not easy, is
- 17:46Speaker 1: not a walk in the park.
- 17:47Speaker 2: No, it's not.
- 17:48Speaker 1: What are some of the challenges.
- 17:49Speaker 2: So one challenge is finding gadgets that work well together. Okay,
- 17:53Speaker 2: not all gadgets can be chained together seamlessly. Yeah, they
- 17:56Speaker 2: might have specific requirements or side effects.
- 17:59Speaker 1: So you need to find the right gadgets.
- 18:01Speaker 2: You need to find the right set of gadgets that
- 18:03Speaker 2: work well together. They work harmoniously together. Yeah. Another challenge
- 18:06Speaker 2: is ASLR. ASLR address space layout randomization.
- 18:12Speaker 1: That's a big one.
- 18:13Speaker 2: It is a big one.
- 18:14Speaker 1: We talked about that.
- 18:14Speaker 2: Before we did.
- 18:15Speaker 1: It randomizes memory addresses. It does make it harder to
- 18:19Speaker 1: predict where things are exactly. So how do attackers deal
- 18:23Speaker 1: with that? Well, they have to get creative, got their
- 18:25Speaker 1: ways around it.
- 18:26Speaker 2: There are sometimes they can exploit other vulnerabilities to leak
- 18:30Speaker 2: information about the memory layout, or use techniques like heap.
- 18:34Speaker 1: Spraying so they can increase the chances of their payload
- 18:39Speaker 1: landing at a predictable address in a specific spot exactly.
- 18:42Speaker 1: So even with ASLR, attackers can still find ways they
- 18:47Speaker 1: can to build their rop chains.
- 18:49Speaker 2: They're very determined.
- 18:51Speaker 1: It's impressive how they can do that.
- 18:53Speaker 2: It's a constant arms race between attackers and defenders.
- 18:56Speaker 1: So it's like attackers are finding ways to bypass.
- 19:00Speaker 2: They are, and then defenders are trying to stay one
- 19:03Speaker 2: step ahead, trying. It's a never ending battle.
- 19:06Speaker 1: So we're nearing the end of part two already of
- 19:09Speaker 1: our rop field adventure Time Flies.
- 19:12Speaker 2: When you're having fun.
- 19:13Speaker 1: What are some key takeaways?
- 19:15Speaker 2: I think the biggest takeaway is that knowledge is power.
- 19:18Speaker 1: Knowledge is power.
- 19:19Speaker 2: The more we understand how attackers think.
- 19:22Speaker 1: Yeah, and operate, the better we can defend against them.
- 19:25Speaker 2: Exactly.
- 19:25Speaker 1: So this deep dive into rop is all about giving
- 19:29Speaker 1: you that knowledge.
- 19:30Speaker 2: It is, even though it's technical, Yeah, it's important to
- 19:33Speaker 2: understand these things, Okay, whether you're a developer, a security professional,
- 19:37Speaker 2: or just someone who's interested, or just someone who's curious
- 19:40Speaker 2: about how things work.
- 19:40Speaker 1: Yeah, and how things can be broken.
- 19:42Speaker 2: And how they can be broken exactly.
- 19:45Speaker 1: Security is everyone's responsibility, it is, So by understanding these concepts,
- 19:49Speaker 1: you can help build a more secure a world.
- 19:53Speaker 2: That's the goal.
- 19:54Speaker 1: Okay. So that brings us to the end of part
- 19:57Speaker 1: two of our deep dive.
- 20:00Speaker 2: Time Flies into ar exploitation. It does.
- 20:03Speaker 1: In part three, we're gonna shift gears and we're going
- 20:06Speaker 1: to explore ARM sixty.
- 20:08Speaker 2: Four the world of mobile devices, the world of mobile devices, smartphones, tablets,
- 20:14Speaker 2: all that good stuff.
- 20:15Speaker 1: So stay tuned and we'll be back soon.
- 20:17Speaker 2: We'll be back.
- 20:18Speaker 1: Welcome back to the deep dive for the final part
- 20:21Speaker 1: of our journey.
- 20:22Speaker 2: I can't believe it's already the final part.
- 20:24Speaker 1: I know it's flown by it has. So we've climbed
- 20:27Speaker 1: the treacherous cliffs of memory corruption, We've navigated the labyrinthine.
- 20:32Speaker 2: Heap, we've seen it all.
- 20:33Speaker 1: We've even mastered stack pivoting like pros, and most importantly,
- 20:38Speaker 1: we've learned how attackers exploit these vulnerabilities right.
- 20:41Speaker 2: To gain control of systems.
- 20:43Speaker 1: Yeah, and we even ventured into the world of ROP.
- 20:47Speaker 2: Oh yes, ROP return oriented programming.
- 20:50Speaker 1: Discovering how attackers can chain together these tiny snippets of code.
- 20:54Speaker 2: It's amazing what they can do to.
- 20:55Speaker 1: Create these really powerful exploits.
- 20:57Speaker 2: It is, but all of our.
- 20:59Speaker 1: Adventure make sures so far have been in the thirty
- 21:02Speaker 1: two bit.
- 21:03Speaker 2: ARM world, right, the land of ARMv seven.
- 21:06Speaker 1: Now it's time to step into the future. The future
- 21:09Speaker 1: is now the world of ARM sixty four. ARM sixty
- 21:14Speaker 1: four the dominant architecture in most modern mobile devices.
- 21:18Speaker 2: Smartphones, tablets, even some laptops.
- 21:21Speaker 1: So Chapter nine of Beginner's Guide to Exploitation on ARM
- 21:25Speaker 1: Volume two, Okay, is our guide for this new landscape,
- 21:30Speaker 1: our roadmap, and we're going to see how the exploitation
- 21:33Speaker 1: techniques we've discussed translate to this new world.
- 21:36Speaker 2: Because it's a different world.
- 21:37Speaker 1: It is a different world.
- 21:39Speaker 2: But there are some similarities.
- 21:40Speaker 1: So is everything we've learned about thirty two BITARM exploitations
- 21:44Speaker 1: still relevant?
- 21:45Speaker 2: That's a good question.
- 21:46Speaker 1: Yeah, or do we need to throw out our playbooks.
- 21:49Speaker 2: I wouldn't throw them out just yet, okay, because the
- 21:51Speaker 2: good news is, yeah, a lot of the core principles
- 21:54Speaker 2: are still the same. Okay, memory corruption, control, flow, hijacking.
- 21:58Speaker 1: So the fundamentals haven't changed.
- 22:00Speaker 2: The fundamentals are the same, Okay, it's just the details
- 22:02Speaker 2: that are different.
- 22:03Speaker 1: So it's like visiting a new country. I like that
- 22:05Speaker 1: analogy where they speak a slightly different dialoge a.
- 22:08Speaker 2: Different dialect of the same language.
- 22:10Speaker 1: Of the same language.
- 22:11Speaker 2: Exactly.
- 22:12Speaker 1: We still need to understand memory layouts. Yes, we need
- 22:15Speaker 1: to exploit vulnerabilities. Of course, overwrite crucial data. That's how
- 22:20Speaker 1: you gain control and manipulate the program counter.
- 22:23Speaker 2: To redirect execution flow.
- 22:25Speaker 1: Okay, so that's reassuring it is. But let's get.
- 22:27Speaker 2: Specific, all right, let's dive into the details.
- 22:29Speaker 1: What are some of the key differences?
- 22:30Speaker 2: Okay, So one of the most noticeable differences is register size.
- 22:34Speaker 1: Register size.
- 22:36Speaker 2: ARM sixty four uses sixty four bit registers, okay, compared
- 22:39Speaker 2: to the thirty two bit registers in ARM v seven.
- 22:43Speaker 1: So everything's just bigger essentially. Yes, more room to store data.
- 22:49Speaker 2: More space to work with.
- 22:50Speaker 1: So the instruction of monics are different too.
- 22:52Speaker 2: Right, Yeah, than the monics are a bit different.
- 22:54Speaker 1: Because you're working with larger registers.
- 22:56Speaker 2: Right, Some instructions have different names or slightly different syntax.
- 23:00Speaker 1: Can you give me some examples?
- 23:01Speaker 2: Sure? So remember how we used posh and pop instructions
- 23:05Speaker 2: in ARMv seven, Yeah.
- 23:06Speaker 1: To add and remove items from the stack.
- 23:08Speaker 2: Well, in AIRM in sixty four, yeah, we use STP
- 23:11Speaker 2: and LDP instead.
- 23:12Speaker 1: SDP and LDP store pair and load pair. So instead
- 23:15Speaker 1: of pushing and popping single registers, right, we're storing and
- 23:20Speaker 1: loading pairs.
- 23:21Speaker 2: Here's the registers.
- 23:22Speaker 1: Okay, so that makes sense it does. What about returning
- 23:25Speaker 1: from functions?
- 23:26Speaker 2: Ah? Yes, that's another difference.
- 23:27Speaker 1: Airmv seven just uses rat.
- 23:30Speaker 2: Right, simple and straightforward.
- 23:31Speaker 1: That AIRM sixty four gets a little fancier okay.
- 23:34Speaker 2: Uses a combination of LDP and RAT interesting it is.
- 23:40Speaker 1: Okay, So there are definitely some tweaks.
- 23:41Speaker 2: Some adjustments so technique, but the underlying concepts.
- 23:47Speaker 1: But the book shows how ROP can still be applied
- 23:50Speaker 1: in AARM sixty four absolutely so they have an AIRM
- 23:53Speaker 1: sixty four version they do of the ROP Level one challenge,
- 23:56Speaker 1: which is great for practice, so you can really see
- 23:59Speaker 1: how these concepts translate.
- 24:00Speaker 2: To the new architecture.
- 24:02Speaker 1: So even with all these changes, it's still about finding
- 24:04Speaker 1: the right gadgets always chaining them together.
- 24:08Speaker 2: That's the heart of ROPS, in the right way to
- 24:10Speaker 2: achieve your goal.
- 24:11Speaker 1: So it seems like ARM sixty four it doesn't completely
- 24:15Speaker 1: rewrite the rules of exploitation.
- 24:17Speaker 2: It just adds a little bit of complexity.
- 24:18Speaker 1: It just requires a bit of adaptation, adaptation and creativity.
- 24:22Speaker 1: So as we wrap up this deep dive, it's been
- 24:25Speaker 1: quite a journey. It has been an amazing journey.
- 24:27Speaker 2: Through the world of ARM exploitation.
- 24:29Speaker 1: What are some key takeaways?
- 24:31Speaker 2: Okay, Well, I think the most important takeaway for our
- 24:33Speaker 2: listeners is that secure coding practices are absolutely essential.
- 24:38Speaker 1: Secure coding because.
- 24:40Speaker 2: Even small errors can have huge consequences.
- 24:43Speaker 1: You have to validate your inputs carefully. You do be
- 24:46Speaker 1: mindful of memory management.
- 24:48Speaker 2: Memory management is.
- 24:49Speaker 1: Key, and always prioritize security from the very beginning. Yeah,
- 24:54Speaker 1: throughout the whole development process.
- 24:55Speaker 2: Absolutely.
- 24:56Speaker 1: Okay, So knowledge is power.
- 24:58Speaker 2: Knowledge is power.
- 24:59Speaker 1: Understanding how these exploits work.
- 25:01Speaker 2: Right, because that's how you protect yourself.
- 25:03Speaker 1: Yeah, you have to know what the attackers are doing exactly,
- 25:05Speaker 1: and you have to keep.
- 25:06Speaker 2: Learning, never stop learning.
- 25:07Speaker 1: Because this world is constantly changing.
- 25:09Speaker 2: It's a constantly evolving landscape.
- 25:11Speaker 1: It's been an amazing journey, it has. We've climbed the
- 25:14Speaker 1: mountains of memory corruption.
- 25:16Speaker 2: We've been to the top, we've.
- 25:17Speaker 1: Explored the depths of the heat.
- 25:19Speaker 2: We've seen it all.
- 25:20Speaker 1: And we've even mastered the art of stack.
- 25:22Speaker 2: Bending state bending.
- 25:24Speaker 1: I like that. Most importantly, we've gained valuable knowledge. Yes,
- 25:28Speaker 1: knowledge is key about how attackers exploit these vulnerabilities and
- 25:33Speaker 1: how we can protect ourselves.
- 25:35Speaker 2: And that's what it's all about.
- 25:36Speaker 1: So thank you for joining us, Thank you for having
- 25:38Speaker 1: me on this deep dive. It's been a pleasure into
- 25:41Speaker 1: the world of arm exploitation. Until next time, stay curious,
- 25:46Speaker 1: stay safe.
- 25:47Speaker 2: Stay secure, and keep exploring the world of cybersecurity.
- 25:51Speaker 1: The fascinating world of cybersecurity,