ruby_smb 2.0.12 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/verify.yml +1 -1
  4. data/examples/dump_secrets_from_sid.rb +207 -0
  5. data/examples/enum_domain_users.rb +75 -0
  6. data/examples/get_computer_info.rb +42 -0
  7. data/examples/query_service_status.rb +42 -4
  8. data/lib/ruby_smb/client.rb +3 -14
  9. data/lib/ruby_smb/dcerpc/bind.rb +28 -20
  10. data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
  11. data/lib/ruby_smb/dcerpc/client.rb +542 -0
  12. data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
  13. data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
  14. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
  15. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
  16. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
  17. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
  18. data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
  19. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
  20. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
  21. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
  22. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
  23. data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
  24. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
  25. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
  26. data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
  27. data/lib/ruby_smb/dcerpc/epm.rb +75 -0
  28. data/lib/ruby_smb/dcerpc/error.rb +17 -0
  29. data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
  30. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
  31. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
  32. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
  33. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
  34. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
  35. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
  36. data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
  37. data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
  38. data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
  39. data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
  40. data/lib/ruby_smb/dcerpc/request.rb +79 -32
  41. data/lib/ruby_smb/dcerpc/response.rb +45 -10
  42. data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
  43. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
  44. data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
  45. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
  46. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
  47. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
  48. data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
  49. data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
  50. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
  51. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
  52. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
  53. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
  54. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
  55. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
  56. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
  57. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
  58. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
  59. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
  60. data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
  61. data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
  62. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
  63. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
  64. data/lib/ruby_smb/dcerpc/samr.rb +613 -0
  65. data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
  66. data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
  67. data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
  68. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
  69. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
  70. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
  71. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
  72. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
  73. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
  74. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
  75. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
  76. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
  77. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
  78. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
  79. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
  80. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
  81. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
  82. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
  83. data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
  84. data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
  85. data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
  86. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
  87. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
  88. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
  89. data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
  90. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
  91. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
  92. data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
  93. data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
  94. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
  95. data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
  96. data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
  97. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
  98. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
  99. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
  100. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
  101. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
  102. data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
  103. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
  104. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
  105. data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
  106. data/lib/ruby_smb/dcerpc.rb +41 -11
  107. data/lib/ruby_smb/field/file_time.rb +1 -1
  108. data/lib/ruby_smb/field/string16.rb +5 -1
  109. data/lib/ruby_smb/ntlm.rb +18 -2
  110. data/lib/ruby_smb/smb1/pipe.rb +4 -0
  111. data/lib/ruby_smb/smb2/pipe.rb +4 -0
  112. data/lib/ruby_smb/version.rb +1 -1
  113. data/spec/lib/ruby_smb/client_spec.rb +1 -2
  114. data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
  115. data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
  116. data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
  117. data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
  118. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
  119. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
  120. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
  121. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
  122. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
  123. data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
  124. data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
  125. data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
  126. data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
  127. data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
  128. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
  129. data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
  130. data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
  131. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
  132. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
  133. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
  134. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
  135. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
  136. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
  137. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
  138. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
  139. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
  140. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
  141. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
  142. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
  143. data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
  144. data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
  145. data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
  146. data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
  147. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
  148. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
  149. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
  150. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
  151. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
  152. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
  153. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
  154. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
  155. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
  156. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
  157. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
  158. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
  159. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
  160. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
  161. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
  162. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
  163. data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
  164. data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
  165. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
  166. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
  167. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
  168. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
  169. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
  170. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
  171. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
  172. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
  173. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
  174. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
  175. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
  176. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
  177. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
  178. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
  179. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
  180. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
  181. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
  182. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
  183. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
  184. data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
  185. data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
  186. data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
  187. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
  188. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
  189. data/spec/support/bin_helper.rb +9 -0
  190. data.tar.gz.sig +0 -0
  191. metadata +96 -5
  192. metadata.gz.sig +0 -0
  193. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
  194. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -0,0 +1,150 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+ WELL_KNOWN_SID_NAME = {
5
+ [0,0] => 'NULL SID',
6
+ [1,0] => 'Everyone',
7
+ [2,0] => 'LOCAL',
8
+ [2,1] => 'CONSOLE LOGON',
9
+ [3,0] => 'CREATOR OWNER',
10
+ [3,1] => 'CREATOR GROUP',
11
+ [3,2] => 'CREATOR OWNER SERVER',
12
+ [3,3] => 'CREATOR GROUP SERVER',
13
+ [3,4] => 'OWNER RIGHTS',
14
+ [5,1] => 'NT AUTHORITY\\DIALUP',
15
+ [5,2] => 'NT AUTHORITY\\NETWORK',
16
+ [5,3] => 'NT AUTHORITY\\BATCH',
17
+ [5,4] => 'NT AUTHORITY\\INTERACTIVE',
18
+ [5,6] => 'NT AUTHORITY\\SERVICE',
19
+ [5,7] => 'NT AUTHORITY\\ANONYMOUS LOGON',
20
+ [5,8] => 'NT AUTHORITY\\PROXY',
21
+ [5,9] => 'NT AUTHORITY\\ENTERPRISE DOMAIN CONTROLLERS',
22
+ [5,10] => 'NT AUTHORITY\\SELF',
23
+ [5,11] => 'NT AUTHORITY\\Authenticated Users',
24
+ [5,12] => 'NT AUTHORITY\\RESTRICTED',
25
+ [5,13] => 'NT AUTHORITY\\TERMINAL SERVER USER',
26
+ [5,14] => 'NT AUTHORITY\\REMOTE INTERACTIVE LOGON',
27
+ [5,15] => 'NT AUTHORITY\\This Organization',
28
+ [5,17] => 'NT AUTHORITY\\IUSR',
29
+ [5,18] => 'NT AUTHORITY\\SYSTEM',
30
+ [5,19] => 'NT AUTHORITY\\LOCAL SERVICE',
31
+ [5,20] => 'NT AUTHORITY\\NETWORK SERVICE',
32
+ [5,22] => 'NT AUTHORITY\\ENTERPRISE READ-ONLY DOMAIN CONTROLLERS BETA',
33
+ [5,33] => 'NT AUTHORITY\\WRITE RESTRICTED',
34
+ [5,32] => 'Builtin Domain'
35
+ }
36
+
37
+ WELL_KNOWN_RID_NAME = {
38
+ 498 => '(domain)\\Enterprise Read-only Domain Controllers',
39
+ 500 => '(domain)\\Administrator',
40
+ 501 => '(domain)\\Guest',
41
+ 502 => '(domain)\\krbtgt',
42
+ 512 => '(domain)\\Domain Admins',
43
+ 513 => '(domain)\\Domain Users',
44
+ 514 => '(domain)\\Domain Guests',
45
+ 515 => '(domain)\\Domain Computers',
46
+ 516 => '(domain)\\Domain Controllers',
47
+ 517 => '(domain)\\Cert Publishers',
48
+ 518 => '(domain)\\Schema Admins',
49
+ 519 => '(domain)\\Enterprise Admins',
50
+ 520 => '(domain)\\Group Policy Creator Owners',
51
+ 521 => '(domain)\\Read-only Domain Controllers',
52
+ 522 => '(domain)\\Cloneable Domain Controllers',
53
+ 544 => 'BUILTIN\\Administrators',
54
+ 545 => 'BUILTIN\\Users',
55
+ 546 => 'BUILTIN\\Guests',
56
+ 548 => 'BUILTIN\\Account Operators',
57
+ 549 => 'BUILTIN\\Server Operators',
58
+ 550 => 'BUILTIN\\Print Operators',
59
+ 551 => 'BUILTIN\\Backup Operators',
60
+ 552 => 'BUILTIN\\Replicator',
61
+ 553 => '(domain)\\RAS and IAS Servers',
62
+ 554 => 'BUILTIN\\Pre-Windows 2000 Compatible Access',
63
+ 555 => 'BUILTIN\\Remote Desktop Users',
64
+ 556 => 'BUILTIN\\Network Configuration Operators',
65
+ 557 => 'BUILTIN\\Incoming Forest Trust Builders',
66
+ 558 => 'BUILTIN\\Performance Monitor Users',
67
+ 559 => 'BUILTIN\\Performance Log Users',
68
+ 560 => 'BUILTIN\\Windows Authorization Access Group',
69
+ 561 => 'BUILTIN\\Terminal Server License Servers',
70
+ 562 => 'BUILTIN\\Distributed COM Users',
71
+ 568 => 'BUILTIN\\IIS_IUSRS',
72
+ 569 => 'BUILTIN\\Cryptographic Operators',
73
+ 571 => '(domain)\\Allowed RODC Password Replication Group',
74
+ 572 => '(domain)\\Denied RODC Password Replication Group',
75
+ 573 => 'BUILTIN\\Event Log Readers',
76
+ 574 => 'BUILTIN\\Certificate Service DCOM Access',
77
+ 575 => 'BUILTIN\\RDS Remote Access Servers',
78
+ 576 => 'BUILTIN\\RDS Endpoint Servers',
79
+ 577 => 'BUILTIN\\RDS Management Servers',
80
+ 578 => 'BUILTIN\\Hyper-V Administrators',
81
+ 579 => 'BUILTIN\\Access Control Assistance Operators',
82
+ 580 => 'BUILTIN\\Remote Management Users'
83
+ }
84
+
85
+ #[2.4.1.1 RPC_SID_IDENTIFIER_AUTHORITY](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/d7e6e5a5-437c-41e5-8ba1-bdfd43e96cbc)
86
+ class RpcSidIdentifierAuthority < Ndr::NdrFixArray
87
+ default_parameters type: :ndr_uint8, initial_length: 6, byte_align: 1
88
+ end
89
+
90
+ # [2.4.2.3 RPC_SID](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/5cb97814-a1c2-4215-b7dc-76d1f4bfad01)
91
+ class RpcSid < Ndr::NdrStruct
92
+ default_parameters byte_align: 4
93
+ endian :little
94
+
95
+ ndr_uint8 :revision
96
+ ndr_uint8 :sub_authority_count, initial_value: -> { self.sub_authority.size }
97
+ rpc_sid_identifier_authority :identifier_authority
98
+ ndr_conf_array :sub_authority, type: :ndr_uint32
99
+
100
+ def snapshot
101
+ sid = ['S', self.revision.to_s, self.identifier_authority[-1].to_s]
102
+ self.sub_authority.each { |e| sid << e.to_s }
103
+ sid.join('-')
104
+ end
105
+
106
+ def assign(val)
107
+ case val
108
+ when String
109
+ elems = val.split('-')
110
+ raise ArgumentError, "Wrong SID format" unless elems[0].downcase == 's'
111
+ self.revision = elems[1].to_i
112
+ self.sub_authority_count = elems[3..-1].size
113
+ self.identifier_authority = [0, 0, 0, 0, 0, elems[2].to_i]
114
+ self.sub_authority = elems[3..-1].map(&:to_i)
115
+ when RpcSid
116
+ super
117
+ else
118
+ raise ArgumentError, "Can only assign String or other RpcSid object (got #{val.class})"
119
+ end
120
+ self
121
+ end
122
+
123
+ def name
124
+ sid = case sub_authority.size
125
+ when 1
126
+ WELL_KNOWN_SID_NAME[[identifier_authority[-1].to_i, sub_authority[0].to_i]]
127
+ when 2
128
+ if identifier_authority[-1] == 5 && sub_authority[0] == 32
129
+ WELL_KNOWN_RID_NAME[sub_authority[1]]
130
+ end
131
+ when 3
132
+ if identifier_authority[-1] == 5 && sub_authority[0] == 5
133
+ "Current Session Logon SID"
134
+ end
135
+ else
136
+ if identifier_authority[-1] == 5
137
+ WELL_KNOWN_RID_NAME[sub_authority.last]
138
+ end
139
+ end
140
+ sid || "Unknown SID (#{self})"
141
+ end
142
+ end
143
+
144
+ class PrpcSid < RpcSid
145
+ extend Ndr::PointerClassPlugin
146
+ end
147
+
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,23 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.13.1 SamrCloseHandle (Opnum 1)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/55d134df-e257-48ad-8afa-cb2ca45cd3cc)
6
+ class SamrCloseHandleRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :sam_handle
12
+
13
+ def initialize_instance
14
+ super
15
+ @opnum = SAMR_CLOSE_HANDLE
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,24 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.13.1 SamrCloseHandle (Opnum 1)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/55d134df-e257-48ad-8afa-cb2ca45cd3cc)
6
+ class SamrCloseHandleResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :sam_handle
12
+ ndr_uint32 :error_status
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_CLOSE_HANDLE
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,32 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [2.2.7.1 PSAMPR_SERVER_NAME](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/7a77f1ce-cc55-4e36-a3c2-87c48f835f86)
6
+ class PsamprServerName < RubySMB::Field::Stringz16
7
+ default_parameters referent_byte_align: 2
8
+ extend Ndr::PointerClassPlugin
9
+ end
10
+
11
+ # [3.1.5.1.4 SamrConnect (Opnum 0)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/defe2091-0a61-4dfa-be9a-2c1206d53a1f)
12
+ class SamrConnectRequest < BinData::Record
13
+ attr_reader :opnum
14
+
15
+ endian :little
16
+
17
+ psampr_server_name :server_name
18
+ # Access control on a server object: bitwise OR of common ACCESS_MASK
19
+ # and server ACCESS_MASK values (see lib/ruby_smb/dcerpc/samr.rb)
20
+ ndr_uint32 :desired_access
21
+
22
+ def initialize_instance
23
+ super
24
+ @opnum = SAMR_CONNECT
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+
32
+
@@ -0,0 +1,23 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.1.4 SamrConnect (Opnum 0)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/defe2091-0a61-4dfa-be9a-2c1206d53a1f)
6
+ class SamrConnectResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :server_handle
12
+ ndr_uint32 :error_status
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_CONNECT
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,26 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.2.5 SamrEnumerateUsersInDomain (Opnum 13)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/6bdc92c0-c692-4ffb-9de7-65858b68da75)
6
+ class SamrEnumerateUsersInDomainRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :domain_handle
12
+ ndr_uint32 :enumeration_context
13
+ # UserAccountControl flags are defined in lib/ruby_smb/dcerpc/samr.rb
14
+ ndr_uint32 :user_account_control
15
+ ndr_uint32 :prefered_maximum_length
16
+
17
+ def initialize_instance
18
+ super
19
+ @opnum = SAMR_ENUMERATE_USERS_IN_DOMAIN
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,55 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [2.2.3.9 SAMPR_RID_ENUMERATION](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/5c94a35a-e7f2-4675-af34-741f5a8ee1a2)
6
+ class SamprRidEnumeration < Ndr::NdrStruct
7
+ default_parameters byte_align: 4
8
+ endian :little
9
+
10
+ ndr_uint32 :relative_id
11
+ rpc_unicode_string :name
12
+ end
13
+
14
+ class SamprRidEnumerationArray < Ndr::NdrConfArray
15
+ default_parameter type: :sampr_rid_enumeration
16
+ end
17
+
18
+ class PsamprRidEnumerationArray < SamprRidEnumerationArray
19
+ extend Ndr::PointerClassPlugin
20
+ end
21
+
22
+ # [2.2.3.10 SAMPR_ENUMERATION_BUFFER](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/c53161a4-38e8-4a28-a33e-0d378fce03dd)
23
+ class SamprEnumerationBuffer < Ndr::NdrStruct
24
+ default_parameters byte_align: 4
25
+ endian :little
26
+
27
+ ndr_uint32 :entries_read
28
+ psampr_rid_enumeration_array :buffer
29
+ end
30
+
31
+ class PsamprEnumerationBuffer < SamprEnumerationBuffer
32
+ extend Ndr::PointerClassPlugin
33
+ end
34
+
35
+ # [3.1.5.2.5 SamrEnumerateUsersInDomain (Opnum 13)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/6bdc92c0-c692-4ffb-9de7-65858b68da75)
36
+ class SamrEnumerateUsersInDomainResponse < BinData::Record
37
+ attr_reader :opnum
38
+
39
+ endian :little
40
+
41
+ ndr_uint32 :enumeration_context
42
+ psampr_enumeration_buffer :buffer
43
+ ndr_uint32 :count_returned
44
+ ndr_uint32 :error_status
45
+
46
+ def initialize_instance
47
+ super
48
+ @opnum = SAMR_ENUMERATE_USERS_IN_DOMAIN
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,48 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ #[2.2.7.6 SAMPR_SID_INFORMATION](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/0c138399-f663-4039-b4e7-b3c9f82bff65)
6
+ class SamprSidInformation < Ndr::NdrStruct
7
+ default_parameter byte_align: 4
8
+
9
+ rpc_sid :sid_pointer
10
+ end
11
+
12
+ class PsamprSidInformation < SamprSidInformation
13
+ extend Ndr::PointerClassPlugin
14
+ end
15
+
16
+ class PsamprSidInformationArray < Ndr::NdrConfArray
17
+ default_parameter type: :psampr_sid_information
18
+ extend Ndr::PointerClassPlugin
19
+ end
20
+
21
+ # [2.2.7.5 SAMPR_PSID_ARRAY](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/1d40622e-52e4-4aaa-bc77-aa626089f116)
22
+ class SamprPsidArray < Ndr::NdrStruct
23
+ default_parameter byte_align: 4
24
+
25
+ ndr_uint32 :sid_count, initial_value: -> { sids.size }
26
+ psampr_sid_information_array :sids
27
+ end
28
+
29
+ # [3.1.5.9.2 SamrGetAliasMembership (Opnum 16)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/03184045-2208-4c02-b38b-ef955d6dc3ef)
30
+ class SamrGetAliasMembershipRequest < BinData::Record
31
+ attr_reader :opnum
32
+
33
+ endian :little
34
+
35
+ sampr_handle :domain_handle
36
+ sampr_psid_array :sid_array
37
+
38
+ def initialize_instance
39
+ super
40
+ @opnum = SAMR_GET_ALIAS_MEMBERSHIP
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+
48
+
@@ -0,0 +1,38 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ class PulongArray < Ndr::NdrConfArray
6
+ default_parameter type: :ndr_uint32
7
+ extend Ndr::PointerClassPlugin
8
+ end
9
+
10
+ # [2.2.7.4 SAMPR_ULONG_ARRAY](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/2feb3806-4db2-45b7-90d2-86c8336a31ba)
11
+ class PsamprUlongArray < Ndr::NdrStruct
12
+ default_parameter byte_align: 4
13
+
14
+ ndr_uint32 :elem_count, initial_value: -> { elements.size }
15
+ pulong_array :elements
16
+ end
17
+
18
+ # [3.1.5.9.2 SamrGetAliasMembership (Opnum 16)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/03184045-2208-4c02-b38b-ef955d6dc3ef)
19
+ class SamrGetAliasMembershipResponse < BinData::Record
20
+ attr_reader :opnum
21
+
22
+ endian :little
23
+
24
+ psampr_ulong_array :membership
25
+ ndr_uint32 :error_status
26
+
27
+ def initialize_instance
28
+ super
29
+ @opnum = SAMR_GET_ALIAS_MEMBERSHIP
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+
@@ -0,0 +1,23 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.9.1 SamrGetGroupsForUser (Opnum 39)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/a4adbf20-040f-4416-a960-e5b7917fdae7)
6
+ class SamrGetGroupsForUserRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :user_handle
12
+
13
+ def initialize_instance
14
+ super
15
+ @opnum = SAMR_GET_GROUPS_FOR_USER
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,48 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [[2.2.7.12 GROUP_MEMBERSHIP](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/dc0d27ac-5218-4709-9d1b-cab6f6d90b10)
6
+ class GroupMembership < Ndr::NdrStruct
7
+ default_parameter byte_align: 4
8
+
9
+ ndr_uint32 :relative_id
10
+ ndr_uint32 :attributes
11
+ end
12
+
13
+ class PgroupMembershipArray < Ndr::NdrConfArray
14
+ default_parameter type: :group_membership
15
+ extend Ndr::PointerClassPlugin
16
+ end
17
+
18
+ # [2.2.7.13 SAMPR_GET_GROUPS_BUFFER](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/31879676-cc95-4cf1-8f75-c09ddcef8750)
19
+ class SamprGetGroupsBuffer < Ndr::NdrStruct
20
+ default_parameter byte_align: 4
21
+
22
+ ndr_uint32 :membership_count, initial_value: -> { groups.size }
23
+ pgroup_membership_array :groups
24
+ end
25
+
26
+ class PsamprGetGroupsBuffer < SamprGetGroupsBuffer
27
+ extend Ndr::PointerClassPlugin
28
+ end
29
+
30
+ # [3.1.5.9.1 SamrGetGroupsForUser (Opnum 39)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/a4adbf20-040f-4416-a960-e5b7917fdae7)
31
+ class SamrGetGroupsForUserResponse < BinData::Record
32
+ attr_reader :opnum
33
+
34
+ endian :little
35
+
36
+ psampr_get_groups_buffer :groups
37
+ ndr_uint32 :error_status
38
+
39
+ def initialize_instance
40
+ super
41
+ @opnum = SAMR_GET_GROUPS_FOR_USER
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,24 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.11.1 SamrLookupDomainInSamServer (Opnum 5)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/47492d59-e095-4398-b03e-8a062b989123)
6
+ class SamrLookupDomainInSamServerRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :server_handle
12
+ rpc_unicode_string :name
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,25 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.11.1 SamrLookupDomainInSamServer (Opnum 5)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/47492d59-e095-4398-b03e-8a062b989123)
6
+ class SamrLookupDomainInSamServerResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ prpc_sid :domain_id
12
+ ndr_uint32 :error_status
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+
25
+
@@ -0,0 +1,27 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.1.5 SamrOpenDomain (Opnum 7)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/ba710c90-5b12-42f8-9e5a-d4aacc1329fa)
6
+ class SamrOpenDomainRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :server_handle
12
+ # Access control on a server object: bitwise OR of common ACCESS_MASK
13
+ # and domain ACCESS_MASK values (see lib/ruby_smb/dcerpc/samr.rb)
14
+ ndr_uint32 :desired_access
15
+ rpc_sid :domain_id
16
+
17
+ def initialize_instance
18
+ super
19
+ @opnum = SAMR_OPEN_DOMAIN
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+
@@ -0,0 +1,24 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.1.5 SamrOpenDomain (Opnum 7)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/ba710c90-5b12-42f8-9e5a-d4aacc1329fa)
6
+ class SamrOpenDomainResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :domain_handle
12
+ ndr_uint32 :error_status
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_OPEN_DOMAIN
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,26 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.1.9 SamrOpenUser (Opnum 34)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/0aee1c31-ec40-4633-bb56-0cf8429093c0)
6
+ class SamrOpenUserRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :domain_handle
12
+ # Access control on a server object: bitwise OR of common ACCESS_MASK
13
+ # and user ACCESS_MASK values (see lib/ruby_smb/dcerpc/samr.rb)
14
+ ndr_uint32 :desired_access
15
+ ndr_uint32 :user_id
16
+
17
+ def initialize_instance
18
+ super
19
+ @opnum = SAMR_OPEN_USER
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,24 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.1.9 SamrOpenUser (Opnum 34)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/0aee1c31-ec40-4633-bb56-0cf8429093c0)
6
+ class SamrOpenUserResponse < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :user_handle
12
+ ndr_uint32 :error_status
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_OPEN_USER
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,23 @@
1
+ module RubySMB
2
+ module Dcerpc
3
+ module Samr
4
+
5
+ # [3.1.5.13.5 SamrRidToSid (Opnum 65)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/00ff8192-a4f6-45ba-9f65-917e46b6a693)
6
+ class SamrRidToSidRequest < BinData::Record
7
+ attr_reader :opnum
8
+
9
+ endian :little
10
+
11
+ sampr_handle :object_handle
12
+ ndr_uint32 :rid
13
+
14
+ def initialize_instance
15
+ super
16
+ @opnum = SAMR_RID_TO_SID
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+