WEBVTT

1
00:00:00.120 --> 00:00:02.640
<v Speaker 1>Welcome to the deep dive. You give it some really

2
00:00:02.680 --> 00:00:08.119
<v Speaker 1>interesting material here, focusing on Windows security internals and PowerShell.

3
00:00:08.240 --> 00:00:09.880
<v Speaker 2>Yeah, it's a great combination to look at.

4
00:00:09.960 --> 00:00:13.080
<v Speaker 1>So that's our focus today. Our mission really is to

5
00:00:13.119 --> 00:00:15.560
<v Speaker 1>pull out the core ideas, give you a shortcut to

6
00:00:15.640 --> 00:00:20.519
<v Speaker 1>understanding how Windows handles security management and how PowerShell fits

7
00:00:20.519 --> 00:00:23.120
<v Speaker 1>in as well, like an investigative.

8
00:00:22.440 --> 00:00:24.679
<v Speaker 2>Tool, right without getting totally lost in the weeds. There's

9
00:00:24.719 --> 00:00:26.600
<v Speaker 2>a lot of detail in these sources exactly.

10
00:00:26.640 --> 00:00:30.640
<v Speaker 1>We're aiming for those aha moments, you know, finding the

11
00:00:30.719 --> 00:00:34.960
<v Speaker 1>surprising bits about Windows security that PowerShell helps uncover.

12
00:00:35.200 --> 00:00:37.719
<v Speaker 2>And what's really cool is how the sources link these

13
00:00:37.960 --> 00:00:41.920
<v Speaker 2>like abstract security concepts directly to practical PowerShell commands.

14
00:00:42.000 --> 00:00:43.560
<v Speaker 1>So it's not just theory, not at all.

15
00:00:43.600 --> 00:00:46.240
<v Speaker 2>We'll actually see how PowerShell can light up the internals.

16
00:00:46.240 --> 00:00:49.560
<v Speaker 1>Okay, let's dive in. The material starts by emphasizing setting

17
00:00:49.640 --> 00:00:53.280
<v Speaker 1>up a PowerShell testing environment. Why is that the first

18
00:00:53.479 --> 00:00:54.280
<v Speaker 1>crucial step.

19
00:00:54.679 --> 00:00:58.000
<v Speaker 2>Well, it's super important because you need a safe place,

20
00:00:58.079 --> 00:01:01.039
<v Speaker 2>a sandbox, right to try out these commands without messing

21
00:01:01.079 --> 00:01:02.039
<v Speaker 2>up your actual system.

22
00:01:02.320 --> 00:01:05.599
<v Speaker 1>Makes sense, you don't want to break anything accidentally exactly.

23
00:01:05.400 --> 00:01:08.959
<v Speaker 2>And the source talks about set execution policy. Think of

24
00:01:09.000 --> 00:01:12.760
<v Speaker 2>that as your first safety net stops accidental script running.

25
00:01:12.519 --> 00:01:14.400
<v Speaker 1>Which can be a security risk in itself.

26
00:01:14.480 --> 00:01:17.200
<v Speaker 2>Oh definitely. And the key thing is that set scope

27
00:01:17.280 --> 00:01:18.680
<v Speaker 2>current user option for.

28
00:01:18.719 --> 00:01:21.400
<v Speaker 1>Keeping tests just within your user account.

29
00:01:21.079 --> 00:01:24.400
<v Speaker 2>Right, isolated testing. If you want system wide changes, well

30
00:01:24.400 --> 00:01:26.879
<v Speaker 2>that's different. You'd need admin privileges for that, and you

31
00:01:26.920 --> 00:01:28.159
<v Speaker 2>wouldn't use the scope parameter.

32
00:01:28.239 --> 00:01:31.120
<v Speaker 1>Then gotcha. And the source notes that some setups, like

33
00:01:31.200 --> 00:01:35.959
<v Speaker 1>maybe open source PowerShell or newer server versions might already

34
00:01:35.959 --> 00:01:37.959
<v Speaker 1>have remote signed as the default.

35
00:01:38.159 --> 00:01:40.879
<v Speaker 2>Yeah, so it's always smart to just check first, know

36
00:01:40.920 --> 00:01:41.640
<v Speaker 2>where you stand.

37
00:01:41.719 --> 00:01:46.239
<v Speaker 1>Okay, Next up PowerShell language basics. For someone diving into

38
00:01:46.239 --> 00:01:49.799
<v Speaker 1>this material, what are the foundational bits that really give

39
00:01:49.840 --> 00:01:50.599
<v Speaker 1>you leverage here?

40
00:01:50.760 --> 00:01:53.920
<v Speaker 2>The sources bring up a few key things special variables

41
00:01:53.959 --> 00:01:57.439
<v Speaker 2>like null p TOBE for your current directory pobid that's.

42
00:01:57.319 --> 00:01:59.120
<v Speaker 1>The PowerShell process idea itself.

43
00:01:59.480 --> 00:02:03.079
<v Speaker 2>Yeah, exactly, and ORNA four for environment variables like EnEv

44
00:02:03.400 --> 00:02:08.120
<v Speaker 2>windeer knowing innovator D is surprisingly useful for security scripting

45
00:02:08.400 --> 00:02:09.840
<v Speaker 2>context matters.

46
00:02:09.680 --> 00:02:12.599
<v Speaker 1>And the difference between single and double quotes crucial.

47
00:02:12.879 --> 00:02:15.759
<v Speaker 2>Double quotes allow string interpolation.

48
00:02:15.599 --> 00:02:18.360
<v Speaker 1>So variables get automatically substituted in right.

49
00:02:18.479 --> 00:02:22.520
<v Speaker 2>Makes building dynamic commands way easier, no messy string joining

50
00:02:22.840 --> 00:02:25.960
<v Speaker 2>single quotes. They treat everything literally good when you need

51
00:02:25.960 --> 00:02:27.120
<v Speaker 2>that exact string.

52
00:02:27.120 --> 00:02:30.560
<v Speaker 1>That interpolation is a huge time saver. The source also

53
00:02:30.599 --> 00:02:34.960
<v Speaker 1>mentions creating objects a new object using a GID as

54
00:02:34.960 --> 00:02:35.400
<v Speaker 1>an example.

55
00:02:35.439 --> 00:02:39.360
<v Speaker 2>Yeah, basic object creation and the naming convention for commands

56
00:02:39.639 --> 00:02:41.800
<v Speaker 2>verb noun like a get item.

57
00:02:41.960 --> 00:02:44.039
<v Speaker 1>Seems designed to make things easier to find.

58
00:02:44.199 --> 00:02:46.759
<v Speaker 2>It really does help. You can often guess command names

59
00:02:46.800 --> 00:02:50.599
<v Speaker 2>and then parameters like megapath with get item, let you focus.

60
00:02:50.280 --> 00:02:52.400
<v Speaker 1>The command so you can target specific.

61
00:02:52.000 --> 00:02:54.240
<v Speaker 2>Things exactly, and we'll get to get member later. But

62
00:02:54.280 --> 00:02:56.599
<v Speaker 2>think of that as your magnifying glass for figuring out

63
00:02:56.599 --> 00:02:58.319
<v Speaker 2>what an object is and what you can do with it.

64
00:02:58.560 --> 00:03:00.479
<v Speaker 1>Okay, so you have these basic tools, how do you

65
00:03:00.520 --> 00:03:02.719
<v Speaker 1>learn to use them effectively? The source talks a lot

66
00:03:02.719 --> 00:03:03.400
<v Speaker 1>about get help.

67
00:03:03.560 --> 00:03:07.960
<v Speaker 2>Oh, get help is your best friend in PowerShell, seriously indispensable.

68
00:03:08.080 --> 00:03:08.840
<v Speaker 1>What does it give you?

69
00:03:08.919 --> 00:03:12.159
<v Speaker 2>The synopsis, the full syntax, detailed descriptions, and what's really

70
00:03:12.159 --> 00:03:14.759
<v Speaker 2>handy is using wild cards for parameter.

71
00:03:14.439 --> 00:03:18.199
<v Speaker 1>Names like the ubjet example to find parameters starting with.

72
00:03:18.159 --> 00:03:21.800
<v Speaker 2>Objeck exactly and the example's parameter that's often the best

73
00:03:21.800 --> 00:03:25.599
<v Speaker 2>part real world usage examples invaluable can't.

74
00:03:25.360 --> 00:03:28.400
<v Speaker 1>Be practical examples. Okay, now, what about making your own

75
00:03:28.479 --> 00:03:32.919
<v Speaker 1>PowerShell tools. The material covers functions. What's key there, Well.

76
00:03:32.840 --> 00:03:36.599
<v Speaker 2>The basics are the function keyword, then your function name.

77
00:03:37.039 --> 00:03:39.800
<v Speaker 2>It's good practice to stick to that verb noun convention

78
00:03:40.120 --> 00:03:43.400
<v Speaker 2>even for your own stuff. Keeps things consistent, makes sense,

79
00:03:43.879 --> 00:03:47.560
<v Speaker 2>and parameters defined in the tarum block. You can specify

80
00:03:47.599 --> 00:03:50.199
<v Speaker 2>types like string name, but you don't have to. PowerShell's

81
00:03:50.199 --> 00:03:50.919
<v Speaker 2>pretty flexible.

82
00:03:51.000 --> 00:03:52.680
<v Speaker 1>What if you don't use param.

83
00:03:52.599 --> 00:03:54.639
<v Speaker 2>Then any arguments you pass just end up in the

84
00:03:54.800 --> 00:03:57.599
<v Speaker 2>arg's array. You access them by number, like ARGs dollars

85
00:03:57.639 --> 00:03:58.639
<v Speaker 2>or r T one.

86
00:03:58.439 --> 00:04:02.520
<v Speaker 1>So named parameters are just numbered arguments. Good flexibility. Okay.

87
00:04:02.599 --> 00:04:06.199
<v Speaker 1>The deep dive then shifts to output. How PowerShell shows

88
00:04:06.240 --> 00:04:07.719
<v Speaker 1>you stuff and how you can control it.

89
00:04:08.000 --> 00:04:11.199
<v Speaker 2>Right, So, when a command runs and you don't assign

90
00:04:11.199 --> 00:04:14.319
<v Speaker 2>the output to a variable, PowerShell steps in and tries

91
00:04:14.360 --> 00:04:17.079
<v Speaker 2>to display it nicely, usually a table or a list.

92
00:04:17.240 --> 00:04:18.959
<v Speaker 1>It guesses the best format.

93
00:04:18.920 --> 00:04:22.600
<v Speaker 2>Kind of yeah, based on the object's properties, but you

94
00:04:22.680 --> 00:04:26.079
<v Speaker 2>have control. Select object is key for picking just the

95
00:04:26.120 --> 00:04:28.959
<v Speaker 2>properties you care about. Cuts down the noise.

96
00:04:29.120 --> 00:04:32.199
<v Speaker 1>Nice and format list forces.

97
00:04:31.800 --> 00:04:35.360
<v Speaker 2>It into a list view one property per line. Basically

98
00:04:35.600 --> 00:04:37.319
<v Speaker 2>great when you want to see all the details for

99
00:04:37.319 --> 00:04:39.439
<v Speaker 2>a single object rather than a wide table.

100
00:04:39.600 --> 00:04:41.839
<v Speaker 1>And if you don't even know what properties are available,

101
00:04:42.160 --> 00:04:44.639
<v Speaker 1>that's where get member comes in again, right with DJ

102
00:04:44.800 --> 00:04:45.959
<v Speaker 1>type property.

103
00:04:45.680 --> 00:04:48.079
<v Speaker 2>Exactly if pipe your command output to get member iban

104
00:04:48.120 --> 00:04:50.240
<v Speaker 2>type property and boom, you get the full list of

105
00:04:50.319 --> 00:04:52.759
<v Speaker 2>data points you can access on those objects. It's like asking,

106
00:04:52.920 --> 00:04:54.399
<v Speaker 2>what can you tell me about yourself?

107
00:04:54.480 --> 00:04:57.800
<v Speaker 1>The decoder ring analogy works. Yeah, and sort object to

108
00:04:57.920 --> 00:04:59.279
<v Speaker 1>organize it, yep, sort.

109
00:04:59.079 --> 00:05:02.199
<v Speaker 2>My name, my side by memory usage, whatever property you need.

110
00:05:02.319 --> 00:05:03.600
<v Speaker 2>Brings order to the chaos.

