libsmb2-dcerpc-lsa.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
  2. /*
  3. Copyright (C) 2020 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef _LIBSMB2_DCERPC_LSA_H_
  16. #define _LIBSMB2_DCERPC_LSA_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define LSA_CLOSE 0x00
  21. #define LSA_OPENPOLICY2 0x2c
  22. #define LSA_LOOKUPSIDS2 0x39
  23. /* Access Mask. LSA specific flags. */
  24. #define POLICY_VIEW_LOCAL_INFORMATION 0x00000001
  25. #define POLICY_VIEW_AUDIT_INFORMATION 0x00000002
  26. #define POLICY_GET_PRIVATE_INFORMATION 0x00000004
  27. #define POLICY_TRUST_ADMIN 0x00000008
  28. #define POLICY_CREATE_ACCOUNT 0x00000010
  29. #define POLICY_CREATE_SECRET 0x00000020
  30. #define POLICY_CREATE_PRIVILEGE 0x00000040
  31. #define POLICY_SET_DEFAULT_QUOTA_LIMITS 0x00000080
  32. #define POLICY_SET_AUDIT_REQUIREMENTS 0x00000100
  33. #define POLICY_AUDIT_LOG_ADMIN 0x00000200
  34. #define POLICY_SERVER_ADMIN 0x00000400
  35. #define POLICY_LOOKUP_NAMES 0x00000800
  36. #define POLICY_NOTIFICATION 0x00001000
  37. extern unsigned char NT_SID_AUTHORITY[6];
  38. typedef struct RPC_SID {
  39. uint8_t Revision;
  40. uint8_t SubAuthorityCount;
  41. uint8_t IdentifierAuthority[6];
  42. uint32_t *SubAuthority;
  43. } RPC_SID, *PRPC_SID;
  44. typedef struct _LSAPR_TRANSLATED_NAME_EX {
  45. uint32_t Use;
  46. char *Name;
  47. uint32_t DomainIndex;
  48. uint32_t Flags;
  49. } LSAPR_TRANSLATED_NAME_EX, *PLSAPR_TRANSLATED_NAME_EX;
  50. typedef struct _LSAPR_TRANSLATED_NAMES_EX {
  51. uint32_t Entries;
  52. LSAPR_TRANSLATED_NAME_EX *Names;
  53. } LSAPR_TRANSLATED_NAMES_EX, *PLSAPR_TRANSLATED_NAMES_EX;
  54. typedef struct _SID_ENUM_BUFFER {
  55. uint32_t Entries;
  56. PRPC_SID *SidInfo;
  57. } LSAPR_SID_ENUM_BUFFER, *PLSAPR_SID_ENUM_BUFFER;
  58. typedef enum _LSAP_LOOKUP_LEVEL {
  59. LsapLookupWksta = 1,
  60. LsapLookupPDC,
  61. LsapLookupTDL,
  62. LsapLookupGC,
  63. LsapLookupXForestReferral,
  64. LsapLookupXForestResolve,
  65. LsapLookupRODCReferralToFullDC
  66. } LSAP_LOOKUP_LEVEL, *PLSAP_LOOKUP_LEVEL;
  67. typedef struct _LSAPR_TRUST_INFORMATION {
  68. char *Name;
  69. RPC_SID Sid;
  70. } LSAPR_TRUST_INFORMATION, *PLSAPR_TRUST_INFORMATION;
  71. typedef struct _LSAPR_REFERENCED_DOMAIN_LIST {
  72. uint32_t Entries;
  73. LSAPR_TRUST_INFORMATION *Domains;
  74. uint32_t MaxEntries; /* must be ignored */
  75. } LSAPR_REFERENCED_DOMAIN_LIST, *PLSAPR_REFERENCED_DOMAIN_LIST;
  76. /* For OPENPOLICY2: RootDirectory MUST be zero. Everything else is ignored. */
  77. typedef struct _LSAPR_OBJECT_ATTRIBUTES {
  78. uint32_t Length;
  79. unsigned char *RootDirectory;
  80. void *ObjectName;
  81. uint32_t Attributes;
  82. void *SecurityDescriptor;
  83. void *SecurityQualityOfService;
  84. } LSAPR_OBJECT_ATTRIBUTES, *PLSAPR_OBJECT_ATTRIBUTES;
  85. struct lsa_close_req {
  86. struct ndr_context_handle PolicyHandle;
  87. };
  88. struct lsa_close_rep {
  89. uint32_t status;
  90. struct ndr_context_handle PolicyHandle;
  91. };
  92. struct lsa_openpolicy2_req {
  93. char *SystemName;
  94. LSAPR_OBJECT_ATTRIBUTES ObjectAttributes;
  95. uint32_t DesiredAccess;
  96. };
  97. struct lsa_openpolicy2_rep {
  98. uint32_t status;
  99. struct ndr_context_handle PolicyHandle;
  100. };
  101. struct lsa_lookupsids2_req {
  102. struct ndr_context_handle PolicyHandle;
  103. LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
  104. LSAPR_TRANSLATED_NAMES_EX TranslatedNames;
  105. LSAP_LOOKUP_LEVEL LookupLevel;
  106. };
  107. struct lsa_lookupsids2_rep {
  108. uint32_t status;
  109. LSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains;
  110. LSAPR_TRANSLATED_NAMES_EX TranslatedNames;
  111. uint32_t MappedCount;
  112. };
  113. int lsa_Close_rep_coder(struct dcerpc_context *dce,
  114. struct dcerpc_pdu *pdu,
  115. struct smb2_iovec *iov, int *offset,
  116. void *ptr);
  117. int lsa_Close_req_coder(struct dcerpc_context *dce,
  118. struct dcerpc_pdu *pdu,
  119. struct smb2_iovec *iov, int *offset,
  120. void *ptr);
  121. int lsa_LookupSids2_rep_coder(struct dcerpc_context *dce,
  122. struct dcerpc_pdu *pdu,
  123. struct smb2_iovec *iov, int *offset,
  124. void *ptr);
  125. int lsa_LookupSids2_req_coder(struct dcerpc_context *dce,
  126. struct dcerpc_pdu *pdu,
  127. struct smb2_iovec *iov, int *offset,
  128. void *ptr);
  129. int lsa_OpenPolicy2_rep_coder(struct dcerpc_context *dce,
  130. struct dcerpc_pdu *pdu,
  131. struct smb2_iovec *iov, int *offset,
  132. void *ptr);
  133. int lsa_OpenPolicy2_req_coder(struct dcerpc_context *dce,
  134. struct dcerpc_pdu *pdu,
  135. struct smb2_iovec *iov, int *offset,
  136. void *ptr);
  137. int lsa_RPC_SID_coder(struct dcerpc_context *dce,
  138. struct dcerpc_pdu *pdu,
  139. struct smb2_iovec *iov, int *offset,
  140. void *ptr);
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif /* !_LIBSMB2_DCERPC_LSA_H_ */