-
Notifications
You must be signed in to change notification settings - Fork 1
/
DCOMPermissions.psm1
984 lines (880 loc) · 51.5 KB
/
DCOMPermissions.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
<#
VERSION DATE AUTHOR
1.0.09 2017-09-15 Tony Pombo
- Initial Release
1.1.03 2017-09-22 Tony Pombo
- Replaced localized English names with SIDs
- Minor code cleanup
#> # Revision History
#Requires -Version 4.0
Set-StrictMode -Version 2.0
$ACL_REVISION = 2
$COM_RIGHTS_EXECUTE = 1
$COM_RIGHTS_EXECUTE_LOCAL = 2
$COM_RIGHTS_EXECUTE_REMOTE = 4
$COM_RIGHTS_ACTIVATE_LOCAL = 8
$COM_RIGHTS_ACTIVATE_REMOTE = 16
$Admins_SID = [System.Security.Principal.SecurityIdentifier]"S-1-5-32-544"
$System_SID = [System.Security.Principal.SecurityIdentifier]"S-1-5-18"
# The code for: Add-Type, Grant-TokenPrivilege, Revoke-TokenPrivilege
# is a subset of the "Grant, Revoke, Query user rights (privileges) using PowerShell" v1.3.1
# script available at https://gallery.technet.microsoft.com/Grant-Revoke-Query-user-26e259b0
Add-Type @'
using System;
namespace PS_LSA
{
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security;
public enum Rights
{
SeTrustedCredManAccessPrivilege, // Access Credential Manager as a trusted caller
SeNetworkLogonRight, // Access this computer from the network
SeTcbPrivilege, // Act as part of the operating system
SeMachineAccountPrivilege, // Add workstations to domain
SeIncreaseQuotaPrivilege, // Adjust memory quotas for a process
SeInteractiveLogonRight, // Allow log on locally
SeRemoteInteractiveLogonRight, // Allow log on through Remote Desktop Services
SeBackupPrivilege, // Back up files and directories
SeChangeNotifyPrivilege, // Bypass traverse checking
SeSystemtimePrivilege, // Change the system time
SeTimeZonePrivilege, // Change the time zone
SeCreatePagefilePrivilege, // Create a pagefile
SeCreateTokenPrivilege, // Create a token object
SeCreateGlobalPrivilege, // Create global objects
SeCreatePermanentPrivilege, // Create permanent shared objects
SeCreateSymbolicLinkPrivilege, // Create symbolic links
SeDebugPrivilege, // Debug programs
SeDenyNetworkLogonRight, // Deny access this computer from the network
SeDenyBatchLogonRight, // Deny log on as a batch job
SeDenyServiceLogonRight, // Deny log on as a service
SeDenyInteractiveLogonRight, // Deny log on locally
SeDenyRemoteInteractiveLogonRight, // Deny log on through Remote Desktop Services
SeEnableDelegationPrivilege, // Enable computer and user accounts to be trusted for delegation
SeRemoteShutdownPrivilege, // Force shutdown from a remote system
SeAuditPrivilege, // Generate security audits
SeImpersonatePrivilege, // Impersonate a client after authentication
SeIncreaseWorkingSetPrivilege, // Increase a process working set
SeIncreaseBasePriorityPrivilege, // Increase scheduling priority
SeLoadDriverPrivilege, // Load and unload device drivers
SeLockMemoryPrivilege, // Lock pages in memory
SeBatchLogonRight, // Log on as a batch job
SeServiceLogonRight, // Log on as a service
SeSecurityPrivilege, // Manage auditing and security log
SeRelabelPrivilege, // Modify an object label
SeSystemEnvironmentPrivilege, // Modify firmware environment values
SeManageVolumePrivilege, // Perform volume maintenance tasks
SeProfileSingleProcessPrivilege, // Profile single process
SeSystemProfilePrivilege, // Profile system performance
SeUnsolicitedInputPrivilege, // "Read unsolicited input from a terminal device"
SeUndockPrivilege, // Remove computer from docking station
SeAssignPrimaryTokenPrivilege, // Replace a process level token
SeRestorePrivilege, // Restore files and directories
SeShutdownPrivilege, // Shut down the system
SeSyncAgentPrivilege, // Synchronize directory service data
SeTakeOwnershipPrivilege // Take ownership of files or other objects
}
public sealed class TokenManipulator
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal sealed class Win32Token
{
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(
IntPtr htok,
bool disall,
ref TokPriv1Luid newst,
int len,
IntPtr prev,
IntPtr relen
);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(
IntPtr h,
int acc,
ref IntPtr phtok
);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(
string host,
string name,
ref long pluid
);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern bool CloseHandle(
IntPtr phtok
);
}
public static void AddPrivilege(Rights privilege)
{
bool retVal;
int lasterror;
TokPriv1Luid tp;
IntPtr hproc = Win32Token.GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
retVal = Win32Token.OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
retVal = Win32Token.LookupPrivilegeValue(null, privilege.ToString(), ref tp.Luid);
retVal = Win32Token.AdjustTokenPrivileges(htok, false, ref tp, Marshal.SizeOf(tp), IntPtr.Zero, IntPtr.Zero);
Win32Token.CloseHandle(htok);
lasterror = Marshal.GetLastWin32Error();
if (lasterror != 0) throw new Win32Exception();
}
public static void RemovePrivilege(Rights privilege)
{
bool retVal;
int lasterror;
TokPriv1Luid tp;
IntPtr hproc = Win32Token.GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
retVal = Win32Token.OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_DISABLED;
retVal = Win32Token.LookupPrivilegeValue(null, privilege.ToString(), ref tp.Luid);
retVal = Win32Token.AdjustTokenPrivileges(htok, false, ref tp, Marshal.SizeOf(tp), IntPtr.Zero, IntPtr.Zero);
Win32Token.CloseHandle(htok);
lasterror = Marshal.GetLastWin32Error();
if (lasterror != 0) throw new Win32Exception();
}
}
}
'@ # This type is used by Grant-TokenPriviledge, Revoke-TokenPrivilege
function Grant-TokenPrivilege {
<#
.SYNOPSIS
Enables privileges in the current process token.
.DESCRIPTION
Enables one or more privileges for the current process token. If a privilege cannot be enabled, an exception is thrown.
.PARAMETER Privilege
Name of the privilege to enable. More than one privilege may be listed.
Possible values:
SeTrustedCredManAccessPrivilege Access Credential Manager as a trusted caller
SeNetworkLogonRight Access this computer from the network
SeTcbPrivilege Act as part of the operating system
SeMachineAccountPrivilege Add workstations to domain
SeIncreaseQuotaPrivilege Adjust memory quotas for a process
SeInteractiveLogonRight Allow log on locally
SeRemoteInteractiveLogonRight Allow log on through Remote Desktop Services
SeBackupPrivilege Back up files and directories
SeChangeNotifyPrivilege Bypass traverse checking
SeSystemtimePrivilege Change the system time
SeTimeZonePrivilege Change the time zone
SeCreatePagefilePrivilege Create a pagefile
SeCreateTokenPrivilege Create a token object
SeCreateGlobalPrivilege Create global objects
SeCreatePermanentPrivilege Create permanent shared objects
SeCreateSymbolicLinkPrivilege Create symbolic links
SeDebugPrivilege Debug programs
SeDenyNetworkLogonRight Deny access this computer from the network
SeDenyBatchLogonRight Deny log on as a batch job
SeDenyServiceLogonRight Deny log on as a service
SeDenyInteractiveLogonRight Deny log on locally
SeDenyRemoteInteractiveLogonRight Deny log on through Remote Desktop Services
SeEnableDelegationPrivilege Enable computer and user accounts to be trusted for delegation
SeRemoteShutdownPrivilege Force shutdown from a remote system
SeAuditPrivilege Generate security audits
SeImpersonatePrivilege Impersonate a client after authentication
SeIncreaseWorkingSetPrivilege Increase a process working set
SeIncreaseBasePriorityPrivilege Increase scheduling priority
SeLoadDriverPrivilege Load and unload device drivers
SeLockMemoryPrivilege Lock pages in memory
SeBatchLogonRight Log on as a batch job
SeServiceLogonRight Log on as a service
SeSecurityPrivilege Manage auditing and security log
SeRelabelPrivilege Modify an object label
SeSystemEnvironmentPrivilege Modify firmware environment values
SeManageVolumePrivilege Perform volume maintenance tasks
SeProfileSingleProcessPrivilege Profile single process
SeSystemProfilePrivilege Profile system performance
SeUnsolicitedInputPrivilege "Read unsolicited input from a terminal device"
SeUndockPrivilege Remove computer from docking station
SeAssignPrimaryTokenPrivilege Replace a process level token
SeRestorePrivilege Restore files and directories
SeShutdownPrivilege Shut down the system
SeSyncAgentPrivilege Synchronize directory service data
SeTakeOwnershipPrivilege Take ownership of files or other objects
.EXAMPLE
Grant-TokenPrivilege SeIncreaseWorkingSetPrivilege
Enables the "Increase a process working set" privilege for the current process.
.INPUTS
PS_LSA.Rights Right
.OUTPUTS
None
.LINK
http://msdn.microsoft.com/en-us/library/aa375202.aspx
http://msdn.microsoft.com/en-us/library/bb530716.aspx
#>
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)]
[Alias('Right')] [PS_LSA.Rights[]] $Privilege
)
process {
foreach ($Priv in $Privilege) {
try { [PS_LSA.TokenManipulator]::AddPrivilege($Priv) }
catch [System.ComponentModel.Win32Exception] {
throw New-Object System.ComponentModel.Win32Exception("$($_.Exception.Message) ($Priv)", $_.Exception)
}
}
}
} # Enables privileges in the current process token
function Revoke-TokenPrivilege {
<#
.SYNOPSIS
Disables privileges in the current process token.
.DESCRIPTION
Disables one or more privileges for the current process token. If a privilege cannot be disabled, an exception is thrown.
.PARAMETER Privilege
Name of the privilege to disable. More than one privilege may be listed.
Possible values:
SeTrustedCredManAccessPrivilege Access Credential Manager as a trusted caller
SeNetworkLogonRight Access this computer from the network
SeTcbPrivilege Act as part of the operating system
SeMachineAccountPrivilege Add workstations to domain
SeIncreaseQuotaPrivilege Adjust memory quotas for a process
SeInteractiveLogonRight Allow log on locally
SeRemoteInteractiveLogonRight Allow log on through Remote Desktop Services
SeBackupPrivilege Back up files and directories
SeChangeNotifyPrivilege Bypass traverse checking
SeSystemtimePrivilege Change the system time
SeTimeZonePrivilege Change the time zone
SeCreatePagefilePrivilege Create a pagefile
SeCreateTokenPrivilege Create a token object
SeCreateGlobalPrivilege Create global objects
SeCreatePermanentPrivilege Create permanent shared objects
SeCreateSymbolicLinkPrivilege Create symbolic links
SeDebugPrivilege Debug programs
SeDenyNetworkLogonRight Deny access this computer from the network
SeDenyBatchLogonRight Deny log on as a batch job
SeDenyServiceLogonRight Deny log on as a service
SeDenyInteractiveLogonRight Deny log on locally
SeDenyRemoteInteractiveLogonRight Deny log on through Remote Desktop Services
SeEnableDelegationPrivilege Enable computer and user accounts to be trusted for delegation
SeRemoteShutdownPrivilege Force shutdown from a remote system
SeAuditPrivilege Generate security audits
SeImpersonatePrivilege Impersonate a client after authentication
SeIncreaseWorkingSetPrivilege Increase a process working set
SeIncreaseBasePriorityPrivilege Increase scheduling priority
SeLoadDriverPrivilege Load and unload device drivers
SeLockMemoryPrivilege Lock pages in memory
SeBatchLogonRight Log on as a batch job
SeServiceLogonRight Log on as a service
SeSecurityPrivilege Manage auditing and security log
SeRelabelPrivilege Modify an object label
SeSystemEnvironmentPrivilege Modify firmware environment values
SeManageVolumePrivilege Perform volume maintenance tasks
SeProfileSingleProcessPrivilege Profile single process
SeSystemProfilePrivilege Profile system performance
SeUnsolicitedInputPrivilege "Read unsolicited input from a terminal device"
SeUndockPrivilege Remove computer from docking station
SeAssignPrimaryTokenPrivilege Replace a process level token
SeRestorePrivilege Restore files and directories
SeShutdownPrivilege Shut down the system
SeSyncAgentPrivilege Synchronize directory service data
SeTakeOwnershipPrivilege Take ownership of files or other objects
.EXAMPLE
Revoke-TokenPrivilege SeIncreaseWorkingSetPrivilege
Disables the "Increase a process working set" privilege for the current process.
.INPUTS
PS_LSA.Rights Right
.OUTPUTS
None
.LINK
http://msdn.microsoft.com/en-us/library/aa375202.aspx
http://msdn.microsoft.com/en-us/library/bb530716.aspx
#>
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)]
[Alias('Right')] [PS_LSA.Rights[]] $Privilege
)
process {
foreach ($Priv in $Privilege) {
try { [PS_LSA.TokenManipulator]::RemovePrivilege($Priv) }
catch [System.ComponentModel.Win32Exception] {
throw New-Object System.ComponentModel.Win32Exception("$($_.Exception.Message) ($Priv)", $_.Exception)
}
}
}
} # Disables privileges in the current process token
function Get-DComPermission {
<#
.SYNOPSIS
Gets DCOM Permissions for a specified Application ID
.DESCRIPTION
Retrieves either the "Access Permissions" or "Launch and Activation Permissions" for a specified Application ID
.PARAMETER ApplicationID
The Application ID for the DCOM object
.PARAMETER Type
Indicates which type of permissions to retrieve
Valid options: Launch, Access
.EXAMPLE
Get-DCOMPermission -ApplicationID "{9CA88EE3-ACB7-47C8-AFC4-AB702511C276}" -Type Launch
.INPUTS
String ApplicationID
String Type
.OUTPUTS
String ApplicationID
String Type
String[] Access
Int AccessMask
System.Security.Principal.SecurityIdentifier SID
String Name
#>
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)]
[Alias("APPID")] [string[]] $ApplicationID,
[Parameter(Position=1, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[ValidateSet("Launch","Access")] [string] $Type
)
begin {
$ErrorActionPreference = "Stop"
New-PSDrive -PSProvider Registry -Root HKEY_CLASSES_ROOT -Name HKCR -Scope Local -ErrorAction SilentlyContinue | Out-Null
}
process {
foreach ($APPID in $ApplicationID) {
Write-Verbose "Getting registry value HKCR:\AppID\$APPID\$($Type)Permission"
$regkey = Get-Item -Path "HKCR:\AppID\$APPID"
try {
$reg_perms = ($regkey | Get-ItemProperty -Name "$($Type)Permission")."$($Type)Permission"
} catch {
if ($_.Exception.Message -match "Property $($Type)Permission does not exist") {
return "Default $Type permissions are inherited for $APPID"
} else {throw $_ }
}
$sd = New-Object System.Security.AccessControl.RawSecurityDescriptor($reg_perms, 0)
foreach ($ace in $sd.DiscretionaryAcl) {
Write-Verbose "Working on $($ace.SecurityIdentifier)"
try { $User = (($ace.SecurityIdentifier).Translate([System.Security.Principal.NTAccount])).Value }
catch { Write-Warning "Unable to map SID to name. $($ace.SecurityIdentifier)" ; $User=$null }
$access = @()
if ($Type -eq "Launch") {
if ( ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_LOCAL) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band ($COM_RIGHTS_EXECUTE_REMOTE -bor
$COM_RIGHTS_ACTIVATE_REMOTE -bor
$COM_RIGHTS_ACTIVATE_LOCAL))) ) { $access += "LocalLaunch" }
if ( ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_REMOTE) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band ($COM_RIGHTS_EXECUTE_LOCAL -bor
$COM_RIGHTS_ACTIVATE_REMOTE -bor
$COM_RIGHTS_ACTIVATE_LOCAL))) ) { $access += "RemoteLaunch" }
if ( ($ace.AccessMask -band $COM_RIGHTS_ACTIVATE_LOCAL) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band ($COM_RIGHTS_EXECUTE_LOCAL -bor
$COM_RIGHTS_EXECUTE_REMOTE -bor
$COM_RIGHTS_ACTIVATE_REMOTE))) ) { $access += "LocalActivation" }
if ( ($ace.AccessMask -band $COM_RIGHTS_ACTIVATE_REMOTE) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band ($COM_RIGHTS_EXECUTE_LOCAL -bor
$COM_RIGHTS_EXECUTE_REMOTE -bor
$COM_RIGHTS_ACTIVATE_LOCAL))) ) { $access += "RemoteActivation" }
} else {
if ( ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_LOCAL) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_REMOTE)) ) { $access += "LocalAccess" }
if ( ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_REMOTE) -or
(($ace.AccessMask -band $COM_RIGHTS_EXECUTE) -and
-not ($ace.AccessMask -band $COM_RIGHTS_EXECUTE_LOCAL)) ) { $access += "RemoteAccess" }
}
New-Object -TypeName PSObject -Property @{
"ApplicationID" = $APPID
"Type" = $ace.AceType ;
"Access" = $access ;
"AccessMask" = $ace.AccessMask ;
"SID" = $ace.SecurityIdentifier ;
"Name" = $User
}
}
}
}
}
function Grant-DComPermissionInternal {
param(
[string] $ApplicationID,
[string] $Type,
[System.Security.Principal.SecurityIdentifier] $SID,
[string[]] $Permissions,
[System.Security.AccessControl.AceType] $AceType,
[Switch] $PassThru
)
New-PSDrive -PSProvider Registry -Root HKEY_CLASSES_ROOT -Name HKCR -Scope Local -ErrorAction SilentlyContinue | Out-Null
Write-Verbose "Getting registry value responsible for COM security"
$regkey = Get-Item -Path "HKCR:\AppID\$ApplicationID"
try {
$reg_perms = ($regkey | Get-ItemProperty -Name "$($Type)Permission")."$($Type)Permission"
$sd = New-Object System.Security.AccessControl.RawSecurityDescriptor($reg_perms, 0)
} catch {
Write-Verbose "Replacing default permissions with new security descriptor"
$sd = New-Object System.Security.AccessControl.RawSecurityDescriptor(
([System.Security.AccessControl.ControlFlags]::DiscretionaryAclPresent -bor
[System.Security.AccessControl.ControlFlags]::SelfRelative),
$System_SID, $System_SID, $null,
$(New-Object System.Security.AccessControl.RawAcl($ACL_REVISION,1)) )
}
Write-Verbose "Determining new ACE properties"
$AccessMask = $COM_RIGHTS_EXECUTE
if ($Permissions -contains "ALL") {
if ($Type -eq "Launch") { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_LOCAL -bor $COM_RIGHTS_EXECUTE_REMOTE -bor $COM_RIGHTS_ACTIVATE_LOCAL -bor $COM_RIGHTS_ACTIVATE_REMOTE }
else { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_LOCAL -bor $COM_RIGHTS_EXECUTE_REMOTE }
} else {
if ($Permissions -contains "LocalLaunch") { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_LOCAL }
if ($Permissions -contains "RemoteLaunch") { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_REMOTE }
if ($Permissions -contains "LocalActivation") { $AccessMask = $AccessMask -bor $COM_RIGHTS_ACTIVATE_LOCAL }
if ($Permissions -contains "RemoteActivation") { $AccessMask = $AccessMask -bor $COM_RIGHTS_ACTIVATE_REMOTE }
if ($Permissions -contains "LocalAccess") { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_LOCAL }
if ($Permissions -contains "RemoteAccess") { $AccessMask = $AccessMask -bor $COM_RIGHTS_EXECUTE_REMOTE }
}
Write-Verbose "Searching for existing ACE for this user"
$acl = $sd.DiscretionaryAcl
$found = $false
foreach ($ace in $acl) {
if ($ace.SecurityIdentifier -eq $SID -and $ace.AceType -eq $AceType) {
$ace.AccessMask = $ace.AccessMask -bor $AccessMask
$found = $true
break
}
}
if (-not $found) {
Write-Verbose "Not found, creating new ACE entry"
$ace = New-Object System.Security.AccessControl.CommonAce(
[System.Security.AccessControl.AceFlags]::None,
[System.Security.AccessControl.AceQualifier]$AceType.value__,
$AccessMask, $SID, $false, $null)
if ($AceType -match "denied") { $acl.InsertAce(0, $ace) }
else { $acl.InsertAce($acl.Count, $ace) }
}
Write-Verbose "Convert to binary and save the ACL"
$sd.DiscretionaryAcl = $acl
$sdbytes = New-Object 'byte[]' $sd.BinaryLength
$sd.GetBinaryForm($sdbytes, 0)
$regkey | New-ItemProperty -Name "$($Type)Permission" -PropertyType Binary -Value $sdBytes -Force | Out-Null
if ($PassThru) { New-Object -TypeName PSObject -Property @{ "ApplicationID" = $ApplicationID ; "Type" = $Type } }
}
function Revoke-DComPermissionInternal {
param(
[string] $ApplicationID,
[string] $Type,
[System.Security.Principal.SecurityIdentifier] $SID,
[string[]] $Permissions,
[System.Security.AccessControl.AceType] $AceType,
[Switch] $PassThru
)
New-PSDrive -PSProvider Registry -Root HKEY_CLASSES_ROOT -Name HKCR -Scope Local -ErrorAction SilentlyContinue | Out-Null
Write-Verbose "Getting registry value responsible for COM security"
$regkey = Get-Item -Path "HKCR:\AppID\$ApplicationID"
try {
$reg_perms = ($regkey | Get-ItemProperty -Name "$($Type)Permission")."$($Type)Permission"
$sd = New-Object System.Security.AccessControl.RawSecurityDescriptor($reg_perms, 0)
} catch { Write-Warning "Using default permissions (no changes made)" ; return }
Write-Verbose "Searching for existing ACE for this user"
$acl = $sd.DiscretionaryAcl
$found = $false
for ($index=0 ; $index -lt $acl.Count; $index++) {
$ace = $acl[$index]
if ($ace.SecurityIdentifier -eq $SID -and $ace.AceType -eq $AceType) {
Write-Verbose "Found ACE for this user"
if ($Permissions -contains "LocalLaunch" -and $ace.AccessMask -band $COM_RIGHTS_EXECUTE_LOCAL)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_EXECUTE_LOCAL }
if ($Permissions -contains "RemoteLaunch" -and $ace.AccessMask -band $COM_RIGHTS_EXECUTE_REMOTE)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_EXECUTE_REMOTE }
if ($Permissions -contains "LocalActivation" -and $ace.AccessMask -band $COM_RIGHTS_ACTIVATE_LOCAL)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_ACTIVATE_LOCAL }
if ($Permissions -contains "RemoteActivation" -and $ace.AccessMask -band $COM_RIGHTS_ACTIVATE_REMOTE)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_ACTIVATE_REMOTE }
if ($Permissions -contains "LocalAccess" -and $ace.AccessMask -band $COM_RIGHTS_EXECUTE_LOCAL)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_EXECUTE_LOCAL }
if ($Permissions -contains "RemoteAccess" -and $ace.AccessMask -band $COM_RIGHTS_EXECUTE_REMOTE)
{ $ace.AccessMask = $ace.AccessMask -bxor $COM_RIGHTS_EXECUTE_REMOTE }
if ($Permissions -contains "ALL" -or $ace.AccessMask -eq 0 -or $ace.AccessMask -eq $COM_RIGHTS_EXECUTE)
{ $acl.RemoveAce($index) }
$found = $true
break
}
}
if (-not $found) { Write-Verbose "ACE not found, no changes made" }
else {
Write-Verbose "Convert to binary and save the ACL"
$sd.DiscretionaryAcl = $acl
$sdbytes = New-Object 'byte[]' $sd.BinaryLength
$sd.GetBinaryForm($sdbytes, 0)
$regkey | New-ItemProperty -Name "$($Type)Permission" -PropertyType Binary -Value $sdBytes -Force | Out-Null
}
if ($PassThru) { New-Object -TypeName PSObject -Property @{ "ApplicationID" = $ApplicationID ; "Type" = $Type } }
}
function Wrapper-DComPermission {
param(
[Parameter(Mandatory=$true)] [ValidateSet("Grant","Revoke")] [string] $Purpose,
[string] $ApplicationID,
[string] $Type,
[string] $Account,
[string[]] $Permissions,
[Switch] $Deny,
[Switch] $PassThru,
[Switch] $OverrideConfigurationPermissions
)
if ($Type -eq "Launch") {
if ($Permissions -contains "LocalAccess") { throw New-Object System.ArgumentException("LocalAccess is not a valid Launch permission") }
if ($Permissions -contains "RemoteAccess") { throw New-Object System.ArgumentException("RemoteAccess is not a valid Launch permission") }
} else {
if ($Permissions -contains "LocalLaunch") { throw New-Object System.ArgumentException("LocalLaunch is not a valid Access permission") }
if ($Permissions -contains "RemoteLaunch") { throw New-Object System.ArgumentException("RemoteLaunch is not a valid Access permission") }
if ($Permissions -contains "LocalActivation") { throw New-Object System.ArgumentException("LocalActivation is not a valid Access permission") }
if ($Permissions -contains "RemoteActivation") { throw New-Object System.ArgumentException("RemoteActivation is not a valid Access permission") }
}
$AceType = [System.Security.AccessControl.AceType]::AccessAllowed
if ($Deny) { $AceType = [System.Security.AccessControl.AceType]::AccessDenied }
Write-Verbose "Getting SID from account name"
$UserNTAccount = New-Object System.Security.Principal.NTAccount($Account)
[System.Security.Principal.SecurityIdentifier] $SID = ($UserNTAccount.Translate([System.Security.Principal.SecurityIdentifier])).Value
try {
if ($Purpose -eq "Grant") { Grant-DComPermissionInternal -ApplicationID $ApplicationID -SID $SID -Type $Type -Permissions $Permissions -AceType $AceType -PassThru:$PassThru }
else { Revoke-DComPermissionInternal -ApplicationID $ApplicationID -SID $SID -Type $Type -Permissions $Permissions -AceType $AceType -PassThru:$PassThru }
} catch [System.Security.SecurityException] {
Write-Verbose "Access denied setting DCOM permissions (registry configuration permissions are lacking...)"
if (-not $OverrideConfigurationPermissions) { Write-Verbose "...Override not specified, aborting" ; throw $_ }
else { Write-Verbose "...Attempting to override" }
if (-not [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"))
{ Write-Warning "No administrator rights (not elevated)" ; throw $_ }
$OldOwner = $null
$RevokePrivilege = $false
# User has admin rights, but Admininstrators do not have rights to change values. Need to change permissions
Write-Verbose "Opening registry key to change its permissions"
try {
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("AppID\$ApplicationID", 'ReadWriteSubTree', 'ChangePermissions')
} catch [System.Security.SecurityException] {
Write-Verbose "Access denied opening registry key to change permissions (not owner)`n`tReopening registry key to take ownership"
try {
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("AppID\$ApplicationID", 'ReadWriteSubTree', 'TakeOwnership')
} catch [System.Security.SecurityException] {
Write-Verbose "Access denied opening registry key to take ownership, enabling Token Privileges and trying again"
Grant-TokenPrivilege -Privilege SeTakeOwnershipPrivilege,SeRestorePrivilege
$RevokePrivilege = $true
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("AppID\$ApplicationID", 'ReadWriteSubTree', 'TakeOwnership')
}
Write-Verbose "Setting owner to Administrators"
try {
$acl = $key.GetAccessControl()
$OldOwner = [System.Security.Principal.NTAccount]$acl.Owner
$acl.SetOwner($Admins_SID)
$key.SetAccessControl($acl)
} catch {
if ($RevokePrivilege) { try { Revoke-TokenPrivilege -Privilege SeTakeOwnershipPrivilege,SeRestorePrivilege } catch {} }
throw $_
} finally {
$key.Close()
}
Write-Verbose "Retry: opening registry key to change its permissions"
try {
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("AppID\$ApplicationID", 'ReadWriteSubTree', 'ChangePermissions')
} catch {
Write-Verbose "Failed again (you should never see this). Restoring original owner"
$key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("AppID\$ApplicationID", 'ReadWriteSubTree', 'TakeOwnership')
$acl = $key.GetAccessControl()
$acl.SetOwner($OldOwner)
$key.SetAccessControl($acl)
$key.Close()
if ($RevokePrivilege) { try { Revoke-TokenPrivilege -Privilege SeTakeOwnershipPrivilege,SeRestorePrivilege } catch {} }
throw $_
}
}
Write-Verbose "Setting ACL to grant Administrators full control"
$acl = $key.GetAccessControl()
$acl_original = $key.GetAccessControl()
$acl_original.SetAccessRuleProtection($acl_original.AreAccessRulesProtected, $true) # Must "change" ACL, or .NET won't save it
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($Admins_SID, "FullControl", "ContainerInherit", "None", "Allow")
$acl.ResetAccessRule($rule) # Replace all ACEs for Administrators with one that grants full control
$key.SetAccessControl($acl)
try {
if ($Purpose -eq "Grant") { Grant-DComPermissionInternal -ApplicationID $ApplicationID -SID $SID -Type $Type -Permissions $Permissions -AceType $AceType -PassThru:$PassThru }
else { Revoke-DComPermissionInternal -ApplicationID $ApplicationID -SID $SID -Type $Type -Permissions $Permissions -AceType $AceType -PassThru:$PassThru }
} catch {
throw $_
} finally {
# Set ACL back to original value
Write-Verbose "Restoring original registry key permissions & owner"
if ($OldOwner) { $acl_original.SetOwner($OldOwner) }
$key.SetAccessControl($acl_original)
$key.Close()
if ($RevokePrivilege) { try { Revoke-TokenPrivilege -Privilege SeTakeOwnershipPrivilege,SeRestorePrivilege } catch {} }
}
}
}
function Grant-DComPermission {
<#
.SYNOPSIS
Grants DCOM Permissions to a specified Application ID's Launch/Activation, or Access permissions
.DESCRIPTION
Grants individual "Access Permissions" or "Launch and Activation Permissions" to a specified Application ID for a specific account
.PARAMETER ApplicationID
The Application ID for the DCOM object
.PARAMETER Type
Indicates which type of permissions to grant
Valid options: Launch, Access
.PARAMETER Account
Account in the form of "Domain\Username". Specify only the username for local accounts.
.PARAMETER Permissions
List of permissions to grant
Valid options for Launch: ALL, LocalLaunch, LocalActivation, RemoteLaunch, RemoteActivation
Valid options for Access: ALL, LocalAccess, RemoteAccess
.PARAMETER Deny
Create a DENY access control entry instead of an ALLOW entry
.PARAMETER PassThru
Outputs the ApplicationID and Type parameters. This is useful for piping to Get-DCOMPermission.
If not specified, nothing is outputted.
.PARAMETER OverrideConfigurationPermissions
For some DCOM objects (such as RuntimeBroker), Administrators do not have the needed "Configuration Permissions" to change the Launch or Access permissions.
In these cases, an access denied error is generated. To avoid this error, specify this option.
If this option is enabled and an access denied error occurs, then the "Configuration Permissions" will be temporarily changed (taking ownership as needed) to allow the DCOM permission change to succeed. Once complete, the configuration permissions and ownership are restored to the original values.
.EXAMPLE
Grant-DCOMPermission -ApplicationID "{9CA88EE3-ACB7-47C8-AFC4-AB702511C276}" -Account "SYSTEM" -Type Launch -Permissions LocalLaunch,LocalActivation
.INPUTS
String ApplicationID
String Type
String Account
String[] Permissions
Switch Deny
Switch PassThru
Switch OverrideConfigurationPermissions
.OUTPUTS
String ApplicationID
String Type
#>
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)] [Alias("APPID")] [string] $ApplicationID,
[Parameter(Mandatory=$true)] [ValidateSet("Launch","Access")] [string] $Type,
[Parameter(Mandatory=$true)] [Alias('Acct','User','Username')] [string] $Account,
[Parameter(Mandatory=$true)] [ValidateSet("LocalLaunch","RemoteLaunch","LocalActivation",
"RemoteActivation","LocalAccess","RemoteAccess","ALL")] [string[]] $Permissions,
[Switch] $Deny,
[Switch] $PassThru,
[Alias("Override")] [Switch] $OverrideConfigurationPermissions
)
$ErrorActionPreference = "Stop"
Wrapper-DComPermission -Purpose Grant -ApplicationID $ApplicationID -Account $Account -Type $Type -Permissions $Permissions -Deny:$Deny -PassThru:$PassThru -OverrideConfigurationPermissions:$OverrideConfigurationPermissions
}
function Revoke-DComPermission {
<#
.SYNOPSIS
Revokes DCOM Permissions from a specified Application ID's Launch/Activation, or Access permissions
.DESCRIPTION
Removes individual "Access Permissions" or "Launch and Activation Permissions" form a specified Application ID for a specific account
.PARAMETER ApplicationID
The Application ID for the DCOM object
.PARAMETER Type
Indicates which type of permissions to revoke
Valid options: Launch, Access
.PARAMETER Account
Account in the form of "Domain\Username". Specify only the username for local accounts.
.PARAMETER Permissions
List of permissions to revoke
Valid options for Launch: ALL, LocalLaunch, LocalActivation, RemoteLaunch, RemoteActivation
Valid options for Access: ALL, LocalAccess, RemoteAccess
.PARAMETER Deny
Revoke a DENY access control entry instead of an ALLOW entry
.PARAMETER PassThru
Outputs the ApplicationID and Type parameters. This is useful for piping to Get-DCOMPermission.
If not specified, nothing is outputted.
.PARAMETER OverrideConfigurationPermissions
For some DCOM objects (such as RuntimeBroker), Administrators do not have the needed "Configuration Permissions" to change the Launch or Access permissions.
In these cases, an access denied error is generated. To avoid this error, specify this option.
If this option is enabled and an access denied error occurs, then the "Configuration Permissions" will be temporarily changed (taking ownership as needed) to allow the DCOM permission change to succeed. Once complete, the configuration permissions and ownership are restored to the original values.
.EXAMPLE
Revoke-DCOMPermission -ApplicationID "{9CA88EE3-ACB7-47C8-AFC4-AB702511C276}" -Account "SYSTEM" -Type Launch -Permissions LocalLaunch,LocalActivation
.INPUTS
String ApplicationID
String Type
String Account
String[] Permissions
Switch Deny
Switch PassThru
Switch OverrideConfigurationPermissions
.OUTPUTS
String ApplicationID
String Type
#>
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)] [Alias("APPID")] [string] $ApplicationID,
[Parameter(Mandatory=$true)] [ValidateSet("Launch","Access")] [string] $Type,
[Parameter(Mandatory=$true)] [Alias('Acct','User','Username')] [string] $Account,
[Parameter(Mandatory=$true)] [ValidateSet("LocalLaunch","RemoteLaunch","LocalActivation",
"RemoteActivation","LocalAccess","RemoteAccess","ALL")] [string[]] $Permissions,
[Switch] $Deny,
[Switch] $PassThru,
[Alias("Override")] [Switch] $OverrideConfigurationPermissions
)
$ErrorActionPreference = "Stop"
Wrapper-DComPermission -Purpose Revoke -ApplicationID $ApplicationID -Account $Account -Type $Type -Permissions $Permissions -Deny:$Deny -PassThru:$PassThru -OverrideConfigurationPermissions:$OverrideConfigurationPermissions
}
Export-ModuleMember -Function Get-DComPermission,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