111
00:05:03.680 --> 00:05:05.759
<v Speaker 1>Okay, so you can view the data how you want

112
00:05:05.759 --> 00:05:07.759
<v Speaker 1>in the console, but what about saving it?

113
00:05:08.319 --> 00:05:12.199
<v Speaker 2>Exporting data out file is the straightforward way. Saves the

114
00:05:12.240 --> 00:05:14.560
<v Speaker 2>text output just as you see it to a file,

115
00:05:14.959 --> 00:05:16.720
<v Speaker 2>then get content reads.

116
00:05:16.480 --> 00:05:17.480
<v Speaker 1>It back end and the symbol.

117
00:05:17.639 --> 00:05:20.560
<v Speaker 2>That's just a shortcut for outfile, quick and easy. But

118
00:05:20.759 --> 00:05:23.680
<v Speaker 2>for like structured data you might want and excel h

119
00:05:23.920 --> 00:05:27.639
<v Speaker 2>that's where export csv comes in. Creates a proper comma

120
00:05:27.680 --> 00:05:31.519
<v Speaker 2>separated value file, much better for spreadsheets or databases.

121
00:05:31.720 --> 00:05:33.680
<v Speaker 1>And that not no type information parameter.

122
00:05:33.800 --> 00:05:37.560
<v Speaker 2>Oh yeah, good catch that just stops PowerShell from Putting

123
00:05:37.759 --> 00:05:41.199
<v Speaker 2>that extra halftag type information line at the top of

124
00:05:41.240 --> 00:05:44.079
<v Speaker 2>the CSV makes it cleaner for other programs to read.

125
00:05:44.279 --> 00:05:47.079
<v Speaker 1>Okay, good tip. We've covered a lot of PowerShell basics.

126
00:05:47.240 --> 00:05:50.199
<v Speaker 1>Now the material shifts gears, heading down into the Windows

127
00:05:50.279 --> 00:05:53.120
<v Speaker 1>kernel and its security role. This feels like the real

128
00:05:53.160 --> 00:05:53.920
<v Speaker 1>deep dive part.

129
00:05:54.040 --> 00:05:56.399
<v Speaker 2>This is where it gets really fascinating. Yeah. The kernel,

130
00:05:56.800 --> 00:05:59.560
<v Speaker 2>that's the absolute core of the OS, where a fundamental

131
00:05:59.560 --> 00:06:00.959
<v Speaker 2>security decisions.

132
00:06:00.600 --> 00:06:03.720
<v Speaker 1>Happen, and the connection point is system calls exactly.

133
00:06:04.040 --> 00:06:07.360
<v Speaker 2>System calls are the bridge the way user mode applications,

134
00:06:07.399 --> 00:06:10.199
<v Speaker 2>the stuff we normally run talk to the privileged kernel

135
00:06:10.199 --> 00:06:13.319
<v Speaker 2>mode where the OS does its heavy lifting and enforcement.

136
00:06:13.240 --> 00:06:16.600
<v Speaker 1>The link between our apps and the OS's security core. Okay,

137
00:06:16.600 --> 00:06:19.680
<v Speaker 1>the material is several key kernel subsystems. Can you give

138
00:06:19.759 --> 00:06:21.360
<v Speaker 1>us the quick security relevance run down?

139
00:06:21.399 --> 00:06:25.560
<v Speaker 2>Sure you've got The object manager manages all kernel objects,

140
00:06:25.639 --> 00:06:29.040
<v Speaker 2>the basic building blocks. The io manager handles data moving

141
00:06:29.040 --> 00:06:32.040
<v Speaker 2>in and out. Process and thread manager creates and manages

142
00:06:32.120 --> 00:06:36.920
<v Speaker 2>running code. Memory manager controls memory use. Configuration manager that's

143
00:06:37.000 --> 00:06:41.360
<v Speaker 2>the registry code integrity. Make sure only trusted code runs.

144
00:06:41.079 --> 00:06:42.000
<v Speaker 1>A lot of managers.

145
00:06:42.879 --> 00:06:49.639
<v Speaker 2>Yeah, and crucially for security, the Security reference monitor, the SRM.

146
00:06:49.920 --> 00:06:52.279
<v Speaker 1>SRM sounds important, the ultimate gatekeeper.

147
00:06:52.319 --> 00:06:54.439
<v Speaker 2>Maybe that's a good way to put it. The SRM

148
00:06:54.519 --> 00:06:57.720
<v Speaker 2>is the kernel component that actually enforces security policy. It

149
00:06:57.759 --> 00:06:59.079
<v Speaker 2>decides who gets access to what.

150
00:06:59.519 --> 00:07:00.319
<v Speaker 1>How does it do that?

151
00:07:00.439 --> 00:07:02.800
<v Speaker 2>It uses two key things mentioned right in your source,

152
00:07:03.079 --> 00:07:06.800
<v Speaker 2>access tokens and security descriptors. Every process has an access

153
00:07:06.839 --> 00:07:09.319
<v Speaker 2>token saying who it is. Every resource, like a file

154
00:07:09.399 --> 00:07:12.519
<v Speaker 2>or registry key, has a security descriptor saying who's allowed

155
00:07:12.519 --> 00:07:13.040
<v Speaker 2>to access.

156
00:07:13.279 --> 00:07:15.079
<v Speaker 1>So the SRN compares the token.

157
00:07:14.839 --> 00:07:19.120
<v Speaker 2>To the descriptor exactly when a process tries to access something,

158
00:07:19.240 --> 00:07:21.959
<v Speaker 2>the SRM looks at its token, looks at the resources

159
00:07:22.000 --> 00:07:26.319
<v Speaker 2>security descriptor, and makes the call allow or deny access.

160
00:07:26.399 --> 00:07:30.160
<v Speaker 1>Tokens and security descriptors yes, central players, yeah, okay. The

161
00:07:30.199 --> 00:07:33.720
<v Speaker 1>material then dives into security descriptors and sids. What's the

162
00:07:33.759 --> 00:07:34.600
<v Speaker 1>relationship there.

163
00:07:35.279 --> 00:07:40.639
<v Speaker 2>Sid's security identifiers are the unique names for users, groups, computers,

164
00:07:40.759 --> 00:07:43.319
<v Speaker 2>anything the system needs to identify for security.

165
00:07:43.759 --> 00:07:46.959
<v Speaker 1>Think of them like unique ideas, and they're inside security

166
00:07:46.959 --> 00:07:47.839
<v Speaker 1>descriptors right.

167
00:07:47.920 --> 00:07:51.480
<v Speaker 2>Security descriptors use sids to specify who is being allowed

168
00:07:51.600 --> 00:07:54.839
<v Speaker 2>or denied access. The source shows using get into SID

169
00:07:54.879 --> 00:07:58.839
<v Speaker 2>to translate the raw SID string like S one five, three, two, five.

170
00:07:58.720 --> 00:08:01.040
<v Speaker 1>Four five into built users.

171
00:08:00.839 --> 00:08:04.879
<v Speaker 2>Exactly, translating the system's internal ID into something we recognize.

172
00:08:04.959 --> 00:08:08.079
<v Speaker 1>So sids are the language of security identity. Next the

173
00:08:08.120 --> 00:08:10.759
<v Speaker 1>object manager and its name space. This sounds like how

174
00:08:10.800 --> 00:08:12.720
<v Speaker 1>the kernel keeps all its objects organized. It is.

175
00:08:12.800 --> 00:08:15.240
<v Speaker 2>Think of the object manager name space the OMNS as

176
00:08:15.319 --> 00:08:17.639
<v Speaker 2>like a hidden file system just for kernel.

177
00:08:17.319 --> 00:08:19.279
<v Speaker 1>Objects, a file system for kernel stuff.

178
00:08:19.399 --> 00:08:22.680
<v Speaker 2>Yeah, it's hierarchical like folders and files. Get ant type

179
00:08:22.720 --> 00:08:27.120
<v Speaker 2>shows you the kinds of objects in there. Directory, symbolic link, token,

180
00:08:27.399 --> 00:08:32.559
<v Speaker 2>process thread, lots more directory objects build the hierarchy and the.

181
00:08:32.519 --> 00:08:35.399
<v Speaker 1>Source mentions the anti object PowerShell drive.

182
00:08:35.559 --> 00:08:38.080
<v Speaker 2>Right that lets you browse this hidden name space using

183
00:08:38.080 --> 00:08:41.519
<v Speaker 2>familiar commands like LS or CD. It's a fantastic way

184
00:08:41.559 --> 00:08:42.080
<v Speaker 2>to explore.

185
00:08:42.320 --> 00:08:46.120
<v Speaker 1>Very cool. And one specific directory gets called out Base

186
00:08:46.279 --> 00:08:48.759
<v Speaker 1>named objects. Why is that one special?

187
00:08:48.919 --> 00:08:51.639
<v Speaker 2>Ah? Base Named objects or B and O. That's the

188
00:08:51.679 --> 00:08:55.559
<v Speaker 2>standard place where different processes potentially running as different users

189
00:08:55.720 --> 00:08:58.799
<v Speaker 2>can create named kernel objects that they can then share.

190
00:08:58.720 --> 00:09:01.559
<v Speaker 1>So for interprocess community sharing resources.

191
00:09:01.600 --> 00:09:04.000
<v Speaker 2>Exactly, if you want two different programs to easily find

192
00:09:04.039 --> 00:09:06.399
<v Speaker 2>and use the same kernel object like a mutex or

193
00:09:06.440 --> 00:09:08.200
<v Speaker 2>an event, putting it in B and O is the

194
00:09:08.200 --> 00:09:10.080
<v Speaker 2>common way to do it. It's the public square for

195
00:09:10.159 --> 00:09:11.200
<v Speaker 2>named kernel objects.

196
00:09:11.279 --> 00:09:14.519
<v Speaker 1>Okay, shared resources go there makes sense. Now back to

197
00:09:14.600 --> 00:09:18.559
<v Speaker 1>system calls. The deep dive mentiones NT and ZW prefixes.

198
00:09:18.840 --> 00:09:21.039
<v Speaker 1>Is there a big difference for us calling.

199
00:09:20.799 --> 00:09:25.320
<v Speaker 2>From user mode? Not really the sources they're mostly interchangeable

200
00:09:25.360 --> 00:09:29.720
<v Speaker 2>from our perspective, and crete mutant ZW crete mutant. They

201
00:09:29.759 --> 00:09:32.039
<v Speaker 2>generally do the same thing when called from an application.

202
00:09:32.360 --> 00:09:35.320
<v Speaker 1>Okay, so just note they signal a system call, right.

203
00:09:35.200 --> 00:09:37.840
<v Speaker 2>And they usually follow that verb noun pattern too, like

204
00:09:38.000 --> 00:09:40.279
<v Speaker 2>create followed by the object type mutant.

205
00:09:40.399 --> 00:09:44.480
<v Speaker 1>Got it. The source also mentions unicodestring structures for parameters,

206
00:09:44.600 --> 00:09:47.080
<v Speaker 1>especially names. What's important about those?

207
00:09:47.559 --> 00:09:51.159
<v Speaker 2>So many system calls take names using this Unicodes string structure.

208
00:09:51.399 --> 00:09:53.600
<v Speaker 2>It's not just a pointer to the characters. It also

209
00:09:53.600 --> 00:09:57.919
<v Speaker 2>includes the strings current length, invites, and the buffer's maximum.

210
00:09:57.399 --> 00:09:59.000
<v Speaker 1>Size self describing strings.

211
00:09:59.120 --> 00:10:01.919
<v Speaker 2>Yeah, and crucial, the length is just the characters used,

212
00:10:02.000 --> 00:10:04.799
<v Speaker 2>not including a null terminator. In fact, you can have

213
00:10:04.919 --> 00:10:07.720
<v Speaker 2>null characters inside object names at this level.

214
00:10:07.840 --> 00:10:10.039
<v Speaker 1>Really, that seems like it could cause problems.

215
00:10:10.279 --> 00:10:14.279
<v Speaker 2>It can mishandling these counted strings versus null terminated strings

216
00:10:14.279 --> 00:10:16.919
<v Speaker 2>has definitely been a source of security bugs over the years.

217
00:10:17.279 --> 00:10:19.000
<v Speaker 2>It uses UCS two encoding.

218
00:10:19.039 --> 00:10:22.200
<v Speaker 1>By the way, good detail. Okay, so a system call runs,

