00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
#include "sep.h"
00032
#include "tokenp.h"
00033
#include "sertlp.h"
00034
#include "zwapi.h"
00035
#include "nturtl.h"
00036
00037
00038
00039
00040
00041
00042
00043
NTSTATUS
00044
SepInheritAcl (
00045 IN PACL Acl,
00046 IN BOOLEAN IsDirectoryObject,
00047 IN PSID OwnerSid,
00048 IN PSID GroupSid,
00049 IN PSID ServerSid OPTIONAL,
00050 IN PSID ClientSid OPTIONAL,
00051 IN PGENERIC_MAPPING GenericMapping,
00052 IN POOL_TYPE PoolType,
00053 OUT PACL *NewAcl
00054 );
00055
00056
00057
#ifdef ALLOC_PRAGMA
00058
#pragma alloc_text(PAGE,SeAssignSecurity)
00059
#pragma alloc_text(PAGE,SeAssignSecurityEx)
00060
#pragma alloc_text(PAGE,SeDeassignSecurity)
00061
#pragma alloc_text(PAGE,SepInheritAcl)
00062
#pragma alloc_text(PAGE,SeAssignWorldSecurityDescriptor)
00063
#pragma alloc_text(PAGE,SepDumpSecurityDescriptor)
00064
#pragma alloc_text(PAGE,SepPrintAcl)
00065
#pragma alloc_text(PAGE,SepPrintSid)
00066
#pragma alloc_text(PAGE,SepDumpTokenInfo)
00067
#pragma alloc_text(PAGE,SepSidTranslation)
00068
#endif
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
#if DBG
00079
00080 BOOLEAN SepDumpSD =
FALSE;
00081 BOOLEAN SepDumpToken =
FALSE;
00082
00083
#endif
00084
00085
00086
00087
00088
NTSTATUS
00089 SeAssignSecurity (
00090 IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
00091 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
00092 OUT PSECURITY_DESCRIPTOR *NewDescriptor,
00093 IN BOOLEAN IsDirectoryObject,
00094 IN
PSECURITY_SUBJECT_CONTEXT SubjectContext,
00095 IN PGENERIC_MAPPING GenericMapping,
00096 IN POOL_TYPE PoolType
00097 )
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 {
00159
NTSTATUS Status;
00160 ULONG AutoInherit = 0;
00161
PAGED_CODE();
00162
00163
#if DBG
00164
if ( ARGUMENT_PRESENT( ExplicitDescriptor) ) {
00165
SepDumpSecurityDescriptor( ExplicitDescriptor,
00166
"\nSeAssignSecurity: Input security descriptor = \n"
00167 );
00168 }
00169
00170
if (ARGUMENT_PRESENT( ParentDescriptor )) {
00171
SepDumpSecurityDescriptor( ParentDescriptor,
00172
"\nSeAssignSecurity: Parent security descriptor = \n"
00173 );
00174 }
00175
#endif // DBG
00176
00177
00178
00179
00180
00181
00182
00183
if ( ParentDescriptor !=
NULL ) {
00184
00185
if ( (ExplicitDescriptor ==
NULL ||
00186 (((PISECURITY_DESCRIPTOR)ExplicitDescriptor)->Control & SE_DACL_PRESENT) == 0 ) &&
00187 (((PISECURITY_DESCRIPTOR)ParentDescriptor)->Control & SE_DACL_AUTO_INHERITED) != 0 ) {
00188 AutoInherit |= SEF_DACL_AUTO_INHERIT;
00189 }
00190
00191
if ( (ExplicitDescriptor ==
NULL ||
00192 (((PISECURITY_DESCRIPTOR)ExplicitDescriptor)->Control & SE_SACL_PRESENT) == 0 ) &&
00193 (((PISECURITY_DESCRIPTOR)ParentDescriptor)->Control & SE_SACL_AUTO_INHERITED) != 0 ) {
00194 AutoInherit |= SEF_SACL_AUTO_INHERIT;
00195 }
00196
00197 }
00198
00199
00200
Status =
RtlpNewSecurityObject (
00201 ParentDescriptor OPTIONAL,
00202 ExplicitDescriptor OPTIONAL,
00203 NewDescriptor,
00204
NULL,
00205 IsDirectoryObject,
00206 AutoInherit,
00207 (HANDLE) SubjectContext,
00208 GenericMapping );
00209
00210
#if DBG
00211
if (
NT_SUCCESS(
Status)) {
00212
SepDumpSecurityDescriptor( *NewDescriptor,
00213
"SeAssignSecurity: Final security descriptor = \n"
00214 );
00215 }
00216
#endif
00217
00218
return Status;
00219
00220
00221
00222 UNREFERENCED_PARAMETER(
PagedPool );
00223
00224 }
00225
00226
00227
NTSTATUS
00228 SeAssignSecurityEx (
00229 IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
00230 IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL,
00231 OUT PSECURITY_DESCRIPTOR *NewDescriptor,
00232 IN GUID *ObjectType OPTIONAL,
00233 IN BOOLEAN IsDirectoryObject,
00234 IN ULONG AutoInheritFlags,
00235 IN
PSECURITY_SUBJECT_CONTEXT SubjectContext,
00236 IN PGENERIC_MAPPING GenericMapping,
00237 IN POOL_TYPE PoolType
00238 )
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 {
00327
NTSTATUS Status;
00328
PAGED_CODE();
00329
00330
#if DBG
00331
if ( ARGUMENT_PRESENT( ExplicitDescriptor) ) {
00332
SepDumpSecurityDescriptor( ExplicitDescriptor,
00333
"\nSeAssignSecurityEx: Input security descriptor = \n"
00334 );
00335 }
00336
00337
if (ARGUMENT_PRESENT( ParentDescriptor )) {
00338
SepDumpSecurityDescriptor( ParentDescriptor,
00339
"\nSeAssignSecurityEx: Parent security descriptor = \n"
00340 );
00341 }
00342
#endif // DBG
00343
00344
00345
Status =
RtlpNewSecurityObject (
00346 ParentDescriptor OPTIONAL,
00347 ExplicitDescriptor OPTIONAL,
00348 NewDescriptor,
00349 ObjectType,
00350 IsDirectoryObject,
00351 AutoInheritFlags,
00352 (HANDLE) SubjectContext,
00353 GenericMapping );
00354
00355
#if DBG
00356
if (
NT_SUCCESS(
Status)) {
00357
SepDumpSecurityDescriptor( *NewDescriptor,
00358
"SeAssignSecurityEx: Final security descriptor = \n"
00359 );
00360 }
00361
#endif
00362
00363
return Status;
00364
00365
00366
00367 UNREFERENCED_PARAMETER(
PagedPool );
00368
00369 }
00370
00371
00372
NTSTATUS
00373 SeDeassignSecurity (
00374 IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor
00375 )
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396 {
00397
PAGED_CODE();
00398
00399
if ((*SecurityDescriptor) !=
NULL) {
00400
ExFreePool( (*SecurityDescriptor) );
00401 }
00402
00403
00404
00405
00406
00407 (*SecurityDescriptor) =
NULL;
00408
00409
return( STATUS_SUCCESS );
00410
00411 }
00412
00413
00414
00415
NTSTATUS
00416 SepInheritAcl (
00417 IN PACL Acl,
00418 IN BOOLEAN IsDirectoryObject,
00419 IN PSID ClientOwnerSid,
00420 IN PSID ClientGroupSid,
00421 IN PSID ServerOwnerSid OPTIONAL,
00422 IN PSID ServerGroupSid OPTIONAL,
00423 IN PGENERIC_MAPPING GenericMapping,
00424 IN POOL_TYPE PoolType,
00425 OUT PACL *NewAcl
00426 )
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472 {
00474
00475
00476
00477
00478
00480
00481
00482
NTSTATUS Status;
00483 ULONG NewAclLength;
00484 BOOLEAN NewAclExplicitlyAssigned;
00485 ULONG NewGenericControl;
00486
00487
PAGED_CODE();
00488
ASSERT( PoolType ==
PagedPool );
00489
00490
00491
00492
00493
00494
if (Acl ==
NULL) {
00495
00496
return STATUS_NO_INHERITANCE;
00497 }
00498
00499
00500
00501
00502
00503
00504
00505
Status =
RtlpInheritAcl(
00506 Acl,
00507
NULL,
00508 0,
00509 IsDirectoryObject,
00510
FALSE,
00511
FALSE,
00512 ClientOwnerSid,
00513 ClientGroupSid,
00514 ServerOwnerSid,
00515 ServerGroupSid,
00516 GenericMapping,
00517
FALSE,
00518
NULL,
00519 NewAcl,
00520 &NewAclExplicitlyAssigned,
00521 &NewGenericControl );
00522
00523
return Status;
00524 }
00525
00526
00527
00528
NTSTATUS
00529 SeAssignWorldSecurityDescriptor(
00530 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
00531 IN OUT PULONG Length,
00532 IN PSECURITY_INFORMATION SecurityInformation
00533 )
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 {
00568
00569 PCHAR Field;
00570 PCHAR Base;
00571 ULONG WorldSidLength;
00572 PISECURITY_DESCRIPTOR_RELATIVE ISecurityDescriptor;
00573 ULONG MinSize;
00574
NTSTATUS Status;
00575
00576
PAGED_CODE();
00577
00578
if ( !ARGUMENT_PRESENT( SecurityInformation )) {
00579
00580
return( STATUS_ACCESS_DENIED );
00581 }
00582
00583 WorldSidLength =
SeLengthSid(
SeWorldSid );
00584
00585 MinSize =
sizeof( SECURITY_DESCRIPTOR_RELATIVE ) + 2 * WorldSidLength;
00586
00587
if ( *Length < MinSize ) {
00588
00589 *Length = MinSize;
00590
return( STATUS_BUFFER_TOO_SMALL );
00591 }
00592
00593 *Length = MinSize;
00594
00595 ISecurityDescriptor = (SECURITY_DESCRIPTOR_RELATIVE *)SecurityDescriptor;
00596
00597
Status =
RtlCreateSecurityDescriptorRelative( ISecurityDescriptor,
00598 SECURITY_DESCRIPTOR_REVISION );
00599
00600
if (!
NT_SUCCESS(
Status )) {
00601
return(
Status );
00602 }
00603
00604 Base = (PCHAR)(ISecurityDescriptor);
00605 Field = Base +
sizeof(SECURITY_DESCRIPTOR_RELATIVE);
00606
00607
if ( *SecurityInformation & OWNER_SECURITY_INFORMATION ) {
00608
00609 RtlCopyMemory( Field,
SeWorldSid, WorldSidLength );
00610 ISecurityDescriptor->Owner = RtlPointerToOffset(Base,Field);
00611 Field += WorldSidLength;
00612 }
00613
00614
if ( *SecurityInformation & GROUP_SECURITY_INFORMATION ) {
00615
00616 RtlCopyMemory( Field,
SeWorldSid, WorldSidLength );
00617 ISecurityDescriptor->Group = RtlPointerToOffset(Base,Field);
00618 }
00619
00620
if ( *SecurityInformation & DACL_SECURITY_INFORMATION ) {
00621 RtlpSetControlBits( ISecurityDescriptor, SE_DACL_PRESENT );
00622 }
00623
00624
if ( *SecurityInformation & SACL_SECURITY_INFORMATION ) {
00625 RtlpSetControlBits( ISecurityDescriptor, SE_SACL_PRESENT );
00626 }
00627
00628 RtlpSetControlBits( ISecurityDescriptor, SE_SELF_RELATIVE );
00629
00630
return( STATUS_SUCCESS );
00631
00632 }
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
VOID
00650 SepDumpSecurityDescriptor(
00651 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
00652 IN PSZ TitleString
00653 )
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676 {
00677
#if DBG
00678
PISECURITY_DESCRIPTOR ISecurityDescriptor;
00679 UCHAR Revision;
00680 SECURITY_DESCRIPTOR_CONTROL Control;
00681 PSID
Owner;
00682 PSID
Group;
00683 PACL Sacl;
00684 PACL
Dacl;
00685
00686
PAGED_CODE();
00687
00688
00689
if (!SepDumpSD) {
00690
return;
00691 }
00692
00693
if (!ARGUMENT_PRESENT( SecurityDescriptor )) {
00694
return;
00695 }
00696
00697
DbgPrint(TitleString);
00698
00699 ISecurityDescriptor = ( PISECURITY_DESCRIPTOR )SecurityDescriptor;
00700
00701 Revision = ISecurityDescriptor->Revision;
00702 Control = ISecurityDescriptor->Control;
00703
00704
Owner = RtlpOwnerAddrSecurityDescriptor( ISecurityDescriptor );
00705
Group = RtlpGroupAddrSecurityDescriptor( ISecurityDescriptor );
00706 Sacl = RtlpSaclAddrSecurityDescriptor( ISecurityDescriptor );
00707
Dacl = RtlpDaclAddrSecurityDescriptor( ISecurityDescriptor );
00708
00709
DbgPrint(
"\nSECURITY DESCRIPTOR\n");
00710
00711
DbgPrint(
"Revision = %d\n",Revision);
00712
00713
00714
00715
00716
00717
if (Control & SE_OWNER_DEFAULTED) {
00718
DbgPrint(
"Owner defaulted\n");
00719 }
00720
if (Control & SE_GROUP_DEFAULTED) {
00721
DbgPrint(
"Group defaulted\n");
00722 }
00723
if (Control & SE_DACL_PRESENT) {
00724
DbgPrint(
"Dacl present\n");
00725 }
00726
if (Control & SE_DACL_DEFAULTED) {
00727
DbgPrint(
"Dacl defaulted\n");
00728 }
00729
if (Control & SE_SACL_PRESENT) {
00730
DbgPrint(
"Sacl present\n");
00731 }
00732
if (Control & SE_SACL_DEFAULTED) {
00733
DbgPrint(
"Sacl defaulted\n");
00734 }
00735
if (Control & SE_SELF_RELATIVE) {
00736
DbgPrint(
"Self relative\n");
00737 }
00738
if (Control & SE_DACL_UNTRUSTED) {
00739
DbgPrint(
"Dacl untrusted\n");
00740 }
00741
if (Control & SE_SERVER_SECURITY) {
00742
DbgPrint(
"Server security\n");
00743 }
00744
00745
DbgPrint(
"Owner ");
00746
SepPrintSid(
Owner );
00747
00748
DbgPrint(
"Group ");
00749
SepPrintSid(
Group );
00750
00751
DbgPrint(
"Sacl");
00752
SepPrintAcl( Sacl );
00753
00754
DbgPrint(
"Dacl");
00755
SepPrintAcl(
Dacl );
00756
#endif
00757
}
00758
00759
00760
00761
VOID
00762 SepPrintAcl (
00763 IN PACL Acl
00764 )
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 {
00785
#if DBG
00786
ULONG i;
00787
PKNOWN_ACE Ace;
00788 BOOLEAN KnownType;
00789
00790
PAGED_CODE();
00791
00792
DbgPrint(
"@ %8lx\n", Acl);
00793
00794
00795
00796
00797
00798
if (Acl ==
NULL) {
00799
00800
return;
00801
00802 }
00803
00804
00805
00806
00807
00808
DbgPrint(
" Revision: %02x", Acl->AclRevision);
00809
DbgPrint(
" Size: %04x", Acl->AclSize);
00810
DbgPrint(
" AceCount: %04x\n", Acl->AceCount);
00811
00812
00813
00814
00815
00816
for (i = 0, Ace =
FirstAce(Acl);
00817 i < Acl->AceCount;
00818 i++, Ace =
NextAce(Ace) ) {
00819
00820
00821
00822
00823
00824
DbgPrint(
"\n AceHeader: %08lx ", *(PULONG)Ace);
00825
00826
00827
00828
00829
00830
if ((Ace->Header.AceType == ACCESS_ALLOWED_ACE_TYPE) ||
00831 (Ace->Header.AceType == ACCESS_DENIED_ACE_TYPE) ||
00832 (Ace->Header.AceType == SYSTEM_AUDIT_ACE_TYPE) ||
00833 (Ace->Header.AceType == SYSTEM_ALARM_ACE_TYPE) ||
00834 (Ace->Header.AceType == ACCESS_ALLOWED_COMPOUND_ACE_TYPE)) {
00835
00836
00837
00838
00839
00840
00841 PCHAR AceTypes[] = {
"Access Allowed",
00842
"Access Denied ",
00843
"System Audit ",
00844
"System Alarm ",
00845
"Compound Grant",
00846 };
00847
00848
DbgPrint(AceTypes[Ace->Header.AceType]);
00849
DbgPrint(
"\n Access Mask: %08lx ", Ace->Mask);
00850 KnownType =
TRUE;
00851
00852 }
else {
00853
00854
DbgPrint(
" Unknown Ace Type\n");
00855 KnownType =
FALSE;
00856 }
00857
00858
DbgPrint(
"\n");
00859
00860
DbgPrint(
" AceSize = %d\n",Ace->Header.AceSize);
00861
00862
DbgPrint(
" Ace Flags = ");
00863
if (Ace->Header.AceFlags & OBJECT_INHERIT_ACE) {
00864
DbgPrint(
"OBJECT_INHERIT_ACE\n");
00865
DbgPrint(
" ");
00866 }
00867
00868
if (Ace->Header.AceFlags & CONTAINER_INHERIT_ACE) {
00869
DbgPrint(
"CONTAINER_INHERIT_ACE\n");
00870
DbgPrint(
" ");
00871 }
00872
00873
if (Ace->Header.AceFlags & NO_PROPAGATE_INHERIT_ACE) {
00874
DbgPrint(
"NO_PROPAGATE_INHERIT_ACE\n");
00875
DbgPrint(
" ");
00876 }
00877
00878
if (Ace->Header.AceFlags & INHERIT_ONLY_ACE) {
00879
DbgPrint(
"INHERIT_ONLY_ACE\n");
00880
DbgPrint(
" ");
00881 }
00882
00883
00884
if (Ace->Header.AceFlags & SUCCESSFUL_ACCESS_ACE_FLAG) {
00885
DbgPrint(
"SUCCESSFUL_ACCESS_ACE_FLAG\n");
00886
DbgPrint(
" ");
00887 }
00888
00889
if (Ace->Header.AceFlags & FAILED_ACCESS_ACE_FLAG) {
00890
DbgPrint(
"FAILED_ACCESS_ACE_FLAG\n");
00891
DbgPrint(
" ");
00892 }
00893
00894
DbgPrint(
"\n");
00895
00896
if (KnownType !=
TRUE) {
00897
continue;
00898 }
00899
00900
if (Ace->Header.AceType != ACCESS_ALLOWED_COMPOUND_ACE_TYPE) {
00901
DbgPrint(
" Sid = ");
00902
SepPrintSid(&Ace->SidStart);
00903 }
else {
00904
DbgPrint(
" Server Sid = ");
00905
SepPrintSid(RtlCompoundAceServerSid(Ace));
00906
DbgPrint(
"\n Client Sid = ");
00907
SepPrintSid(RtlCompoundAceClientSid( Ace ));
00908 }
00909 }
00910
#endif
00911
}
00912
00913
00914
00915
VOID
00916 SepPrintSid(
00917 IN PSID Sid
00918 )
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937 {
00938
#if DBG
00939
UCHAR i;
00940 ULONG Tmp;
00941 PISID ISid;
00942 STRING AccountName;
00943 UCHAR
Buffer[128];
00944
00945
PAGED_CODE();
00946
00947
if (Sid ==
NULL) {
00948
DbgPrint(
"Sid is NULL\n");
00949
return;
00950 }
00951
00952
Buffer[0] = 0;
00953
00954 AccountName.MaximumLength = 127;
00955 AccountName.Length = 0;
00956 AccountName.Buffer = (PVOID)&
Buffer[0];
00957
00958
if (
SepSidTranslation( Sid, &AccountName )) {
00959
00960
DbgPrint(
"%s ", AccountName.Buffer );
00961 }
00962
00963 ISid = (PISID)Sid;
00964
00965
DbgPrint(
"S-%lu-", (
USHORT)ISid->Revision );
00966
if ( (ISid->IdentifierAuthority.Value[0] != 0) ||
00967 (ISid->IdentifierAuthority.Value[1] != 0) ){
00968
DbgPrint(
"0x%02hx%02hx%02hx%02hx%02hx%02hx",
00969 (
USHORT)ISid->IdentifierAuthority.Value[0],
00970 (
USHORT)ISid->IdentifierAuthority.Value[1],
00971 (
USHORT)ISid->IdentifierAuthority.Value[2],
00972 (
USHORT)ISid->IdentifierAuthority.Value[3],
00973 (
USHORT)ISid->IdentifierAuthority.Value[4],
00974 (
USHORT)ISid->IdentifierAuthority.Value[5] );
00975 }
else {
00976 Tmp = (ULONG)ISid->IdentifierAuthority.Value[5] +
00977 (ULONG)(ISid->IdentifierAuthority.Value[4] << 8) +
00978 (ULONG)(ISid->IdentifierAuthority.Value[3] << 16) +
00979 (ULONG)(ISid->IdentifierAuthority.Value[2] << 24);
00980
DbgPrint(
"%lu", Tmp);
00981 }
00982
00983
00984
for (i=0;i<ISid->SubAuthorityCount ;i++ ) {
00985
DbgPrint(
"-%lu", ISid->SubAuthority[i]);
00986 }
00987
DbgPrint(
"\n");
00988
#endif
00989
}
00990
00991
00992
00993
00994
VOID
00995 SepDumpTokenInfo(
00996 IN PACCESS_TOKEN Token
00997 )
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016 {
01017
#if DBG
01018
ULONG UserAndGroupCount;
01019 PSID_AND_ATTRIBUTES TokenSid;
01020 ULONG i;
01021
PTOKEN IToken;
01022
01023
PAGED_CODE();
01024
01025
if (!SepDumpToken) {
01026
return;
01027 }
01028
01029 IToken = (
TOKEN *)
Token;
01030
01031 UserAndGroupCount = IToken->UserAndGroupCount;
01032
01033
DbgPrint(
"\n\nToken Address=%lx\n",IToken);
01034
DbgPrint(
"Token User and Groups Array:\n\n");
01035
01036
for ( i = 0 , TokenSid = IToken->UserAndGroups;
01037 i < UserAndGroupCount ;
01038 i++, TokenSid++
01039 ) {
01040
01041
SepPrintSid( TokenSid->Sid );
01042
01043 }
01044
01045
if ( IToken->RestrictedSids ) {
01046 UserAndGroupCount = IToken->RestrictedSidCount;
01047
01048
DbgPrint(
"Restricted Sids Array:\n\n");
01049
01050
for ( i = 0 , TokenSid = IToken->RestrictedSids;
01051 i < UserAndGroupCount ;
01052 i++, TokenSid++
01053 ) {
01054
01055
SepPrintSid( TokenSid->Sid );
01056
01057 }
01058 }
01059
#endif
01060
}
01061
01062
01063
01064 BOOLEAN
01065 SepSidTranslation(
01066 PSID Sid,
01067 PSTRING AccountName
01068 )
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091 {
01092
PAGED_CODE();
01093
01094
if (
RtlEqualSid(Sid,
SeWorldSid)) {
01095
RtlInitString( AccountName,
"WORLD ");
01096
return(
TRUE);
01097 }
01098
01099
if (
RtlEqualSid(Sid,
SeLocalSid)) {
01100
RtlInitString( AccountName,
"LOCAL ");
01101
return(
TRUE);
01102 }
01103
01104
if (
RtlEqualSid(Sid,
SeNetworkSid)) {
01105
RtlInitString( AccountName,
"NETWORK ");
01106
return(
TRUE);
01107 }
01108
01109
if (
RtlEqualSid(Sid,
SeBatchSid)) {
01110
RtlInitString( AccountName,
"BATCH ");
01111
return(
TRUE);
01112 }
01113
01114
if (
RtlEqualSid(Sid,
SeInteractiveSid)) {
01115
RtlInitString( AccountName,
"INTERACTIVE ");
01116
return(
TRUE);
01117 }
01118
01119
if (
RtlEqualSid(Sid,
SeLocalSystemSid)) {
01120
RtlInitString( AccountName,
"SYSTEM ");
01121
return(
TRUE);
01122 }
01123
01124
if (
RtlEqualSid(Sid,
SeCreatorOwnerSid)) {
01125
RtlInitString( AccountName,
"CREATOR_OWNER ");
01126
return(
TRUE);
01127 }
01128
01129
if (
RtlEqualSid(Sid,
SeCreatorGroupSid)) {
01130
RtlInitString( AccountName,
"CREATOR_GROUP ");
01131
return(
TRUE);
01132 }
01133
01134
if (
RtlEqualSid(Sid,
SeCreatorOwnerServerSid)) {
01135
RtlInitString( AccountName,
"CREATOR_OWNER_SERVER ");
01136
return(
TRUE);
01137 }
01138
01139
if (
RtlEqualSid(Sid,
SeCreatorGroupServerSid)) {
01140
RtlInitString( AccountName,
"CREATOR_GROUP_SERVER ");
01141
return(
TRUE);
01142 }
01143
01144
return(
FALSE);
01145 }
01146
01147
01148
01149