1N/A#include "compat.h"
1N/A#include "types.h"
1N/A#include "layout.h"
1N/A#include "sd.h"
1N/A
1N/A/**
1N/A * init_system_file_sd -
1N/A *
1N/A * NTFS 3.1 - System files security decriptors
1N/A * =====================================================
1N/A *
1N/A * Create the security descriptor for system file number @sys_file_no and
1N/A * return a pointer to the descriptor.
1N/A *
1N/A * Note the root directory system file (".") is very different and handled by a
1N/A * different function.
1N/A *
1N/A * The sd is returned in *@sd_val and has length *@sd_val_len.
1N/A *
1N/A * Do NOT free *@sd_val as it is static memory. This also means that you can
1N/A * only use *@sd_val until the next call to this function.
1N/A */
1N/Avoid init_system_file_sd(int sys_file_no, u8 **sd_val, int *sd_val_len)
1N/A{
1N/A static u8 sd_array[0x68];
1N/A SECURITY_DESCRIPTOR_RELATIVE *sd;
1N/A ACL *acl;
1N/A ACCESS_ALLOWED_ACE *aa_ace;
1N/A SID *sid;
1N/A
1N/A if (sys_file_no < 0) {
1N/A *sd_val = NULL;
1N/A *sd_val_len = 0;
1N/A return;
1N/A }
1N/A *sd_val = sd_array;
1N/A sd = (SECURITY_DESCRIPTOR_RELATIVE*)&sd_array;
1N/A sd->revision = 1;
1N/A sd->alignment = 0;
1N/A sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
1N/A *sd_val_len = 0x64;
1N/A sd->owner = const_cpu_to_le32(0x48);
1N/A sd->group = const_cpu_to_le32(0x54);
1N/A sd->sacl = const_cpu_to_le32(0);
1N/A sd->dacl = const_cpu_to_le32(0x14);
1N/A /*
1N/A * Now at offset 0x14, as specified in the security descriptor, we have
1N/A * the DACL.
1N/A */
1N/A acl = (ACL*)((char*)sd + le32_to_cpu(sd->dacl));
1N/A acl->revision = 2;
1N/A acl->alignment1 = 0;
1N/A acl->size = const_cpu_to_le16(0x34);
1N/A acl->ace_count = const_cpu_to_le16(2);
1N/A acl->alignment2 = const_cpu_to_le16(0);
1N/A /*
1N/A * Now at offset 0x1c, just after the DACL's ACL, we have the first
1N/A * ACE of the DACL. The type of the ACE is access allowed.
1N/A */
1N/A aa_ace = (ACCESS_ALLOWED_ACE*)((char*)acl + sizeof(ACL));
1N/A aa_ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A aa_ace->flags = 0;
1N/A aa_ace->size = const_cpu_to_le16(0x14);
1N/A switch (sys_file_no) {
1N/A case FILE_AttrDef:
1N/A case FILE_Boot:
1N/A aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
1N/A FILE_READ_ATTRIBUTES | FILE_READ_EA | FILE_READ_DATA;
1N/A break;
1N/A default:
1N/A aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_WRITE |
1N/A FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES |
1N/A FILE_WRITE_EA | FILE_READ_EA | FILE_APPEND_DATA |
1N/A FILE_WRITE_DATA | FILE_READ_DATA;
1N/A break;
1N/A }
1N/A aa_ace->sid.revision = 1;
1N/A aa_ace->sid.sub_authority_count = 1;
1N/A aa_ace->sid.identifier_authority.value[0] = 0;
1N/A aa_ace->sid.identifier_authority.value[1] = 0;
1N/A aa_ace->sid.identifier_authority.value[2] = 0;
1N/A aa_ace->sid.identifier_authority.value[3] = 0;
1N/A aa_ace->sid.identifier_authority.value[4] = 0;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A aa_ace->sid.identifier_authority.value[5] = 5;
1N/A aa_ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A /*
1N/A * Now at offset 0x30 within security descriptor, just after the first
1N/A * ACE of the DACL. All system files, except the root directory, have
1N/A * a second ACE.
1N/A */
1N/A /* The second ACE of the DACL. Type is access allowed. */
1N/A aa_ace = (ACCESS_ALLOWED_ACE*)((char*)aa_ace +
1N/A le16_to_cpu(aa_ace->size));
1N/A aa_ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A aa_ace->flags = 0;
1N/A aa_ace->size = const_cpu_to_le16(0x18);
1N/A /* Only $AttrDef and $Boot behave differently to everything else. */
1N/A switch (sys_file_no) {
1N/A case FILE_AttrDef:
1N/A case FILE_Boot:
1N/A aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
1N/A FILE_READ_ATTRIBUTES | FILE_READ_EA |
1N/A FILE_READ_DATA;
1N/A break;
1N/A default:
1N/A aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
1N/A FILE_WRITE_ATTRIBUTES |
1N/A FILE_READ_ATTRIBUTES | FILE_WRITE_EA |
1N/A FILE_READ_EA | FILE_APPEND_DATA |
1N/A FILE_WRITE_DATA | FILE_READ_DATA;
1N/A break;
1N/A }
1N/A aa_ace->sid.revision = 1;
1N/A aa_ace->sid.sub_authority_count = 2;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A aa_ace->sid.identifier_authority.value[0] = 0;
1N/A aa_ace->sid.identifier_authority.value[1] = 0;
1N/A aa_ace->sid.identifier_authority.value[2] = 0;
1N/A aa_ace->sid.identifier_authority.value[3] = 0;
1N/A aa_ace->sid.identifier_authority.value[4] = 0;
1N/A aa_ace->sid.identifier_authority.value[5] = 5;
1N/A aa_ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A aa_ace->sid.sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A /*
1N/A * Now at offset 0x48 into the security descriptor, as specified in the
1N/A * security descriptor, we now have the owner SID.
1N/A */
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->owner));
1N/A sid->revision = 1;
1N/A sid->sub_authority_count = 1;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] = const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A /*
1N/A * Now at offset 0x54 into the security descriptor, as specified in the
1N/A * security descriptor, we have the group SID.
1N/A */
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->group));
1N/A sid->revision = 1;
1N/A sid->sub_authority_count = 2;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] = const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A sid->sub_authority[1] = const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A}
1N/A
1N/A/**
1N/A * init_root_sd -
1N/A *
1N/A * Creates the security_descriptor for the root folder on ntfs 3.1 as created
1N/A * by Windows Vista (when the format is done from the disk management MMC
1N/A * snap-in, note this is different from the format done from the disk
1N/A * properties in Windows Explorer).
1N/A */
1N/Avoid init_root_sd(u8 **sd_val, int *sd_val_len)
1N/A{
1N/A SECURITY_DESCRIPTOR_RELATIVE *sd;
1N/A ACL *acl;
1N/A ACCESS_ALLOWED_ACE *ace;
1N/A SID *sid;
1N/A
1N/A static char sd_array[0x102c];
1N/A *sd_val_len = 0x102c;
1N/A *sd_val = (u8*)&sd_array;
1N/A
1N/A //security descriptor relative
1N/A sd = (SECURITY_DESCRIPTOR_RELATIVE*)sd_array;
1N/A sd->revision = SECURITY_DESCRIPTOR_REVISION;
1N/A sd->alignment = 0;
1N/A sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
1N/A sd->owner = const_cpu_to_le32(0x1014);
1N/A sd->group = const_cpu_to_le32(0x1020);
1N/A sd->sacl = 0;
1N/A sd->dacl = const_cpu_to_le32(sizeof(SECURITY_DESCRIPTOR_RELATIVE));
1N/A
1N/A //acl
1N/A acl = (ACL*)((u8*)sd + sizeof(SECURITY_DESCRIPTOR_RELATIVE));
1N/A acl->revision = ACL_REVISION;
1N/A acl->alignment1 = 0;
1N/A acl->size = const_cpu_to_le16(0x1000);
1N/A acl->ace_count = const_cpu_to_le16(0x08);
1N/A acl->alignment2 = 0;
1N/A
1N/A //ace1
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)acl + sizeof(ACL));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = 0;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = STANDARD_RIGHTS_ALL | FILE_WRITE_ATTRIBUTES |
1N/A FILE_LIST_DIRECTORY | FILE_WRITE_DATA |
1N/A FILE_ADD_SUBDIRECTORY | FILE_READ_EA | FILE_WRITE_EA |
1N/A FILE_TRAVERSE | FILE_DELETE_CHILD |
1N/A FILE_READ_ATTRIBUTES;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] = const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A //ace2
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
1N/A INHERIT_ONLY_ACE;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = GENERIC_ALL;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] = const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A //ace3
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = 0;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = STANDARD_RIGHTS_ALL | FILE_WRITE_ATTRIBUTES |
1N/A FILE_LIST_DIRECTORY | FILE_WRITE_DATA |
1N/A FILE_ADD_SUBDIRECTORY | FILE_READ_EA | FILE_WRITE_EA |
1N/A FILE_TRAVERSE | FILE_DELETE_CHILD |
1N/A FILE_READ_ATTRIBUTES;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A
1N/A //ace4
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
1N/A INHERIT_ONLY_ACE;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = GENERIC_ALL;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A
1N/A //ace5
1N/A ace = (ACCESS_ALLOWED_ACE*)((char*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = 0;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = SYNCHRONIZE | READ_CONTROL | DELETE |
1N/A FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES |
1N/A FILE_TRAVERSE | FILE_WRITE_EA | FILE_READ_EA |
1N/A FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE |
1N/A FILE_LIST_DIRECTORY;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_AUTHENTICATED_USER_RID);
1N/A
1N/A //ace6
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
1N/A INHERIT_ONLY_ACE;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | DELETE;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_AUTHENTICATED_USER_RID);
1N/A
1N/A //ace7
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = 0;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = SYNCHRONIZE | READ_CONTROL | FILE_READ_ATTRIBUTES |
1N/A FILE_TRAVERSE | FILE_READ_EA | FILE_LIST_DIRECTORY;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] = const_cpu_to_le32(DOMAIN_ALIAS_RID_USERS);
1N/A
1N/A //ace8
1N/A ace = (ACCESS_ALLOWED_ACE*)((u8*)ace + le16_to_cpu(ace->size));
1N/A ace->type = ACCESS_ALLOWED_ACE_TYPE;
1N/A ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
1N/A INHERIT_ONLY_ACE;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = GENERIC_READ | GENERIC_EXECUTE;
1N/A ace->sid.revision = SID_REVISION;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] = const_cpu_to_le32(DOMAIN_ALIAS_RID_USERS);
1N/A
1N/A //owner sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->owner));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] = const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A
1N/A //group sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->group));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] = const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A}
1N/A
1N/A/**
1N/A * init_secure_sds -
1N/A *
1N/A * NTFS 3.1 - System files security decriptors
1N/A * ===========================================
1N/A * Create the security descriptor entries in $SDS data stream like they
1N/A * are in a partition, newly formatted with windows 2003
1N/A */
1N/Avoid init_secure_sds(char *sd_val)
1N/A{
1N/A SECURITY_DESCRIPTOR_HEADER *sds;
1N/A SECURITY_DESCRIPTOR_RELATIVE *sd;
1N/A ACL *acl;
1N/A ACCESS_ALLOWED_ACE *ace;
1N/A SID *sid;
1N/A
1N/A/*
1N/A * security descriptor #1
1N/A */
1N/A //header
1N/A sds = (SECURITY_DESCRIPTOR_HEADER*)((char*)sd_val);
1N/A sds->hash = const_cpu_to_le32(0xF80312F0);
1N/A sds->security_id = const_cpu_to_le32(0x0100);
1N/A sds->offset = const_cpu_to_le64(0x00);
1N/A sds->length = const_cpu_to_le32(0x7C);
1N/A //security descriptor relative
1N/A sd = (SECURITY_DESCRIPTOR_RELATIVE*)((char*)sds +
1N/A sizeof(SECURITY_DESCRIPTOR_HEADER));
1N/A sd->revision = 0x01;
1N/A sd->alignment = 0x00;
1N/A sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
1N/A sd->owner = const_cpu_to_le32(0x48);
1N/A sd->group = const_cpu_to_le32(0x58);
1N/A sd->sacl = const_cpu_to_le32(0x00);
1N/A sd->dacl = const_cpu_to_le32(0x14);
1N/A
1N/A //acl
1N/A acl = (ACL*)((char*)sd + sizeof(SECURITY_DESCRIPTOR_RELATIVE));
1N/A acl->revision = 0x02;
1N/A acl->alignment1 = 0x00;
1N/A acl->size = const_cpu_to_le16(0x34);
1N/A acl->ace_count = const_cpu_to_le16(0x02);
1N/A acl->alignment2 = 0x00;
1N/A
1N/A //ace1
1N/A ace = (ACCESS_ALLOWED_ACE*)((char*)acl + sizeof(ACL));
1N/A ace->type = 0x00;
1N/A ace->flags = 0x00;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = const_cpu_to_le32(0x120089);
1N/A ace->sid.revision = 0x01;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A //ace2
1N/A ace = (ACCESS_ALLOWED_ACE*)((char*)ace + le16_to_cpu(ace->size));
1N/A ace->type = 0x00;
1N/A ace->flags = 0x00;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = const_cpu_to_le32(0x120089);
1N/A ace->sid.revision = 0x01;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A //owner sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->owner));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A sid->sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A //group sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->group));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A sid->sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A/*
1N/A * security descriptor #2
1N/A */
1N/A //header
1N/A sds = (SECURITY_DESCRIPTOR_HEADER*)((char*)sd_val + 0x80);
1N/A sds->hash = const_cpu_to_le32(0xB32451);
1N/A sds->security_id = const_cpu_to_le32(0x0101);
1N/A sds->offset = const_cpu_to_le64(0x80);
1N/A sds->length = const_cpu_to_le32(0x7C);
1N/A
1N/A //security descriptor relative
1N/A sd = (SECURITY_DESCRIPTOR_RELATIVE*)((char*)sds +
1N/A sizeof(SECURITY_DESCRIPTOR_HEADER));
1N/A sd->revision = 0x01;
1N/A sd->alignment = 0x00;
1N/A sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
1N/A sd->owner = const_cpu_to_le32(0x48);
1N/A sd->group = const_cpu_to_le32(0x58);
1N/A sd->sacl = const_cpu_to_le32(0x00);
1N/A sd->dacl = const_cpu_to_le32(0x14);
1N/A
1N/A //acl
1N/A acl = (ACL*)((char*)sd + sizeof(SECURITY_DESCRIPTOR_RELATIVE));
1N/A acl->revision = 0x02;
1N/A acl->alignment1 = 0x00;
1N/A acl->size = const_cpu_to_le16(0x34);
1N/A acl->ace_count = const_cpu_to_le16(0x02);
1N/A acl->alignment2 = 0x00;
1N/A
1N/A //ace1
1N/A ace = (ACCESS_ALLOWED_ACE*)((char*)acl + sizeof(ACL));
1N/A ace->type = 0x00;
1N/A ace->flags = 0x00;
1N/A ace->size = const_cpu_to_le16(0x14);
1N/A ace->mask = const_cpu_to_le32(0x12019F);
1N/A ace->sid.revision = 0x01;
1N/A ace->sid.sub_authority_count = 0x01;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_LOCAL_SYSTEM_RID);
1N/A //ace2
1N/A ace = (ACCESS_ALLOWED_ACE*)((char*)ace + le16_to_cpu(ace->size));
1N/A ace->type = 0x00;
1N/A ace->flags = 0x00;
1N/A ace->size = const_cpu_to_le16(0x18);
1N/A ace->mask = const_cpu_to_le32(0x12019F);
1N/A ace->sid.revision = 0x01;
1N/A ace->sid.sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A ace->sid.identifier_authority.value[0] = 0;
1N/A ace->sid.identifier_authority.value[1] = 0;
1N/A ace->sid.identifier_authority.value[2] = 0;
1N/A ace->sid.identifier_authority.value[3] = 0;
1N/A ace->sid.identifier_authority.value[4] = 0;
1N/A ace->sid.identifier_authority.value[5] = 5;
1N/A ace->sid.sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A ace->sid.sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A //owner sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->owner));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A sid->sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A //group sid
1N/A sid = (SID*)((char*)sd + le32_to_cpu(sd->group));
1N/A sid->revision = 0x01;
1N/A sid->sub_authority_count = 0x02;
1N/A /* SECURITY_NT_SID_AUTHORITY (S-1-5) */
1N/A sid->identifier_authority.value[0] = 0;
1N/A sid->identifier_authority.value[1] = 0;
1N/A sid->identifier_authority.value[2] = 0;
1N/A sid->identifier_authority.value[3] = 0;
1N/A sid->identifier_authority.value[4] = 0;
1N/A sid->identifier_authority.value[5] = 5;
1N/A sid->sub_authority[0] =
1N/A const_cpu_to_le32(SECURITY_BUILTIN_DOMAIN_RID);
1N/A sid->sub_authority[1] =
1N/A const_cpu_to_le32(DOMAIN_ALIAS_RID_ADMINS);
1N/A
1N/A return;
1N/A}