219
00:10:22.360 --> 00:10:27.159
<v Speaker 1>it needs to report back success, failure, what happened. That's

220
00:10:27.159 --> 00:10:28.639
<v Speaker 1>where anti status codes come in.

221
00:10:28.639 --> 00:10:32.320
<v Speaker 2>Exactly, and status codes are the standard return values. They

222
00:10:32.360 --> 00:10:33.559
<v Speaker 2>tell you the outcome, and.

223
00:10:33.480 --> 00:10:36.000
<v Speaker 1>They're more than just error or okay, oh yeah.

224
00:10:36.279 --> 00:10:39.279
<v Speaker 2>The source breaks down the structure. There's a severity level

225
00:10:39.759 --> 00:10:44.279
<v Speaker 2>success info, warning, error, a facility code telling you which

226
00:10:44.279 --> 00:10:47.600
<v Speaker 2>part of the system generated the status like default debugger

227
00:10:47.720 --> 00:10:50.720
<v Speaker 2>win thirty two, and the specific status code number.

228
00:10:50.840 --> 00:10:52.600
<v Speaker 1>So lots of context.

229
00:10:52.200 --> 00:10:55.360
<v Speaker 2>Tons and get end status in the PowerShell module lets

230
00:10:55.360 --> 00:10:57.639
<v Speaker 2>you look up these codes, get the symbolic name and

231
00:10:57.679 --> 00:11:00.320
<v Speaker 2>the message text. Super useful for debugs.

232
00:11:00.320 --> 00:11:03.559
<v Speaker 1>And PowerShell itself often turns these into exceptions.

233
00:11:03.559 --> 00:11:06.559
<v Speaker 2>We see right when a PowerShell command wraps a system

234
00:11:06.559 --> 00:11:09.240
<v Speaker 2>call and gets an error and sisteris it often surfaces

235
00:11:09.240 --> 00:11:11.360
<v Speaker 2>that as a dot net exception. The example of get

236
00:11:11.480 --> 00:11:13.360
<v Speaker 2>ent directory on a non existent.

237
00:11:13.039 --> 00:11:15.759
<v Speaker 1>Path gives that object name not found exception.

238
00:11:15.480 --> 00:11:17.600
<v Speaker 2>Yep, and you can take the error code from that exception,

239
00:11:17.720 --> 00:11:20.200
<v Speaker 2>feed it to get end status and get the underlying

240
00:11:20.200 --> 00:11:23.240
<v Speaker 2>into status info. It shows how PowerShell bridges that low

241
00:11:23.320 --> 00:11:25.600
<v Speaker 2>level kernel world with the managed dot net.

242
00:11:25.519 --> 00:11:31.320
<v Speaker 1>World neat connection. Okay, next topic, object handles. User applications

243
00:11:31.399 --> 00:11:35.279
<v Speaker 1>don't touch kernel objects directly. They use these handles as

244
00:11:35.519 --> 00:11:36.440
<v Speaker 1>like tickets.

245
00:11:36.600 --> 00:11:40.720
<v Speaker 2>Precisely, when you successfully create or open a kernel object

246
00:11:40.879 --> 00:11:44.200
<v Speaker 2>via a system call, the kernel gives your process back

247
00:11:44.240 --> 00:11:46.720
<v Speaker 2>a handle. Think of it as an index number into

248
00:11:46.720 --> 00:11:48.559
<v Speaker 2>your process's private handle table.

249
00:11:48.600 --> 00:11:51.000
<v Speaker 1>And what's in that handle table entry Three key things.

250
00:11:51.399 --> 00:11:54.600
<v Speaker 2>The handle number itself, the access rights that were granted

251
00:11:54.600 --> 00:11:57.799
<v Speaker 2>to your process for that object like read, write, synchronize,

252
00:11:58.080 --> 00:12:00.919
<v Speaker 2>and critically a pointer to the action object down in

253
00:12:01.000 --> 00:12:01.679
<v Speaker 2>kernel memory.

254
00:12:01.840 --> 00:12:05.840
<v Speaker 1>So when my app uses that handle later, say, to

255
00:12:06.000 --> 00:12:07.159
<v Speaker 1>read from a file.

256
00:12:06.960 --> 00:12:09.679
<v Speaker 2>Object, it passes the handle number in another system call.

257
00:12:10.080 --> 00:12:12.279
<v Speaker 2>The kernel uses that number to look up the entry

258
00:12:12.279 --> 00:12:14.919
<v Speaker 2>in your process as handle table. Then it does vital

259
00:12:15.000 --> 00:12:17.759
<v Speaker 2>checks like what First, it checks if the access you're

260
00:12:17.759 --> 00:12:21.399
<v Speaker 2>requesting now, say read access is allowed by the access

261
00:12:21.480 --> 00:12:24.679
<v Speaker 2>rights granted when the handle was created stored in the table. Second,

262
00:12:24.759 --> 00:12:26.720
<v Speaker 2>it checks if the handle actually points to the right

263
00:12:26.759 --> 00:12:29.320
<v Speaker 2>type of object trying to read from a mutex handle

264
00:12:29.360 --> 00:12:30.120
<v Speaker 2>that's going to fail.

265
00:12:30.480 --> 00:12:33.759
<v Speaker 1>Makes sense, access check and type check. Secure way to

266
00:12:33.799 --> 00:12:39.159
<v Speaker 1>manage things, which brings us to access masks those granted

267
00:12:39.240 --> 00:12:39.799
<v Speaker 1>rights right.

268
00:12:39.840 --> 00:12:42.799
<v Speaker 2>The permissions granted are stored as a thirty two bit

269
00:12:42.960 --> 00:12:46.159
<v Speaker 2>number called an access mask. It's a bitfield. Different bits

270
00:12:46.240 --> 00:12:48.039
<v Speaker 2>mean different permissions.

271
00:12:47.480 --> 00:12:50.080
<v Speaker 1>And it's specific to the object type largely.

272
00:12:50.200 --> 00:12:54.200
<v Speaker 2>Yes, the top sixteen bits are generally type specific. So

273
00:12:54.440 --> 00:12:57.279
<v Speaker 2>a file object's access mask will have bits for things

274
00:12:57.320 --> 00:13:00.559
<v Speaker 2>like read data, write data, a pen data, while a

275
00:13:00.600 --> 00:13:04.200
<v Speaker 2>thread object will have bits for terminate, suspend, resume, set information,

276
00:13:04.360 --> 00:13:04.679
<v Speaker 2>and so.

277
00:13:04.720 --> 00:13:08.879
<v Speaker 1>On, granular permissions tailored to the object. The source then

278
00:13:08.960 --> 00:13:12.799
<v Speaker 1>shows duplicating handles with copynt object. Why would you do that?

279
00:13:12.960 --> 00:13:16.159
<v Speaker 2>Copy anti object lets you duplicate an existing handle. You

280
00:13:16.159 --> 00:13:18.320
<v Speaker 2>can just make an identical copy or and this is useful.

281
00:13:18.360 --> 00:13:20.759
<v Speaker 2>You can request different access rights for the new handle.

282
00:13:20.919 --> 00:13:23.600
<v Speaker 1>Ah, so you could create a less privileged version of

283
00:13:23.600 --> 00:13:24.639
<v Speaker 1>a handle exactly.

284
00:13:24.720 --> 00:13:26.720
<v Speaker 2>Maybe you have a handle with full access, but you

285
00:13:26.759 --> 00:13:29.000
<v Speaker 2>want to pass a handle to another part of your

286
00:13:29.039 --> 00:13:32.039
<v Speaker 2>code or another process that only has a query access.

287
00:13:32.360 --> 00:13:35.279
<v Speaker 2>Duplicating the handle with a restricted desired access mask is

288
00:13:35.279 --> 00:13:35.799
<v Speaker 2>how you do that.

289
00:13:36.200 --> 00:13:40.360
<v Speaker 1>Smart and compare and object checks if two handles point

290
00:13:40.399 --> 00:13:42.840
<v Speaker 1>to the same actual kernel object.

291
00:13:42.519 --> 00:13:45.840
<v Speaker 2>Yep, even if they have different access rights. Compare end

292
00:13:45.840 --> 00:13:48.799
<v Speaker 2>to object tells you if they're ultimately referencing the same

293
00:13:48.840 --> 00:13:49.879
<v Speaker 2>thing done in the kernel.

294
00:13:50.519 --> 00:13:54.080
<v Speaker 1>Cool. What about that protect from close attribute sounds obvious?

295
00:13:54.240 --> 00:13:56.440
<v Speaker 2>It is what it sounds like. If you set that

296
00:13:56.559 --> 00:13:59.919
<v Speaker 2>astribute on a handle, the system won't let it be closed.

297
00:14:00.279 --> 00:14:03.919
<v Speaker 2>Palls to close handle will fail with status handle not closeable.

298
00:14:04.000 --> 00:14:06.519
<v Speaker 1>Why to keep a critical handle alive?

299
00:14:06.840 --> 00:14:10.000
<v Speaker 2>Could be maybe you need to guarantee a resource stays

300
00:14:10.000 --> 00:14:13.440
<v Speaker 2>accessible and don't want some stray code closing the handle prematurely.

301
00:14:13.519 --> 00:14:17.519
<v Speaker 1>Okay. The deep dive then talks about enquery information object

302
00:14:17.799 --> 00:14:21.480
<v Speaker 1>and end set information object, sort of generic get and

303
00:14:21.519 --> 00:14:23.000
<v Speaker 1>set for object data.

304
00:14:23.120 --> 00:14:25.720
<v Speaker 2>That's the idea. Instead of having dozens of specific system

305
00:14:25.759 --> 00:14:28.399
<v Speaker 2>calls for every little piece of info about every object type,

306
00:14:28.480 --> 00:14:30.759
<v Speaker 2>the kernel provides these general purpose calls.

307
00:14:30.759 --> 00:14:31.440
<v Speaker 1>How do they work?

308
00:14:31.639 --> 00:14:34.399
<v Speaker 2>You give them the handle, an information class number that

309
00:14:34.399 --> 00:14:37.039
<v Speaker 2>specifies what data you want, and a buffer to put

310
00:14:37.039 --> 00:14:39.559
<v Speaker 2>the data in for query or get from for set.

311
00:14:39.600 --> 00:14:42.440
<v Speaker 1>And how do you know the right information class number? Ah?

312
00:14:42.519 --> 00:14:46.000
<v Speaker 2>Well, get nt object information class can list the known

313
00:14:46.039 --> 00:14:49.360
<v Speaker 2>ones for an object type, but as the source notes,

314
00:14:49.559 --> 00:14:52.759
<v Speaker 2>not all classes are officially documented. Sometimes it involves a

315
00:14:52.759 --> 00:14:54.919
<v Speaker 2>bit of digging or experimentation, like.

316
00:14:54.960 --> 00:14:58.720
<v Speaker 1>Figuring out database fields. The example with querying process info

317
00:14:58.840 --> 00:15:01.919
<v Speaker 1>and getting buffer too small that highlights needing the right

318
00:15:01.960 --> 00:15:03.639
<v Speaker 1>buffer size exactly.

319
00:15:03.799 --> 00:15:05.759
<v Speaker 2>You often have to figure out how much space the

320
00:15:05.799 --> 00:15:08.600
<v Speaker 2>information needs. Sometimes you call it once to get their

321
00:15:08.639 --> 00:15:11.840
<v Speaker 2>required size, allocate a buffer, then call it again, or

322
00:15:12.080 --> 00:15:14.240
<v Speaker 2>just guess with the like parameter until it works.

323
00:15:14.399 --> 00:15:18.240
<v Speaker 1>Got it okay? Quickly. Touching on device objects and symbolic

324
00:15:18.279 --> 00:15:20.080
<v Speaker 1>links in the OMNS. How do they fit in?

325
00:15:20.360 --> 00:15:23.600
<v Speaker 2>Device objects represent hardware or virtual devices. You can see

326
00:15:23.600 --> 00:15:27.720
<v Speaker 2>them under nty object. Device Symbolic links like system root

327
00:15:27.799 --> 00:15:31.159
<v Speaker 2>are just pointers or aliases to other paths in the OMNS.

328
00:15:31.320 --> 00:15:33.279
<v Speaker 1>So when I open see windowsnoepad dot.

329
00:15:33.240 --> 00:15:36.360
<v Speaker 2>Ex, the system uses symbolic links C likely points to

