Latest / CyberSecurity Summary / Windows APT Warfare: Identify and prevent Windows APT attacks effectively
Transcript
- 0:00Speaker 1: Ever wonder what happens in that split second when you
- 0:01Speaker 1: click on a program.
- 0:02Speaker 2: It seems so simple, doesn't it, Yeah, exactly.
- 0:05Speaker 1: But apparently it kicks off this incredibly complex series of
- 0:08Speaker 1: events deep inside your Windows system.
- 0:11Speaker 2: It's a whole journey. And you know, as we'll find out,
- 0:14Speaker 2: that complexity can sometimes well, it can open doors for vulnerabilities.
- 0:19Speaker 1: Right, So today we're doing a deep dive into that
- 0:22Speaker 1: hidden world Windows internals. We're using that book you shared,
- 0:26Speaker 1: Windows ABT Warfare as our guide.
- 0:29Speaker 2: That's the one. And yeah, this isn't your average user guide.
- 0:32Speaker 2: It's really aimed at people who want to get under
- 0:35Speaker 2: the hood of Windows security.
- 0:37Speaker 1: Wise, like engineers, malware folks.
- 0:39Speaker 2: Exactly, Windows engineers, malware researchers, ethical hackers, people like that.
- 0:43Speaker 2: It gets really hands on with stuff like reverse engineering,
- 0:46Speaker 2: exploit development, how attacks actually work at a low level.
- 0:49Speaker 1: Okay, So our mission today then is to pull out
- 0:52Speaker 1: the really crucial, maybe even the mind blowing stuff from
- 0:55Speaker 1: this book.
- 0:56Speaker 2: Yeah, to still it down right.
- 0:57Speaker 1: We want to give you the listener those aha moments
- 1:01Speaker 1: about how Windows programs get built, how they run.
- 1:04Speaker 2: And critically, how that whole process can be targeted, how
- 1:08Speaker 2: it can be manipulated by attackers.
- 1:10Speaker 1: Exactly, trying to cut through some of the heavy technical
- 1:13Speaker 1: jargon and make it, you know, engaging.
- 1:15Speaker 2: Absolutely think of it as a guided tour of Windows
- 1:18Speaker 2: Core using the book's insights. We'll hit the key mechanisms,
- 1:21Speaker 2: the security side of things, so.
- 1:23Speaker 1: You get a quick but hopefully thorough grasp of some
- 1:26Speaker 1: fundamental ideas.
- 1:27Speaker 2: Right, and this knowledge is honestly pretty powerful, whether you
- 1:31Speaker 2: just want to stay informed, or understand software better, or
- 1:34Speaker 2: maybe even prep for some technical cybersecurity chats.
- 1:37Speaker 1: Okay, let's get started in time for that deep dive
- 1:39Speaker 1: into Windows APT warfare, uncovering how programs come alive and
- 1:44Speaker 1: why that's maybe a double edged sword sometimes.
- 1:46Speaker 2: Let's do it. We should probably start right at the
- 1:48Speaker 2: beginning the journey. A simple C program takes from code
- 1:52Speaker 2: someone writes to well to a running process on your.
- 1:56Speaker 1: Machine, even just Hello World, Right, seems basic, but there's
- 2:00Speaker 1: a whole transformation happening behind.
- 2:01Speaker 2: The scenes totally. First up, you've got the C compiler.
- 2:04Speaker 1: Okay, what's its job? Exact?
- 2:06Speaker 2: It basically translates that human readable C code into assembly
- 2:10Speaker 2: language assembly.
- 2:12Speaker 1: Now, for those of us maybe not deep into coding,
- 2:14Speaker 1: how's that different? From C. Why does that matter here?
- 2:17Speaker 2: Good question. C is relatively high level, closer to how
- 2:20Speaker 2: we think. Assembly is much much closer to what the
- 2:24Speaker 2: computer's processor actually understands.
- 2:26Speaker 1: So like direct instructions for the chip.
- 2:28Speaker 2: Pretty much each assembly line is usually one tiny instruction
- 2:32Speaker 2: for the processor. And understanding that level is key because
- 2:35Speaker 2: a lot of core Windows functions and definitely malware operate
- 2:39Speaker 2: down there.
- 2:40Speaker 1: Okay, so C to assembly, then what there's an assembler
- 2:43Speaker 1: involved too?
- 2:44Speaker 2: Yep. The assembler takes that assembly code and turns it
- 2:46Speaker 2: into the actual machine code.
- 2:48Speaker 1: The raw binary ones and zeros.
- 2:51Speaker 2: That's it, the processor's native language.
- 2:53Speaker 1: The book mentioned tools like TDMGCC visual Studio, those are
- 2:58Speaker 1: the things doing this compiling and.
- 2:59Speaker 2: A SI exactly those tools integrated development environments. They handle
- 3:04Speaker 2: all these steps for you, packaging your C code into
- 3:06Speaker 2: that final runnable file.
- 3:08Speaker 1: But it's not just the machine code thrown into a file,
- 3:11Speaker 1: is it? The Windows linker steps in here? Sounds important?
- 3:15Speaker 2: Oh, absolutely crucial. The linker takes all the compiled machine code,
- 3:19Speaker 2: grabs any other bits of the program needs like libraries, data,
- 3:24Speaker 2: and packages it all up, packages it into the portable
- 3:27Speaker 2: executable format, the PE format. That's your standard dot ex
- 3:30Speaker 2: file in Windows.
- 3:31Speaker 1: Okay, PE format. What key things does the linker pack
- 3:34Speaker 1: in there? The book's mentioned a few.
- 3:36Speaker 2: Right, Well, it sets a default image based address often
- 3:39Speaker 2: zero by four hundred thousand. That's like the program's preferred
- 3:42Speaker 2: home in memory referred okay, And it organizes everything into
- 3:46Speaker 2: sections within that PE file, like.
- 3:48Speaker 1: The dot text section. What's that for?
- 3:50Speaker 2: That's where the actual executable code lives. Then you've got
- 3:53Speaker 2: dot I data read only data like text string exactly
- 3:56Speaker 2: like your Hello World string. And then there's dot iData
- 4:00Speaker 2: that holds the import address table or IAT BIAT.
- 4:03Speaker 1: Something tells me we'll be hearing more about that one.
- 4:06Speaker 1: What's its job?
- 4:07Speaker 2: Think of it like your program's phone book for outside help.
- 4:10Speaker 2: It lists all the functions your program needs to call
- 4:12Speaker 2: from other places, usually Windows own libraries.
- 4:15Speaker 1: The DLLs, so it knows who to call for certain tasks, right, And.
- 4:19Speaker 2: When your program runs, Windows uses the IAT to find
- 4:22Speaker 2: the actual memory addresses of those functions. But crucially, if
- 4:26Speaker 2: an attacker can rewrite those phone numbers.
- 4:29Speaker 1: Ah, they can redirect calls to their own code exactly.
- 4:32Speaker 2: It's a key vulnerability point. We'll definitely come back to
- 4:35Speaker 2: that The linker also adds the optional header tons of
- 4:38Speaker 2: metadata the loader needs later.
- 4:40Speaker 1: Okay, so we've got this static PE file on disc
- 4:44Speaker 1: How does it become a living, breathing process in memory.
- 4:47Speaker 1: That's the system application loader's job. Yep.
- 4:50Speaker 2: The loader takes that PE file and brings it to life.
- 4:53Speaker 2: It reads those sections code data imports, and carefully places
- 4:57Speaker 2: them into memory.
- 4:58Speaker 1: Following the instructions in the pehaders.
- 5:00Speaker 2: Precisely using that base address as a starting point. It
- 5:03Speaker 2: writes the sections to memory at the right offsets and
- 5:06Speaker 2: does some initial setup to get the program ready to run.
- 5:09Speaker 1: So it's not just copying, it's really constructing the process
- 5:11Speaker 1: and memory more dynamic than.
- 5:13Speaker 2: I thought, absolutely, and getting this initial journey CCODE to
- 5:16Speaker 2: running process. It's fundamental. It really sets the stage for
- 5:20Speaker 2: all the security stuff the book dives into later how
- 5:23Speaker 2: this very process gets targeted.
- 5:25Speaker 1: Right, So building on that, how the PE file gets made.
- 5:29Speaker 1: Chapter two looks at how that static file actually lays
- 5:32Speaker 1: out in memory when it's running process memory.
- 5:35Speaker 2: Yeah, how those PE parts, the doss header, the NT
- 5:38Speaker 2: headers with the file header, and the optional header, the
- 5:40Speaker 2: section headers. How they all get mapped into the process's
- 5:44Speaker 2: virtual memory space.
- 5:45Speaker 1: It's all structured following the rules laid out in those
- 5:47Speaker 1: headers exactly.
- 5:48Speaker 2: The book talks about the file mapping process, how the
- 5:51Speaker 2: system copies bits of the PE file into memory addresses.
- 5:55Speaker 2: It uses things like size of headers.
- 5:57Speaker 1: That's how big the header part is, right, and.
- 5:59Speaker 2: Then to raw data and relative virtual address RVA guide
- 6:03Speaker 2: where the content of each section goes in memory.
- 6:05Speaker 1: RVA relative virtual address so like an offset from the.
- 6:09Speaker 2: Start pretty much an address relative to the module's base
- 6:12Speaker 2: address in memory. Understanding rva's is key if you ever
- 6:16Speaker 2: want to pick apart a PE file or understand how
- 6:19Speaker 2: things link up internally.
- 6:21Speaker 1: Okay, and knowing how this mapping works leads into some well,
- 6:25Speaker 1: some shadier techniques discussed in the book, Yeah, like PE
- 6:28Speaker 1: infection or PE patching.
- 6:30Speaker 2: Yeah. The core idea there is adding your own malicious section,
- 6:34Speaker 2: maybe with some shell code.
- 6:36Speaker 1: Shell code being that small, self contained bit of malicious.
- 6:38Speaker 2: Code, right, You add that to a normal program. Then
- 6:41Speaker 2: you tweak the program's entry point.
- 6:43Speaker 1: So when the program starts, it runs the malicious code first.
- 6:45Speaker 2: Exactly, it gets redirected. It sounds really hard to spot too, would.
- 6:49Speaker 1: A normal user even notice anything? What are the signs?
- 6:53Speaker 2: That's the tricky part. The original program might still seem
- 6:56Speaker 2: to work fine afterwards, maybe it takes a bit longer
- 6:58Speaker 2: to start unusual network activity. Security software might flag it,
- 7:02Speaker 2: hopefully by spotting the extra section or the modified entry point.
- 7:05Speaker 2: But yeah, it can be subtle.
- 7:07Speaker 1: The book used that Pikachu volleyball example. Right, infecting pickaball
- 7:10Speaker 1: dot ex.
- 7:11Speaker 2: Yeah, you think you're launching a game, but note something
- 7:14Speaker 2: else runs first really drives the point.
- 7:17Speaker 1: Huh, definitely. And then there's process hollowing That sounds even sneakier.
- 7:21Speaker 2: It's a step up, for sure. An attacker starts a
- 7:24Speaker 2: legitimate process, say Google Update dot ex, but pauses it
- 7:29Speaker 2: immediately creates it in a suspended state.
- 7:32Speaker 1: Okay, so it's loaded but not running code yet. Right.
- 7:35Speaker 2: Then they basically hollow it out. They unmap its original
- 7:38Speaker 2: memory and replace it entirely with their own malicious code.
- 7:42Speaker 1: So the legit process is just a shell, a container
- 7:44Speaker 1: for the bad stuff exactly.
- 7:46Speaker 2: And the really deceptive part, the process's internal data structures
- 7:50Speaker 2: like the people we'll talk about, might still point to
- 7:53Speaker 2: the original Google Update dot.
- 7:54Speaker 1: Ex, so it looks legitimate to the system.
- 7:57Speaker 2: It can. Yeah, the book even says sometimes the original
- 8:00Speaker 2: digital signature can appear valid because the systems looking at
- 8:04Speaker 2: the initial process information, not the hollowed out content, makes
- 8:07Speaker 2: detection way harder.
- 8:08Speaker 1: Wow hiding and plain sight. The book also mentions tiny linker.
- 8:12Speaker 1: What's that about?
- 8:13Speaker 2: Oh yeah, tiny linker, It's about building a really stripped
- 8:16Speaker 2: down minimal compiler and linker.
- 8:19Speaker 1: Why would you do that?
- 8:20Speaker 2: Well, partly to understand the absolute bare minimum needed for
- 8:24Speaker 2: a PE file, But attackers like it because they can
- 8:26Speaker 2: create incredibly small executables, tiny payloads that might slip past
- 8:32Speaker 2: some security checks that look for larger, more complex files.
- 8:35Speaker 1: Okay, so from legit programs loading, we're already seeing how
- 8:38Speaker 1: those mechanics get twisted. Chapter three moves on to how
- 8:41Speaker 1: running programs talk to Windows Dynamic API calling.
- 8:45Speaker 2: Right, programs need to ask Windows to do things open files,
- 8:49Speaker 2: show Windows talk to the network. They do this by
- 8:52Speaker 2: calling Windows APIs application programming interfaces. Often this happens right
- 8:57Speaker 2: down at the assembly code level.
- 8:58Speaker 1: And there are rules for how these calls are made.
- 9:00Speaker 1: Conventions like WinAPI exactly.
- 9:03Speaker 2: Calling conventions are like protocols for function calls. They dictate
- 9:07Speaker 2: how arguments get passed on the stack in registers. Who
- 9:10Speaker 2: cleans up the memory afterwards, where does a return value go?
- 9:13Speaker 1: The book used message box as an example.
- 9:15Speaker 2: The pop up box yeah, a classic example of the
- 9:17Speaker 2: WinAPI convention. Parameters usually pushed onto the stack right to left,
- 9:21Speaker 2: and the message box a function itself, cleans up the
- 9:24Speaker 2: stack when it's done.
- 9:25Speaker 1: Okay. Then the book introduces these really important but apparently
- 9:29Speaker 1: often undocumented structures, the TEB and the PEB.
- 9:33Speaker 2: Ah Yes, the thread environment block TB and the process
- 9:37Speaker 2: environment block P. They hold a gold mine of info
- 9:40Speaker 2: about a running program.
- 9:42Speaker 1: So TEB is for threads, individual execution.
- 9:45Speaker 2: Paths, exactly thread specific data. The book highlights fields like
- 9:49Speaker 2: exceptionalists for error handling, stack base and stack limit defining
- 9:53Speaker 2: the threads, stack memory, client TITE holding process and thread IDs.
- 9:57Speaker 1: And crucially a pointer to the P right and.
- 10:00Speaker 2: A pointer to itself. So the PAY, on the other hand,
- 10:03Speaker 2: holds info for the entire process.
- 10:04Speaker 1: What kind of stuff is in the P.
- 10:06Speaker 2: Things like the being debugged flag. Malware hates debuggers, so
- 10:09Speaker 2: they check this. There's the image base address where the
- 10:11Speaker 2: main program module loaded process parameters, has info like command
- 10:16Speaker 2: line arguments, and a really important one a pointer to
- 10:19Speaker 2: pebble door data.
- 10:20Speaker 1: Pebble door data sounds like it releads to loading things.
- 10:23Speaker 2: It does. It's all about the modules, the DLLs that
- 10:26Speaker 2: the process is loaded into its memory.
- 10:28Speaker 1: So these TIB and PEB structures give a program context
- 10:31Speaker 1: self awareness, and the book says you can sometimes access
- 10:34Speaker 1: this info directly without using standard Windows functions.
- 10:37Speaker 2: Yeah, especially in thirty two bit Windows. The FS segment
- 10:40Speaker 2: register often points to the teb letting code access feels
- 10:44Speaker 2: directly GS register in sixty four bit. This is how
- 10:47Speaker 2: stealthy malware can gather info about its environment without making
- 10:50Speaker 2: noisy API calls that security software might be watching.
- 10:53Speaker 1: Sneaky at pebble. D R data structure sounds key then
- 10:56Speaker 1: for tracking loaded DLLs.
- 10:58Speaker 2: It is. It contains links inload order. Modulist tracks DLLs
- 11:02Speaker 2: in the order they loaded. In memory order. Modulists tracks
- 11:05Speaker 2: them by memory address, an initialization order. Modulist, well, that's
- 11:09Speaker 2: about initialization order.
- 11:11Speaker 1: And each entry in these lists is an LDR datable
- 11:14Speaker 1: entry holding details about each DLL YEP.
- 11:17Speaker 2: Things like the DLL's base address in memory dll base,
- 11:20Speaker 2: its entry point, its size, its full path and file name,
- 11:23Speaker 2: a full down name based a law name, even a
- 11:25Speaker 2: load count showing how many times it's been referenced.
- 11:28Speaker 1: Wow tons of detail, and the book explains how attackers
- 11:31Speaker 1: can use this.
- 11:31Speaker 2: Walk through these lists exactly. They can traverse the pet
- 11:34Speaker 2: LDR structure follow the pointers in those link lists to
- 11:38Speaker 2: find the base address of a specific DLL they need,
- 11:41Speaker 2: like kernel thirty two dot dll.
- 11:43Speaker 1: Without calling load library or get module handle.
- 11:46Speaker 2: Right, they find it manually internally evades detection that might
- 11:50Speaker 2: be watching those specific API calls. It's like using an
- 11:53Speaker 2: internal undocumented map instead of asking for directions.
- 11:56Speaker 1: Very clever. It gets worse the can thisss with these entries.
- 11:59Speaker 2: Yeah. The book mentions techniques to actually modify the LDR
- 12:02Speaker 2: datable entry structures. You could potentially rename a loaded DLL
- 12:06Speaker 2: in memory, just change the name string to confuse analysis tools,
- 12:10Speaker 2: or even unlink malicious DLL entirely from these lists hide module,
- 12:14Speaker 2: making it invisible to standard enumeration methods.
- 12:18Speaker 1: That's serious manipulation. The chapter also mentions parameter forgery changing
- 12:22Speaker 1: command line arc briefly.
- 12:23Speaker 2: Yeah, create a process suspended, then go into its PEB
- 12:26Speaker 2: and fiddle with the process parameter structure to change what
- 12:29Speaker 2: command line arguments it thinks it was launched.
- 12:31Speaker 1: With so many ways to mess with a process. Once
- 12:34Speaker 1: you understand these internals. Okay. Chapter four goes back to
- 12:37Speaker 1: shell code, specifically how it finds those Windows API functions
- 12:41Speaker 1: it needs. Right.
- 12:43Speaker 2: Because shell cut often gets injected in weird ways, it
- 12:46Speaker 2: can't rely on the normal loading process setting up that
- 12:50Speaker 2: import address table IAT for it. It has to find
- 12:53Speaker 2: functions itself dynamically at run time.
- 12:56Speaker 1: And the key is the export address table the E within.
- 12:59Speaker 2: Each LL Exactly, The ET is like the dla's public directory.
- 13:04Speaker 2: It lists all the functions the DLA exports for others
- 13:06Speaker 2: to use what's in the ET. It has a few
- 13:08Speaker 2: key arrays. Address of functions points to the actual code
- 13:11Speaker 2: for each exported function, as rva's address of names points
- 13:15Speaker 2: to the names of the functions, and address of name
- 13:17Speaker 2: ordinals maps the names to ordinal numbers.
- 13:20Speaker 1: So shell code can read this ET to find the
- 13:22Speaker 1: address of, say, create filet A inside kernel three D
- 13:25Speaker 1: two dot DL precisely.
- 13:27Speaker 2: The book even talks about building a simple tool to
- 13:29Speaker 2: purse a DL's ET and list its exports. Then it
- 13:32Speaker 2: shows how shell code uses the TBNP tricks we just
- 13:34Speaker 2: discussed to first find the DL's base address and memory.
- 13:38Speaker 1: Like finding kernel threet two dot DLL's.
- 13:40Speaker 2: Address right, and then it manually parses that DL's PE
- 13:44Speaker 2: headers to find the ET, and then searches through the
- 13:48Speaker 2: ET's arrays address of names, address off name ordinals, address
- 13:51Speaker 2: of functions to locate the exact memory address of the
- 13:54Speaker 2: specific function at once.
- 13:56Speaker 1: All without calling get proke address.
- 13:58Speaker 2: Exactly, totally self sufficient, like a little detective inside the
- 14:01Speaker 2: process memory.
- 14:02Speaker 1: That's amazing. The chapter actually walks through writing by eighty
- 14:05Speaker 1: six assembly shell code to do this.
- 14:07Speaker 2: That sounds intense, it is definitely low level. The thirty
- 14:09Speaker 2: two B shell code dot atism example in the book
- 14:12Speaker 2: is detailed shows accessing TUB, finding PAYAB, walking the LDR
- 14:15Speaker 2: list for kernel thirty two dot DL, parsing its headers,
- 14:19Speaker 2: finding the EET, and then crawling the ET tables to
- 14:22Speaker 2: get the address for fatal exit. It's a masterclass in
- 14:25Speaker 2: manual low level function resolution.
- 14:27Speaker 1: Phew. Okay, But for those not quite ready for assembly,
- 14:30Speaker 1: the book mentions automating shell code generation from C or
- 14:33Speaker 1: C plus plus AP.
- 14:34Speaker 2: Yeah. Thankfully, there are tools and techniques to compile CC
- 14:37Speaker 2: plus plus code down into position independent shell code, which
- 14:40Speaker 2: makes it much more accessible. Kind of bridges the gap makes.
- 14:43Speaker 1: Sense, okay. Chapter five dives deeper into the application loader itself,
- 14:47Speaker 1: especially that import address table, the IAT. We keep mentioning.
- 14:51Speaker 2: Yeah, the IAT is just so central to recap. It's
- 14:55Speaker 2: that table of function pointers and module. When the loader
- 14:58Speaker 2: loads your program at, the IAT sees which functions you
- 15:02Speaker 2: need from other DLLs, goes.
- 15:03Speaker 1: And finds the real addresses of those functions in memory.
- 15:06Speaker 2: And patches the IAT, filling in those pointers. So when
- 15:10Speaker 2: your code calls say create filarea, the IAT entry now
- 15:13Speaker 2: points directly to the real create filia code loaded somewhere
- 15:17Speaker 2: in memory, connects the dots exactly. It wires everything up.
- 15:20Speaker 2: And the book then covers a really advanced technique loading
- 15:23Speaker 2: and running a whole ex inside another process's memory, no
- 15:27Speaker 2: separate file on disk.
- 15:28Speaker 1: Yeah, super stealthy used by APT groups.
- 15:31Speaker 2: Yeah, The book mentions threat actors like Mustang, Panda, APT
- 15:34Speaker 2: forty one, and even tools like metasploit using this for
- 15:38Speaker 2: stage payloads. It avoids creating a new process that security
- 15:41Speaker 2: tools might immediately notice.
- 15:43Speaker 1: Makes sense. Then there's IAT hooking, another way to mess
- 15:46Speaker 1: with these function calls. Yep.
- 15:47Speaker 2: With IAT hooking, you modify the IAT after the loader
- 15:51Speaker 2: has filled it in. You change a pointer that should
- 15:54Speaker 2: go to a legitimate function like message box A to
- 15:57Speaker 2: point to your own malicious function instead, so.
- 16:00Speaker 1: The program thinks it's calling the real function but gets
- 16:02Speaker 1: hijacked exactly.
- 16:04Speaker 2: The book uses message box A hijacking as an example.
- 16:07Speaker 2: Legitimate uses exist, like in game plugins or sandboxes, but
- 16:11Speaker 2: malware uses it to intercept data, redirect control flow, things
- 16:14Speaker 2: like that.
- 16:15Speaker 1: And then DLL sideloading comes up again.
- 16:17Speaker 2: Right exploiting that search order program needs some dot DLL.
- 16:21Speaker 2: Loader checks the program's own folder first, then system thirty two,
- 16:24Speaker 2: et CETERA. Attacker puts a malicious sump dot DLL in
- 16:27Speaker 2: the program's folder, and the.
- 16:28Speaker 1: Loader finds and loads the malicious one before it ever
- 16:31Speaker 1: looks in system thirty two.
- 16:32Speaker 2: That's the idea. The book uses hijacking Chrome with a
- 16:35Speaker 2: phadversion dot DLL as an example. Very common attack vector.
- 16:38Speaker 1: And DLL proxying. What was that?
- 16:40Speaker 2: That's a variation. The malicious DLL gets loaded via sideloading,
- 16:45Speaker 2: but it actually exports all the same functions as the
- 16:48Speaker 2: real DLL it replaced. When the program calls a function,
- 16:51Speaker 2: the malicious DLL might do something bad first, then it
- 16:55Speaker 2: proxies the call, passing it along to the actual legitimate DLL,
- 16:59Speaker 2: which it loads itself.
- 17:00Speaker 1: So the program still works, but the attacker gets their
- 17:03Speaker 1: code executed too clever. Chapter five really shows the loading
- 17:07Speaker 1: process is full of potential attack surfaces. Chapter six talks
- 17:11Speaker 1: about PE module relocation. This is about loading things at
- 17:14Speaker 1: different addresses exactly. Remember the linker sets a preferred image
- 17:17Speaker 1: based address right like zero by four hundred thousand.
- 17:20Speaker 2: In a running system, that address might already be taken
- 17:23Speaker 2: by something else, So the program just fails, not necessarily.
- 17:26Speaker 2: That's where relocation comes in. It's a mechanism built into
- 17:28Speaker 2: the PE format that allows a module to be loaded
- 17:31Speaker 2: and run correctly even if it lands at a different
- 17:34Speaker 2: address than its preferred one.
- 17:35Speaker 1: How does that work? Does something get adjusted?
- 17:38Speaker 2: Yes, there's a relocation table inside the PE file. It
- 17:42Speaker 2: lists all the places in the code and data that
- 17:44Speaker 2: contain absolute memory addresses addresses that assume the module is
- 17:48Speaker 2: loaded at its preferred image base.
- 17:50Speaker 1: Ah. So if it loads somewhere else, those addresses would
- 17:53Speaker 1: be wrong exactly.
- 17:54Speaker 2: So when the LOADO puts the module at a different address,
- 17:57Speaker 2: it reads this relocation table and goes through and fixes
- 18:01Speaker 2: up all those listed addresses, adjusting them based on the
- 18:05Speaker 2: actual load address.
- 18:06Speaker 1: Making sure all the internal pointers are correct.
- 18:08Speaker 2: For the new location precisely. The book mentions tiny loader
- 18:11Speaker 2: again here showing how a custom loader like ploader dot
- 18:14Speaker 2: cpp can handle this. It parses the relocation table and
- 18:18Speaker 2: applies the fix ups when loading a module, often using
- 18:22Speaker 2: virtual allock to get memory wherever it can, and then
- 18:24Speaker 2: carefully patching the loaded code and data.
- 18:27Speaker 1: Very important for those in memory loading techniques we discuss Okay,
- 18:30Speaker 1: chapter seven packers. We've probably all run into packed executables.
- 18:35Speaker 1: What's the deal with them?
- 18:36Speaker 2: Packers are tools that basically wrap an executable. They compress it,
- 18:40Speaker 2: maybe encrypt it, definitely obfuscate it. The original program gets
- 18:43Speaker 2: bundled inside a shell or stub.
- 18:45Speaker 1: So it's like putting the real program inside a protective.
- 18:48Speaker 2: Box kind of yeah, or maybe a confusing box. The
- 18:52Speaker 2: book shows how the memory layout changes. You often get
- 18:55Speaker 2: a section marked readable, writeable and executable text up x,
- 18:59Speaker 2: where the un packed code will go. You get a
- 19:02Speaker 2: payload section holding the packed original program, and you get
- 19:05Speaker 2: the packer stub COODE.
- 19:07Speaker 1: And the stub is the code that does the unpacking.
- 19:09Speaker 2: YEP. When you run the packed file, the stub executes first.
- 19:13Speaker 2: Its job is to decompress or decrypt the payload into
- 19:16Speaker 2: that textrap x section. Often it also has to act
- 19:19Speaker 2: like a mini loader itself, fixing imports, handling relocations for
- 19:22Speaker 2: the unpacked code.
- 19:23Speaker 1: And then it jumps to the original program starting point.
- 19:26Speaker 2: Right jumps to the original entry point OEP of the
- 19:29Speaker 2: now unpacked program, and the original application starts running, hopefully
- 19:32Speaker 2: unaware it was ever packed.
- 19:34Speaker 1: Other different kinds of packers.
- 19:36Speaker 2: Broadly, Yeah, compression packers like upx or mprs mostly just
- 19:41Speaker 2: aimed to make the file smaller. Protective packers like VM
- 19:44Speaker 2: protect themta Enigma protector. They focus heavily on making reverse
- 19:48Speaker 2: engineering and analysis really difficult.
- 19:51Speaker 1: How do they do that? What are these anti reverse
- 19:53Speaker 1: engineering tricks?
- 19:54Speaker 2: Oh? Loads of them. Obfuscation, making the code intentionally confusing,
- 19:59Speaker 2: anti VM checks, trying to detect if it's running in
- 20:01Speaker 2: a sandbox, Anti debugger tricks checking that PEB being debugged,
- 20:05Speaker 2: flag using weird API calls to crash debuggers.
- 20:09Speaker 1: Anti tampering too, like checking file integrity.
- 20:12Speaker 2: Yeah, using checksums, maybe comparing against the pe headers checksum,
- 20:16Speaker 2: checking digital signatures authenticode. Some even use virtualization. They translate
- 20:21Speaker 2: the original code into a custom bytecode and run it
- 20:24Speaker 2: on a tiny virtual machine. Embedded in the packer stub,
- 20:28Speaker 2: super complex stuff.
- 20:29Speaker 1: Plus commercial features like licensing checks sometimes right.
- 20:32Speaker 2: The book also touches on building a simple packer, reading
- 20:35Speaker 2: the original ex compressing it, writing an assemile stub to
- 20:39Speaker 2: handle unpacking, combining it all using tools like YASM and GCC.
- 20:43Speaker 1: And the unpacker stub itself has key parts right.
- 20:46Speaker 2: Yeah, routines like decompress image, recarnate HDR to rebuild the
- 20:50Speaker 2: pehaders for the unpacked code, and look a poet to
- 20:53Speaker 2: find where to jump. The book uses packing an old
- 20:55Speaker 2: game and a schnaft as an example shows the size reduction,
- 20:58Speaker 2: but more importantly how tools like IDPro can't easily see
- 21:02Speaker 2: the original game code anymore. It's all hidden inside the
- 21:05Speaker 2: packer stub and payload.
- 21:07Speaker 1: Okay, moving to chapter nine. Digital signatures in Authentic Code.
- 21:11Speaker 1: We see these all the time when downloading stuff. What's
- 21:13Speaker 1: their main job?
- 21:14Speaker 2: Authentic Code is Microsoft's tech for signing code. Two main
- 21:17Speaker 2: goals verify the publisher is this really from who it
- 21:21Speaker 2: says is from? And verify integrity have this file been
- 21:25Speaker 2: messed with since it was signed?
- 21:26Speaker 1: Relies on trust right certificate authorities.
- 21:29Speaker 2: YEP, trusted CAS vouch for the publisher's identity before issuing
- 21:32Speaker 2: the certificate used for signing.
- 21:34Speaker 1: The book mentioned embedded versus detached signatures.
- 21:37Speaker 2: Right embedded is most common for exs and DLLs. The
- 21:40Speaker 2: signature data is literally tacked onto the end of the
- 21:43Speaker 2: PE file itself. Detached signatures are separate, maybe in catalog files,
- 21:47Speaker 2: often just containing a hash of the sign file.
- 21:50Speaker 1: So Windows checks that embedded signature when we run a downloaded.
- 21:53Speaker 2: Ex usually yeah, using APIs like when verify trust. Different
- 21:58Speaker 2: file types actually use different backend components called subject interface
- 22:02Speaker 2: packages SIPs to handle the specifics of validation.
- 22:06Speaker 1: And hashing is key for the integrity check.
- 22:08Speaker 2: Absolutely, a cryptographic hash is calculated over the executable's content. But,
- 22:13Speaker 2: and this is crucial, certain parts are excluded from the hash,
- 22:16Speaker 2: like what the p header's check, some field, the security
- 22:20Speaker 2: directory entry itself which points to where the signature is stored,
- 22:23Speaker 2: and the actual signature block data are all skipped during.
- 22:26Speaker 1: Hashingh skipping the signature block itself that sends an exploit
- 22:31Speaker 1: opportunity there. But first, mock signatures? Can you just fake one?
- 22:36Speaker 2: The book tries it copies the signature block from a
- 22:39Speaker 2: signed file like Google Update, dot ex and paste it
- 22:42Speaker 2: onto an unsigned one like Pikachu Volleyball.
- 22:44Speaker 1: Do it work?
- 22:45Speaker 2: Nope. The signature data is there, but the hash embedded
- 22:48Speaker 2: inside that signature block belongs to Google Update, not Pikachu.
- 22:52Speaker 2: When Windows calculates Pikachu's hash and compares it, they won't match.
- 22:56Speaker 2: Verification fails.
- 22:57Speaker 1: Okay, so simple copying doesn't work. What about bypassing the
- 23:02Speaker 1: hash check?
- 23:03Speaker 2: Now you're talking. The book mentions research by Matt Graeber
- 23:06Speaker 2: showing how you can potentially hook or patch the verification
- 23:09Speaker 2: function in memory, specifically crypt SIP verify indirect data to
- 23:14Speaker 2: just always return true, always say the signature is valid
- 23:17Speaker 2: even when it's not.
- 23:18Speaker 1: So you trick the system into thinking the check past
- 23:21Speaker 1: even if the hash is wrong.
- 23:23Speaker 2: Essentially, yes, a way to make a fake signature look
- 23:26Speaker 2: legit at a certain level.
- 23:27Speaker 1: Wow, and signature steganography hiding stuff in the signature.
- 23:31Speaker 2: Yeah, this exploits that exclusion we mentioned. Since the signature
- 23:34Speaker 2: block itself isn't hashed, you can append extra data after
- 23:37Speaker 2: the actual signature data within that block. You just need
- 23:40Speaker 2: to update the size field correctly.
- 23:41Speaker 1: And the signature still validates it.
- 23:43Speaker 2: Can Yeah, the original signed hash is still correct for
- 23:46Speaker 2: the original part of the file, but now you've smuggled
- 23:48Speaker 2: extra data inside the signature block, potentially hiding malware payloads
- 23:52Speaker 2: where scanners might not look closely.
- 23:54Speaker 1: Very sneaky. Lastly, getting signed by abusing path normalization exploiting
- 24:00Speaker 1: how Windows handles paths.
- 24:02Speaker 2: This is another subtle one, again based on path normalization research.
- 24:05Speaker 2: If you create a file with a weird name like
- 24:08Speaker 2: Google update dot ex with a trailing space, Windows might
- 24:12Speaker 2: normalize that path differently during signature checks compared to other operations.
- 24:17Speaker 1: So you can have a legitimate Google update dot ex
- 24:20Speaker 1: with a valid signature, and maybe a malicious Pikachu volleyball
- 24:24Speaker 1: file at a path that normalizes to look like the
- 24:27Speaker 1: Google update path during the check.
- 24:29Speaker 2: Under certain complex conditions. Yes, it's about creating collisions in
- 24:34Speaker 2: how paths are interpreted, potentially tricking the system into associating
- 24:37Speaker 2: a valid signature with the wrong file. Due to these
- 24:40Speaker 2: normalization quirks.
- 24:42Speaker 1: The man signatures are way more complex and fragile than
- 24:44Speaker 1: they seem. Okay. Chapter ten User account Control UAC, and
- 24:48Speaker 1: bypassing it, UAC is meant to stop malware getting admin
- 24:51Speaker 1: rights easily. Right.
- 24:52Speaker 2: That's the goal. Stop programs from getting elevated privileges without
- 24:56Speaker 2: your permission. It runs most things as a standard user,
- 24:58Speaker 2: even if you're logged in as admin, and prompts you
- 25:00Speaker 2: when something needs more power. Only certain trusted system services
- 25:04Speaker 2: can bypass the prompt automatically.
- 25:06Speaker 1: The book mentions Ray launch admin process in a pinfo
- 25:09Speaker 1: dot DLL. What's that?
- 25:11Speaker 2: That's described as the core function in the UAC service
- 25:14Speaker 2: that handles elevation requests. It receives the request, validates it
- 25:18Speaker 2: based on rules, and if it passes, launches the process
- 25:21Speaker 2: with admin rights. It takes parameters like the executable path,
- 25:25Speaker 2: command line, et cetera. It's the gatekeeper and.
- 25:27Speaker 1: It has checks A two level authentication Yeah.
- 25:30Speaker 2: Authentication A and B.
- 25:32Speaker 1: What do they check?
- 25:32Speaker 2: Authentication A is mostly about the path. Is it running
- 25:36Speaker 2: from a trusted system location like CU Windows? Is it
- 25:39Speaker 2: on a known blacklist? Authentication B is stricter. Does it
- 25:43Speaker 2: have a valid digital signature? Does the filename maybe match
- 25:47Speaker 2: internal version info? If a program passes both checks, it can.
- 25:50Speaker 1: Get elevated automatically.
- 25:52Speaker 2: No prompt exactly. If it's configured for auto elevation, like
- 25:55Speaker 2: many built in Windows tools, are has a valid signature
- 25:58Speaker 2: and runs from a trusted path UAC might let it
- 26:01Speaker 2: elevate silently.
- 26:02Speaker 1: Which naturally leads to bypass techniques trying to meet those
- 26:05Speaker 1: conditions illegitimately.
- 26:06Speaker 2: You got it. The chapter covers several ways DLL sideloading
- 26:10Speaker 2: again but targeting one of those auto elevating privileged processes.
- 26:14Speaker 2: If you can get your malicious DLL loaded by one.
- 26:16Speaker 1: Of them, your DLL runs with elevated.
- 26:18Speaker 2: Rights too, bingo. Another way is using elevated comm objects
- 26:22Speaker 2: CALM objects, yeah, component object model. Some COMM objects, like
- 26:26Speaker 2: ifile operation for file tasks are designed to run elevated.
- 26:30Speaker 2: A low privileged process might be able to create and
- 26:33Speaker 2: use one of these elevated objects to perform admin level
- 26:35Speaker 2: actions by passing the usual UAC flow. Wikileaksvault seven mentioned
- 26:40Speaker 2: stuff like this.
- 26:41Speaker 1: Then there's CMSTP Connection Manager Profile.
- 26:44Speaker 2: Installer right, another legit Windows tool, CMSTP dot exc that
- 26:47Speaker 2: can be abused by crafting a malicious dot inf file
- 26:51Speaker 2: and tricking CMSTP into processing it. Attackers found ways to
- 26:54Speaker 2: execute arbitrary code with elevated privileges. Often involves making the
- 26:58Speaker 2: attacker process look like explore dot ex and messing with its.
- 27:01Speaker 1: Pebe and finally trusted path collisions again using long.
- 27:05Speaker 2: Paths YEP back to path normalization. An attacker puts their
- 27:09Speaker 2: malicious executable maybe one vulnerable to DLL side loading itself
- 27:14Speaker 2: like BitLocker wizardleve dot exc in the books, example, in
- 27:18Speaker 2: a non trusted location, but they use a very long
- 27:22Speaker 2: or weirdly constructed.
- 27:23Speaker 1: Path, so that when UAC checks the path after normalization, it.
- 27:27Speaker 2: Looks like it's coming from a trusted directory like System
- 27:30Speaker 2: thirty two, even though it isn't really there. The check
- 27:32Speaker 2: pass is based on the normalized path, and UAC might
- 27:35Speaker 2: grant auto.
- 27:36Speaker 1: Elevation, exploiting the gap between the real path and how
- 27:39Speaker 1: the system interprets it for checks. Wow. Okay. Finally, the
- 27:43Speaker 1: appendix NTFS paths symbols.
- 27:46Speaker 2: Why is this important because so many security checks, as
- 27:49Speaker 2: we've seen, rely on comparing file paths. Understanding how Windows
- 27:53Speaker 2: defines paths when thirty two versus antipaths, how it converts
- 27:57Speaker 2: and normalizes them is crucial for finding bugs or ways
- 27:59Speaker 2: to trick those comparisons.
- 28:01Speaker 1: The book mentions different path types DOS paths, UNC paths,
- 28:05Speaker 1: and that prefix being special.
- 28:06Speaker 2: Yeah. The prefix tells Windows don't normalize this path much
- 28:09Speaker 2: and allow it to be longer than two hundred and
- 28:11Speaker 2: sixty characters. It bypasses many standard steps which could be
- 28:14Speaker 2: abut oh yeah. The appendix gives examples creating folders with
- 28:18Speaker 2: trailing dots or spaces that confuse, explore, using path normalization
- 28:23Speaker 2: differences to bypass signature checks, even how the CD command
- 28:26Speaker 2: behaves weirdly sometimes. It also mentions symbolic links like shortcuts,
- 28:31Speaker 2: but more powerful, and how viewing them with one object
- 28:34Speaker 2: can reveal filesystem structure and device paths like NUL. Apparently,
- 28:39Speaker 2: using paths doesn't restrict the parent directory sequence, which could
- 28:43Speaker 2: potentially allow access to unexpected places. It really shows that
- 28:46Speaker 2: path handling is full of subtle complexities.
- 28:49Speaker 1: What a deep dive. That was seriously intricate stuff, all
- 28:52Speaker 1: pulled from Windows APT warfare. Looking back, what's the big
- 28:55Speaker 1: picture takeaway for you?
- 28:57Speaker 2: For me, it's just the here hidden complexity. Clicking an
- 28:59Speaker 2: icon seems simple, but the journey from code to process,
- 29:02Speaker 2: the memory layout, the API calls the security layers like
- 29:05Speaker 2: signatures in UAC.
- 29:07Speaker 1: It's incredibly deep and every layer has potential weaknesses.
- 29:10Speaker 2: Exactly every mechanism from PE loading to path handling can
- 29:14Speaker 2: potentially be manipulated or subverted. If you understand it well enough.
- 29:18Speaker 2: It really highlights that constant cat and mouse game between
- 29:22Speaker 2: attackers finding flaws and defenders trying to patch them or
- 29:26Speaker 2: detect exploitation.
- 29:27Speaker 1: Right and hopefully for you listening, getting even a glimpse
- 29:30Speaker 1: of these underlying mechanisms helps make sense of how software works,
- 29:34Speaker 1: maybe helps you spot weird behavior, or just understand the
- 29:38Speaker 1: news about security breaches a bit better.
- 29:40Speaker 2: Absolutely, if any of this sparked your interest reverse engineering,
- 29:44Speaker 2: malware analysis, Windows internals, generally, definitely dig deeper. The book itself,
- 29:49Speaker 2: Windows APT Warfare and its githab Repo seem like great
- 29:53Speaker 2: starting points for more hands on exploration.
- 29:55Speaker 1: Definitely. So maybe the final thought to leave you with
- 29:58Speaker 1: is this, in this world where cyber shreds are always evolving,
- 30:02Speaker 1: always getting more sophisticated, isn't.
- 30:04Speaker 2: Really understanding these fundamental building blocks, the very guts of
- 30:07Speaker 2: the operating system like we've touched on today. Isn't that
- 30:09Speaker 2: the most critical foundation for both the attackers and the defenders.
- 30:13Speaker 1: It really feels like it's all about continuous learning, right Yea.
- 30:16Speaker 1: The deeper we understand these internals, the better equipped we
- 30:19Speaker 1: all are