Latest / CyberSecurity Summary / The IDA Pro Book, 2nd Edition
Transcript
- 0:00Speaker 1: Welcome to our deep dive into reverse engineering with IDA pro.
- 0:04Speaker 1: You sent over some excerpts from the IDA pro book. Yeah,
- 0:07Speaker 1: so it looks like you're ready to really get into
- 0:09Speaker 1: the nuts and bolts of software.
- 0:12Speaker 2: Absolutely. Yeah, it's a whole world where we kind of
- 0:15Speaker 2: get to look under the hood and see how things
- 0:16Speaker 2: actually work.
- 0:17Speaker 1: I've always wondered, like who uses IDA pro.
- 0:20Speaker 2: You know, it's used by like security researchers obviously, you know,
- 0:23Speaker 2: analyzing malware and things like that, but also like software engineers,
- 0:27Speaker 2: Oh wow, who have to deal with legacy code and
- 0:30Speaker 2: they need to update something or figure out how something works.
- 0:35Speaker 1: So when you say like figure out how something works,
- 0:37Speaker 1: what does that actually mean? What's IDA pro doing?
- 0:41Speaker 2: Well, you know, computers run on machine code, which is
- 0:44Speaker 2: just ones and zeros, right, and that's not very human readable.
- 0:48Speaker 2: So ida pro takes those ones and zeros and turns
- 0:51Speaker 2: them into assembly language, which is a little more human readable.
- 0:55Speaker 1: Okay, So it's like a translator yeah, exactly between computer
- 0:58Speaker 1: and something we can at least try to understand.
- 1:00Speaker 2: And it stores all that information in a database that
- 1:03Speaker 2: you can work with, which is in dot IDB file
- 1:06Speaker 2: and you don't even need the original program to look
- 1:08Speaker 2: at the analysis after that.
- 1:10Speaker 1: So backing up a little bit, how does IDA pro
- 1:13Speaker 1: even know what kind of file it's looking at? I
- 1:15Speaker 1: mean a lot of times you can't tell by the
- 1:16Speaker 1: file extension.
- 1:17Speaker 2: Yeah, you can't go by file extensions, you know, it's
- 1:20Speaker 2: very surface level. You need to look at the actual
- 1:22Speaker 2: contents of the file.
- 1:24Speaker 1: So it's like more than just judging a book by
- 1:26Speaker 1: its cover. It's actually looking inside and kind of getting
- 1:29Speaker 1: a fingerprint.
- 1:29Speaker 2: It uses things called magic numbers, which are like digital
- 1:33Speaker 2: fingerprints that tell you what type of file it is.
- 1:36Speaker 1: So once you know what you're looking at, what are
- 1:38Speaker 1: some of the things that IDA can do well.
- 1:41Speaker 2: It can identify like standard library routines that a lot
- 1:44Speaker 2: of programs use, okay, and by identifying those, you can
- 1:48Speaker 2: kind of like skip over those parts and look at
- 1:50Speaker 2: the more unique parts of the code.
- 1:52Speaker 1: So it's kind of like if you were reading a book,
- 1:53Speaker 1: you could skip the chapters that are the same in
- 1:55Speaker 1: every book, yeah, exactly, and get to the good stuff.
- 1:58Speaker 2: It can also do things like visualized code as graphs,
- 2:02Speaker 2: so you can see like a map of how the
- 2:04Speaker 2: program flows. Wow, all the different paths it can take.
- 2:09Speaker 1: That's got to be really helpful, especially for like more
- 2:12Speaker 1: complicated code.
- 2:13Speaker 2: Yeah, and you know, you can even extend IDA to
- 2:15Speaker 2: support new processors, processors that haven't even been invented yet.
- 2:19Speaker 1: So okay, we've talked about what it can do, but
- 2:23Speaker 1: what does it actually look like when you're using IDA pro.
- 2:26Speaker 2: Well, when you open it up, you see like a
- 2:27Speaker 2: multi windowed interface. Okay, it might seem a little overwhelming
- 2:31Speaker 2: at first, but each window serves a specific purpose.
- 2:33Speaker 1: Okay, So you have like different tools.
- 2:35Speaker 2: In there, yeah, exactly. Like you have the graph view,
- 2:38Speaker 2: which we talked about right, shows the code flow. There's
- 2:41Speaker 2: the text view, which shows the disassemble code line by line.
- 2:44Speaker 1: It's a lot of different ways to look at it. Yeah.
- 2:47Speaker 2: You have the functions window, which lists all the functions
- 2:50Speaker 2: that it's identified in the program.
- 2:51Speaker 1: And then you have the output window.
- 2:52Speaker 2: Yeah, the output window which shows you messages from idea,
- 2:55Speaker 2: and the strings window, which is really useful for finding
- 2:58Speaker 2: like human reatable text.
- 3:01Speaker 1: So you have to kind of know how to navigate
- 3:03Speaker 1: all those different windows. Yeah.
- 3:04Speaker 2: Absolutely, it's actually designed to be pretty intuitive. You can
- 3:08Speaker 2: jump to certain addresses in the code, okay. You can
- 3:11Speaker 2: use like the navigation history like a web browser.
- 3:14Speaker 1: So you can go back.
- 3:15Speaker 2: Yeah, and you can follow like cross references, which are
- 3:18Speaker 2: like links between different parts of the code, so.
- 3:20Speaker 1: Like a map and a compass for software.
- 3:22Speaker 2: Exactly.
- 3:23Speaker 1: All right, well let's talk about those instructions. So I imagine
- 3:26Speaker 1: it's like steps in a recipe or something.
- 3:28Speaker 2: Yeah. Some instructions are just executed sequentially, one after the other,
- 3:32Speaker 2: like a recipe, right, But other instructions can introduce like branching.
- 3:36Speaker 1: So the program can go in different directions.
- 3:38Speaker 2: Yeah, exactly. It's called conditional branching.
- 3:41Speaker 1: An idea pro can can help you look at all
- 3:43Speaker 1: those different paths. Yeah.
- 3:44Speaker 2: It disassembles both paths of a branch, so you can
- 3:47Speaker 2: see like all the potential flows of execution.
- 3:50Speaker 1: And then you have function calls, which are like mini
- 3:52Speaker 1: programs within the bigger program. Yeah exactly, So that can
- 3:56Speaker 1: get really complicated.
- 3:57Speaker 2: You know, understanding how those function calls work is really
- 4:00Speaker 2: crucial for understanding the logic of a program.
- 4:03Speaker 1: So how do these functions communicate with each other?
- 4:06Speaker 2: Well, that's where calling conventions come in. They're like the
- 4:09Speaker 2: rules of etiquette for how functions talk to each other.
- 4:13Speaker 1: So why is it important to understand the calling conventions?
- 4:17Speaker 2: Because if you don't understand the rules of communication, then
- 4:19Speaker 2: you're not going to understand what the code is doing.
- 4:22Speaker 2: It's like trying to understand a foreign language without knowing
- 4:25Speaker 2: the grammar.
- 4:26Speaker 1: Okay. And so there are different types of calling conventions.
- 4:29Speaker 2: Yeah, Like common ones are sedical and SETI.
- 4:32Speaker 1: Call, and id pro can help you understand which calling
- 4:35Speaker 1: convention is being used.
- 4:36Speaker 2: Yeah, it gives you clues and helps you decipher it.
- 4:39Speaker 1: But it's hard to keep track of all that data
- 4:41Speaker 1: moving between these functions.
- 4:43Speaker 2: Well, that's where stack frames come in. Each function has
- 4:46Speaker 2: like a little workspace and memory where it stores its
- 4:49Speaker 2: local variables and parameters and things like that.
- 4:51Speaker 1: So it's like its own little office exactly.
- 4:54Speaker 2: And ida pro lets you view those stack frames and
- 4:57Speaker 2: even modify them.
- 4:58Speaker 1: Wow, this is getting really complicated.
- 5:00Speaker 2: Yeah, but he's pretty powerful.
- 5:02Speaker 1: I'm hooked. I want to learn more.
- 5:04Speaker 2: All right, let's get good. So we've been talking about code,
- 5:06Speaker 2: but what about data. How does ida pro handle the data?
- 5:10Speaker 1: Yeah, because it's not just about the instructions, right, it's
- 5:12Speaker 1: about how the program actually uses data exactly.
- 5:15Speaker 2: Yeah, have the instructions like the verbs, but you need
- 5:18Speaker 2: the nouns to understand what's going on. So ida pro
- 5:22Speaker 2: goes beyond just showing you a bunch of raw bites.
- 5:24Speaker 1: Oh okay.
- 5:25Speaker 2: It lets you define data types, erase structures, all kinds
- 5:27Speaker 2: of things.
- 5:28Speaker 1: Wait, structures, what are those?
- 5:29Speaker 2: Well, imagine you have a program that's storing information about people.
- 5:34Speaker 2: Each person has a name and age, an address.
- 5:37Speaker 1: Okay.
- 5:37Speaker 2: A structure lets you group all that data together under
- 5:40Speaker 2: one name.
- 5:41Speaker 1: So instead of seeing just a bunch of variables, you
- 5:43Speaker 1: see like a person with information.
- 5:46Speaker 2: And ida pro lets you create and apply these structures
- 5:49Speaker 2: to make the disassembly much more readable.
- 5:52Speaker 1: Oh that's cool. Yeah, especially if you're working with some
- 5:54Speaker 1: kind of complex data format.
- 5:56Speaker 2: Yeah, and remember those type libraries we talked about. Those
- 5:59Speaker 2: come in hand and here too, because id pro has
- 6:02Speaker 2: these libraries that define standard data structures.
- 6:05Speaker 1: So it's like a reference guide yeah for a data format.
- 6:08Speaker 2: So it can often automatically recognize and apply these structures
- 6:12Speaker 2: for you.
- 6:12Speaker 1: Well that's awesome. Saves you a lot of time.
- 6:14Speaker 2: And once you have the code and the data well defined,
- 6:18Speaker 2: you can start to see the bigger picture. Okay, this
- 6:21Speaker 2: is where idpro's graphing capabilities come in.
- 6:24Speaker 1: The graphs, right, Why are these so important again?
- 6:26Speaker 2: Well, they give you a visual representation of the relationships
- 6:29Speaker 2: between different parts of the program. They can show you
- 6:32Speaker 2: how code flows within a function, how functions call each other,
- 6:36Speaker 2: how data.
- 6:37Speaker 1: Is accessed, so it's like a map of the software exactly.
- 6:41Speaker 2: And there are two main types of graphs.
- 6:43Speaker 1: Okay.
- 6:43Speaker 2: You have external graphs, which use separate graphing applications, and
- 6:47Speaker 2: then you have integrated graphs, which are built right into
- 6:50Speaker 2: IDA so.
- 6:51Speaker 1: You don't have to leave id pro.
- 6:52Speaker 2: Yeah, exactly. And the integrated graphs are really cool because
- 6:55Speaker 2: they're interactive.
- 6:56Speaker 1: What does that mean.
- 6:57Speaker 2: Well, you can zoom in and out, you can pan around,
- 6:59Speaker 2: you can click on different nodes in the graph to
- 7:01Speaker 2: jump to.
- 7:02Speaker 1: The corresponding kind Oh that's awesome.
- 7:04Speaker 2: It makes it much more engaging to understand the structure
- 7:07Speaker 2: of the program.
- 7:08Speaker 1: And there were different types of graphs, right, yeah, like
- 7:09Speaker 1: flow chart graphs. Those show the flow of the program.
- 7:12Speaker 2: Yeah, the flow of execution within a function, okay. And
- 7:15Speaker 2: then you have call graphs, which show you the hierarchy
- 7:18Speaker 2: of function calls, like who calls who exactly.
- 7:21Speaker 1: So it seems like there's a lot of customization that
- 7:23Speaker 1: you can do in IDA pro.
- 7:25Speaker 2: Yeah. Absolutely.
- 7:26Speaker 1: Yeah.
- 7:27Speaker 2: One of the first things you want to look at
- 7:28Speaker 2: is the configuration options. You can customize like the font,
- 7:32Speaker 2: the colors, keyboard shortcuts, all kinds of.
- 7:35Speaker 1: Things, so you can make it work the way you
- 7:36Speaker 1: want it to exactly.
- 7:38Speaker 2: And then if you want to go even further, you
- 7:40Speaker 2: can use ida Pro's scripting language IDC.
- 7:44Speaker 1: I've heard about IDC scripting, but like, what can you
- 7:47Speaker 1: actually do with it?
- 7:47Speaker 2: Oh? All kinds of things. Let's say you're analyzing a
- 7:50Speaker 2: program that uses a custom encryption algorithm. You could write
- 7:55Speaker 2: an IDC script to automatically decrypt the data.
- 7:58Speaker 1: Oh wow.
- 7:59Speaker 2: Or you could use it to rename a bunch of
- 8:00Speaker 2: functions that have like generic names.
- 8:03Speaker 1: Oh. So it's like you have these little helpers working
- 8:05Speaker 1: behind the scenes exactly. And you can even go beyond
- 8:07Speaker 1: IDC scripting with like external plug in.
- 8:10Speaker 2: Yeah, you can write plugins to add whole new features
- 8:13Speaker 2: to id pro.
- 8:14Speaker 1: So it's like you're expanding on its capability exactly. Wow.
- 8:17Speaker 1: That's a lot.
- 8:17Speaker 2: But even with all this power, sometimes you need a
- 8:20Speaker 2: little extra help and that's where FLIRTA comes in.
- 8:23Speaker 1: FLOORTA What was that again?
- 8:24Speaker 2: It stands for Fast Library Identification and Recognition Technology.
- 8:28Speaker 1: Oh okay, I remember you mentioned that.
- 8:30Speaker 2: It's really helpful because it lets ida pro automatically identify
- 8:34Speaker 2: standard library functions.
- 8:35Speaker 1: Why that's so important, Well.
- 8:37Speaker 2: A lot of programs use common libraries for things like
- 8:40Speaker 2: string manipulation, map operations.
- 8:42Speaker 1: Right.
- 8:43Speaker 2: Without flotaate, you would have to manually analyze those library
- 8:47Speaker 2: functions every time.
- 8:48Speaker 1: Oh, that would be tedious.
- 8:49Speaker 2: Yeah, it would be really time consuming. Yeah, So floirtaate
- 8:52Speaker 2: basically takes care of that for you, so you.
- 8:54Speaker 1: Can focus on the interesting parts of the code. Exactly
- 8:57Speaker 1: how does it even work?
- 8:58Speaker 2: Well, it uses these things called signature files, which are
- 9:01Speaker 2: basically databases of function signatures. Okay, and when ideapro loads
- 9:07Speaker 2: a binary, it compares the code to those signature files.
- 9:11Speaker 1: So it's like a fingerprint databasect library functions.
- 9:15Speaker 2: And if it finds a match, it can tell you
- 9:16Speaker 2: exactly what that function is, what it's calling convention is,
- 9:20Speaker 2: what parameters it takes.
- 9:22Speaker 1: That's amazing. So what about when you have custom functions
- 9:27Speaker 1: or functions with non standard calling conventions? How do you
- 9:30Speaker 1: deal with those?
- 9:31Speaker 2: That's where understanding those calling conventions and the stack comes.
- 9:34Speaker 1: In the calling convention. Those were the rules of etiquette
- 9:37Speaker 1: right exactly for how functions talk to each other. Yea,
- 9:39Speaker 1: and the stack was like a temporary workspace exactly.
- 9:43Speaker 2: So different calling conventions use the stack in different ways.
- 9:46Speaker 2: Some require the caller to clean up the stack after
- 9:48Speaker 2: a function call, Others require the function itself to do
- 9:51Speaker 2: the cleaning.
- 9:52Speaker 1: So if you don't know which convention's being used, you
- 9:55Speaker 1: could misinterpret what's happening exactly.
- 9:57Speaker 2: You might think data is being passed when it's not,
- 10:00Speaker 2: or you might miss something important about how the function
- 10:03Speaker 2: is managing its data.
- 10:04Speaker 1: So you have to know the secret handshake, yeah, for
- 10:08Speaker 1: each different.
- 10:09Speaker 2: Function, and idea pro can actually help you figure out
- 10:11Speaker 2: which handshake is being used. Cool by analyzing the code.
- 10:15Speaker 1: So how can we see what's happening on the stack
- 10:18Speaker 1: as the program is running.
- 10:19Speaker 2: That's where the debugger comes in.
- 10:21Speaker 1: Oh yeah, the debugger.
- 10:22Speaker 2: It lets you step through the code one instruction at
- 10:25Speaker 2: a time, and you can see how data is pushed
- 10:28Speaker 2: onto the stack and popped off the stack.
- 10:30Speaker 1: So you can actually see the stack in action.
- 10:32Speaker 2: Yeah, exactly.
- 10:33Speaker 1: That's incredible.
- 10:34Speaker 2: It's a really powerful tool.
- 10:35Speaker 1: We've covered a lot.
- 10:36Speaker 2: We've only just scratched the surface of what ideapro can
- 10:39Speaker 2: do and the techniques that reverse engineers use.
- 10:42Speaker 1: But this is a good start, right, Yeah.
- 10:44Speaker 2: Absolutely, it's a great foundation to build upon.
- 10:46Speaker 1: So we talked about analyzing code and data, you know,
- 10:50Speaker 1: understanding those functions and how they communicate with each other,
- 10:53Speaker 1: even using that debugger to step through the program. But
- 10:56Speaker 1: I imagine like things get even more complicated when developers
- 11:00Speaker 1: try to make their code hard to understand on purpose.
- 11:03Speaker 2: Yeah, you're talking about obfuscated code. It's a common tactic,
- 11:07Speaker 2: especially for like malware authors who want to hide what
- 11:10Speaker 2: their code is doing.
- 11:11Speaker 1: So it's like they're trying to make it look like
- 11:12Speaker 1: a big tangled mess of spaghetti so nobody can figure
- 11:16Speaker 1: out the recipe.
- 11:18Speaker 2: Obfuscation techniques can range from simple things like renaming variables
- 11:22Speaker 2: to more complex things that actually change the structure and
- 11:25Speaker 2: logic of the code.
- 11:26Speaker 1: So how do reverse engineers even begin to make sense
- 11:29Speaker 1: of that? Does IDA pro help with that at all?
- 11:32Speaker 2: Yeah? It does. The debugger is really helpful here, okay,
- 11:35Speaker 2: because it lets you step through the code and observe
- 11:38Speaker 2: its behavior and look for clues about how the obfuscation
- 11:42Speaker 2: is being applied or removed.
- 11:43Speaker 1: So it's like peeling back the layers of an onion
- 11:46Speaker 1: to get to the real code. Underneath.
- 11:48Speaker 2: And once you've identified those key points in the code
- 11:51Speaker 2: where the obfuscation is being handled, you can often use
- 11:55Speaker 2: IDA pro scripting capabilities to automate the deoffuscation process.
- 11:59Speaker 1: Wow, that's pretty cool.
- 12:00Speaker 2: Yeah, you can write scripts to like unpack data, decrypt code,
- 12:04Speaker 2: even emulate the obfuscation routines to get back to the
- 12:07Speaker 2: original code.
- 12:08Speaker 1: So you really need to understand both how the obfuscation
- 12:11Speaker 1: works and how to use IDA pros scripting.
- 12:13Speaker 2: Yeah, it can be pretty challenging, but it's often necessary
- 12:16Speaker 2: to understand what the code is really doing, especially if.
- 12:19Speaker 1: You think it might be malicious. Right, speaking of malicious code,
- 12:23Speaker 1: you mentioned that IDA pros often used for vulnerability analysis. Yeah,
- 12:27Speaker 1: can you tell me more about that.
- 12:28Speaker 2: So a vulnerability is basically a weakness and a piece
- 12:31Speaker 2: of software that an attacker could exploit to gain unauthorized
- 12:36Speaker 2: access or control.
- 12:37Speaker 1: So they're looking for like security holes.
- 12:39Speaker 2: Exactly, and IDEA pro is a great tool for finding
- 12:42Speaker 2: and analyzing these vulnerabilities.
- 12:44Speaker 1: How do they actually use it to find them?
- 12:46Speaker 2: Well, they use it to dissect the software, looking for
- 12:49Speaker 2: common coding errors that can lead to vulnerabilities, things like
- 12:54Speaker 2: buffer overflows where data is written beyond the allocated space
- 12:58Speaker 2: and memory or form a string vulnerabilities where an attacker
- 13:02Speaker 2: can manipulate the way data is formatted to gain control
- 13:06Speaker 2: of the program's execution.
- 13:07Speaker 1: That sounds pretty complicated, Yeah it is.
- 13:10Speaker 2: It's a specialized field, but the tools and techniques are
- 13:13Speaker 2: fundamentally the same as those used for general reverse engineering.
- 13:17Speaker 1: And you mentioned earlier that IDA pro has a built
- 13:20Speaker 1: in debugger. Is that used for vulnerability analysis as well?
- 13:23Speaker 2: Oh? Absolutely, It's invaluable because it allows you to step
- 13:27Speaker 2: through the code and observe how data is handled and
- 13:31Speaker 2: identify those potential points of weakness where an attacker might
- 13:35Speaker 2: be able to inject malicious code or manipulate the program's behavior.
- 13:40Speaker 1: So again, it's like being a detective looking for clues.
- 13:42Speaker 2: And one of the most effective techniques for vulnerability analysis
- 13:45Speaker 2: is called differential analysis. It involves comparing different versions of
- 13:49Speaker 2: a program, typically a patched version and an unpatched version,
- 13:53Speaker 2: to see.
- 13:53Speaker 1: What's changed, So you're looking for the differences.
- 13:55Speaker 2: Exactly, and by analyzing those differences, security researchers can often
- 13:59Speaker 2: identify the code that was vulnerable and understand how the
- 14:03Speaker 2: patch fixed the issue.
- 14:05Speaker 1: So they can figure out how to protect against attacks. Right,
- 14:08Speaker 1: that's amazing. It sounds like a constant arms race is
- 14:11Speaker 1: between the security researchers and the attackers.
- 14:14Speaker 2: You know, as attackers develop new techniques and exploit new vulnerabilities,
- 14:18Speaker 2: the defenders have to adapt and develop new countermeasures.
- 14:21Speaker 1: Well, it's definitely a fascinating field and an important one too. Absolutely,
- 14:25Speaker 1: we've covered so much ground in this deep dive. We
- 14:28Speaker 1: have from the basics of reverse engineering to some pretty
- 14:32Speaker 1: advanced techniques. Yeah, anything else you want to add before
- 14:35Speaker 1: we wrap up.
- 14:35Speaker 2: I think we've touched on the most important aspects, But
- 14:38Speaker 2: I do want to emphasize that this is just the beginning.
- 14:41Speaker 2: Reverse engineering is a vast and constantly evolving field.
- 14:46Speaker 1: So there's always more to learn.
- 14:47Speaker 2: Yeah, always more to learn, new tools and techniques, to
- 14:51Speaker 2: explore new challenges to tackle.
- 14:53Speaker 1: It sounds exciting and maybe a little bit daunting.
- 14:57Speaker 2: It can be both, but IDPro is a really powerful
- 15:00Speaker 2: and with dedication and a thirst for knowledge, you can
- 15:04Speaker 2: unlock a lot of the secrets of the digital world.
- 15:06Speaker 1: Well, I'm definitely inspired to learn more. Thanks for taking
- 15:09Speaker 1: us on this deep dive into idea pro.
- 15:12Speaker 2: You're welcome.
- 15:12Speaker 1: It's been great.
- 15:13Speaker 2: It's been my pleasure,