330
00:15:36.399 --> 00:15:39.120
<v Speaker 2>a device hard disc volume X path. Windows might involve

331
00:15:39.159 --> 00:15:41.519
<v Speaker 2>system route to resolve the path down to the actual

332
00:15:41.559 --> 00:15:45.480
<v Speaker 2>file object, passing through the device object representing the disk volume,

333
00:15:45.720 --> 00:15:47.360
<v Speaker 2>all involving the object manager.

334
00:15:47.679 --> 00:15:54.759
<v Speaker 1>Path resolution involves the OMMS. Okay, next, process and thread

335
00:15:54.840 --> 00:15:56.360
<v Speaker 1>manager key security points.

336
00:15:56.720 --> 00:15:59.039
<v Speaker 2>Processes and threads are the things that run code, and

337
00:15:59.039 --> 00:16:02.799
<v Speaker 2>they are securable objects themselves. They have security descriptors, so you.

338
00:16:02.799 --> 00:16:05.120
<v Speaker 1>Need permission to say terminate another process.

339
00:16:05.200 --> 00:16:08.919
<v Speaker 2>Absolutely and importantly you generally can't open a process or

340
00:16:09.000 --> 00:16:12.320
<v Speaker 2>thread just by knowing its name. You need its unique

341
00:16:12.600 --> 00:16:17.679
<v Speaker 2>process ID PID or thread id TID helps prevent arbitrary

342
00:16:17.679 --> 00:16:19.799
<v Speaker 2>interference just based on names.

343
00:16:19.879 --> 00:16:23.200
<v Speaker 1>Right, need the specific ID. Okay. Memory management in sections

344
00:16:23.320 --> 00:16:25.159
<v Speaker 1>sounds like fertile ground for security issues.

345
00:16:25.200 --> 00:16:27.919
<v Speaker 2>Definitely. Sections are blocks of memory that can be shared

346
00:16:27.960 --> 00:16:31.720
<v Speaker 2>between processes. New antisection creates one add in section, maps

347
00:16:31.720 --> 00:16:33.759
<v Speaker 2>it into a process's address space.

348
00:16:33.519 --> 00:16:35.200
<v Speaker 1>And you control permissions on that memory.

349
00:16:35.320 --> 00:16:38.559
<v Speaker 2>Yes crucial. You specify protection like read only read write,

350
00:16:38.600 --> 00:16:42.039
<v Speaker 2>execute read write. The kernel enforces these. Trying to map

351
00:16:42.080 --> 00:16:45.440
<v Speaker 2>a section with incompatible permissions fails, as the example.

352
00:16:45.080 --> 00:16:48.879
<v Speaker 1>Showed and shared ritable sections. The source mentions CVE twenty

353
00:16:48.960 --> 00:16:51.840
<v Speaker 1>nineteen Uro nine, four to three. That sounds bad.

354
00:16:52.080 --> 00:16:55.639
<v Speaker 2>It was a privileged process shared a section. A lower

355
00:16:55.639 --> 00:16:58.840
<v Speaker 2>privileged process could map it as writable modified data the

356
00:16:58.840 --> 00:17:03.120
<v Speaker 2>privileged process trusted and potentially get code execution. Big problem.

357
00:17:03.360 --> 00:17:07.039
<v Speaker 1>Yikes. How would you even find such shared sections?

358
00:17:07.279 --> 00:17:09.680
<v Speaker 2>The source shows using get and handle to look at

359
00:17:09.720 --> 00:17:13.759
<v Speaker 2>all handles and processes, filtering for section objects, and using

360
00:17:13.799 --> 00:17:16.400
<v Speaker 2>test n access mask to see if any have right

361
00:17:16.519 --> 00:17:21.000
<v Speaker 2>access section map right or potentially dangerous combinations like section

362
00:17:21.119 --> 00:17:25.000
<v Speaker 2>exten size. You'd compare handles between a high privilege and

363
00:17:25.039 --> 00:17:26.519
<v Speaker 2>low privileged process, so.

364
00:17:26.440 --> 00:17:30.079
<v Speaker 1>You can hunt for potentially risky sharing configurations and even

365
00:17:30.119 --> 00:17:30.599
<v Speaker 1>fuzz them.

366
00:17:30.720 --> 00:17:33.200
<v Speaker 2>Yeah, if you find a writable shared section, you could

367
00:17:33.279 --> 00:17:36.240
<v Speaker 2>use right anti virtual memory to poke at it, write

368
00:17:36.279 --> 00:17:39.039
<v Speaker 2>unexpected data. See if you can crash or exploit the

369
00:17:39.079 --> 00:17:41.559
<v Speaker 2>other process sharing it. Show in t section even gives

370
00:17:41.559 --> 00:17:43.319
<v Speaker 2>you a x editor GUI for it.

371
00:17:43.359 --> 00:17:46.599
<v Speaker 1>Wow. The big takeaway seems to be writable and executable

372
00:17:46.599 --> 00:17:48.039
<v Speaker 1>memory is inherently dangerous.

373
00:17:48.160 --> 00:17:51.799
<v Speaker 2>Extremely that combo is classic malware territory for code injection.

374
00:17:52.279 --> 00:17:54.480
<v Speaker 2>He's very careful justification if you used at all?

375
00:17:54.880 --> 00:17:57.960
<v Speaker 1>Okay, shifting up a level. Now user mode applications and

376
00:17:58.119 --> 00:18:02.279
<v Speaker 1>Win thirty two APIs. This is where most developers live. Right,

377
00:18:02.319 --> 00:18:03.799
<v Speaker 1>how does this relate to the kernel stuff?

378
00:18:03.960 --> 00:18:06.880
<v Speaker 2>Right? Most apps don't call nt create file directly. They

379
00:18:06.920 --> 00:18:09.960
<v Speaker 2>call the Win thirty two API function create file. These

380
00:18:10.000 --> 00:18:14.240
<v Speaker 2>Win thirty two APIs are the documented stable interface for applications,

381
00:18:14.240 --> 00:18:17.799
<v Speaker 2>the layer of abstraction exactly. They provide functions for everything files,

382
00:18:17.880 --> 00:18:21.079
<v Speaker 2>Windows network registry under the hood. Many of these WIN

383
00:18:21.160 --> 00:18:23.920
<v Speaker 2>thirty two functions eventually translate into one or more and

384
00:18:24.200 --> 00:18:26.640
<v Speaker 2>or ZW system calls to the kernel to do the

385
00:18:26.680 --> 00:18:29.599
<v Speaker 2>actual work. Understanding that translation is key, So.

386
00:18:29.559 --> 00:18:31.920
<v Speaker 1>Win thirty two is the friendly face. System calls are

387
00:18:31.920 --> 00:18:35.599
<v Speaker 1>the engine room. Okay. DLL imports and API sets what

388
00:18:35.680 --> 00:18:36.039
<v Speaker 1>are these?

389
00:18:36.279 --> 00:18:40.759
<v Speaker 2>Ds? Dynamic link libraries are shared code libraries. Apps import

390
00:18:40.759 --> 00:18:43.400
<v Speaker 2>functions from them. Get Win thirty two module import. Let's

391
00:18:43.440 --> 00:18:46.519
<v Speaker 2>you see which functions and app uses from which DLLs.

392
00:18:46.160 --> 00:18:49.079
<v Speaker 1>Useful for understanding dependencies and API.

393
00:18:48.799 --> 00:18:51.359
<v Speaker 2>Sets Introduced in Windows seven. They're like virtual DLLs, and

394
00:18:51.400 --> 00:18:55.000
<v Speaker 2>app might link against apm's wind core process threads LANs

395
00:18:55.000 --> 00:18:57.920
<v Speaker 2>onesaushal on zero dot dll instead of directly against kernel

396
00:18:57.960 --> 00:19:01.240
<v Speaker 2>thirty two dot dll or at VAP thirty two dot dll.

397
00:19:01.480 --> 00:19:04.359
<v Speaker 2>It decouples the app from the exact DLLLL Providing the

398
00:19:04.359 --> 00:19:07.559
<v Speaker 2>function makes it easier for Microsoft to refactor things behind

399
00:19:07.559 --> 00:19:10.799
<v Speaker 2>the scenes without breaking apps. Get n TAPA set. Let's

400
00:19:10.799 --> 00:19:14.319
<v Speaker 2>you see which real DLL actually backs a specific API

401
00:19:14.440 --> 00:19:16.519
<v Speaker 2>set on your system as flexibility.

402
00:19:16.559 --> 00:19:20.680
<v Speaker 1>Okay, next, searching for DLLs and DL hijacking. This is

403
00:19:20.680 --> 00:19:22.039
<v Speaker 1>a classic attack, right Oh yeah?

404
00:19:22.119 --> 00:19:24.799
<v Speaker 2>Very common. When an app asks to load a DLL

405
00:19:24.960 --> 00:19:28.359
<v Speaker 2>just by name like graphics dot DLL without a full path,

406
00:19:28.720 --> 00:19:29.440
<v Speaker 2>Windows has to.

407
00:19:29.440 --> 00:19:30.960
<v Speaker 1>Search for it where does it look.

408
00:19:31.119 --> 00:19:33.799
<v Speaker 2>The search order has changed over time for security reasons.

409
00:19:33.920 --> 00:19:37.319
<v Speaker 2>Older Windows versions often check the app's current directory first,

410
00:19:37.400 --> 00:19:39.160
<v Speaker 2>which was dangerous.

411
00:19:38.759 --> 00:19:41.960
<v Speaker 1>Because an attacker could drop a malicious graphics dot DLL.

412
00:19:41.640 --> 00:19:44.599
<v Speaker 2>There precisely if a privileged app loaded it from an

413
00:19:44.680 --> 00:19:49.880
<v Speaker 2>unsecured directory boom dll hijack code execution. Vista and later

414
00:19:49.960 --> 00:19:54.279
<v Speaker 2>have a safer default order prioritizing system directories, but vulnerabilities

415
00:19:54.279 --> 00:19:57.039
<v Speaker 2>can still exist if apps aren't careful about where they

416
00:19:57.119 --> 00:20:00.039
<v Speaker 2>load DLLs from, or if their current directory is attacker can.

417
00:20:00.519 --> 00:20:03.440
<v Speaker 1>Always specify the full path if you can't. Basically, Windows

418
00:20:03.440 --> 00:20:06.480
<v Speaker 1>stations and desktops UI stuff, but security implications.

419
00:20:06.759 --> 00:20:11.279
<v Speaker 2>Yes, Window stations are secure containers for UI elements, primarily desktops.

420
00:20:11.759 --> 00:20:14.960
<v Speaker 2>WINDSTA is the main interactive one we use why separate

421
00:20:15.000 --> 00:20:18.880
<v Speaker 2>stations Isolation services might run in a different Window station

422
00:20:19.039 --> 00:20:22.799
<v Speaker 2>from the interactive user. It prevents processes in one station

423
00:20:22.880 --> 00:20:26.920
<v Speaker 2>from easily interfering with the UI of another. Desktops live

424
00:20:27.000 --> 00:20:31.359
<v Speaker 2>inside window stations, providing another layer. Get INNT window station

425
00:20:31.519 --> 00:20:33.240
<v Speaker 2>name and get in desktop name.

426
00:20:33.319 --> 00:20:36.359
<v Speaker 1>Let you list them boundaries even for the UI. Uh

427
00:20:36.400 --> 00:20:39.039
<v Speaker 1>huh okay. Windows messages. How Windows talk to.

428
00:20:39.039 --> 00:20:41.880
<v Speaker 2>Each other fundamentally, yeah, A message is just a number

429
00:20:41.960 --> 00:20:45.359
<v Speaker 2>identifying the message type, plus a couple of parameters. Apps

430
00:20:45.400 --> 00:20:48.400
<v Speaker 2>can send messages, wait for processing, or post them, put

431
00:20:48.400 --> 00:20:49.440
<v Speaker 2>in a queue and continue.

432
00:20:49.480 --> 00:20:50.960
<v Speaker 1>And windows belong to threads.

433
00:20:51.119 --> 00:20:54.359
<v Speaker 2>Right. Each window has thread affinity. Only the thread that

434
00:20:54.440 --> 00:20:58.240
<v Speaker 2>created it should really process its messages. That thread runs

435
00:20:58.279 --> 00:21:01.799
<v Speaker 2>a message loop using APIs like get message and dispatch message.

