Latest / CyberSecurity Summary / Windows Security Internals: A Deep Dive into Windows Authentication, Authorization, and Auditing
Transcript
- 0:00Speaker 1: Welcome to the deep dive. You give it some really
- 0:02Speaker 1: interesting material here, focusing on Windows security internals and PowerShell.
- 0:08Speaker 2: Yeah, it's a great combination to look at.
- 0:09Speaker 1: So that's our focus today. Our mission really is to
- 0:13Speaker 1: pull out the core ideas, give you a shortcut to
- 0:15Speaker 1: understanding how Windows handles security management and how PowerShell fits
- 0:20Speaker 1: in as well, like an investigative.
- 0:22Speaker 2: Tool, right without getting totally lost in the weeds. There's
- 0:24Speaker 2: a lot of detail in these sources exactly.
- 0:26Speaker 1: We're aiming for those aha moments, you know, finding the
- 0:30Speaker 1: surprising bits about Windows security that PowerShell helps uncover.
- 0:35Speaker 2: And what's really cool is how the sources link these
- 0:37Speaker 2: like abstract security concepts directly to practical PowerShell commands.
- 0:42Speaker 1: So it's not just theory, not at all.
- 0:43Speaker 2: We'll actually see how PowerShell can light up the internals.
- 0:46Speaker 1: Okay, let's dive in. The material starts by emphasizing setting
- 0:49Speaker 1: up a PowerShell testing environment. Why is that the first
- 0:53Speaker 1: crucial step.
- 0:54Speaker 2: Well, it's super important because you need a safe place,
- 0:58Speaker 2: a sandbox, right to try out these commands without messing
- 1:01Speaker 2: up your actual system.
- 1:02Speaker 1: Makes sense, you don't want to break anything accidentally exactly.
- 1:05Speaker 2: And the source talks about set execution policy. Think of
- 1:09Speaker 2: that as your first safety net stops accidental script running.
- 1:12Speaker 1: Which can be a security risk in itself.
- 1:14Speaker 2: Oh definitely. And the key thing is that set scope
- 1:17Speaker 2: current user option for.
- 1:18Speaker 1: Keeping tests just within your user account.
- 1:21Speaker 2: Right, isolated testing. If you want system wide changes, well
- 1:24Speaker 2: that's different. You'd need admin privileges for that, and you
- 1:26Speaker 2: wouldn't use the scope parameter.
- 1:28Speaker 1: Then gotcha. And the source notes that some setups, like
- 1:31Speaker 1: maybe open source PowerShell or newer server versions might already
- 1:35Speaker 1: have remote signed as the default.
- 1:38Speaker 2: Yeah, so it's always smart to just check first, know
- 1:40Speaker 2: where you stand.
- 1:41Speaker 1: Okay, Next up PowerShell language basics. For someone diving into
- 1:46Speaker 1: this material, what are the foundational bits that really give
- 1:49Speaker 1: you leverage here?
- 1:50Speaker 2: The sources bring up a few key things special variables
- 1:53Speaker 2: like null p TOBE for your current directory pobid that's.
- 1:57Speaker 1: The PowerShell process idea itself.
- 1:59Speaker 2: Yeah, exactly, and ORNA four for environment variables like EnEv
- 2:03Speaker 2: windeer knowing innovator D is surprisingly useful for security scripting
- 2:08Speaker 2: context matters.
- 2:09Speaker 1: And the difference between single and double quotes crucial.
- 2:12Speaker 2: Double quotes allow string interpolation.
- 2:15Speaker 1: So variables get automatically substituted in right.
- 2:18Speaker 2: Makes building dynamic commands way easier, no messy string joining
- 2:22Speaker 2: single quotes. They treat everything literally good when you need
- 2:25Speaker 2: that exact string.
- 2:27Speaker 1: That interpolation is a huge time saver. The source also
- 2:30Speaker 1: mentions creating objects a new object using a GID as
- 2:34Speaker 1: an example.
- 2:35Speaker 2: Yeah, basic object creation and the naming convention for commands
- 2:39Speaker 2: verb noun like a get item.
- 2:41Speaker 1: Seems designed to make things easier to find.
- 2:44Speaker 2: It really does help. You can often guess command names
- 2:46Speaker 2: and then parameters like megapath with get item, let you focus.
- 2:50Speaker 1: The command so you can target specific.
- 2:52Speaker 2: Things exactly, and we'll get to get member later. But
- 2:54Speaker 2: think of that as your magnifying glass for figuring out
- 2:56Speaker 2: what an object is and what you can do with it.
- 2:58Speaker 1: Okay, so you have these basic tools, how do you
- 3:00Speaker 1: learn to use them effectively? The source talks a lot
- 3:02Speaker 1: about get help.
- 3:03Speaker 2: Oh, get help is your best friend in PowerShell, seriously indispensable.
- 3:08Speaker 1: What does it give you?
- 3:08Speaker 2: The synopsis, the full syntax, detailed descriptions, and what's really
- 3:12Speaker 2: handy is using wild cards for parameter.
- 3:14Speaker 1: Names like the ubjet example to find parameters starting with.
- 3:18Speaker 2: Objeck exactly and the example's parameter that's often the best
- 3:21Speaker 2: part real world usage examples invaluable can't.
- 3:25Speaker 1: Be practical examples. Okay, now, what about making your own
- 3:28Speaker 1: PowerShell tools. The material covers functions. What's key there, Well.
- 3:32Speaker 2: The basics are the function keyword, then your function name.
- 3:37Speaker 2: It's good practice to stick to that verb noun convention
- 3:40Speaker 2: even for your own stuff. Keeps things consistent, makes sense,
- 3:43Speaker 2: and parameters defined in the tarum block. You can specify
- 3:47Speaker 2: types like string name, but you don't have to. PowerShell's
- 3:50Speaker 2: pretty flexible.
- 3:51Speaker 1: What if you don't use param.
- 3:52Speaker 2: Then any arguments you pass just end up in the
- 3:54Speaker 2: arg's array. You access them by number, like ARGs dollars
- 3:57Speaker 2: or r T one.
- 3:58Speaker 1: So named parameters are just numbered arguments. Good flexibility. Okay.
- 4:02Speaker 1: The deep dive then shifts to output. How PowerShell shows
- 4:06Speaker 1: you stuff and how you can control it.
- 4:08Speaker 2: Right, So, when a command runs and you don't assign
- 4:11Speaker 2: the output to a variable, PowerShell steps in and tries
- 4:14Speaker 2: to display it nicely, usually a table or a list.
- 4:17Speaker 1: It guesses the best format.
- 4:18Speaker 2: Kind of yeah, based on the object's properties, but you
- 4:22Speaker 2: have control. Select object is key for picking just the
- 4:26Speaker 2: properties you care about. Cuts down the noise.
- 4:29Speaker 1: Nice and format list forces.
- 4:31Speaker 2: It into a list view one property per line. Basically
- 4:35Speaker 2: great when you want to see all the details for
- 4:37Speaker 2: a single object rather than a wide table.
- 4:39Speaker 1: And if you don't even know what properties are available,
- 4:42Speaker 1: that's where get member comes in again, right with DJ
- 4:44Speaker 1: type property.
- 4:45Speaker 2: Exactly if pipe your command output to get member iban
- 4:48Speaker 2: type property and boom, you get the full list of
- 4:50Speaker 2: data points you can access on those objects. It's like asking,
- 4:52Speaker 2: what can you tell me about yourself?
- 4:54Speaker 1: The decoder ring analogy works. Yeah, and sort object to
- 4:57Speaker 1: organize it, yep, sort.
- 4:59Speaker 2: My name, my side by memory usage, whatever property you need.
- 5:02Speaker 2: Brings order to the chaos.
- 5:03Speaker 1: Okay, so you can view the data how you want
- 5:05Speaker 1: in the console, but what about saving it?
- 5:08Speaker 2: Exporting data out file is the straightforward way. Saves the
- 5:12Speaker 2: text output just as you see it to a file,
- 5:14Speaker 2: then get content reads.
- 5:16Speaker 1: It back end and the symbol.
- 5:17Speaker 2: That's just a shortcut for outfile, quick and easy. But
- 5:20Speaker 2: for like structured data you might want and excel h
- 5:23Speaker 2: that's where export csv comes in. Creates a proper comma
- 5:27Speaker 2: separated value file, much better for spreadsheets or databases.
- 5:31Speaker 1: And that not no type information parameter.
- 5:33Speaker 2: Oh yeah, good catch that just stops PowerShell from Putting
- 5:37Speaker 2: that extra halftag type information line at the top of
- 5:41Speaker 2: the CSV makes it cleaner for other programs to read.
- 5:44Speaker 1: Okay, good tip. We've covered a lot of PowerShell basics.
- 5:47Speaker 1: Now the material shifts gears, heading down into the Windows
- 5:50Speaker 1: kernel and its security role. This feels like the real
- 5:53Speaker 1: deep dive part.
- 5:54Speaker 2: This is where it gets really fascinating. Yeah. The kernel,
- 5:56Speaker 2: that's the absolute core of the OS, where a fundamental
- 5:59Speaker 2: security decisions.
- 6:00Speaker 1: Happen, and the connection point is system calls exactly.
- 6:04Speaker 2: System calls are the bridge the way user mode applications,
- 6:07Speaker 2: the stuff we normally run talk to the privileged kernel
- 6:10Speaker 2: mode where the OS does its heavy lifting and enforcement.
- 6:13Speaker 1: The link between our apps and the OS's security core. Okay,
- 6:16Speaker 1: the material is several key kernel subsystems. Can you give
- 6:19Speaker 1: us the quick security relevance run down?
- 6:21Speaker 2: Sure you've got The object manager manages all kernel objects,
- 6:25Speaker 2: the basic building blocks. The io manager handles data moving
- 6:29Speaker 2: in and out. Process and thread manager creates and manages
- 6:32Speaker 2: running code. Memory manager controls memory use. Configuration manager that's
- 6:37Speaker 2: the registry code integrity. Make sure only trusted code runs.
- 6:41Speaker 1: A lot of managers.
- 6:42Speaker 2: Yeah, and crucially for security, the Security reference monitor, the SRM.
- 6:49Speaker 1: SRM sounds important, the ultimate gatekeeper.
- 6:52Speaker 2: Maybe that's a good way to put it. The SRM
- 6:54Speaker 2: is the kernel component that actually enforces security policy. It
- 6:57Speaker 2: decides who gets access to what.
- 6:59Speaker 1: How does it do that?
- 7:00Speaker 2: It uses two key things mentioned right in your source,
- 7:03Speaker 2: access tokens and security descriptors. Every process has an access
- 7:06Speaker 2: token saying who it is. Every resource, like a file
- 7:09Speaker 2: or registry key, has a security descriptor saying who's allowed
- 7:12Speaker 2: to access.
- 7:13Speaker 1: So the SRN compares the token.
- 7:14Speaker 2: To the descriptor exactly when a process tries to access something,
- 7:19Speaker 2: the SRM looks at its token, looks at the resources
- 7:22Speaker 2: security descriptor, and makes the call allow or deny access.
- 7:26Speaker 1: Tokens and security descriptors yes, central players, yeah, okay. The
- 7:30Speaker 1: material then dives into security descriptors and sids. What's the
- 7:33Speaker 1: relationship there.
- 7:35Speaker 2: Sid's security identifiers are the unique names for users, groups, computers,
- 7:40Speaker 2: anything the system needs to identify for security.
- 7:43Speaker 1: Think of them like unique ideas, and they're inside security
- 7:46Speaker 1: descriptors right.
- 7:47Speaker 2: Security descriptors use sids to specify who is being allowed
- 7:51Speaker 2: or denied access. The source shows using get into SID
- 7:54Speaker 2: to translate the raw SID string like S one five, three, two, five.
- 7:58Speaker 1: Four five into built users.
- 8:00Speaker 2: Exactly, translating the system's internal ID into something we recognize.
- 8:04Speaker 1: So sids are the language of security identity. Next the
- 8:08Speaker 1: object manager and its name space. This sounds like how
- 8:10Speaker 1: the kernel keeps all its objects organized. It is.
- 8:12Speaker 2: Think of the object manager name space the OMNS as
- 8:15Speaker 2: like a hidden file system just for kernel.
- 8:17Speaker 1: Objects, a file system for kernel stuff.
- 8:19Speaker 2: Yeah, it's hierarchical like folders and files. Get ant type
- 8:22Speaker 2: shows you the kinds of objects in there. Directory, symbolic link, token,
- 8:27Speaker 2: process thread, lots more directory objects build the hierarchy and the.
- 8:32Speaker 1: Source mentions the anti object PowerShell drive.
- 8:35Speaker 2: Right that lets you browse this hidden name space using
- 8:38Speaker 2: familiar commands like LS or CD. It's a fantastic way
- 8:41Speaker 2: to explore.
- 8:42Speaker 1: Very cool. And one specific directory gets called out Base
- 8:46Speaker 1: named objects. Why is that one special?
- 8:48Speaker 2: Ah? Base Named objects or B and O. That's the
- 8:51Speaker 2: standard place where different processes potentially running as different users
- 8:55Speaker 2: can create named kernel objects that they can then share.
- 8:58Speaker 1: So for interprocess community sharing resources.
- 9:01Speaker 2: Exactly, if you want two different programs to easily find
- 9:04Speaker 2: and use the same kernel object like a mutex or
- 9:06Speaker 2: an event, putting it in B and O is the
- 9:08Speaker 2: common way to do it. It's the public square for
- 9:10Speaker 2: named kernel objects.
- 9:11Speaker 1: Okay, shared resources go there makes sense. Now back to
- 9:14Speaker 1: system calls. The deep dive mentiones NT and ZW prefixes.
- 9:18Speaker 1: Is there a big difference for us calling.
- 9:20Speaker 2: From user mode? Not really the sources they're mostly interchangeable
- 9:25Speaker 2: from our perspective, and crete mutant ZW crete mutant. They
- 9:29Speaker 2: generally do the same thing when called from an application.
- 9:32Speaker 1: Okay, so just note they signal a system call, right.
- 9:35Speaker 2: And they usually follow that verb noun pattern too, like
- 9:38Speaker 2: create followed by the object type mutant.
- 9:40Speaker 1: Got it. The source also mentions unicodestring structures for parameters,
- 9:44Speaker 1: especially names. What's important about those?
- 9:47Speaker 2: So many system calls take names using this Unicodes string structure.
- 9:51Speaker 2: It's not just a pointer to the characters. It also
- 9:53Speaker 2: includes the strings current length, invites, and the buffer's maximum.
- 9:57Speaker 1: Size self describing strings.
- 9:59Speaker 2: Yeah, and crucial, the length is just the characters used,
- 10:02Speaker 2: not including a null terminator. In fact, you can have
- 10:04Speaker 2: null characters inside object names at this level.
- 10:07Speaker 1: Really, that seems like it could cause problems.
- 10:10Speaker 2: It can mishandling these counted strings versus null terminated strings
- 10:14Speaker 2: has definitely been a source of security bugs over the years.
- 10:17Speaker 2: It uses UCS two encoding.
- 10:19Speaker 1: By the way, good detail. Okay, so a system call runs,
- 10:22Speaker 1: it needs to report back success, failure, what happened. That's
- 10:27Speaker 1: where anti status codes come in.
- 10:28Speaker 2: Exactly, and status codes are the standard return values. They
- 10:32Speaker 2: tell you the outcome, and.
- 10:33Speaker 1: They're more than just error or okay, oh yeah.
- 10:36Speaker 2: The source breaks down the structure. There's a severity level
- 10:39Speaker 2: success info, warning, error, a facility code telling you which
- 10:44Speaker 2: part of the system generated the status like default debugger
- 10:47Speaker 2: win thirty two, and the specific status code number.
- 10:50Speaker 1: So lots of context.
- 10:52Speaker 2: Tons and get end status in the PowerShell module lets
- 10:55Speaker 2: you look up these codes, get the symbolic name and
- 10:57Speaker 2: the message text. Super useful for debugs.
- 11:00Speaker 1: And PowerShell itself often turns these into exceptions.
- 11:03Speaker 2: We see right when a PowerShell command wraps a system
- 11:06Speaker 2: call and gets an error and sisteris it often surfaces
- 11:09Speaker 2: that as a dot net exception. The example of get
- 11:11Speaker 2: ent directory on a non existent.
- 11:13Speaker 1: Path gives that object name not found exception.
- 11:15Speaker 2: Yep, and you can take the error code from that exception,
- 11:17Speaker 2: feed it to get end status and get the underlying
- 11:20Speaker 2: into status info. It shows how PowerShell bridges that low
- 11:23Speaker 2: level kernel world with the managed dot net.
- 11:25Speaker 1: World neat connection. Okay, next topic, object handles. User applications
- 11:31Speaker 1: don't touch kernel objects directly. They use these handles as
- 11:35Speaker 1: like tickets.
- 11:36Speaker 2: Precisely, when you successfully create or open a kernel object
- 11:40Speaker 2: via a system call, the kernel gives your process back
- 11:44Speaker 2: a handle. Think of it as an index number into
- 11:46Speaker 2: your process's private handle table.
- 11:48Speaker 1: And what's in that handle table entry Three key things.
- 11:51Speaker 2: The handle number itself, the access rights that were granted
- 11:54Speaker 2: to your process for that object like read, write, synchronize,
- 11:58Speaker 2: and critically a pointer to the action object down in
- 12:01Speaker 2: kernel memory.
- 12:01Speaker 1: So when my app uses that handle later, say, to
- 12:06Speaker 1: read from a file.
- 12:06Speaker 2: Object, it passes the handle number in another system call.
- 12:10Speaker 2: The kernel uses that number to look up the entry
- 12:12Speaker 2: in your process as handle table. Then it does vital
- 12:15Speaker 2: checks like what First, it checks if the access you're
- 12:17Speaker 2: requesting now, say read access is allowed by the access
- 12:21Speaker 2: rights granted when the handle was created stored in the table. Second,
- 12:24Speaker 2: it checks if the handle actually points to the right
- 12:26Speaker 2: type of object trying to read from a mutex handle
- 12:29Speaker 2: that's going to fail.
- 12:30Speaker 1: Makes sense, access check and type check. Secure way to
- 12:33Speaker 1: manage things, which brings us to access masks those granted
- 12:39Speaker 1: rights right.
- 12:39Speaker 2: The permissions granted are stored as a thirty two bit
- 12:42Speaker 2: number called an access mask. It's a bitfield. Different bits
- 12:46Speaker 2: mean different permissions.
- 12:47Speaker 1: And it's specific to the object type largely.
- 12:50Speaker 2: Yes, the top sixteen bits are generally type specific. So
- 12:54Speaker 2: a file object's access mask will have bits for things
- 12:57Speaker 2: like read data, write data, a pen data, while a
- 13:00Speaker 2: thread object will have bits for terminate, suspend, resume, set information,
- 13:04Speaker 2: and so.
- 13:04Speaker 1: On, granular permissions tailored to the object. The source then
- 13:08Speaker 1: shows duplicating handles with copynt object. Why would you do that?
- 13:12Speaker 2: Copy anti object lets you duplicate an existing handle. You
- 13:16Speaker 2: can just make an identical copy or and this is useful.
- 13:18Speaker 2: You can request different access rights for the new handle.
- 13:20Speaker 1: Ah, so you could create a less privileged version of
- 13:23Speaker 1: a handle exactly.
- 13:24Speaker 2: Maybe you have a handle with full access, but you
- 13:26Speaker 2: want to pass a handle to another part of your
- 13:29Speaker 2: code or another process that only has a query access.
- 13:32Speaker 2: Duplicating the handle with a restricted desired access mask is
- 13:35Speaker 2: how you do that.
- 13:36Speaker 1: Smart and compare and object checks if two handles point
- 13:40Speaker 1: to the same actual kernel object.
- 13:42Speaker 2: Yep, even if they have different access rights. Compare end
- 13:45Speaker 2: to object tells you if they're ultimately referencing the same
- 13:48Speaker 2: thing done in the kernel.
- 13:50Speaker 1: Cool. What about that protect from close attribute sounds obvious?
- 13:54Speaker 2: It is what it sounds like. If you set that
- 13:56Speaker 2: astribute on a handle, the system won't let it be closed.
- 14:00Speaker 2: Palls to close handle will fail with status handle not closeable.
- 14:04Speaker 1: Why to keep a critical handle alive?
- 14:06Speaker 2: Could be maybe you need to guarantee a resource stays
- 14:10Speaker 2: accessible and don't want some stray code closing the handle prematurely.
- 14:13Speaker 1: Okay. The deep dive then talks about enquery information object
- 14:17Speaker 1: and end set information object, sort of generic get and
- 14:21Speaker 1: set for object data.
- 14:23Speaker 2: That's the idea. Instead of having dozens of specific system
- 14:25Speaker 2: calls for every little piece of info about every object type,
- 14:28Speaker 2: the kernel provides these general purpose calls.
- 14:30Speaker 1: How do they work?
- 14:31Speaker 2: You give them the handle, an information class number that
- 14:34Speaker 2: specifies what data you want, and a buffer to put
- 14:37Speaker 2: the data in for query or get from for set.
- 14:39Speaker 1: And how do you know the right information class number? Ah?
- 14:42Speaker 2: Well, get nt object information class can list the known
- 14:46Speaker 2: ones for an object type, but as the source notes,
- 14:49Speaker 2: not all classes are officially documented. Sometimes it involves a
- 14:52Speaker 2: bit of digging or experimentation, like.
- 14:54Speaker 1: Figuring out database fields. The example with querying process info
- 14:58Speaker 1: and getting buffer too small that highlights needing the right
- 15:01Speaker 1: buffer size exactly.
- 15:03Speaker 2: You often have to figure out how much space the
- 15:05Speaker 2: information needs. Sometimes you call it once to get their
- 15:08Speaker 2: required size, allocate a buffer, then call it again, or
- 15:12Speaker 2: just guess with the like parameter until it works.
- 15:14Speaker 1: Got it okay? Quickly. Touching on device objects and symbolic
- 15:18Speaker 1: links in the OMNS. How do they fit in?
- 15:20Speaker 2: Device objects represent hardware or virtual devices. You can see
- 15:23Speaker 2: them under nty object. Device Symbolic links like system root
- 15:27Speaker 2: are just pointers or aliases to other paths in the OMNS.
- 15:31Speaker 1: So when I open see windowsnoepad dot.
- 15:33Speaker 2: Ex, the system uses symbolic links C likely points to
- 15:36Speaker 2: a device hard disc volume X path. Windows might involve
- 15:39Speaker 2: system route to resolve the path down to the actual
- 15:41Speaker 2: file object, passing through the device object representing the disk volume,
- 15:45Speaker 2: all involving the object manager.
- 15:47Speaker 1: Path resolution involves the OMMS. Okay, next, process and thread
- 15:54Speaker 1: manager key security points.
- 15:56Speaker 2: Processes and threads are the things that run code, and
- 15:59Speaker 2: they are securable objects themselves. They have security descriptors, so you.
- 16:02Speaker 1: Need permission to say terminate another process.
- 16:05Speaker 2: Absolutely and importantly you generally can't open a process or
- 16:09Speaker 2: thread just by knowing its name. You need its unique
- 16:12Speaker 2: process ID PID or thread id TID helps prevent arbitrary
- 16:17Speaker 2: interference just based on names.
- 16:19Speaker 1: Right, need the specific ID. Okay. Memory management in sections
- 16:23Speaker 1: sounds like fertile ground for security issues.
- 16:25Speaker 2: Definitely. Sections are blocks of memory that can be shared
- 16:27Speaker 2: between processes. New antisection creates one add in section, maps
- 16:31Speaker 2: it into a process's address space.
- 16:33Speaker 1: And you control permissions on that memory.
- 16:35Speaker 2: Yes crucial. You specify protection like read only read write,
- 16:38Speaker 2: execute read write. The kernel enforces these. Trying to map
- 16:42Speaker 2: a section with incompatible permissions fails, as the example.
- 16:45Speaker 1: Showed and shared ritable sections. The source mentions CVE twenty
- 16:48Speaker 1: nineteen Uro nine, four to three. That sounds bad.
- 16:52Speaker 2: It was a privileged process shared a section. A lower
- 16:55Speaker 2: privileged process could map it as writable modified data the
- 16:58Speaker 2: privileged process trusted and potentially get code execution. Big problem.
- 17:03Speaker 1: Yikes. How would you even find such shared sections?
- 17:07Speaker 2: The source shows using get and handle to look at
- 17:09Speaker 2: all handles and processes, filtering for section objects, and using
- 17:13Speaker 2: test n access mask to see if any have right
- 17:16Speaker 2: access section map right or potentially dangerous combinations like section
- 17:21Speaker 2: exten size. You'd compare handles between a high privilege and
- 17:25Speaker 2: low privileged process, so.
- 17:26Speaker 1: You can hunt for potentially risky sharing configurations and even
- 17:30Speaker 1: fuzz them.
- 17:30Speaker 2: Yeah, if you find a writable shared section, you could
- 17:33Speaker 2: use right anti virtual memory to poke at it, write
- 17:36Speaker 2: unexpected data. See if you can crash or exploit the
- 17:39Speaker 2: other process sharing it. Show in t section even gives
- 17:41Speaker 2: you a x editor GUI for it.
- 17:43Speaker 1: Wow. The big takeaway seems to be writable and executable
- 17:46Speaker 1: memory is inherently dangerous.
- 17:48Speaker 2: Extremely that combo is classic malware territory for code injection.
- 17:52Speaker 2: He's very careful justification if you used at all?
- 17:54Speaker 1: Okay, shifting up a level. Now user mode applications and
- 17:58Speaker 1: Win thirty two APIs. This is where most developers live. Right,
- 18:02Speaker 1: how does this relate to the kernel stuff?
- 18:03Speaker 2: Right? Most apps don't call nt create file directly. They
- 18:06Speaker 2: call the Win thirty two API function create file. These
- 18:10Speaker 2: Win thirty two APIs are the documented stable interface for applications,
- 18:14Speaker 2: the layer of abstraction exactly. They provide functions for everything files,
- 18:17Speaker 2: Windows network registry under the hood. Many of these WIN
- 18:21Speaker 2: thirty two functions eventually translate into one or more and
- 18:24Speaker 2: or ZW system calls to the kernel to do the
- 18:26Speaker 2: actual work. Understanding that translation is key, So.
- 18:29Speaker 1: Win thirty two is the friendly face. System calls are
- 18:31Speaker 1: the engine room. Okay. DLL imports and API sets what
- 18:35Speaker 1: are these?
- 18:36Speaker 2: Ds? Dynamic link libraries are shared code libraries. Apps import
- 18:40Speaker 2: functions from them. Get Win thirty two module import. Let's
- 18:43Speaker 2: you see which functions and app uses from which DLLs.
- 18:46Speaker 1: Useful for understanding dependencies and API.
- 18:48Speaker 2: Sets Introduced in Windows seven. They're like virtual DLLs, and
- 18:51Speaker 2: app might link against apm's wind core process threads LANs
- 18:55Speaker 2: onesaushal on zero dot dll instead of directly against kernel
- 18:57Speaker 2: thirty two dot dll or at VAP thirty two dot dll.
- 19:01Speaker 2: It decouples the app from the exact DLLLL Providing the
- 19:04Speaker 2: function makes it easier for Microsoft to refactor things behind
- 19:07Speaker 2: the scenes without breaking apps. Get n TAPA set. Let's
- 19:10Speaker 2: you see which real DLL actually backs a specific API
- 19:14Speaker 2: set on your system as flexibility.
- 19:16Speaker 1: Okay, next, searching for DLLs and DL hijacking. This is
- 19:20Speaker 1: a classic attack, right Oh yeah?
- 19:22Speaker 2: Very common. When an app asks to load a DLL
- 19:24Speaker 2: just by name like graphics dot DLL without a full path,
- 19:28Speaker 2: Windows has to.
- 19:29Speaker 1: Search for it where does it look.
- 19:31Speaker 2: The search order has changed over time for security reasons.
- 19:33Speaker 2: Older Windows versions often check the app's current directory first,
- 19:37Speaker 2: which was dangerous.
- 19:38Speaker 1: Because an attacker could drop a malicious graphics dot DLL.
- 19:41Speaker 2: There precisely if a privileged app loaded it from an
- 19:44Speaker 2: unsecured directory boom dll hijack code execution. Vista and later
- 19:49Speaker 2: have a safer default order prioritizing system directories, but vulnerabilities
- 19:54Speaker 2: can still exist if apps aren't careful about where they
- 19:57Speaker 2: load DLLs from, or if their current directory is attacker can.
- 20:00Speaker 1: Always specify the full path if you can't. Basically, Windows
- 20:03Speaker 1: stations and desktops UI stuff, but security implications.
- 20:06Speaker 2: Yes, Window stations are secure containers for UI elements, primarily desktops.
- 20:11Speaker 2: WINDSTA is the main interactive one we use why separate
- 20:15Speaker 2: stations Isolation services might run in a different Window station
- 20:19Speaker 2: from the interactive user. It prevents processes in one station
- 20:22Speaker 2: from easily interfering with the UI of another. Desktops live
- 20:27Speaker 2: inside window stations, providing another layer. Get INNT window station
- 20:31Speaker 2: name and get in desktop name.
- 20:33Speaker 1: Let you list them boundaries even for the UI. Uh
- 20:36Speaker 1: huh okay. Windows messages. How Windows talk to.
- 20:39Speaker 2: Each other fundamentally, yeah, A message is just a number
- 20:41Speaker 2: identifying the message type, plus a couple of parameters. Apps
- 20:45Speaker 2: can send messages, wait for processing, or post them, put
- 20:48Speaker 2: in a queue and continue.
- 20:49Speaker 1: And windows belong to threads.
- 20:51Speaker 2: Right. Each window has thread affinity. Only the thread that
- 20:54Speaker 2: created it should really process its messages. That thread runs
- 20:58Speaker 2: a message loop using APIs like get message and dispatch message.
- 21:01Speaker 1: The source has a conceptual example of sending a message
- 21:04Speaker 1: to notepad. Yeah.
- 21:05Speaker 2: It shows finding the notepad window, get an itt window,
- 21:08Speaker 2: maybe finding its edit child control, and conceptually how you'd
- 21:12Speaker 2: send it a message, perhaps to pace text or close it.
- 21:14Speaker 2: It shows the potential for programmatic UI interaction, which could
- 21:18Speaker 2: be used for.
- 21:18Speaker 1: Good or bad. Okay. Console sessions, we have the physical console,
- 21:22Speaker 1: but also remote desktop, fast user switching exactly.
- 21:25Speaker 2: Each of those creates a separate session get and T
- 21:28Speaker 2: process info only group objects. Session edge shows you which
- 21:32Speaker 2: session each processes in.
- 21:33Speaker 1: Why separate sessions isolation?
- 21:35Speaker 2: Again? Each session gets its own memory areas for certain things,
- 21:39Speaker 2: its own instance of base named objects, its own window stations.
- 21:42Speaker 2: Session zero is special reserve for system services usually no
- 21:45Speaker 2: GUI there.
- 21:46Speaker 1: Session zero for services that leads into shatter attacks and UIPI.
- 21:50Speaker 1: What were shatter attacked?
- 21:51Speaker 2: Back before Vista user apps and many services ran together
- 21:54Speaker 2: in session zero, a low privileged app could send malicious
- 21:57Speaker 2: window messages to a high privileged service window in the
- 22:00Speaker 2: same session, tricking it into doing things or even running code.
- 22:04Speaker 2: That was a shatter attack.
- 22:05Speaker 1: Asked how is it fixed?
- 22:06Speaker 2: Two main things Invista session zero isolation moved interactive users
- 22:11Speaker 2: out of session zero and user interface privilege isolation UIPI
- 22:15Speaker 2: was introduced.
- 22:16Speaker 1: What does UIPI do.
- 22:17Speaker 2: It prevents lower privileged low integrity level processes from sending
- 22:21Speaker 2: most window messages to higher privileged process windows, even if
- 22:24Speaker 2: they're on the same desktop in the same session. It
- 22:27Speaker 2: blocks that message based attack vector.
- 22:29Speaker 1: A crucial privilege boundary for the UI and the source
- 22:32Speaker 1: mentioned procession based named objects in Windows directories again right.
- 22:35Speaker 2: Under sessions ID base Named objects and sessions ID Windows.
- 22:38Speaker 2: This keeps named objects and window stations isolated between different
- 22:42Speaker 2: user sessions. NT object session drive lets you see the
- 22:45Speaker 2: BNO for your current.
- 22:46Speaker 1: Session isolation everywhere, okay. Comparing Win thirty two APIs versus
- 22:50Speaker 1: system calls again using create mutexx Win thirty two and
- 22:54Speaker 1: anti create mutant ciscle key differences.
- 22:56Speaker 2: Look at the return values. Create mutech x returns the
- 22:59Speaker 2: handled directly on success or NLL on failure. Anti create
- 23:03Speaker 2: mutant returns an anti status code indicating success or failure,
- 23:07Speaker 2: and the handle comes back through an output parameter a pointer.
- 23:10Speaker 1: So Win thirty two often hides the anti status and
- 23:12Speaker 1: pointer stuff.
- 23:13Speaker 2: Yeah. It translates the anti status error into an NUL
- 23:16Speaker 2: return or sets an error code retrievable via get laster.
- 23:20Speaker 2: It's a more abstract, arguably simpler interface for the application developer.
- 23:24Speaker 1: Got it registry interaction. The module has WIN thirty two.
- 23:27Speaker 2: Path Yes, so you can use familiar paths like HKLM
- 23:30Speaker 2: Software Microsoft with commands like get an it key instead
- 23:33Speaker 2: of the native OMNS path Registry Machine.
- 23:36Speaker 1: Software handy, and you can convert between them yep.
- 23:39Speaker 2: The key objects return have properties like Win thirty two
- 23:41Speaker 2: path and full path the OMNS path for easy conversion.
- 23:45Speaker 1: PowerShell has built in registry drives HKLM HKCU. Why use
- 23:51Speaker 1: the module's provider.
- 23:52Speaker 2: Ah The NUL character issue malware sometimes hides keys or
- 23:56Speaker 2: values by putting an NUL character inside the name the bill,
- 24:00Speaker 2: and PowerShell provider can't handle those because it relies on
- 24:03Speaker 2: annual terminated strings, but.
- 24:04Speaker 1: The anti object module can yes.
- 24:06Speaker 2: Because it uses the native APIs which work with counted strings,
- 24:09Speaker 2: so it can see and interact with those hidden by
- 24:11Speaker 2: annual entries, crucial for finding certain types of malware persistence.
- 24:15Speaker 1: Meki okay path limits max path still a thing.
- 24:18Speaker 2: Still a thing in many Win thirty two APIs that
- 24:22Speaker 2: two hundred and sixty character limit two hundred and fifty
- 24:25Speaker 2: nine usable for paths. Get anti file path demonstrates it.
- 24:28Speaker 2: Try to convert a longer path and you'll get status
- 24:31Speaker 2: name a too long.
- 24:32Speaker 1: A classic Windows limitation process. Creation Yeah, anti create user
- 24:36Speaker 1: process versus create process. We use create process usually.
- 24:39Speaker 2: Always use create process or wrappers like start process or
- 24:42Speaker 2: a new Win thirty two process. Anti create user process
- 24:45Speaker 2: is the raw kernel call, but create process does a
- 24:48Speaker 2: ton of essential setup work and user mode talking to CSRSS,
- 24:51Speaker 2: setting up environment variables, et cetera.
- 24:53Speaker 1: Skipping create process would lead to a broken process pretty much.
- 24:56Speaker 2: It wouldn't be properly initialized for the user environment. New
- 24:59Speaker 2: and thirty fo process is a wrapped around Create.
- 25:01Speaker 1: Process and the source mentions command line parsing issues with
- 25:04Speaker 1: new wind thirty two process.
- 25:05Speaker 2: Right it tries to be helpful splitting on spaces adding
- 25:08Speaker 2: lot exx. But if you just give it, say C
- 25:11Speaker 2: program files my app and there's also a C program
- 25:13Speaker 2: dot exx which one.
- 25:14Speaker 1: Runs, ambiguity and potential hijacking.
- 25:17Speaker 2: Exactly if a privileged process runs something based on a
- 25:20Speaker 2: path that could be manipulated, like relying on the path, environment,
- 25:23Speaker 2: variable or relative paths, it could be tricked into running
- 25:26Speaker 2: the wrong executable or loading malicious DLLs. Best practice use
- 25:31Speaker 2: applicate application name with the full explicit path to the
- 25:35Speaker 2: executable you intend to run.
- 25:36Speaker 1: Be specific, avoid ambiguity. Okay, Shell APIs and file associations.
- 25:42Speaker 1: How does double clicking my doc dot txt work?
- 25:44Speaker 2: Explorer doesn't try to run my doc dot txt. It
- 25:47Speaker 2: looks up the file association for dot txt in the registry,
- 25:50Speaker 2: finds that notepad or whatever is the handler. Then it
- 25:53Speaker 2: uses shell APIs probably shall execute, telling it to open
- 25:56Speaker 2: my dooc dot txt using notepad.
- 25:58Speaker 1: So new wind thirty two pm dot txt.
- 26:01Speaker 2: Would fail yep, because not txt isn't an executable. You
- 26:04Speaker 2: need that shell layer to handle document types. The source
- 26:07Speaker 2: shows querying the registry to find the handler and mentions
- 26:10Speaker 2: shell execute verbs like open print et cetera.
- 26:13Speaker 1: Smart indirection Okay, quick recap, LSAs and SCM.
- 26:16Speaker 2: Still vital, absolutely fundamental. LSS Local Security Authorities subsystem handles authentication,
- 26:23Speaker 2: log on sessions, security policy, SCM Service Control Manager manages
- 26:28Speaker 2: background services, core security infrastructure.
- 26:31Speaker 1: Got it now? Finding those hidden registry keys with NUL
- 26:34Speaker 1: characters again, how.
- 26:35Speaker 2: Exactly the source shows creating one with new end key
- 26:38Speaker 2: embedding a zero back take zero in the name string.
- 26:41Speaker 2: Then you use else recurs in the NT object registry
- 26:44Speaker 2: derive and pipe it to where object name matches zero
- 26:47Speaker 2: to find keys containing that NUL.
- 26:50Speaker 1: And for hidden values.
- 26:51Speaker 2: Similar idea, Create a value with an NUL in its name,
- 26:54Speaker 2: then use a custom function like the select hidden value shown,
- 26:56Speaker 2: which likely iterates through value names character by character looking
- 27:00Speaker 2: for the nul. It bypasses the standard tools limitation.
- 27:03Speaker 1: Very clever, okay, Final section intro. Tokens. We mentioned them,
- 27:07Speaker 1: but let's define them clearly right.
- 27:08Speaker 2: Tokens are the objects that represent the security context of
- 27:12Speaker 2: a process or thread. Who is it? What can it do?
- 27:15Speaker 2: Two main types primary tokens Every process has one, defines
- 27:18Speaker 2: its main identity, usually the user who launched it. And
- 27:22Speaker 2: impersonation tokens allow a thread to temporarily act with a
- 27:25Speaker 2: different identity, maybe a client's identity for a specific task.
- 27:29Speaker 1: Primary is the baseline. Impersonation is temporary borrowing. Sets us
- 27:33Speaker 1: up nicely for the next part.
- 27:34Speaker 2: YEP, Now we dive into what's in those tokens and
- 27:37Speaker 2: how they're used.
- 27:38Speaker 1: All right, let's unpack primary tokens in more detail. These
- 27:41Speaker 1: are the main ID badges for processes.
- 27:43Speaker 2: Right, that's exactly it. Every running process gets one. It
- 27:47Speaker 2: holds the security identity, primarily the SID of the user
- 27:50Speaker 2: account that started.
- 27:51Speaker 1: It, and this is what the SRM looks at for
- 27:53Speaker 1: access checks.
- 27:54Speaker 2: Correct. When that process tries to touch a file or
- 27:57Speaker 2: registry key, whatever, the SRM grabs this primary token and
- 28:01Speaker 2: compares it against the resources security descriptor.
- 28:04Speaker 1: And the source mention. Figure four two showing the token details.
- 28:06Speaker 2: What are the critical parts, Yeah, that figures helpful. Key
- 28:09Speaker 2: things are the user SID obviously, the token type primary
- 28:14Speaker 2: versus impersonation, maybe an impersonation level if it's that type.
- 28:18Speaker 2: And then those four sixty four bit IDs.
- 28:20Speaker 1: Right, token ID, authentication.
- 28:21Speaker 2: ID, authentication ID, origin login ID, and modified ID. The
- 28:25Speaker 2: token ID is just a unique identifier for this specific
- 28:28Speaker 2: token instance.
- 28:30Speaker 1: But the authentication ID seems important, linking back to a
- 28:33Speaker 1: log on session very important.
- 28:34Speaker 2: When you log on, Elsas creates a log on session
- 28:37Speaker 2: and the SRM assigns it a unique authentication ID. Every
- 28:41Speaker 2: token created during that session gets the same authentication ID,
- 28:45Speaker 2: So if I.
- 28:45Speaker 1: Log off and log back on, I get a new authentication.
- 28:48Speaker 2: IDY, even if you're the same user. It distinguishes different
- 28:51Speaker 2: login instances. Helps with auditing and resource management.
- 28:54Speaker 1: Makes sense, and we can see this with get in
- 28:56Speaker 1: token right.
- 28:57Speaker 2: Get in token grabs the token object. You can then
- 28:59Speaker 2: look properties like token dot user or use format in
- 29:03Speaker 2: token for a nicely formatted summary.
- 29:05Speaker 1: What does format and token show?
- 29:06Speaker 2: User groups with their sids and attributes, privileges and key
- 29:10Speaker 2: stuff all shows even more and show in token gives
- 29:13Speaker 2: you that GUI view similar to the figure commandline.
- 29:15Speaker 1: And GUI good options. Okay, impersonation tokens? Why does services
- 29:19Speaker 1: use these? So?
- 29:20Speaker 2: A service often running as a powerful account like system
- 29:23Speaker 2: might need to access a resource on behalf of a
- 29:26Speaker 2: specific user who connected to it, like reading that user's files.
- 29:30Speaker 1: But the system account might not have permission for that
- 29:32Speaker 1: user's files.
- 29:33Speaker 2: Directly exactly, so the service thread temporarily impersonates the user
- 29:38Speaker 2: who made the request. It borrows their identity using an
- 29:41Speaker 2: impersonation token. Now when it accesses the file, the SRM
- 29:46Speaker 2: check uses the user's identity from the impersonation token, not
- 29:50Speaker 2: the service's identity, a way.
- 29:52Speaker 1: To act as the user for a specific task. The
- 29:55Speaker 1: source showed trying different impersonation levels with invoke in token
- 29:59Speaker 1: and getting an.
- 29:59Speaker 2: Error right this status bat impersonation level error. It tried
- 30:03Speaker 2: impersonating at the identification level, which is very weak lets
- 30:06Speaker 2: the server see who the client is, but not act
- 30:08Speaker 2: as them, especially not remotely.
- 30:10Speaker 1: So trying to open an object failed.
- 30:12Speaker 2: Yes, because that operation required a higher level, probably impersonation level,
- 30:17Speaker 2: which does allow acting locally as the client. It wasn't
- 30:19Speaker 2: an access denied on the object itself, but a failure
- 30:23Speaker 2: because the type of impersonation wasn't sufficient for the action.
- 30:27Speaker 1: Subtle but important difference and duplicating a token handle isn't
- 30:31Speaker 1: the same as duplicating the token object correct.
- 30:34Speaker 2: Duplicating the handle just gives you another reference pointer to
- 30:36Speaker 2: the same token To create a new independent token object
- 30:39Speaker 2: based on another, like making an impersonation token from a
- 30:42Speaker 2: primary one, you need the duplicate access right on the
- 30:45Speaker 2: original token.
- 30:46Speaker 1: Handle and you use anti duplicate token.
- 30:48Speaker 2: Which is wrapped by copy and token and PowerShell. That
- 30:51Speaker 2: creates a whole new token object you can then modify
- 30:54Speaker 2: or use for impersonation. The source shows creating a delegation
- 30:58Speaker 2: level token. This way, that's the highest level, allowing remote
- 31:01Speaker 2: impersonation to delegation.
- 31:03Speaker 1: Sounds powerful and potentially risky. Well, okay. The use for
- 31:07Speaker 1: deny only attribute on sids in a token. How does
- 31:11Speaker 1: that work?
- 31:11Speaker 2: It changes how the SRM evaluates acees. If a SID
- 31:15Speaker 2: in your token has used for denyingly set that SID
- 31:18Speaker 2: only counts when checking deny acees in a security descriptor.
- 31:22Speaker 2: It's completely ignored for allow aces.
- 31:24Speaker 1: So it can only be used to deny access, not
- 31:26Speaker 1: grant it.
- 31:27Speaker 2: Pretty much, the example was good. You're in the employee
- 31:29Speaker 2: group allow access and remote access group deny access marked
- 31:33Speaker 2: use for nine only. The deny still wins because of
- 31:36Speaker 2: that attribute. It lets you build rules where specific memberships
- 31:39Speaker 2: explicitly block access even if other memberships would normally allow it.
- 31:43Speaker 1: Explicit denials take precedence. Got it now. Token privileges These
- 31:49Speaker 1: aren't access rights on objects, but system wide powers exactly.
- 31:53Speaker 2: Privileges grant the ability to perform specific system operations regardless
- 31:56Speaker 2: of object permissions. Get and token privilege lists them for
- 31:59Speaker 2: a token. Examples see shut down privilege, reboot the machine.
- 32:02Speaker 2: See change notified privilege bypassed drivers. Checking lets you access
- 32:06Speaker 2: see users other user desktop even if you can't list
- 32:08Speaker 2: other users. See load driver privileged load kernel drivers very
- 32:11Speaker 2: powerful type to code signing. See take ownership privilege, become
- 32:15Speaker 2: owner of file subjects, serie label privilege, change integrity labels.
- 32:19Speaker 1: Big powers, need careful assignment, okay, sandbox tokens restricted right, restricted,
- 32:24Speaker 1: low box. What's the goal here?
- 32:26Speaker 2: Containment? Limit the damage If a process gets compromised, especially
- 32:30Speaker 2: one handling untrusted input like a web browser or PDF reader,
- 32:34Speaker 2: Run it with a weaker token, so even if hacked,
- 32:37Speaker 2: it can't do much harm.
- 32:39Speaker 1: Makes sense? How to restrict a tokens work? They're the
- 32:41Speaker 1: oldest type.
- 32:42Speaker 2: Yeah, you create a new token based on an existing one,
- 32:45Speaker 2: but you add limitations. You specify restricting sids. These only
- 32:49Speaker 2: count for allow acees, limiting what it can access. You
- 32:53Speaker 2: can mark existing groups as use for deny only, and
- 32:57Speaker 2: you can explicitly disable privilege, so.
- 33:00Speaker 1: You surgically weaken the original token. Right.
- 33:02Speaker 2: The example shows making one adding nt authority restricted, making
- 33:07Speaker 2: everyone deny only disabling privileges. Browsers like Chrome Firefox use
- 33:11Speaker 2: this concept heavily.
- 33:12Speaker 1: Okay, what about right restricted tokens?
- 33:15Speaker 2: Simpler, much simpler concept. A process with this token is
- 33:18Speaker 2: blocked from writing to most things, but can usually still
- 33:20Speaker 2: read and execute introduced in XPSP two for hardening services.
- 33:25Speaker 1: Easier but maybe less secure.
- 33:27Speaker 2: Potentially the source nodes a compromise. Process could still read
- 33:30Speaker 2: sensitive files even if it can't write them.
- 33:32Speaker 1: It's a trade off read okay, right blocked, got it
- 33:36Speaker 1: and low box tokens.
- 33:38Speaker 2: The source doesn't detail them much here, but they're a
- 33:40Speaker 2: newer type often used with app containers. For UWP apps
- 33:44Speaker 2: even more restrictive focus on deep isolation following least privilege principles.
- 33:48Speaker 1: So different levels of sandboxing available via tokens. Shifting topics,
- 33:53Speaker 1: administrator privileges if not just one root SID in Windows.
- 33:57Speaker 2: Definitely not being an administray is more nuanced. It's a
- 34:01Speaker 2: combination of things, usually membership in the builty in administrators
- 34:05Speaker 2: group sid s one five thirty two five four four
- 34:08Speaker 2: that group having powerful permissions granted on resources, and the
- 34:12Speaker 2: token possessing certain key privileges. Which privileges are typically admin
- 34:16Speaker 2: level things like c create token privilege, make new tokens,
- 34:19Speaker 2: CTB privilege act as part of the OS extremely powerful
- 34:22Speaker 2: cetic ownership privilege, ce load driver privilege see a HEP privilege,
- 34:27Speaker 2: SARAH store privilege see the bug privilege, access any processes
- 34:30Speaker 2: memory see impersonate privilege. Having these indicates administrative capability and.
- 34:34Speaker 1: The source mentioned elevated sids based.
- 34:37Speaker 2: On the RA yeah kind of kernel shortcut for certain checks.
- 34:41Speaker 2: Instead of looking for specific well known sids, the kernel
- 34:45Speaker 2: just checks the last number the RID. If it's say
- 34:48Speaker 2: five hundred and forty four administrators RID or five forty
- 34:51Speaker 2: five users RID, it treats it as having that role
- 34:54Speaker 2: in certain contexts.
- 34:55Speaker 1: Interesting pattern matching, okay. User count control UAC and elevation
- 34:59Speaker 1: the pop up boxes.
- 34:59Speaker 2: We are right. UAC aims to have even administrators run
- 35:03Speaker 2: with standard user rights by default. When you need to
- 35:06Speaker 2: do something requiring admin rights, UAC prompts for consent. If
- 35:10Speaker 2: you give it, the task runs elevated with your full
- 35:12Speaker 2: administrator token.
- 35:13Speaker 1: And apps can request elevation automatically.
- 35:16Speaker 2: True their manifest file Yeah, an XML file embedded in
- 35:18Speaker 2: the dot ex get executable manifest shows it. It specifies
- 35:22Speaker 2: an execution level as invoker, run as caller, highest available,
- 35:26Speaker 2: run elevated if possible or required.
- 35:29Speaker 3: Administrator must elevate and how do you manually elevate something?
- 35:32Speaker 2: Start processed after verb runas in PowerShell or using the
- 35:36Speaker 2: shell execute API with the runa's verb both trigger the
- 35:39Speaker 2: UAC prompt if needed.
- 35:40Speaker 1: Okay, link tokens and elevation type. What's that?
- 35:43Speaker 2: When an admin logs in UAC actually creates two tokens,
- 35:47Speaker 2: a standard limited one and the full admin one, they're linked.
- 35:50Speaker 2: Elevation is the process of switching from the limited token
- 35:53Speaker 2: to the full one for a specific task.
- 35:56Speaker 1: After UAC consent, split tokens one limited one full makes sense?
- 36:00Speaker 1: Security attributes more data in tokens.
- 36:03Speaker 2: Yeah, Extra bits of info beyond sids and privileges can
- 36:06Speaker 2: be strings, numbers, sids, binary data. They add more context
- 36:10Speaker 2: for potentially finer grained access decisions, especially with conditional acees
- 36:15Speaker 2: can have flags like non inheritable, case sensitive new end
- 36:18Speaker 2: token can add them, but needs see create token privilege.
- 36:21Speaker 1: More context for decisions. Okay. Token assignment and impersonation criteria.
- 36:25Speaker 1: What rules apply when assigning or impersonating tokens.
- 36:28Speaker 2: Assigning a primary token if not inherited, needs assigned primary
- 36:32Speaker 2: access on the token. Kernel checks integrity levels, log on
- 36:35Speaker 2: session relationships. Impersonation is more complex see token can impersonate
- 36:38Speaker 2: function check's integrity levels, can't impersonate higher privileges See impersonate
- 36:42Speaker 2: Privilege often needed UPI flags, log on sessions, user sids.
- 36:47Speaker 1: And the system account gets special treatment big.
- 36:49Speaker 2: Time because user log on sessions ultimately derive from the
- 36:53Speaker 2: initial system session. System can basically impersonate any user token
- 36:58Speaker 2: of equal or lower integrity, even without seeing person at privilege.
- 37:01Speaker 2: It's implicitly trusted in that way.
- 37:03Speaker 1: Wow. System is powerful and Windows ten added a check
- 37:07Speaker 1: for the elevated flag.
- 37:09Speaker 2: Right before wind ten. You could potentially impersonate and admin's
- 37:12Speaker 2: elevated token if you first lowered its integrity level. Win
- 37:15Speaker 2: ten added a check you can't impersonate the elevated token
- 37:18Speaker 2: of the same user if your current token isn't also elevated,
- 37:22Speaker 2: closed a potential loophole.
- 37:23Speaker 1: Good hardening step and test antoken impersonation checks if impersonation.
- 37:28Speaker 2: Is allowed YEP, and set antoken integrity level lets you
- 37:30Speaker 2: change integrity levels. Useful for testing these rules.
- 37:33Speaker 1: Okay? Finding UI access processes? What are they and why
- 37:36Speaker 1: look for them?
- 37:37Speaker 2: Processes with the UI Access's flag set in their token
- 37:40Speaker 2: can bypass some UIPI restrictions. They can send messages to
- 37:43Speaker 2: higher privileged windows, needed for things like screen readers, accessibility.
- 37:47Speaker 1: Tools, but potentially risky if nowhere gets.
- 37:49Speaker 2: It exactly, so finding them is useful. The source shows
- 37:52Speaker 2: get and process with excess query limited information and a
- 37:56Speaker 2: filterscript checkingtoken dot UI access to list them identifies processes
- 38:00Speaker 2: with that special UI interaction capability.
- 38:03Speaker 1: Good to note okay. Final major topic security descriptors the
- 38:06Speaker 1: actual rules. What are the components?
- 38:08Speaker 2: Four main parts Owner SID, who controls the permissions Group
- 38:12Speaker 2: SID mostly for POSTX compatibility less used in Windows, access checks,
- 38:16Speaker 2: DACL Discretionary Access Control List, and SACL System Access Control List.
- 38:22Speaker 1: DCL is where the allowed NY rules live exactly.
- 38:24Speaker 2: It's a list of AC's access control entries. Each AC
- 38:27Speaker 2: says six gets allowed to I access Y. The acess
- 38:30Speaker 2: mask Y details the specific permissions and the SECL primarily
- 38:35Speaker 2: for auditing ACS. There say a log an event if
- 38:37Speaker 2: SidD X tries axs Y and succeeds fails. Since Vista,
- 38:40Speaker 2: it also holds mandatory integrity lobles, non auditing, ACEES.
- 38:43Speaker 3: Owner group, DACL, SACL, got it well known sad's predefined
- 38:48Speaker 3: identifiers YEP, consistent across systems, NL, SID, everyone, WD, local
- 38:55Speaker 3: creator owner, built in.
- 38:57Speaker 2: Users BU system sy administrators B authenticated users AU medium
- 39:02Speaker 2: mandatory level lots of them. They have a structure revision
- 39:05Speaker 2: authority like NT authority five. Then relative identifiers built in
- 39:10Speaker 2: users is S one five thirty two five forty five
- 39:13Speaker 2: authority five RIDE thirty two for builton domain ride five
- 39:16Speaker 2: forty five for users group.
- 39:18Speaker 1: Hierarchical structure access control lists ACLS. The DACL and SACL
- 39:22Speaker 1: are types of these.
- 39:23Speaker 2: Structure simple header revision size followed by the list of ACS.
- 39:27Speaker 2: Revision tells you the ACL version two, three four commonly, and.
- 39:29Speaker 1: The access control entries acees themselves.
- 39:32Speaker 2: ACE header type, flag size, and type specific data. For
- 39:35Speaker 2: standard loagenie acees, the data is the SID and the
- 39:38Speaker 2: access mask. Many types allow deny audit callback object ACS
- 39:41Speaker 2: for property specific permissions.
- 39:43Speaker 1: And AC flags modified behavior.
- 39:45Speaker 2: Right inherently inherited from parent. Critical successful access, failed access
- 39:49Speaker 2: for auditing, fine grained control okay.
- 39:51Speaker 1: Constructing and viewing security descriptors with PowerShell.
- 39:54Speaker 2: New n Security Descriptor lets you build one setting owner group,
- 39:57Speaker 2: adding ACS format and security discret Victor is key for
- 40:00Speaker 2: viewing shows owner group, DAC l ACS sec LACS clearly
- 40:06Speaker 2: use show all and map generic for more detail and
- 40:08Speaker 2: friendly permission names also shows control flex for the sd itself.
- 40:12Speaker 1: Powerful Inspection Tools Security Descriptor Definition Language SDDL.
- 40:17Speaker 2: The text format yeah much easier to read, write and
- 40:19Speaker 2: store than binary blobs. Get NTCID. SDDL converts a SID
- 40:24Speaker 2: to its SDDL string. Has aliases like wd BA, s y,
- 40:28Speaker 2: A U, i U for well known sids, human.
- 40:31Speaker 1: Readable security descriptors and conditional expressions in SDDL for dynamic rules.
- 40:35Speaker 2: Exactly ACS that only apply if conditions based on security
- 40:38Speaker 2: attributes in the token or on the resource are met
- 40:41Speaker 2: at access time. Use attributes like token, integrity level, TI, user, SID, TU,
- 40:45Speaker 2: device properties, et cetera. Uses operators like containers and errata
- 40:49Speaker 2: adds huge flexibility.
- 40:50Speaker 1: Context where access control cool Finally brute forcing known sids
- 40:54Speaker 1: with get account sids.
- 40:55Speaker 2: How why the function takes a base SID like S
- 40:59Speaker 2: one five for NT authority and a range of IDs
- 41:03Speaker 2: it tries. Each ried constructs the full SID and attempts
- 41:07Speaker 2: to look up the account name. If it finds a
- 41:09Speaker 2: name from the local system LSS, it means that SID exists.
- 41:14Speaker 1: So you can discover accounts by iterating rids YEP.
- 41:17Speaker 2: Useful for mapping out all the built in accounts and
- 41:19Speaker 2: groups under S one five or S one five thirty
- 41:21Speaker 2: two built in as the example shows a discovery technique.
- 41:25Speaker 1: A systematic way to find existing principles. Wow, that brings
- 41:29Speaker 1: us to the end of this really really deep dive.
- 41:31Speaker 2: It certainly covered a lot of ground, from setting up PowerShell,
- 41:34Speaker 2: the language basics all the way down into kernel objects, handles, tokens,
- 41:38Speaker 2: security descriptors. It's intricate stuff, it really is.
- 41:41Speaker 1: But it's amazing how PowerShell, especially with modules like the
- 41:44Speaker 1: one discussed in the source, lets you interact with and
- 41:48Speaker 1: really understand these core window security mechanisms.
- 41:51Speaker 2: Absolutely it pulls back the curtain and having gone through
- 41:54Speaker 2: this gives you a fantastic foundation. You know, you can
- 41:56Speaker 2: now dig deeper into specific areas process security, privileged management, ecls,
- 42:00Speaker 2: on specific objects, whatever interests you or is relevant to
- 42:03Speaker 2: your work.
- 42:04Speaker 1: Definitely, powershow really is the key to unlocking a lot
- 42:07Speaker 1: of this.
- 42:07Speaker 2: It provides the tools to explore as far as you
- 42:09Speaker 2: want to go.
- 42:10Speaker 1: So the final thought to leave you with knowing just
- 42:13Speaker 1: how granularly Windows controls access down to individual permissions and attributes.
- 42:18Speaker 1: What are some maybe unexpected ways this might impact application
- 42:22Speaker 1: behavior or security configurations you see every day. Certainly gives
- 42:26Speaker 1: you a new perspective. Thanks for joining us on this
- 42:28Speaker 1: deep dive