Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

447 lines
16 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. tsevars.c
  5. Abstract:
  6. This Module contains variables used in security test routines.
  7. Author:
  8. Jim Kelly (JimK) 23-Mar-1990
  9. Environment:
  10. Test.
  11. Revision History:
  12. --*/
  13. #include "tsecomm.c" // Mode dependent macros and routines.
  14. #ifndef _TSEVARS_
  15. #define _TSEVARS_
  16. typedef enum _USERS {
  17. Fred,
  18. Wilma,
  19. Pebbles,
  20. Barney,
  21. Betty,
  22. Bambam,
  23. Dino
  24. } USERS;
  25. //
  26. // Define the Bedrock domain and its inhabitants
  27. //
  28. // Bedrock Domain S-1-39824-21-3-17
  29. // Fred S-1-39824-21-3-17-2
  30. // Wilma S-1-39824-21-3-17-3
  31. // Pebbles S-1-39824-21-3-17-4
  32. // Dino S-1-39824-21-3-17-5
  33. // Barney S-1-39824-21-3-17-6
  34. // Betty S-1-39824-21-3-17-7
  35. // Bambam S-1-39824-21-3-17-8
  36. // Flintstone S-1-39824-21-3-17-9
  37. // Rubble S-1-39824-21-3-17-10
  38. // Adult S-1-39824-21-3-17-11
  39. // Child S-1-39824-21-3-17-12
  40. // Neanderthol S-1-39824-21-3-17-13
  41. //
  42. #define BEDROCK_AUTHORITY {0,0,0,0,155,144}
  43. #define BEDROCKA_AUTHORITY {0,0,0,0,155,145}
  44. #define BEDROCKB_AUTHORITY {0,0,0,0,155,146}
  45. #define BEDROCKC_AUTHORITY {0,0,0,0,155,147}
  46. #define BEDROCKD_AUTHORITY {0,0,0,0,155,148}
  47. #define BEDROCKE_AUTHORITY {0,0,0,0,155,149}
  48. #define BEDROCK_SUBAUTHORITY_0 0x00000015L
  49. #define BEDROCK_SUBAUTHORITY_1 0x00000003L
  50. #define BEDROCK_SUBAUTHORITY_2 0x00000011L
  51. #define BEDROCKA_SUBAUTHORITY_0 0x00000015L
  52. #define BEDROCKA_SUBAUTHORITY_1 0x00000003L
  53. #define BEDROCKA_SUBAUTHORITY_2 0x00000111L
  54. #define BEDROCKB_SUBAUTHORITY_0 0x00000015L
  55. #define BEDROCKB_SUBAUTHORITY_1 0x00000003L
  56. #define BEDROCKB_SUBAUTHORITY_2 0x00000211L
  57. #define BEDROCKC_SUBAUTHORITY_0 0x00000015L
  58. #define BEDROCKC_SUBAUTHORITY_1 0x00000003L
  59. #define BEDROCKC_SUBAUTHORITY_2 0x00000311L
  60. #define BEDROCKD_SUBAUTHORITY_0 0x00000015L
  61. #define BEDROCKD_SUBAUTHORITY_1 0x00000003L
  62. #define BEDROCKD_SUBAUTHORITY_2 0x00000411L
  63. #define BEDROCKE_SUBAUTHORITY_0 0x00000015L
  64. #define BEDROCKE_SUBAUTHORITY_1 0x00000003L
  65. #define BEDROCKE_SUBAUTHORITY_2 0x00000511L
  66. #define FRED_RID 0x00000002L
  67. #define WILMA_RID 0x00000003L
  68. #define PEBBLES_RID 0x00000004L
  69. #define DINO_RID 0x00000005L
  70. #define BARNEY_RID 0x00000006L
  71. #define BETTY_RID 0x00000007L
  72. #define BAMBAM_RID 0x00000008L
  73. #define FLINTSTONE_RID 0x00000009L
  74. #define RUBBLE_RID 0x0000000AL
  75. #define ADULT_RID 0x0000000BL
  76. #define CHILD_RID 0x0000000CL
  77. #define NEANDERTHOL_RID 0x0000000DL
  78. PSID BedrockDomainSid;
  79. PSID BedrockADomainSid;
  80. PSID BedrockBDomainSid;
  81. PSID BedrockCDomainSid;
  82. PSID BedrockDDomainSid;
  83. PSID BedrockEDomainSid;
  84. PSID FredSid;
  85. PSID WilmaSid;
  86. PSID PebblesSid;
  87. PSID DinoSid;
  88. PSID BarneySid;
  89. PSID BettySid;
  90. PSID BambamSid;
  91. PSID FlintstoneSid;
  92. PSID RubbleSid;
  93. PSID AdultSid;
  94. PSID ChildSid;
  95. PSID NeandertholSid;
  96. //
  97. // Universal well known SIDs
  98. //
  99. PSID NullSid;
  100. PSID WorldSid;
  101. PSID LocalSid;
  102. PSID CreatorOwnerSid;
  103. PSID CreatorGroupSid;
  104. //
  105. // Sids defined by NT
  106. //
  107. PSID NtAuthoritySid;
  108. PSID DialupSid;
  109. PSID NetworkSid;
  110. PSID BatchSid;
  111. PSID InteractiveSid;
  112. PSID LocalSystemSid;
  113. ////////////////////////////////////////////////////////////////////////
  114. // //
  115. // Define the well known privileges //
  116. // //
  117. ////////////////////////////////////////////////////////////////////////
  118. LUID CreateTokenPrivilege;
  119. LUID AssignPrimaryTokenPrivilege;
  120. LUID LockMemoryPrivilege;
  121. LUID IncreaseQuotaPrivilege;
  122. LUID UnsolicitedInputPrivilege;
  123. LUID TcbPrivilege;
  124. LUID SecurityPrivilege;
  125. LUID TakeOwnershipPrivilege;
  126. LUID LpcReplyBoostPrivilege;
  127. LUID CreatePagefilePrivilege;
  128. LUID IncreaseBasePriorityPrivilege;
  129. LUID SystemProfilePrivilege;
  130. LUID SystemtimePrivilege;
  131. LUID ProfileSingleProcessPrivilege;
  132. LUID RestorePrivilege;
  133. LUID BackupPrivilege;
  134. LUID CreatePermanentPrivilege;
  135. LUID ShutdownPrivilege;
  136. LUID DebugPrivilege;
  137. BOOLEAN
  138. TSeVariableInitialization()
  139. /*++
  140. Routine Description:
  141. This function initializes the global variables used in security
  142. tests.
  143. Arguments:
  144. None.
  145. Return Value:
  146. TRUE if variables successfully initialized.
  147. FALSE if not successfully initialized.
  148. --*/
  149. {
  150. ULONG SidWithZeroSubAuthorities;
  151. ULONG SidWithOneSubAuthority;
  152. ULONG SidWithThreeSubAuthorities;
  153. ULONG SidWithFourSubAuthorities;
  154. SID_IDENTIFIER_AUTHORITY NullSidAuthority = SECURITY_NULL_SID_AUTHORITY;
  155. SID_IDENTIFIER_AUTHORITY WorldSidAuthority = SECURITY_WORLD_SID_AUTHORITY;
  156. SID_IDENTIFIER_AUTHORITY LocalSidAuthority = SECURITY_LOCAL_SID_AUTHORITY;
  157. SID_IDENTIFIER_AUTHORITY CreatorSidAuthority = SECURITY_CREATOR_SID_AUTHORITY;
  158. SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
  159. SID_IDENTIFIER_AUTHORITY BedrockAuthority = BEDROCK_AUTHORITY;
  160. SID_IDENTIFIER_AUTHORITY BedrockAAuthority = BEDROCKA_AUTHORITY;
  161. SID_IDENTIFIER_AUTHORITY BedrockBAuthority = BEDROCKB_AUTHORITY;
  162. SID_IDENTIFIER_AUTHORITY BedrockCAuthority = BEDROCKC_AUTHORITY;
  163. SID_IDENTIFIER_AUTHORITY BedrockDAuthority = BEDROCKD_AUTHORITY;
  164. SID_IDENTIFIER_AUTHORITY BedrockEAuthority = BEDROCKE_AUTHORITY;
  165. //
  166. // The following SID sizes need to be allocated
  167. //
  168. SidWithZeroSubAuthorities = RtlLengthRequiredSid( 0 );
  169. SidWithOneSubAuthority = RtlLengthRequiredSid( 1 );
  170. SidWithThreeSubAuthorities = RtlLengthRequiredSid( 3 );
  171. SidWithFourSubAuthorities = RtlLengthRequiredSid( 4 );
  172. //
  173. // Allocate and initialize the universal SIDs
  174. //
  175. NullSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  176. WorldSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  177. LocalSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  178. CreatorOwnerSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  179. CreatorGroupSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  180. RtlInitializeSid( NullSid, &NullSidAuthority, 1 );
  181. RtlInitializeSid( WorldSid, &WorldSidAuthority, 1 );
  182. RtlInitializeSid( LocalSid, &LocalSidAuthority, 1 );
  183. RtlInitializeSid( CreatorOwnerSid, &CreatorSidAuthority, 1 );
  184. RtlInitializeSid( CreatorGroupSid, &CreatorSidAuthority, 1 );
  185. *(RtlSubAuthoritySid( NullSid, 0 )) = SECURITY_NULL_RID;
  186. *(RtlSubAuthoritySid( WorldSid, 0 )) = SECURITY_WORLD_RID;
  187. *(RtlSubAuthoritySid( LocalSid, 0 )) = SECURITY_LOCAL_RID;
  188. *(RtlSubAuthoritySid( CreatorOwnerSid, 0 )) = SECURITY_CREATOR_OWNER_RID;
  189. *(RtlSubAuthoritySid( CreatorGroupSid, 0 )) = SECURITY_CREATOR_GROUP_RID;
  190. //
  191. // Allocate and initialize the NT defined SIDs
  192. //
  193. NtAuthoritySid = (PSID)TstAllocatePool(PagedPool,SidWithZeroSubAuthorities);
  194. DialupSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  195. NetworkSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  196. BatchSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  197. InteractiveSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  198. LocalSystemSid = (PSID)TstAllocatePool(PagedPool,SidWithOneSubAuthority);
  199. RtlInitializeSid( NtAuthoritySid, &NtAuthority, 0 );
  200. RtlInitializeSid( DialupSid, &NtAuthority, 1 );
  201. RtlInitializeSid( NetworkSid, &NtAuthority, 1 );
  202. RtlInitializeSid( BatchSid, &NtAuthority, 1 );
  203. RtlInitializeSid( InteractiveSid, &NtAuthority, 1 );
  204. RtlInitializeSid( LocalSystemSid, &NtAuthority, 1 );
  205. *(RtlSubAuthoritySid( DialupSid, 0 )) = SECURITY_DIALUP_RID;
  206. *(RtlSubAuthoritySid( NetworkSid, 0 )) = SECURITY_NETWORK_RID;
  207. *(RtlSubAuthoritySid( BatchSid, 0 )) = SECURITY_BATCH_RID;
  208. *(RtlSubAuthoritySid( InteractiveSid, 0 )) = SECURITY_INTERACTIVE_RID;
  209. *(RtlSubAuthoritySid( LocalSystemSid, 0 )) = SECURITY_LOCAL_SYSTEM_RID;
  210. //
  211. // Allocate and initialize the Bedrock SIDs
  212. //
  213. BedrockDomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  214. BedrockADomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  215. BedrockBDomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  216. BedrockCDomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  217. BedrockDDomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  218. BedrockEDomainSid = (PSID)TstAllocatePool(PagedPool,SidWithThreeSubAuthorities);
  219. FredSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  220. WilmaSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  221. PebblesSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  222. DinoSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  223. BarneySid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  224. BettySid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  225. BambamSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  226. FlintstoneSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  227. RubbleSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  228. AdultSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  229. ChildSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  230. NeandertholSid = (PSID)TstAllocatePool(PagedPool,SidWithFourSubAuthorities);
  231. RtlInitializeSid( BedrockDomainSid, &BedrockAuthority, 3 );
  232. *(RtlSubAuthoritySid( BedrockDomainSid, 0)) = BEDROCK_SUBAUTHORITY_0;
  233. *(RtlSubAuthoritySid( BedrockDomainSid, 1)) = BEDROCK_SUBAUTHORITY_1;
  234. *(RtlSubAuthoritySid( BedrockDomainSid, 2)) = BEDROCK_SUBAUTHORITY_2;
  235. RtlInitializeSid( BedrockADomainSid, &BedrockAAuthority, 3 );
  236. *(RtlSubAuthoritySid( BedrockADomainSid, 0)) = BEDROCKA_SUBAUTHORITY_0;
  237. *(RtlSubAuthoritySid( BedrockADomainSid, 1)) = BEDROCKA_SUBAUTHORITY_1;
  238. *(RtlSubAuthoritySid( BedrockADomainSid, 2)) = BEDROCKA_SUBAUTHORITY_2;
  239. RtlInitializeSid( BedrockBDomainSid, &BedrockBAuthority, 3 );
  240. *(RtlSubAuthoritySid( BedrockBDomainSid, 0)) = BEDROCKB_SUBAUTHORITY_0;
  241. *(RtlSubAuthoritySid( BedrockBDomainSid, 1)) = BEDROCKB_SUBAUTHORITY_1;
  242. *(RtlSubAuthoritySid( BedrockBDomainSid, 2)) = BEDROCKB_SUBAUTHORITY_2;
  243. RtlInitializeSid( BedrockCDomainSid, &BedrockCAuthority, 3 );
  244. *(RtlSubAuthoritySid( BedrockCDomainSid, 0)) = BEDROCKC_SUBAUTHORITY_0;
  245. *(RtlSubAuthoritySid( BedrockCDomainSid, 1)) = BEDROCKC_SUBAUTHORITY_1;
  246. *(RtlSubAuthoritySid( BedrockCDomainSid, 2)) = BEDROCKC_SUBAUTHORITY_2;
  247. RtlInitializeSid( BedrockDDomainSid, &BedrockDAuthority, 3 );
  248. *(RtlSubAuthoritySid( BedrockDDomainSid, 0)) = BEDROCKD_SUBAUTHORITY_0;
  249. *(RtlSubAuthoritySid( BedrockDDomainSid, 1)) = BEDROCKD_SUBAUTHORITY_1;
  250. *(RtlSubAuthoritySid( BedrockDDomainSid, 2)) = BEDROCKD_SUBAUTHORITY_2;
  251. RtlInitializeSid( BedrockEDomainSid, &BedrockEAuthority, 3 );
  252. *(RtlSubAuthoritySid( BedrockEDomainSid, 0)) = BEDROCKE_SUBAUTHORITY_0;
  253. *(RtlSubAuthoritySid( BedrockEDomainSid, 1)) = BEDROCKE_SUBAUTHORITY_1;
  254. *(RtlSubAuthoritySid( BedrockEDomainSid, 2)) = BEDROCKE_SUBAUTHORITY_2;
  255. RtlCopySid( SidWithFourSubAuthorities, FredSid, BedrockDomainSid);
  256. *(RtlSubAuthorityCountSid( FredSid )) += 1;
  257. *(RtlSubAuthoritySid( FredSid, 3)) = FRED_RID;
  258. RtlCopySid( SidWithFourSubAuthorities, WilmaSid, BedrockDomainSid);
  259. *(RtlSubAuthorityCountSid( WilmaSid )) += 1;
  260. *(RtlSubAuthoritySid( WilmaSid, 3)) = WILMA_RID;
  261. RtlCopySid( SidWithFourSubAuthorities, PebblesSid, BedrockDomainSid);
  262. *(RtlSubAuthorityCountSid( PebblesSid )) += 1;
  263. *(RtlSubAuthoritySid( PebblesSid, 3)) = PEBBLES_RID;
  264. RtlCopySid( SidWithFourSubAuthorities, DinoSid, BedrockDomainSid);
  265. *(RtlSubAuthorityCountSid( DinoSid )) += 1;
  266. *(RtlSubAuthoritySid( DinoSid, 3)) = DINO_RID;
  267. RtlCopySid( SidWithFourSubAuthorities, BarneySid, BedrockDomainSid);
  268. *(RtlSubAuthorityCountSid( BarneySid )) += 1;
  269. *(RtlSubAuthoritySid( BarneySid, 3)) = BARNEY_RID;
  270. RtlCopySid( SidWithFourSubAuthorities, BettySid, BedrockDomainSid);
  271. *(RtlSubAuthorityCountSid( BettySid )) += 1;
  272. *(RtlSubAuthoritySid( BettySid, 3)) = BETTY_RID;
  273. RtlCopySid( SidWithFourSubAuthorities, BambamSid, BedrockDomainSid);
  274. *(RtlSubAuthorityCountSid( BambamSid )) += 1;
  275. *(RtlSubAuthoritySid( BambamSid, 3)) = BAMBAM_RID;
  276. RtlCopySid( SidWithFourSubAuthorities, FlintstoneSid, BedrockDomainSid);
  277. *(RtlSubAuthorityCountSid( FlintstoneSid )) += 1;
  278. *(RtlSubAuthoritySid( FlintstoneSid, 3)) = FLINTSTONE_RID;
  279. RtlCopySid( SidWithFourSubAuthorities, RubbleSid, BedrockDomainSid);
  280. *(RtlSubAuthorityCountSid( RubbleSid )) += 1;
  281. *(RtlSubAuthoritySid( RubbleSid, 3)) = RUBBLE_RID;
  282. RtlCopySid( SidWithFourSubAuthorities, AdultSid, BedrockDomainSid);
  283. *(RtlSubAuthorityCountSid( AdultSid )) += 1;
  284. *(RtlSubAuthoritySid( AdultSid, 3)) = ADULT_RID;
  285. RtlCopySid( SidWithFourSubAuthorities, ChildSid, BedrockDomainSid);
  286. *(RtlSubAuthorityCountSid( ChildSid )) += 1;
  287. *(RtlSubAuthoritySid( ChildSid, 3)) = CHILD_RID;
  288. RtlCopySid( SidWithFourSubAuthorities, NeandertholSid, BedrockDomainSid);
  289. *(RtlSubAuthorityCountSid( NeandertholSid )) += 1;
  290. *(RtlSubAuthoritySid( NeandertholSid, 3)) = NEANDERTHOL_RID;
  291. CreateTokenPrivilege =
  292. RtlConvertLongToLargeInteger(SE_CREATE_TOKEN_PRIVILEGE);
  293. AssignPrimaryTokenPrivilege =
  294. RtlConvertLongToLargeInteger(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE);
  295. LockMemoryPrivilege =
  296. RtlConvertLongToLargeInteger(SE_LOCK_MEMORY_PRIVILEGE);
  297. IncreaseQuotaPrivilege =
  298. RtlConvertLongToLargeInteger(SE_INCREASE_QUOTA_PRIVILEGE);
  299. UnsolicitedInputPrivilege =
  300. RtlConvertLongToLargeInteger(SE_UNSOLICITED_INPUT_PRIVILEGE);
  301. TcbPrivilege =
  302. RtlConvertLongToLargeInteger(SE_TCB_PRIVILEGE);
  303. SecurityPrivilege =
  304. RtlConvertLongToLargeInteger(SE_SECURITY_PRIVILEGE);
  305. TakeOwnershipPrivilege =
  306. RtlConvertLongToLargeInteger(SE_TAKE_OWNERSHIP_PRIVILEGE);
  307. LpcReplyBoostPrivilege =
  308. RtlConvertLongToLargeInteger(SE_LPC_REPLY_BOOST_PRIVILEGE);
  309. CreatePagefilePrivilege =
  310. RtlConvertLongToLargeInteger(SE_CREATE_PAGEFILE_PRIVILEGE);
  311. IncreaseBasePriorityPrivilege =
  312. RtlConvertLongToLargeInteger(SE_INC_BASE_PRIORITY_PRIVILEGE);
  313. SystemProfilePrivilege =
  314. RtlConvertLongToLargeInteger(SE_SYSTEM_PROFILE_PRIVILEGE);
  315. SystemtimePrivilege =
  316. RtlConvertLongToLargeInteger(SE_SYSTEMTIME_PRIVILEGE);
  317. ProfileSingleProcessPrivilege =
  318. RtlConvertLongToLargeInteger(SE_PROF_SINGLE_PROCESS_PRIVILEGE);
  319. CreatePermanentPrivilege =
  320. RtlConvertLongToLargeInteger(SE_CREATE_PERMANENT_PRIVILEGE);
  321. BackupPrivilege =
  322. RtlConvertLongToLargeInteger(SE_BACKUP_PRIVILEGE);
  323. RestorePrivilege =
  324. RtlConvertLongToLargeInteger(SE_RESTORE_PRIVILEGE);
  325. ShutdownPrivilege =
  326. RtlConvertLongToLargeInteger(SE_SHUTDOWN_PRIVILEGE);
  327. DebugPrivilege =
  328. RtlConvertLongToLargeInteger(SE_DEBUG_PRIVILEGE);
  329. return TRUE;
  330. }
  331. #endif // _TSEVARS_