436
00:21:01.960 --> 00:21:04.480
<v Speaker 1>The source has a conceptual example of sending a message

437
00:21:04.480 --> 00:21:05.759
<v Speaker 1>to notepad. Yeah.

438
00:21:05.920 --> 00:21:08.720
<v Speaker 2>It shows finding the notepad window, get an itt window,

439
00:21:08.839 --> 00:21:12.079
<v Speaker 2>maybe finding its edit child control, and conceptually how you'd

440
00:21:12.079 --> 00:21:14.400
<v Speaker 2>send it a message, perhaps to pace text or close it.

441
00:21:14.720 --> 00:21:18.319
<v Speaker 2>It shows the potential for programmatic UI interaction, which could

442
00:21:18.319 --> 00:21:18.720
<v Speaker 2>be used for.

443
00:21:18.640 --> 00:21:22.119
<v Speaker 1>Good or bad. Okay. Console sessions, we have the physical console,

444
00:21:22.160 --> 00:21:25.599
<v Speaker 1>but also remote desktop, fast user switching exactly.

445
00:21:25.799 --> 00:21:28.599
<v Speaker 2>Each of those creates a separate session get and T

446
00:21:28.839 --> 00:21:32.160
<v Speaker 2>process info only group objects. Session edge shows you which

447
00:21:32.200 --> 00:21:33.680
<v Speaker 2>session each processes in.

448
00:21:33.839 --> 00:21:35.440
<v Speaker 1>Why separate sessions isolation?

449
00:21:35.599 --> 00:21:39.119
<v Speaker 2>Again? Each session gets its own memory areas for certain things,

450
00:21:39.160 --> 00:21:42.319
<v Speaker 2>its own instance of base named objects, its own window stations.

451
00:21:42.640 --> 00:21:45.519
<v Speaker 2>Session zero is special reserve for system services usually no

452
00:21:45.640 --> 00:21:46.279
<v Speaker 2>GUI there.

453
00:21:46.400 --> 00:21:50.000
<v Speaker 1>Session zero for services that leads into shatter attacks and UIPI.

454
00:21:50.119 --> 00:21:51.119
<v Speaker 1>What were shatter attacked?

455
00:21:51.119 --> 00:21:54.440
<v Speaker 2>Back before Vista user apps and many services ran together

456
00:21:54.480 --> 00:21:57.759
<v Speaker 2>in session zero, a low privileged app could send malicious

457
00:21:57.799 --> 00:22:00.519
<v Speaker 2>window messages to a high privileged service window in the

458
00:22:00.559 --> 00:22:03.960
<v Speaker 2>same session, tricking it into doing things or even running code.

459
00:22:04.039 --> 00:22:05.079
<v Speaker 2>That was a shatter attack.

460
00:22:05.160 --> 00:22:06.400
<v Speaker 1>Asked how is it fixed?

461
00:22:06.519 --> 00:22:10.960
<v Speaker 2>Two main things Invista session zero isolation moved interactive users

462
00:22:11.000 --> 00:22:15.240
<v Speaker 2>out of session zero and user interface privilege isolation UIPI

463
00:22:15.480 --> 00:22:16.119
<v Speaker 2>was introduced.

464
00:22:16.200 --> 00:22:17.240
<v Speaker 1>What does UIPI do.

465
00:22:17.559 --> 00:22:21.400
<v Speaker 2>It prevents lower privileged low integrity level processes from sending

466
00:22:21.559 --> 00:22:24.680
<v Speaker 2>most window messages to higher privileged process windows, even if

467
00:22:24.720 --> 00:22:27.000
<v Speaker 2>they're on the same desktop in the same session. It

468
00:22:27.079 --> 00:22:29.440
<v Speaker 2>blocks that message based attack vector.

469
00:22:29.319 --> 00:22:31.920
<v Speaker 1>A crucial privilege boundary for the UI and the source

470
00:22:32.000 --> 00:22:35.559
<v Speaker 1>mentioned procession based named objects in Windows directories again right.

471
00:22:35.599 --> 00:22:38.640
<v Speaker 2>Under sessions ID base Named objects and sessions ID Windows.

472
00:22:38.680 --> 00:22:41.920
<v Speaker 2>This keeps named objects and window stations isolated between different

473
00:22:42.000 --> 00:22:45.559
<v Speaker 2>user sessions. NT object session drive lets you see the

474
00:22:45.640 --> 00:22:47.039
<v Speaker 2>BNO for your current.

475
00:22:46.799 --> 00:22:50.759
<v Speaker 1>Session isolation everywhere, okay. Comparing Win thirty two APIs versus

476
00:22:50.839 --> 00:22:53.960
<v Speaker 1>system calls again using create mutexx Win thirty two and

477
00:22:54.000 --> 00:22:56.680
<v Speaker 1>anti create mutant ciscle key differences.

478
00:22:56.720 --> 00:22:59.599
<v Speaker 2>Look at the return values. Create mutech x returns the

479
00:22:59.599 --> 00:23:03.480
<v Speaker 2>handled directly on success or NLL on failure. Anti create

480
00:23:03.559 --> 00:23:06.839
<v Speaker 2>mutant returns an anti status code indicating success or failure,

481
00:23:07.079 --> 00:23:09.920
<v Speaker 2>and the handle comes back through an output parameter a pointer.

482
00:23:10.119 --> 00:23:12.400
<v Speaker 1>So Win thirty two often hides the anti status and

483
00:23:12.440 --> 00:23:13.079
<v Speaker 1>pointer stuff.

484
00:23:13.279 --> 00:23:16.480
<v Speaker 2>Yeah. It translates the anti status error into an NUL

485
00:23:16.559 --> 00:23:19.599
<v Speaker 2>return or sets an error code retrievable via get laster.

486
00:23:20.079 --> 00:23:24.079
<v Speaker 2>It's a more abstract, arguably simpler interface for the application developer.

487
00:23:24.319 --> 00:23:27.759
<v Speaker 1>Got it registry interaction. The module has WIN thirty two.

488
00:23:27.599 --> 00:23:30.720
<v Speaker 2>Path Yes, so you can use familiar paths like HKLM

489
00:23:30.799 --> 00:23:33.839
<v Speaker 2>Software Microsoft with commands like get an it key instead

490
00:23:33.880 --> 00:23:36.880
<v Speaker 2>of the native OMNS path Registry Machine.

491
00:23:36.519 --> 00:23:39.240
<v Speaker 1>Software handy, and you can convert between them yep.

492
00:23:39.359 --> 00:23:41.920
<v Speaker 2>The key objects return have properties like Win thirty two

493
00:23:41.960 --> 00:23:45.119
<v Speaker 2>path and full path the OMNS path for easy conversion.

494
00:23:45.319 --> 00:23:51.440
<v Speaker 1>PowerShell has built in registry drives HKLM HKCU. Why use

495
00:23:51.480 --> 00:23:52.880
<v Speaker 1>the module's provider.

496
00:23:52.519 --> 00:23:56.279
<v Speaker 2>Ah The NUL character issue malware sometimes hides keys or

497
00:23:56.359 --> 00:23:59.920
<v Speaker 2>values by putting an NUL character inside the name the bill,

498
00:24:00.119 --> 00:24:03.000
<v Speaker 2>and PowerShell provider can't handle those because it relies on

499
00:24:03.039 --> 00:24:04.799
<v Speaker 2>annual terminated strings, but.

500
00:24:04.799 --> 00:24:07.000
<v Speaker 1>The anti object module can yes.

501
00:24:06.839 --> 00:24:09.680
<v Speaker 2>Because it uses the native APIs which work with counted strings,

502
00:24:09.680 --> 00:24:11.720
<v Speaker 2>so it can see and interact with those hidden by

503
00:24:11.720 --> 00:24:15.440
<v Speaker 2>annual entries, crucial for finding certain types of malware persistence.

504
00:24:15.559 --> 00:24:18.559
<v Speaker 1>Meki okay path limits max path still a thing.

505
00:24:18.799 --> 00:24:22.400
<v Speaker 2>Still a thing in many Win thirty two APIs that

506
00:24:22.440 --> 00:24:24.920
<v Speaker 2>two hundred and sixty character limit two hundred and fifty

507
00:24:25.000 --> 00:24:28.720
<v Speaker 2>nine usable for paths. Get anti file path demonstrates it.

508
00:24:28.759 --> 00:24:31.039
<v Speaker 2>Try to convert a longer path and you'll get status

509
00:24:31.119 --> 00:24:31.839
<v Speaker 2>name a too long.

510
00:24:32.079 --> 00:24:36.200
<v Speaker 1>A classic Windows limitation process. Creation Yeah, anti create user

511
00:24:36.200 --> 00:24:39.240
<v Speaker 1>process versus create process. We use create process usually.

512
00:24:39.119 --> 00:24:42.240
<v Speaker 2>Always use create process or wrappers like start process or

513
00:24:42.279 --> 00:24:45.119
<v Speaker 2>a new Win thirty two process. Anti create user process

514
00:24:45.200 --> 00:24:48.200
<v Speaker 2>is the raw kernel call, but create process does a

515
00:24:48.200 --> 00:24:51.680
<v Speaker 2>ton of essential setup work and user mode talking to CSRSS,

516
00:24:51.720 --> 00:24:53.640
<v Speaker 2>setting up environment variables, et cetera.

517
00:24:53.839 --> 00:24:56.920
<v Speaker 1>Skipping create process would lead to a broken process pretty much.

518
00:24:56.920 --> 00:24:59.559
<v Speaker 2>It wouldn't be properly initialized for the user environment. New

519
00:24:59.559 --> 00:25:01.480
<v Speaker 2>and thirty fo process is a wrapped around Create.

520
00:25:01.359 --> 00:25:04.160
<v Speaker 1>Process and the source mentions command line parsing issues with

521
00:25:04.240 --> 00:25:05.480
<v Speaker 1>new wind thirty two process.

522
00:25:05.680 --> 00:25:08.559
<v Speaker 2>Right it tries to be helpful splitting on spaces adding

523
00:25:08.559 --> 00:25:10.920
<v Speaker 2>lot exx. But if you just give it, say C

524
00:25:11.039 --> 00:25:13.200
<v Speaker 2>program files my app and there's also a C program

525
00:25:13.319 --> 00:25:14.640
<v Speaker 2>dot exx which one.

526
00:25:14.519 --> 00:25:17.920
<v Speaker 1>Runs, ambiguity and potential hijacking.

527
00:25:17.680 --> 00:25:20.680
<v Speaker 2>Exactly if a privileged process runs something based on a

528
00:25:20.720 --> 00:25:23.839
<v Speaker 2>path that could be manipulated, like relying on the path, environment,

529
00:25:23.880 --> 00:25:26.599
<v Speaker 2>variable or relative paths, it could be tricked into running

530
00:25:26.599 --> 00:25:31.640
<v Speaker 2>the wrong executable or loading malicious DLLs. Best practice use

531
00:25:31.680 --> 00:25:35.240
<v Speaker 2>applicate application name with the full explicit path to the

532
00:25:35.279 --> 00:25:36.680
<v Speaker 2>executable you intend to run.

533
00:25:36.799 --> 00:25:41.720
<v Speaker 1>Be specific, avoid ambiguity. Okay, Shell APIs and file associations.

534
00:25:42.000 --> 00:25:44.799
<v Speaker 1>How does double clicking my doc dot txt work?

535
00:25:44.960 --> 00:25:47.559
<v Speaker 2>Explorer doesn't try to run my doc dot txt. It

536
00:25:47.559 --> 00:25:50.559
<v Speaker 2>looks up the file association for dot txt in the registry,

537
00:25:50.920 --> 00:25:53.640
<v Speaker 2>finds that notepad or whatever is the handler. Then it

538
00:25:53.720 --> 00:25:56.920
<v Speaker 2>uses shell APIs probably shall execute, telling it to open

539
00:25:56.960 --> 00:25:58.680
<v Speaker 2>my dooc dot txt using notepad.

540
00:25:58.759 --> 00:26:01.839
<v Speaker 1>So new wind thirty two pm dot txt.

541
00:26:01.559 --> 00:26:04.559
<v Speaker 2>Would fail yep, because not txt isn't an executable. You

542
00:26:04.640 --> 00:26:07.440
<v Speaker 2>need that shell layer to handle document types. The source

543
00:26:07.440 --> 00:26:10.400
<v Speaker 2>shows querying the registry to find the handler and mentions

