Latest / CyberCode Academy / Course 25 - API Python Hacking | Episode 2: Foundations of Windows Internals and API Mechanisms
Transcript
- 0:00Speaker 1: I want you to picture something you probably do. I mean,
- 0:03Speaker 1: we all do this every single day, probably one hundred
- 0:05Speaker 1: times a day, without even thinking about it. You grab
- 0:08Speaker 1: your mouse, you slide it over to an icon on
- 0:10Speaker 1: your desktop, maybe it's Chrome, maybe it's Notepad, and you
- 0:13Speaker 1: double click right.
- 0:14Speaker 2: It is the absolute muscle memory of the modern world.
- 0:16Speaker 2: We don't even process that we're doing it.
- 0:18Speaker 1: Anymore, exactly. It feels completely instantaneous. You click boom, the
- 0:22Speaker 1: window opens, and you start typing. But looking at the
- 0:26Speaker 1: research we've pulled for this deep dive into Windows internals today,
- 0:30Speaker 1: that split second is actually a massive, incredibly complex negotiation.
- 0:35Speaker 1: It's not magic at all. It's more like, well, it's
- 0:37Speaker 1: a bureaucracy.
- 0:38Speaker 2: That is the perfect word for it, a bureaucracy. We
- 0:41Speaker 2: tend to treat the operating system like this black box
- 0:44Speaker 2: that just instantly obeys our commands. But when you peel
- 0:47Speaker 2: back the layers and look inside, it's a very strict,
- 0:50Speaker 2: high speed bureaucracy. There are literal ID cards being checked,
- 0:54Speaker 2: there are office spaces being assigned, resources being walled off,
- 0:57Speaker 2: and there's a very specific language b spoken that most
- 1:01Speaker 2: everyday users never even hear.
- 1:03Speaker 1: And that is exactly our mission for you. On this
- 1:05Speaker 1: deep dive. We are moving way past the user interface.
- 1:10Speaker 1: We're ignoring the pretty buttons and the drop down menus,
- 1:13Speaker 1: and we are going straight into the engine room.
- 1:15Speaker 2: Yeah, we are getting our hands dirty.
- 1:16Speaker 1: Today, we really are. We're going to unpack the actual
- 1:19Speaker 1: difference between processes and threads, which is a huge distinction.
- 1:23Speaker 1: We're looking at the security obsession of tokens, and then
- 1:26Speaker 1: we're going to explore the massive library that really runs
- 1:29Speaker 1: the whole show, the Windows API.
- 1:31Speaker 2: This really is the bridge material. Yeah, if you want
- 1:34Speaker 2: to go from saying, you know, I'm pretty good with
- 1:36Speaker 2: computers to actually understanding cybersecurity, forensic analysis or low level programming,
- 1:43Speaker 2: you absolutely have to speak this internal language. Otherwise you're
- 1:46Speaker 2: just sort of flying blind, or you're just hoping the
- 1:48Speaker 2: machine does what you think it's doing based on the
- 1:50Speaker 2: shiny interface.
- 1:52Speaker 1: So let's start with the basic architecture of that double click.
- 1:55Speaker 1: We usually say colloquially that we are launching a process,
- 2:00Speaker 1: but the sources we reviewed make a really interesting distinction
- 2:03Speaker 1: here that I think trips a lot of people up. Initially,
- 2:06Speaker 1: a process isn't actually the thing that does the.
- 2:09Speaker 2: Work is No, not at all, and this is probably
- 2:12Speaker 2: the biggest misconception in Window's architecture. People use the terms interchangeably,
- 2:17Speaker 2: but think of a process strictly as a container. In
- 2:20Speaker 2: the technical literature, they often compared to an office building.
- 2:24Speaker 2: The process just owns the real estate.
- 2:26Speaker 1: And in this case, the real estate is the virtual
- 2:28Speaker 1: memory space.
- 2:28Speaker 2: Right exactly, it's the virtual memory space and the security boundaries.
- 2:32Speaker 2: The process provides the walls of the building.
- 2:34Speaker 1: And that virtual memory part is key for stability because
- 2:37Speaker 1: it's completely isolated from the other buildings.
- 2:40Speaker 2: Crucial, it is absolutely crucial. Process A cannot just reach
- 2:44Speaker 2: over and grab data from Process b's memory. It's physically
- 2:49Speaker 2: well logically walled off. That's why if your web browser
- 2:52Speaker 2: crashes because the script goes haywire, it doesn't take down
- 2:55Speaker 2: the word document you've been working on for three hours.
- 2:58Speaker 2: They are in completely different office buildings with different addresses.
- 3:01Speaker 1: Okay, so the process is the building. It has the
- 3:04Speaker 1: address on the street, it pays the rent on the RAM.
- 3:07Speaker 1: But an empty building doesn't write code or browse the web.
- 3:11Speaker 2: Right, the lights are on, but nobody's home. The building
- 3:13Speaker 2: just sits there. That's where the thread comes in. If
- 3:15Speaker 2: the process is the building. The thread is the employee
- 3:18Speaker 2: actually sitting at the desk doing the work. The operating
- 3:21Speaker 2: system actually schedules the CPU time the raw processing power
- 3:25Speaker 2: to the thread, not the process.
- 3:27Speaker 1: Okay, so the thread is the actual unit of execution
- 3:30Speaker 1: the worker be.
- 3:31Speaker 2: Precisely, the thread executes the code from your application. And
- 3:34Speaker 2: this explains the concept of multi threading, which we hear
- 3:37Speaker 2: about in tech marketing all the time. A single process
- 3:40Speaker 2: one building can hire fifty employees, so.
- 3:42Speaker 1: One core thread can just spawn five or ten others,
- 3:45Speaker 1: depending on what the program needs.
- 3:46Speaker 2: Yeah, think of a web browser. One thread might be
- 3:50Speaker 2: painting the user interface so the screen doesn't freeze when
- 3:53Speaker 2: you click a button. Another thread is running quietly in
- 3:57Speaker 2: the background saving a massive file you're downloading. Another is
- 4:02Speaker 2: talking to the network to fetch a new web page.
- 4:04Speaker 1: And they all share the same office resources. They share
- 4:07Speaker 1: that same memory space we talked about, but they're doing
- 4:09Speaker 1: entirely different tasks simultaneously.
- 4:12Speaker 2: Right. They can easily hand files back and forth because
- 4:14Speaker 2: they're in the same building, and this efficiency is great
- 4:17Speaker 2: for performance, but it introduces a massive security.
- 4:20Speaker 1: Problem because they're all in the same room exactly.
- 4:23Speaker 2: You have all these threads running and this totally open
- 4:26Speaker 2: memory space inside the building. How do you stop a
- 4:29Speaker 2: rogue program or a rogue employee. To keep the analogy
- 4:32Speaker 2: going from just walking into the CEO's office and doing
- 4:34Speaker 2: whatever it wants.
- 4:35Speaker 1: You'd need a bouncer or at least a very strict
- 4:38Speaker 1: HR department checking IDs.
- 4:39Speaker 2: You need an ID badge, And in Windows that badge
- 4:43Speaker 2: is called the access token.
- 4:44Speaker 1: Now, this was the part of the research that really
- 4:46Speaker 1: clicked for me regarding why Windows behaves the way it does,
- 4:49Speaker 1: the sheer bureaucracy of it. Every single process has a
- 4:53Speaker 1: token attached to it.
- 4:54Speaker 2: Every single one, no exceptions. Whether it's your desktop interface
- 4:58Speaker 2: like Explore, dot a X, a hidden background system service,
- 5:02Speaker 2: or a piece of ransom where you accidentally downloaded. That
- 5:05Speaker 2: token is the ultimate security context.
- 5:07Speaker 1: What exactly is on the badge?
- 5:08Speaker 2: Then it holds your SIDS. Those are security identify numbers.
- 5:12Speaker 2: It hold a list of the user groups you belong to,
- 5:15Speaker 2: like administrators or standard users, and most importantly, it holds
- 5:19Speaker 2: your privileges.
- 5:19Speaker 1: Privileges like SEEDA bug privilege. I actually see that one
- 5:23Speaker 1: pop up in air logs or event viewers sometimes.
- 5:25Speaker 2: Yeah, that's a massive one. Seed to bug. Basically lets
- 5:28Speaker 2: you debug other programs. But in low level technical terms,
- 5:31Speaker 2: debugging means you can read and write to another program's memory.
- 5:34Speaker 2: You can control them. If your token has that specific
- 5:38Speaker 2: privilege stamped on it, the operating system essentially opens the
- 5:41Speaker 2: doors to the rest of the system. If it doesn't,
- 5:43Speaker 2: you hit a brick wall and get the dreaded access
- 5:46Speaker 2: connide message.
- 5:47Speaker 1: But here is the massive gotcha that I think frustrates
- 5:49Speaker 1: a lot of system admins and power users. The sources
- 5:53Speaker 1: call it the golden rule of tokens. You cannot add
- 5:57Speaker 1: privileges to a running token.
- 5:58Speaker 2: It's immutable in that direction. You cannot upgrade it on
- 6:01Speaker 2: the fly. You can strip trivileges away, which is something
- 6:04Speaker 2: modern web browsers do a lot. They'll sandbox themselves by
- 6:07Speaker 2: voluntarily dropping their rights. So if a malicious site hacks
- 6:11Speaker 2: the browser tab, the damage is totally contained.
- 6:13Speaker 1: But you can't go the other way.
- 6:15Speaker 2: No, you cannot simply say, hey, I need to say
- 6:18Speaker 2: this system file to the Windows directory. Let me just
- 6:20Speaker 2: quickly staple admin rights to my current badge. Windows absolutely
- 6:24Speaker 2: forbids that.
- 6:25Speaker 1: Which perfectly explains the user account control screen. You know
- 6:29Speaker 1: that moment your screen dims and a box pops up,
- 6:31Speaker 1: asking do you want to allow this app to make
- 6:33Speaker 1: changes to your device?
- 6:35Speaker 2: Right? That screen is essentially Windows HR stepping in. It's saying, hey,
- 6:39Speaker 2: you're trying to do something that your current badge does
- 6:42Speaker 2: not allow. Do you want me to destroy this current
- 6:44Speaker 2: process and build a brand new one with the right permissions? Wait?
- 6:47Speaker 2: Literally destroy it effectively, yes, because you can't upgrade the
- 6:51Speaker 2: old badge. Windows literally pauses everything, tears down that process
- 6:56Speaker 2: and builds a brand new office building from scratch. But
- 7:00Speaker 2: this time, when it creates the process, it hands it
- 7:03Speaker 2: the admin token.
- 7:04Speaker 1: Wow, that's why you have to completely restart apps to
- 7:06Speaker 1: run them as administrator. You write click run as admin,
- 7:10Speaker 1: and you're quite literally building a new office building because
- 7:12Speaker 1: you couldn't change the security rules of the old one.
- 7:15Speaker 2: Exactly, you are spawning a new container with a new
- 7:18Speaker 2: ID card. And for cybersecurity understanding, this hierarchy is everything.
- 7:23Speaker 2: If a hacker compromises a process that has a restricted token,
- 7:27Speaker 2: like we said, maybe a basic browser tab, they are
- 7:30Speaker 2: trapped inside that context.
- 7:31Speaker 1: They're stuck in the mailroom. They can't just take the
- 7:33Speaker 1: elevator to the executive suite.
- 7:35Speaker 2: Right, they can't just become admin magically. Unless they find
- 7:38Speaker 2: a specific vulnerability to exploit, they are contained by that token.
- 7:43Speaker 2: They would have to find a way to pivot into
- 7:45Speaker 2: a completely different process that already has the higher level badge.
- 7:48Speaker 1: Okay, so we've got the container which is the process,
- 7:50Speaker 1: we have the worker which is the thread, and we
- 7:52Speaker 1: have the ID badge, which is the token. But all
- 7:55Speaker 1: these components have to actually talk to each other to
- 7:57Speaker 1: get work done. They need a shared language, and that's
- 8:00Speaker 1: where we get to the Windows API.
- 8:01Speaker 2: The Application Programming Interface. This is the massive tool set.
- 8:05Speaker 2: We are talking about thousands and thousands of specific commands
- 8:10Speaker 2: that developers use to politely ask the operating system to
- 8:14Speaker 2: do things for them.
- 8:15Speaker 1: It's really important to distinguish where this asking happens because
- 8:19Speaker 1: we as users and all our applications live in something
- 8:21Speaker 1: called user space.
- 8:23Speaker 2: Right. User space is the comfortable lounge. It's safe, it's
- 8:25Speaker 2: highly restricted. It's where your apps can crash all day
- 8:28Speaker 2: long without completely killing the computer. But the physical hardware,
- 8:33Speaker 2: the memory management, the file system on your hard drive,
- 8:36Speaker 2: that all lives down in the kernel. And you generally
- 8:39Speaker 2: do not want user space applications touching the kernel directly.
- 8:43Speaker 1: Right, Because if I write a bad line of code
- 8:45Speaker 1: and user space. My little calculator app crashes, No big deal.
- 8:48Speaker 1: But if I screwup a memory addressed down in.
- 8:50Speaker 2: The kernel, you blue screen the entire machine. Everything stops
- 8:54Speaker 2: game over, So the OS protects the kernel aggressively. The
- 8:57Speaker 2: APIX as the waiter in a restaurant, you are sitting
- 9:01Speaker 2: at your table in userspace. You do not walk into
- 9:04Speaker 2: the kernel kitchen to cook your own food. You tell
- 9:06Speaker 2: the weiter the API, hey, I want to open.
- 9:08Speaker 1: A file, and the waiter handles the logistics exactly.
- 9:11Speaker 2: The API takes that request, checks your token to see
- 9:13Speaker 2: if you can even afford the meal, goes down to
- 9:15Speaker 2: the kernel kitchen, gets the file, and brings it back
- 9:18Speaker 2: to your table.
- 9:19Speaker 1: Let's talk about what the waiter actually brings back. Because
- 9:22Speaker 1: the notes mention a concept called pass by reference, and
- 9:25Speaker 1: this feels like a programming one oh one concept that
- 9:28Speaker 1: applies directly to how Windows thinks internally.
- 9:31Speaker 2: It does. It's the core of how Windows handles resources efficiently.
- 9:34Speaker 2: Imagine you have a massive twenty volume encyclopedia that represents
- 9:39Speaker 2: your data. If you want to show me a specific
- 9:41Speaker 2: paragraph on a specific page, you don't photocopy the entire
- 9:45Speaker 2: twenty volumes and mail them to me.
- 9:46Speaker 1: That would be incredibly slow and a waste of paper
- 9:49Speaker 1: or in this case memory.
- 9:51Speaker 2: Right, Instead, you just hand me a small slip of
- 9:53Speaker 2: paper that says, look at shelf four, volume two, page
- 9:57Speaker 2: one hundred. You're passing a reference. In Windows terminology, that
- 10:01Speaker 2: little slip of paper is called a handle.
- 10:03Speaker 1: So a handle is essentially just a pointer to the
- 10:05Speaker 1: real thing.
- 10:06Speaker 2: That's exactly it. It's an abstract object. Usually it's just
- 10:09Speaker 2: an inetuer number that points to a specific memory location
- 10:13Speaker 2: or a resource inside the kernel. When these internal systems
- 10:16Speaker 2: talk to each other, they aren't throwing the raw, heavy
- 10:19Speaker 2: data back and forth. They are passing handles. Here's the
- 10:22Speaker 2: handle to this active window. Here is the handle to
- 10:25Speaker 2: the network connection.
- 10:27Speaker 1: And I assume this is where the token comes into
- 10:29Speaker 1: play again, right, Yes.
- 10:29Speaker 2: It's a constant loop. When your thread tries to actually
- 10:33Speaker 2: use a handle, say it wants to write data to
- 10:35Speaker 2: a file handle, the system instantly checks your token against
- 10:38Speaker 2: the permissions required for that specific handle. It's all interconnected building, worker, badge, waiter,
- 10:44Speaker 2: slip of paper.
- 10:45Speaker 1: I want to look closely at the anatomy of these
- 10:47Speaker 1: API requests because for anyone looking at system logs or
- 10:50Speaker 1: maybe dabbling in reverse engineering. The naming convention of these
- 10:54Speaker 1: APIs can be super confusing. For instance, we see a
- 10:57Speaker 1: command called find window in the official document, but if
- 11:00Speaker 1: you look at the actual system files, it's often written
- 11:03Speaker 1: as fine window A or find window W. What are
- 11:06Speaker 1: those suffixes?
- 11:07Speaker 2: This is a classic legacy artifact. You have to remember.
- 11:11Speaker 2: Windows has been around a long time. The core architecture
- 11:14Speaker 2: dates back to the late eighties and early nineties. The
- 11:17Speaker 2: A at the end of an API call stands for ANSI.
- 11:20Speaker 2: That's the old school standard character set used in early computing,
- 11:24Speaker 2: one byte per.
- 11:25Speaker 1: Character, just standard English letters and numbers basically, So what
- 11:28Speaker 1: is the W.
- 11:29Speaker 2: The W stands for a wide that means Unicode two
- 11:32Speaker 2: bytes per character.
- 11:33Speaker 1: So the W laws for things like emoji's, cong complex
- 11:36Speaker 1: Arabic scripts, things like that exactly.
- 11:38Speaker 2: And modern Windows is natively Unicode under the hood. If
- 11:43Speaker 2: you were writing a modern application today, you want to
- 11:46Speaker 2: use the W functions. If you try to force complex
- 11:49Speaker 2: foreign characters into the old A function, you're going to
- 11:53Speaker 2: get buffer overflows or just a screen full of garbage
- 11:56Speaker 2: text because the system is trying to physically squeeze a
- 11:58Speaker 2: wide character into a narrow slot.
- 12:00Speaker 1: And then you have the sequels, the X functions. I
- 12:03Speaker 1: have to admit I was laughing when I saw fine
- 12:05Speaker 1: window X in the docs.
- 12:07Speaker 2: Yeah, the extended versions. Microsoft is completely obsessive about backward compatibility.
- 12:11Speaker 2: It's actually one of their biggest selling points. They absolutely
- 12:14Speaker 2: cannot just change how the original fine window command works
- 12:17Speaker 2: because it would instantly break thousands of enterprise software programs
- 12:21Speaker 2: written in nineteen ninety eight that major corporations still rely on.
- 12:24Speaker 1: So if they need to add a new feature to
- 12:26Speaker 1: the command, they can't touch the original. They just create
- 12:28Speaker 1: fine window X.
- 12:29Speaker 2: Right. It's like the Fasten the Furious movie franchise. They
- 12:32Speaker 2: just keep adding suffixes to the titles. Sometimes you even
- 12:35Speaker 2: see X two or X three for a single command.
- 12:38Speaker 1: So knowing this actually matters for security, right.
- 12:40Speaker 2: It absolutely matters. If you are a malware analyst and
- 12:43Speaker 2: you are looking at a suspicious file and you see
- 12:46Speaker 2: it explicitly calling the old A functions, it tells you something.
- 12:50Speaker 2: It might tell you the malware relies on very old
- 12:53Speaker 2: legacy code, or perhaps the attacker is trying to exploit
- 12:57Speaker 2: a specific known vulnerability in how Windows hand handles, ANSI
- 13:01Speaker 2: strings give you a profile of the software.
- 13:04Speaker 1: Speaking of profiling, we have all these commands, thousands of them,
- 13:07Speaker 1: But where do they actually live. They have to be
- 13:09Speaker 1: stored somewhere in your hard drive.
- 13:11Speaker 2: They live in what I like to call the library
- 13:13Speaker 2: of Alexandria of Windows, the DLLs dynamic link libraries.
- 13:16Speaker 1: I think most users only know DLLs as that annoying
- 13:19Speaker 1: file that was missing when a PC game wouldn't load
- 13:22Speaker 1: in two thousand and five.
- 13:23Speaker 2: True, the classic missing DLL error. But think of a
- 13:26Speaker 2: DLL as a public bookshelf. You do not want your
- 13:29Speaker 2: tiny calculator application to contain the actual code for every
- 13:33Speaker 2: single function Windows is capable of performing. If it did,
- 13:36Speaker 2: the calculator app would be fifty gigabytes in size.
- 13:38Speaker 1: So instead of owning the code, it borrows it exactly.
- 13:41Speaker 2: It says, hey, I need to draw a graphical window
- 13:43Speaker 2: on the screen, so it dynamically links to user thirty
- 13:46Speaker 2: two dot DLL. It only checks out the specific books
- 13:49Speaker 2: it needs to do its job.
- 13:50Speaker 1: And looking at what books a program checks out provides
- 13:53Speaker 1: a sort of psychological profile of the application. You can
- 13:56Speaker 1: tell exactly what a program intends to do just by
- 13:59Speaker 1: looking at its library card.
- 14:00Speaker 2: That's my absolute favorite way to describe it. Profiling. You
- 14:03Speaker 2: look at a program's imports, the d's at requests, and
- 14:07Speaker 2: you instantly build a behavioral profile before you even run it.
- 14:10Speaker 1: So let's run down the list of the big five
- 14:12Speaker 1: DLLs because this is intensely practical stuff for our listeners.
- 14:16Speaker 1: First up is Kernel thirty two dot DL.
- 14:18Speaker 2: The heavylifter. Kernel thirty two handles memory management, creating processes,
- 14:22Speaker 2: starting threads, interacting with the filesystem. Almost every single program
- 14:26Speaker 2: imports this because every program needs memory just to exist.
- 14:29Speaker 2: If you see this, it just means the program is running.
- 14:31Speaker 2: It's totally normal, okay.
- 14:32Speaker 1: Next up are the visual ones User thirty two dot
- 14:35Speaker 1: DLL and GDI thirty two dot DL.
- 14:38Speaker 2: I call these the artists. User thirty two handles things
- 14:41Speaker 2: like clicking buttons, mouse movements, scrolling, and window frames. GDI
- 14:46Speaker 2: handles the actual graphics rendering. If a program imports these ds,
- 14:50Speaker 2: it means it has a visible interface. It's something you
- 14:52Speaker 2: can look at and click on.
- 14:53Speaker 1: Then there is at VAP thirty two dot DLL Advanced
- 14:57Speaker 1: API the bouncer.
- 14:59Speaker 2: This handle the registry, the service manager, and user accounts.
- 15:03Speaker 2: If you see a program importing at VP thirty two.
- 15:06Speaker 2: It's likely trying to change system settings, create new users,
- 15:09Speaker 2: or modify the registry keys that control what launches at startup.
- 15:13Speaker 2: This one is very common in installers, but also very
- 15:15Speaker 2: common in malware trying to gain persistence.
- 15:17Speaker 1: Let's talk about the networking side net AP thirty two
- 15:20Speaker 1: dot DLL or WS two three to two dot dll networking.
- 15:24Speaker 2: And this is exactly where you put your detective head on.
- 15:26Speaker 2: Let's say you download a simple notepad clone, a basic
- 15:29Speaker 2: text editor, and you look at its imports and you
- 15:31Speaker 2: see it's loading the networking DLLs. You have to ask yourself, why,
- 15:34Speaker 2: why on earth does a text editor need to open
- 15:36Speaker 2: a network socket to the Internet.
- 15:38Speaker 1: It really shouldn't unless it has some kind of cloud
- 15:40Speaker 1: sinking feature. But even then, I'd be incredibly suspicious of
- 15:43Speaker 1: a random app doing that.
- 15:44Speaker 2: Exactly it shouldn't be doing that. That is an immediate
- 15:47Speaker 2: indicator of compromise. You don't need one thousand dollars Enterprise
- 15:50Speaker 2: Antivirus Suite to tell you that's suspicious. You just need
- 15:53Speaker 2: to read the imports and ask does this behavior make
- 15:56Speaker 2: sense for this tool?
- 15:57Speaker 1: Don't forget Shell thirty two dot DLA. That was the
- 16:01Speaker 1: last of the Big five in the notes.
- 16:02Speaker 2: Right Shell thirty two that handles command line operations and
- 16:06Speaker 2: shell execution. If your app needs to open a command
- 16:09Speaker 2: prompt and run hidden scripts, it uses this. Again. If
- 16:13Speaker 2: your calculator app is loading shell thirty two to run
- 16:15Speaker 2: command prompts, you have a major problem.
- 16:18Speaker 1: So we rely on the official Windows documentation MSDN to
- 16:21Speaker 1: tell us what all these functions do. We look up
- 16:23Speaker 1: the DLL, we look up the function name, we read
- 16:25Speaker 1: the manual, but the sources point out something fascinating. The
- 16:29Speaker 1: public menu that Microsoft provides isn't the entire menu.
- 16:33Speaker 2: No, it's really not. And this is where we get
- 16:35Speaker 2: into the dark matter of Windows. Microsoft has internal needs.
- 16:38Speaker 2: They have highly specific functions required for the OS to
- 16:41Speaker 2: run itself that they never intended for third party developers
- 16:44Speaker 2: to ever use. These are called undocumented calls.
- 16:47Speaker 1: The secret menu, the secret.
- 16:49Speaker 2: Menu, and malware authors absolutely love these because standard security
- 16:53Speaker 2: tools sometimes aren't watching these internal undocumented functions as closely.
- 16:58Speaker 2: If you don't know a backdoor exists, you don't put
- 17:00Speaker 2: a security guard in front of it.
- 17:02Speaker 1: The practical example provided in the research was ipcunfig, a
- 17:05Speaker 1: really simple tool. Everyone uses it to see their IP
- 17:08Speaker 1: address or fix their internet.
- 17:10Speaker 2: Right. So, say your internet is acting up and you
- 17:12Speaker 2: want to clear your DNS cache. You open a command
- 17:15Speaker 2: prompt and type ipconfig slash flushbanes. Now, if you X
- 17:20Speaker 2: ray the ipconfig executable using a standard analysis tool like
- 17:23Speaker 2: dependency Walker, which basically scans the file to see all
- 17:26Speaker 2: its imports, you'll see it loads a DLL called DNSAPI.
- 17:30Speaker 1: Dot dl makes total sense. It's doing DNS stuff, so
- 17:33Speaker 1: it loads the DNS.
- 17:34Speaker 2: Library, and inside that library there is a documented function
- 17:37Speaker 2: called DNS flush resolver cash that's right there in the manual.
- 17:41Speaker 2: Microsoft tells developers exactly how to use it. But ipinfig
- 17:44Speaker 2: also calls something else, a function named DNS catch data table.
- 17:47Speaker 1: Which is completely missing from the official manual.
- 17:50Speaker 2: Completely invisible. If you search for it on the official
- 17:53Speaker 2: Microsoft Developer site you might find absolutely nothing, or maybe
- 17:57Speaker 2: just a blank placeholder page kind of Figure literally needs
- 18:01Speaker 2: it to display the current cache to you on the screen.
- 18:04Speaker 2: It uses that secret internal function to grab the data
- 18:07Speaker 2: table and print it out.
- 18:09Speaker 1: So if it's not in the book, how do we
- 18:11Speaker 1: even know it exists?
- 18:13Speaker 2: Because tools like dependency Walker can look directly at the
- 18:16Speaker 2: exports table inside the actual DLL file. It's like reading
- 18:20Speaker 2: the physical spine of the book on the library shelf,
- 18:23Speaker 2: even if the librarian left it out of the master catalog,
- 18:26Speaker 2: the code is physically there. The name is literally stamped
- 18:29Speaker 2: into the binary That is just fascinating.
- 18:31Speaker 1: So by reverse engineering the tools that Microsoft builds for itself,
- 18:34Speaker 1: security researchers find these hidden capabilities exactly.
- 18:38Speaker 2: And this is the true essence of studying Windows internals.
- 18:41Speaker 2: It's realizing that the official documentation is just a map,
- 18:45Speaker 2: but it is not the actual territory. The territory is
- 18:47Speaker 2: what's physically compiled into the binary files. When you understand that,
- 18:51Speaker 2: you can start discovering and doing things that the manual
- 18:53Speaker 2: explicitly says are impossible.
- 18:55Speaker 1: It turns the computer from a mysterious black box into
- 18:59Speaker 1: a completely transparent glass box.
- 19:01Speaker 2: And that is a really powerful shift in mindset. You
- 19:04Speaker 2: stop just hoping the software works securely and you start
- 19:07Speaker 2: verifying exactly how it works. You stop trusting the shiny
- 19:11Speaker 2: icon on your desktop, and you start inspecting the engine underneath.
- 19:14Speaker 2: So for the.
- 19:15Speaker 1: Listener right now, who wants to actually see this, who
- 19:17Speaker 1: wants to peel back the curtain and not just take
- 19:19Speaker 1: our word for it, what's the move. Here, what's the
- 19:22Speaker 1: review exercise they can do today?
- 19:24Speaker 2: Here is the challenge for you. I want you to
- 19:26Speaker 2: download a tool called Dependency Walker, or, if you want
- 19:30Speaker 2: something a bit more modern, a tool called Pea Studio.
- 19:33Speaker 2: They are both free, standard analysis tools used in the
- 19:36Speaker 2: industry every day.
- 19:37Speaker 1: Okay, they've got the tool downloaded. What next?
- 19:40Speaker 2: Then find something incredibly boring on your system Notepad dot
- 19:44Speaker 2: xx or KALC dot x. Just drag and drop it
- 19:47Speaker 2: executable filed directly into the tool.
- 19:49Speaker 1: And what exactly are they looking for?
- 19:50Speaker 2: Once it loads, look for the panel mark imports. You
- 19:54Speaker 2: will immediately see those exact DLL names we talked about today,
- 19:58Speaker 2: Colonel thirty two, User thirty two. Click on them to
- 20:01Speaker 2: expand the tree, and you will see a massive list
- 20:04Speaker 2: of the specific function names. The program is requesting things
- 20:07Speaker 2: like create file, reg open key, draw text.
- 20:10Speaker 1: And the goal is to try to reverse engineer the
- 20:13Speaker 1: logic just by reading those function names exactly.
- 20:15Speaker 2: You look at it and go, oh, it's calling red
- 20:17Speaker 2: open key. It must be checking the registry for my
- 20:19Speaker 2: user preferences. Oh it's calling get clipboard data. It must
- 20:22Speaker 2: be looking at the text I just copied. Spend just
- 20:24Speaker 2: ten minutes staring at the actual guts of a program
- 20:27Speaker 2: you use every day. I guarantee it fundamentally changes your
- 20:30Speaker 2: perspective on how software works.
- 20:32Speaker 1: It really reinforces that core idea we started with today.
- 20:35Speaker 1: These system calls are the vocabulary, the tokens are the
- 20:38Speaker 1: ID badges, and the processes are really just the empty
- 20:41Speaker 1: buildings where all this frantic bureaucracy happens.
- 20:44Speaker 2: And once you actually speak that vocabulary, nothing on your
- 20:47Speaker 2: system can keep a secret from you. Ever again, you
- 20:50Speaker 2: transition from being just a user to becoming the master
- 20:53Speaker 2: of the machine.
- 20:53Speaker 1: That is a very powerful place to be. Thank you
- 20:56Speaker 1: for taking us down into the engine room today and
- 20:58Speaker 1: breaking this down.
- 20:59Speaker 2: It is always a place to look under the hood.
- 21:01Speaker 1: And to you listening, go download Dependency Walker or Peace Studio,
- 21:05Speaker 1: take a close look at what your calculator app is
- 21:08Speaker 1: really doing behind the scenes, and we will see you
- 21:10Speaker 1: on the next deep dive.