544
00:26:10.400 --> 00:26:12.960
<v Speaker 2>shell execute verbs like open print et cetera.

545
00:26:13.119 --> 00:26:16.359
<v Speaker 1>Smart indirection Okay, quick recap, LSAs and SCM.

546
00:26:16.279 --> 00:26:22.400
<v Speaker 2>Still vital, absolutely fundamental. LSS Local Security Authorities subsystem handles authentication,

547
00:26:23.039 --> 00:26:28.039
<v Speaker 2>log on sessions, security policy, SCM Service Control Manager manages

548
00:26:28.079 --> 00:26:30.920
<v Speaker 2>background services, core security infrastructure.

549
00:26:31.000 --> 00:26:34.119
<v Speaker 1>Got it now? Finding those hidden registry keys with NUL

550
00:26:34.200 --> 00:26:35.200
<v Speaker 1>characters again, how.

551
00:26:35.079 --> 00:26:38.039
<v Speaker 2>Exactly the source shows creating one with new end key

552
00:26:38.160 --> 00:26:40.880
<v Speaker 2>embedding a zero back take zero in the name string.

553
00:26:41.200 --> 00:26:44.240
<v Speaker 2>Then you use else recurs in the NT object registry

554
00:26:44.599 --> 00:26:47.640
<v Speaker 2>derive and pipe it to where object name matches zero

555
00:26:47.720 --> 00:26:49.720
<v Speaker 2>to find keys containing that NUL.

556
00:26:50.000 --> 00:26:50.960
<v Speaker 1>And for hidden values.

557
00:26:51.000 --> 00:26:53.960
<v Speaker 2>Similar idea, Create a value with an NUL in its name,

558
00:26:54.079 --> 00:26:56.839
<v Speaker 2>then use a custom function like the select hidden value shown,

559
00:26:56.880 --> 00:27:00.240
<v Speaker 2>which likely iterates through value names character by character looking

560
00:27:00.319 --> 00:27:03.279
<v Speaker 2>for the nul. It bypasses the standard tools limitation.

561
00:27:03.519 --> 00:27:07.200
<v Speaker 1>Very clever, okay, Final section intro. Tokens. We mentioned them,

562
00:27:07.200 --> 00:27:08.799
<v Speaker 1>but let's define them clearly right.

563
00:27:08.880 --> 00:27:12.160
<v Speaker 2>Tokens are the objects that represent the security context of

564
00:27:12.200 --> 00:27:14.839
<v Speaker 2>a process or thread. Who is it? What can it do?

565
00:27:15.079 --> 00:27:18.799
<v Speaker 2>Two main types primary tokens Every process has one, defines

566
00:27:18.839 --> 00:27:22.119
<v Speaker 2>its main identity, usually the user who launched it. And

567
00:27:22.240 --> 00:27:25.559
<v Speaker 2>impersonation tokens allow a thread to temporarily act with a

568
00:27:25.559 --> 00:27:29.279
<v Speaker 2>different identity, maybe a client's identity for a specific task.

569
00:27:29.559 --> 00:27:33.400
<v Speaker 1>Primary is the baseline. Impersonation is temporary borrowing. Sets us

570
00:27:33.440 --> 00:27:34.559
<v Speaker 1>up nicely for the next part.

571
00:27:34.640 --> 00:27:37.039
<v Speaker 2>YEP, Now we dive into what's in those tokens and

572
00:27:37.039 --> 00:27:37.880
<v Speaker 2>how they're used.

573
00:27:38.000 --> 00:27:41.240
<v Speaker 1>All right, let's unpack primary tokens in more detail. These

574
00:27:41.279 --> 00:27:43.559
<v Speaker 1>are the main ID badges for processes.

575
00:27:43.640 --> 00:27:47.119
<v Speaker 2>Right, that's exactly it. Every running process gets one. It

576
00:27:47.200 --> 00:27:50.799
<v Speaker 2>holds the security identity, primarily the SID of the user

577
00:27:50.839 --> 00:27:52.079
<v Speaker 2>account that started.

578
00:27:51.759 --> 00:27:53.559
<v Speaker 1>It, and this is what the SRM looks at for

579
00:27:53.640 --> 00:27:54.400
<v Speaker 1>access checks.

580
00:27:54.559 --> 00:27:57.400
<v Speaker 2>Correct. When that process tries to touch a file or

581
00:27:57.480 --> 00:28:01.200
<v Speaker 2>registry key, whatever, the SRM grabs this primary token and

582
00:28:01.279 --> 00:28:04.480
<v Speaker 2>compares it against the resources security descriptor.

583
00:28:04.039 --> 00:28:06.799
<v Speaker 1>And the source mention. Figure four two showing the token details.

584
00:28:06.960 --> 00:28:09.599
<v Speaker 2>What are the critical parts, Yeah, that figures helpful. Key

585
00:28:09.680 --> 00:28:14.039
<v Speaker 2>things are the user SID obviously, the token type primary

586
00:28:14.079 --> 00:28:17.680
<v Speaker 2>versus impersonation, maybe an impersonation level if it's that type.

587
00:28:18.000 --> 00:28:20.400
<v Speaker 2>And then those four sixty four bit IDs.

588
00:28:20.079 --> 00:28:22.079
<v Speaker 1>Right, token ID, authentication.

589
00:28:21.640 --> 00:28:25.599
<v Speaker 2>ID, authentication ID, origin login ID, and modified ID. The

590
00:28:25.599 --> 00:28:28.799
<v Speaker 2>token ID is just a unique identifier for this specific

591
00:28:28.960 --> 00:28:29.799
<v Speaker 2>token instance.

592
00:28:30.079 --> 00:28:32.960
<v Speaker 1>But the authentication ID seems important, linking back to a

593
00:28:33.000 --> 00:28:34.599
<v Speaker 1>log on session very important.

594
00:28:34.680 --> 00:28:37.279
<v Speaker 2>When you log on, Elsas creates a log on session

595
00:28:37.480 --> 00:28:41.559
<v Speaker 2>and the SRM assigns it a unique authentication ID. Every

596
00:28:41.599 --> 00:28:44.920
<v Speaker 2>token created during that session gets the same authentication ID,

597
00:28:45.319 --> 00:28:45.839
<v Speaker 2>So if I.

598
00:28:45.799 --> 00:28:49.200
<v Speaker 1>Log off and log back on, I get a new authentication.

599
00:28:48.640 --> 00:28:51.640
<v Speaker 2>IDY, even if you're the same user. It distinguishes different

600
00:28:51.640 --> 00:28:54.480
<v Speaker 2>login instances. Helps with auditing and resource management.

601
00:28:54.559 --> 00:28:56.319
<v Speaker 1>Makes sense, and we can see this with get in

602
00:28:56.400 --> 00:28:57.200
<v Speaker 1>token right.

603
00:28:57.519 --> 00:28:59.759
<v Speaker 2>Get in token grabs the token object. You can then

604
00:28:59.799 --> 00:29:03.160
<v Speaker 2>look properties like token dot user or use format in

605
00:29:03.200 --> 00:29:05.079
<v Speaker 2>token for a nicely formatted summary.

606
00:29:05.200 --> 00:29:06.480
<v Speaker 1>What does format and token show?

607
00:29:06.759 --> 00:29:10.720
<v Speaker 2>User groups with their sids and attributes, privileges and key

608
00:29:10.759 --> 00:29:13.480
<v Speaker 2>stuff all shows even more and show in token gives

609
00:29:13.519 --> 00:29:16.480
<v Speaker 2>you that GUI view similar to the figure commandline.

610
00:29:15.960 --> 00:29:19.519
<v Speaker 1>And GUI good options. Okay, impersonation tokens? Why does services

611
00:29:19.599 --> 00:29:20.119
<v Speaker 1>use these? So?

612
00:29:20.160 --> 00:29:23.279
<v Speaker 2>A service often running as a powerful account like system

613
00:29:23.880 --> 00:29:26.480
<v Speaker 2>might need to access a resource on behalf of a

614
00:29:26.519 --> 00:29:30.640
<v Speaker 2>specific user who connected to it, like reading that user's files.

615
00:29:30.279 --> 00:29:32.720
<v Speaker 1>But the system account might not have permission for that

616
00:29:32.839 --> 00:29:33.839
<v Speaker 1>user's files.

617
00:29:33.519 --> 00:29:38.079
<v Speaker 2>Directly exactly, so the service thread temporarily impersonates the user

618
00:29:38.079 --> 00:29:41.279
<v Speaker 2>who made the request. It borrows their identity using an

619
00:29:41.279 --> 00:29:46.160
<v Speaker 2>impersonation token. Now when it accesses the file, the SRM

620
00:29:46.240 --> 00:29:50.559
<v Speaker 2>check uses the user's identity from the impersonation token, not

621
00:29:50.759 --> 00:29:52.519
<v Speaker 2>the service's identity, a way.

622
00:29:52.319 --> 00:29:55.279
<v Speaker 1>To act as the user for a specific task. The

623
00:29:55.319 --> 00:29:58.920
<v Speaker 1>source showed trying different impersonation levels with invoke in token

624
00:29:59.240 --> 00:29:59.759
<v Speaker 1>and getting an.

625
00:29:59.759 --> 00:30:03.519
<v Speaker 2>Error right this status bat impersonation level error. It tried

626
00:30:03.640 --> 00:30:06.759
<v Speaker 2>impersonating at the identification level, which is very weak lets

627
00:30:06.799 --> 00:30:08.920
<v Speaker 2>the server see who the client is, but not act

628
00:30:08.960 --> 00:30:10.759
<v Speaker 2>as them, especially not remotely.

629
00:30:10.960 --> 00:30:12.680
<v Speaker 1>So trying to open an object failed.

630
00:30:12.839 --> 00:30:17.039
<v Speaker 2>Yes, because that operation required a higher level, probably impersonation level,

631
00:30:17.240 --> 00:30:19.920
<v Speaker 2>which does allow acting locally as the client. It wasn't

632
00:30:19.960 --> 00:30:23.640
<v Speaker 2>an access denied on the object itself, but a failure

633
00:30:23.759 --> 00:30:26.640
<v Speaker 2>because the type of impersonation wasn't sufficient for the action.

634
00:30:27.160 --> 00:30:31.480
<v Speaker 1>Subtle but important difference and duplicating a token handle isn't

635
00:30:31.480 --> 00:30:33.920
<v Speaker 1>the same as duplicating the token object correct.

636
00:30:34.000 --> 00:30:36.480
<v Speaker 2>Duplicating the handle just gives you another reference pointer to

637
00:30:36.519 --> 00:30:39.920
<v Speaker 2>the same token To create a new independent token object

638
00:30:39.920 --> 00:30:42.880
<v Speaker 2>based on another, like making an impersonation token from a

639
00:30:42.920 --> 00:30:45.559
<v Speaker 2>primary one, you need the duplicate access right on the

640
00:30:45.599 --> 00:30:46.640
<v Speaker 2>original token.

641
00:30:46.359 --> 00:30:48.680
<v Speaker 1>Handle and you use anti duplicate token.

642
00:30:48.480 --> 00:30:51.440
<v Speaker 2>Which is wrapped by copy and token and PowerShell. That

643
00:30:51.480 --> 00:30:54.279
<v Speaker 2>creates a whole new token object you can then modify

644
00:30:54.440 --> 00:30:58.440
<v Speaker 2>or use for impersonation. The source shows creating a delegation

645
00:30:58.599 --> 00:31:01.759
<v Speaker 2>level token. This way, that's the highest level, allowing remote

646
00:31:01.799 --> 00:31:03.640
<v Speaker 2>impersonation to delegation.

647
00:31:03.759 --> 00:31:07.519
<v Speaker 1>Sounds powerful and potentially risky. Well, okay. The use for

648
00:31:07.599 --> 00:31:11.079
<v Speaker 1>deny only attribute on sids in a token. How does

649
00:31:11.119 --> 00:31:11.559
<v Speaker 1>that work?

650
00:31:11.759 --> 00:31:15.480
<v Speaker 2>It changes how the SRM evaluates acees. If a SID

651
00:31:15.599 --> 00:31:18.519
<v Speaker 2>in your token has used for denyingly set that SID

652
00:31:18.680 --> 00:31:21.839
<v Speaker 2>only counts when checking deny acees in a security descriptor.

653
00:31:22.000 --> 00:31:24.720
<v Speaker 2>It's completely ignored for allow aces.

654
00:31:24.400 --> 00:31:26.319
<v Speaker 1>So it can only be used to deny access, not

655
00:31:26.440 --> 00:31:26.920
<v Speaker 1>grant it.

656
00:31:27.079 --> 00:31:29.519
<v Speaker 2>Pretty much, the example was good. You're in the employee

657
00:31:29.559 --> 00:31:33.119
<v Speaker 2>group allow access and remote access group deny access marked

658
00:31:33.200 --> 00:31:36.359
<v Speaker 2>use for nine only. The deny still wins because of

659
00:31:36.359 --> 00:31:39.559
<v Speaker 2>that attribute. It lets you build rules where specific memberships

660
00:31:39.599 --> 00:31:43.160
<v Speaker 2>explicitly block access even if other memberships would normally allow it.

661
00:31:43.640 --> 00:31:49.359
<v Speaker 1>Explicit denials take precedence. Got it now. Token privileges These

662
00:31:49.400 --> 00:31:53.119
<v Speaker 1>aren't access rights on objects, but system wide powers exactly.

663
00:31:53.119 --> 00:31:56.799
<v Speaker 2>Privileges grant the ability to perform specific system operations regardless

664
00:31:56.839 --> 00:31:59.519
<v Speaker 2>of object permissions. Get and token privilege lists them for

665
00:31:59.559 --> 00:32:02.799
<v Speaker 2>a token. Examples see shut down privilege, reboot the machine.

666
00:32:02.920 --> 00:32:06.279
<v Speaker 2>See change notified privilege bypassed drivers. Checking lets you access

667
00:32:06.400 --> 00:32:08.880
<v Speaker 2>see users other user desktop even if you can't list

668
00:32:08.920 --> 00:32:11.920
<v Speaker 2>other users. See load driver privileged load kernel drivers very

669
00:32:11.920 --> 00:32:15.039
<v Speaker 2>powerful type to code signing. See take ownership privilege, become

670
00:32:15.079 --> 00:32:19.519
<v Speaker 2>owner of file subjects, serie label privilege, change integrity labels.

671
00:32:19.160 --> 00:32:24.480
<v Speaker 1>Big powers, need careful assignment, okay, sandbox tokens restricted right, restricted,

672
00:32:24.559 --> 00:32:26.359
<v Speaker 1>low box. What's the goal here?

673
00:32:26.559 --> 00:32:30.440
<v Speaker 2>Containment? Limit the damage If a process gets compromised, especially

674
00:32:30.480 --> 00:32:34.240
<v Speaker 2>one handling untrusted input like a web browser or PDF reader,

675
00:32:34.880 --> 00:32:37.480
<v Speaker 2>Run it with a weaker token, so even if hacked,

676
00:32:37.920 --> 00:32:39.079
<v Speaker 2>it can't do much harm.

677
00:32:39.279 --> 00:32:41.799
<v Speaker 1>Makes sense? How to restrict a tokens work? They're the

678
00:32:41.799 --> 00:32:42.359
<v Speaker 1>oldest type.

679
00:32:42.519 --> 00:32:45.319
<v Speaker 2>Yeah, you create a new token based on an existing one,

680
00:32:45.359 --> 00:32:49.799
<v Speaker 2>but you add limitations. You specify restricting sids. These only

681
00:32:49.880 --> 00:32:53.839
<v Speaker 2>count for allow acees, limiting what it can access. You

682
00:32:53.839 --> 00:32:57.400
<v Speaker 2>can mark existing groups as use for deny only, and

683
00:32:57.799 --> 00:33:00.720
<v Speaker 2>you can explicitly disable privilege, so.

684
00:33:00.720 --> 00:33:02.839
<v Speaker 1>You surgically weaken the original token. Right.

685
00:33:02.960 --> 00:33:06.960
<v Speaker 2>The example shows making one adding nt authority restricted, making

686
00:33:07.000 --> 00:33:11.720
<v Speaker 2>everyone deny only disabling privileges. Browsers like Chrome Firefox use

687
00:33:11.759 --> 00:33:12.720
<v Speaker 2>this concept heavily.

688
00:33:12.920 --> 00:33:15.000
<v Speaker 1>Okay, what about right restricted tokens?

689
00:33:15.400 --> 00:33:18.319
<v Speaker 2>Simpler, much simpler concept. A process with this token is

690
00:33:18.319 --> 00:33:20.640
<v Speaker 2>blocked from writing to most things, but can usually still

691
00:33:20.680 --> 00:33:25.359
<v Speaker 2>read and execute introduced in XPSP two for hardening services.

692
00:33:25.480 --> 00:33:27.279
<v Speaker 1>Easier but maybe less secure.

693
00:33:27.480 --> 00:33:30.599
<v Speaker 2>Potentially the source nodes a compromise. Process could still read

694
00:33:30.640 --> 00:33:32.400
<v Speaker 2>sensitive files even if it can't write them.

695
00:33:32.440 --> 00:33:35.680
<v Speaker 1>It's a trade off read okay, right blocked, got it

696
00:33:36.559 --> 00:33:37.680
<v Speaker 1>and low box tokens.

697
00:33:38.039 --> 00:33:40.319
<v Speaker 2>The source doesn't detail them much here, but they're a

698
00:33:40.359 --> 00:33:43.799
<v Speaker 2>newer type often used with app containers. For UWP apps

699
00:33:44.039 --> 00:33:48.960
<v Speaker 2>even more restrictive focus on deep isolation following least privilege principles.

700
00:33:48.440 --> 00:33:52.799
<v Speaker 1>So different levels of sandboxing available via tokens. Shifting topics,

701
00:33:53.319 --> 00:33:58.640
<v Speaker 1>administrator privileges if not just one root SID in Windows.

702
00:33:57.880 --> 00:34:01.799
<v Speaker 2>Definitely not being an administray is more nuanced. It's a

703
00:34:01.799 --> 00:34:05.319
<v Speaker 2>combination of things, usually membership in the builty in administrators

704
00:34:05.319 --> 00:34:08.360
<v Speaker 2>group sid s one five thirty two five four four

705
00:34:08.760 --> 00:34:12.199
<v Speaker 2>that group having powerful permissions granted on resources, and the

706
00:34:12.280 --> 00:34:16.320
<v Speaker 2>token possessing certain key privileges. Which privileges are typically admin

707
00:34:16.440 --> 00:34:19.280
<v Speaker 2>level things like c create token privilege, make new tokens,

708
00:34:19.320 --> 00:34:22.719
<v Speaker 2>CTB privilege act as part of the OS extremely powerful

709
00:34:22.840 --> 00:34:27.079
<v Speaker 2>cetic ownership privilege, ce load driver privilege see a HEP privilege,

710
00:34:27.119 --> 00:34:30.280
<v Speaker 2>SARAH store privilege see the bug privilege, access any processes

711
00:34:30.360 --> 00:34:35.000
<v Speaker 2>memory see impersonate privilege. Having these indicates administrative capability and.

712
00:34:34.920 --> 00:34:37.519
<v Speaker 1>The source mentioned elevated sids based.

713
00:34:37.239 --> 00:34:41.360
<v Speaker 2>On the RA yeah kind of kernel shortcut for certain checks.

714
00:34:41.440 --> 00:34:45.159
<v Speaker 2>Instead of looking for specific well known sids, the kernel

715
00:34:45.239 --> 00:34:48.079
<v Speaker 2>just checks the last number the RID. If it's say

716
00:34:48.159 --> 00:34:51.480
<v Speaker 2>five hundred and forty four administrators RID or five forty

717
00:34:51.480 --> 00:34:54.480
<v Speaker 2>five users RID, it treats it as having that role

718
00:34:54.519 --> 00:34:55.639
<v Speaker 2>in certain contexts.

719
00:34:55.719 --> 00:34:58.960
<v Speaker 1>Interesting pattern matching, okay. User count control UAC and elevation

720
00:34:59.039 --> 00:34:59.760
<v Speaker 1>the pop up boxes.

721
00:34:59.760 --> 00:35:03.440
<v Speaker 2>We are right. UAC aims to have even administrators run

722
00:35:03.480 --> 00:35:06.079
<v Speaker 2>with standard user rights by default. When you need to

723
00:35:06.119 --> 00:35:10.039
<v Speaker 2>do something requiring admin rights, UAC prompts for consent. If

724
00:35:10.079 --> 00:35:12.679
<v Speaker 2>you give it, the task runs elevated with your full

725
00:35:12.679 --> 00:35:14.000
<v Speaker 2>administrator token.

726
00:35:13.880 --> 00:35:16.440
<v Speaker 1>And apps can request elevation automatically.

727
00:35:16.000 --> 00:35:18.880
<v Speaker 2>True their manifest file Yeah, an XML file embedded in

728
00:35:18.880 --> 00:35:22.239
<v Speaker 2>the dot ex get executable manifest shows it. It specifies

729
00:35:22.239 --> 00:35:26.639
<v Speaker 2>an execution level as invoker, run as caller, highest available,

730
00:35:26.760 --> 00:35:29.039
<v Speaker 2>run elevated if possible or required.

731
00:35:29.039 --> 00:35:32.599
<v Speaker 3>Administrator must elevate and how do you manually elevate something?

732
00:35:32.760 --> 00:35:36.360
<v Speaker 2>Start processed after verb runas in PowerShell or using the

733
00:35:36.360 --> 00:35:39.440
<v Speaker 2>shell execute API with the runa's verb both trigger the

734
00:35:39.480 --> 00:35:40.599
<v Speaker 2>UAC prompt if needed.

735
00:35:40.719 --> 00:35:43.079
<v Speaker 1>Okay, link tokens and elevation type. What's that?

736
00:35:43.440 --> 00:35:47.079
<v Speaker 2>When an admin logs in UAC actually creates two tokens,

737
00:35:47.280 --> 00:35:50.320
<v Speaker 2>a standard limited one and the full admin one, they're linked.

738
00:35:50.920 --> 00:35:53.519
<v Speaker 2>Elevation is the process of switching from the limited token

739
00:35:53.559 --> 00:35:55.639
<v Speaker 2>to the full one for a specific task.

740
00:35:56.239 --> 00:36:00.719
<v Speaker 1>After UAC consent, split tokens one limited one full makes sense?

741
00:36:00.760 --> 00:36:03.599
<v Speaker 1>Security attributes more data in tokens.

742
00:36:03.320 --> 00:36:06.360
<v Speaker 2>Yeah, Extra bits of info beyond sids and privileges can

743
00:36:06.400 --> 00:36:10.440
<v Speaker 2>be strings, numbers, sids, binary data. They add more context

744
00:36:10.519 --> 00:36:14.400
<v Speaker 2>for potentially finer grained access decisions, especially with conditional acees

745
00:36:15.039 --> 00:36:18.519
<v Speaker 2>can have flags like non inheritable, case sensitive new end

746
00:36:18.519 --> 00:36:21.880
<v Speaker 2>token can add them, but needs see create token privilege.

747
00:36:21.440 --> 00:36:24.920
<v Speaker 1>More context for decisions. Okay. Token assignment and impersonation criteria.

748
00:36:25.280 --> 00:36:28.679
<v Speaker 1>What rules apply when assigning or impersonating tokens.

749
00:36:28.320 --> 00:36:31.960
<v Speaker 2>Assigning a primary token if not inherited, needs assigned primary

750
00:36:32.000 --> 00:36:34.960
<v Speaker 2>access on the token. Kernel checks integrity levels, log on

751
00:36:35.000 --> 00:36:38.800
<v Speaker 2>session relationships. Impersonation is more complex see token can impersonate

752
00:36:38.800 --> 00:36:42.880
<v Speaker 2>function check's integrity levels, can't impersonate higher privileges See impersonate

753
00:36:42.920 --> 00:36:47.599
<v Speaker 2>Privilege often needed UPI flags, log on sessions, user sids.

754
00:36:47.119 --> 00:36:49.840
<v Speaker 1>And the system account gets special treatment big.

755
00:36:49.639 --> 00:36:53.440
<v Speaker 2>Time because user log on sessions ultimately derive from the

756
00:36:53.480 --> 00:36:57.840
<v Speaker 2>initial system session. System can basically impersonate any user token

757
00:36:58.039 --> 00:37:01.599
<v Speaker 2>of equal or lower integrity, even without seeing person at privilege.

758
00:37:01.639 --> 00:37:03.320
<v Speaker 2>It's implicitly trusted in that way.

759
00:37:03.400 --> 00:37:07.440
<v Speaker 1>Wow. System is powerful and Windows ten added a check

760
00:37:07.480 --> 00:37:09.159
<v Speaker 1>for the elevated flag.

761
00:37:09.079 --> 00:37:12.239
<v Speaker 2>Right before wind ten. You could potentially impersonate and admin's

762
00:37:12.239 --> 00:37:15.320
<v Speaker 2>elevated token if you first lowered its integrity level. Win

763
00:37:15.400 --> 00:37:18.920
<v Speaker 2>ten added a check you can't impersonate the elevated token

764
00:37:18.960 --> 00:37:22.159
<v Speaker 2>of the same user if your current token isn't also elevated,

765
00:37:22.639 --> 00:37:23.880
<v Speaker 2>closed a potential loophole.

766
00:37:23.960 --> 00:37:28.719
<v Speaker 1>Good hardening step and test antoken impersonation checks if impersonation.

767
00:37:28.199 --> 00:37:30.840
<v Speaker 2>Is allowed YEP, and set antoken integrity level lets you

768
00:37:30.960 --> 00:37:33.440
<v Speaker 2>change integrity levels. Useful for testing these rules.

769
00:37:33.519 --> 00:37:36.840
<v Speaker 1>Okay? Finding UI access processes? What are they and why

770
00:37:36.920 --> 00:37:37.400
<v Speaker 1>look for them?

771
00:37:37.559 --> 00:37:40.639
<v Speaker 2>Processes with the UI Access's flag set in their token

772
00:37:40.719 --> 00:37:43.800
<v Speaker 2>can bypass some UIPI restrictions. They can send messages to

773
00:37:43.880 --> 00:37:48.480
<v Speaker 2>higher privileged windows, needed for things like screen readers, accessibility.

774
00:37:47.760 --> 00:37:50.119
<v Speaker 1>Tools, but potentially risky if nowhere gets.

775
00:37:49.880 --> 00:37:52.800
<v Speaker 2>It exactly, so finding them is useful. The source shows

776
00:37:52.800 --> 00:37:56.079
<v Speaker 2>get and process with excess query limited information and a

777
00:37:56.119 --> 00:38:00.639
<v Speaker 2>filterscript checkingtoken dot UI access to list them identifies processes

778
00:38:00.679 --> 00:38:03.760
<v Speaker 2>with that special UI interaction capability.

779
00:38:03.280 --> 00:38:06.920
<v Speaker 1>Good to note okay. Final major topic security descriptors the

780
00:38:06.960 --> 00:38:08.639
<v Speaker 1>actual rules. What are the components?

781
00:38:08.760 --> 00:38:12.440
<v Speaker 2>Four main parts Owner SID, who controls the permissions Group

782
00:38:12.599 --> 00:38:16.480
<v Speaker 2>SID mostly for POSTX compatibility less used in Windows, access checks,

783
00:38:16.920 --> 00:38:22.119
<v Speaker 2>DACL Discretionary Access Control List, and SACL System Access Control List.

784
00:38:22.159 --> 00:38:24.440
<v Speaker 1>DCL is where the allowed NY rules live exactly.

785
00:38:24.559 --> 00:38:27.639
<v Speaker 2>It's a list of AC's access control entries. Each AC

786
00:38:27.719 --> 00:38:30.760
<v Speaker 2>says six gets allowed to I access Y. The acess

787
00:38:30.800 --> 00:38:34.960
<v Speaker 2>mask Y details the specific permissions and the SECL primarily

788
00:38:35.000 --> 00:38:37.400
<v Speaker 2>for auditing ACS. There say a log an event if

789
00:38:37.480 --> 00:38:40.440
<v Speaker 2>SidD X tries axs Y and succeeds fails. Since Vista,

790
00:38:40.480 --> 00:38:44.199
<v Speaker 2>it also holds mandatory integrity lobles, non auditing, ACEES.

791
00:38:43.719 --> 00:38:48.679
<v Speaker 3>Owner group, DACL, SACL, got it well known sad's predefined

792
00:38:48.719 --> 00:38:55.440
<v Speaker 3>identifiers YEP, consistent across systems, NL, SID, everyone, WD, local

793
00:38:55.679 --> 00:38:57.039
<v Speaker 3>creator owner, built in.

794
00:38:57.119 --> 00:39:02.719
<v Speaker 2>Users BU system sy administrators B authenticated users AU medium

795
00:39:02.760 --> 00:39:05.760
<v Speaker 2>mandatory level lots of them. They have a structure revision

796
00:39:05.800 --> 00:39:10.559
<v Speaker 2>authority like NT authority five. Then relative identifiers built in

797
00:39:10.639 --> 00:39:13.320
<v Speaker 2>users is S one five thirty two five forty five

798
00:39:13.360 --> 00:39:16.480
<v Speaker 2>authority five RIDE thirty two for builton domain ride five

799
00:39:16.599 --> 00:39:17.920
<v Speaker 2>forty five for users group.

800
00:39:18.000 --> 00:39:22.400
<v Speaker 1>Hierarchical structure access control lists ACLS. The DACL and SACL

801
00:39:22.679 --> 00:39:23.440
<v Speaker 1>are types of these.

802
00:39:23.559 --> 00:39:26.960
<v Speaker 2>Structure simple header revision size followed by the list of ACS.

803
00:39:27.079 --> 00:39:30.000
<v Speaker 2>Revision tells you the ACL version two, three four commonly, and.

804
00:39:29.960 --> 00:39:32.519
<v Speaker 1>The access control entries acees themselves.

805
00:39:32.079 --> 00:39:35.440
<v Speaker 2>ACE header type, flag size, and type specific data. For

806
00:39:35.519 --> 00:39:37.960
<v Speaker 2>standard loagenie acees, the data is the SID and the

807
00:39:38.000 --> 00:39:41.840
<v Speaker 2>access mask. Many types allow deny audit callback object ACS

808
00:39:41.920 --> 00:39:44.159
<v Speaker 2>for property specific permissions.

809
00:39:43.599 --> 00:39:46.039
<v Speaker 1>And AC flags modified behavior.

810
00:39:45.719 --> 00:39:49.559
<v Speaker 2>Right inherently inherited from parent. Critical successful access, failed access

811
00:39:49.559 --> 00:39:51.480
<v Speaker 2>for auditing, fine grained control okay.

812
00:39:51.599 --> 00:39:54.559
<v Speaker 1>Constructing and viewing security descriptors with PowerShell.

813
00:39:54.239 --> 00:39:57.519
<v Speaker 2>New n Security Descriptor lets you build one setting owner group,

814
00:39:57.599 --> 00:40:00.599
<v Speaker 2>adding ACS format and security discret Victor is key for

815
00:40:00.679 --> 00:40:05.599
<v Speaker 2>viewing shows owner group, DAC l ACS sec LACS clearly

816
00:40:06.119 --> 00:40:08.559
<v Speaker 2>use show all and map generic for more detail and

817
00:40:08.559 --> 00:40:12.599
<v Speaker 2>friendly permission names also shows control flex for the sd itself.

818
00:40:12.400 --> 00:40:16.760
<v Speaker 1>Powerful Inspection Tools Security Descriptor Definition Language SDDL.

819
00:40:17.079 --> 00:40:19.559
<v Speaker 2>The text format yeah much easier to read, write and

820
00:40:19.599 --> 00:40:24.039
<v Speaker 2>store than binary blobs. Get NTCID. SDDL converts a SID

821
00:40:24.159 --> 00:40:28.519
<v Speaker 2>to its SDDL string. Has aliases like wd BA, s y,

822
00:40:28.679 --> 00:40:31.599
<v Speaker 2>A U, i U for well known sids, human.

823
00:40:31.440 --> 00:40:36.079
<v Speaker 1>Readable security descriptors and conditional expressions in SDDL for dynamic rules.

824
00:40:35.920 --> 00:40:38.960
<v Speaker 2>Exactly ACS that only apply if conditions based on security

825
00:40:38.960 --> 00:40:41.199
<v Speaker 2>attributes in the token or on the resource are met

826
00:40:41.239 --> 00:40:45.719
<v Speaker 2>at access time. Use attributes like token, integrity level, TI, user, SID, TU,

827
00:40:45.880 --> 00:40:49.280
<v Speaker 2>device properties, et cetera. Uses operators like containers and errata

828
00:40:49.320 --> 00:40:51.280
<v Speaker 2>adds huge flexibility.

829
00:40:50.719 --> 00:40:54.440
<v Speaker 1>Context where access control cool Finally brute forcing known sids

830
00:40:54.440 --> 00:40:55.400
<v Speaker 1>with get account sids.

831
00:40:55.719 --> 00:40:59.440
<v Speaker 2>How why the function takes a base SID like S

832
00:40:59.480 --> 00:41:02.719
<v Speaker 2>one five for NT authority and a range of IDs

833
00:41:03.280 --> 00:41:07.039
<v Speaker 2>it tries. Each ried constructs the full SID and attempts

834
00:41:07.079 --> 00:41:09.800
<v Speaker 2>to look up the account name. If it finds a

835
00:41:09.880 --> 00:41:13.960
<v Speaker 2>name from the local system LSS, it means that SID exists.

836
00:41:14.079 --> 00:41:16.880
<v Speaker 1>So you can discover accounts by iterating rids YEP.

837
00:41:17.239 --> 00:41:19.480
<v Speaker 2>Useful for mapping out all the built in accounts and

838
00:41:19.519 --> 00:41:21.840
<v Speaker 2>groups under S one five or S one five thirty

839
00:41:21.880 --> 00:41:25.599
<v Speaker 2>two built in as the example shows a discovery technique.

840
00:41:25.360 --> 00:41:29.119
<v Speaker 1>A systematic way to find existing principles. Wow, that brings

841
00:41:29.159 --> 00:41:31.639
<v Speaker 1>us to the end of this really really deep dive.

842
00:41:31.760 --> 00:41:34.440
<v Speaker 2>It certainly covered a lot of ground, from setting up PowerShell,

843
00:41:34.480 --> 00:41:38.159
<v Speaker 2>the language basics all the way down into kernel objects, handles, tokens,

844
00:41:38.199 --> 00:41:41.400
<v Speaker 2>security descriptors. It's intricate stuff, it really is.

845
00:41:41.679 --> 00:41:44.079
<v Speaker 1>But it's amazing how PowerShell, especially with modules like the

846
00:41:44.079 --> 00:41:47.159
<v Speaker 1>one discussed in the source, lets you interact with and

847
00:41:48.199 --> 00:41:51.559
<v Speaker 1>really understand these core window security mechanisms.

848
00:41:51.599 --> 00:41:54.000
<v Speaker 2>Absolutely it pulls back the curtain and having gone through

849
00:41:54.000 --> 00:41:56.239
<v Speaker 2>this gives you a fantastic foundation. You know, you can

850
00:41:56.280 --> 00:42:00.880
<v Speaker 2>now dig deeper into specific areas process security, privileged management, ecls,

851
00:42:00.920 --> 00:42:03.559
<v Speaker 2>on specific objects, whatever interests you or is relevant to

852
00:42:03.599 --> 00:42:04.039
<v Speaker 2>your work.

853
00:42:04.360 --> 00:42:07.079
<v Speaker 1>Definitely, powershow really is the key to unlocking a lot

854
00:42:07.119 --> 00:42:07.280
<v Speaker 1>of this.

855
00:42:07.559 --> 00:42:09.800
<v Speaker 2>It provides the tools to explore as far as you

856
00:42:09.840 --> 00:42:10.239
<v Speaker 2>want to go.

857
00:42:10.519 --> 00:42:13.119
<v Speaker 1>So the final thought to leave you with knowing just

858
00:42:13.159 --> 00:42:17.960
<v Speaker 1>how granularly Windows controls access down to individual permissions and attributes.

859
00:42:18.639 --> 00:42:21.960
<v Speaker 1>What are some maybe unexpected ways this might impact application

860
00:42:22.039 --> 00:42:26.199
<v Speaker 1>behavior or security configurations you see every day. Certainly gives

861
00:42:26.239 --> 00:42:28.079
<v Speaker 1>you a new perspective. Thanks for joining us on this

862
00:42:28.159 --> 00:42:28.639
<v Speaker 1>deep dive
