ruby_smb 2.0.10 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/verify.yml +5 -16
  4. data/examples/auth_capture.rb +71 -0
  5. data/examples/dump_secrets_from_sid.rb +207 -0
  6. data/examples/enum_domain_users.rb +75 -0
  7. data/examples/get_computer_info.rb +42 -0
  8. data/examples/query_service_status.rb +42 -4
  9. data/lib/ruby_smb/client/negotiation.rb +1 -1
  10. data/lib/ruby_smb/client.rb +10 -20
  11. data/lib/ruby_smb/dcerpc/bind.rb +28 -20
  12. data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
  13. data/lib/ruby_smb/dcerpc/client.rb +542 -0
  14. data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
  15. data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
  16. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
  17. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
  18. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
  19. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
  20. data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
  21. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
  22. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
  23. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
  24. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
  25. data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
  26. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
  27. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
  28. data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
  29. data/lib/ruby_smb/dcerpc/epm.rb +75 -0
  30. data/lib/ruby_smb/dcerpc/error.rb +17 -0
  31. data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
  32. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
  33. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
  34. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
  35. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
  36. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
  37. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
  38. data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
  39. data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
  40. data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
  41. data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
  42. data/lib/ruby_smb/dcerpc/request.rb +79 -32
  43. data/lib/ruby_smb/dcerpc/response.rb +45 -10
  44. data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
  45. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
  46. data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
  47. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
  48. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
  49. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
  50. data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
  51. data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
  52. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
  53. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
  54. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
  55. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
  56. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
  57. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
  58. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
  59. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
  60. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
  61. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
  62. data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
  63. data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
  64. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
  65. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
  66. data/lib/ruby_smb/dcerpc/samr.rb +613 -0
  67. data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
  68. data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
  69. data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
  70. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
  71. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
  72. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
  73. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
  74. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
  75. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
  76. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
  77. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
  78. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
  79. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
  80. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
  81. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
  82. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
  83. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
  84. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
  85. data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
  86. data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
  87. data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
  88. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
  89. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
  90. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
  91. data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
  92. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
  93. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
  94. data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
  95. data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
  96. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
  97. data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
  98. data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
  99. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
  100. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
  101. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
  102. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
  103. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
  104. data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
  105. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
  106. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
  107. data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
  108. data/lib/ruby_smb/dcerpc.rb +41 -11
  109. data/lib/ruby_smb/dialect.rb +45 -0
  110. data/lib/ruby_smb/dispatcher/base.rb +1 -1
  111. data/lib/ruby_smb/field/file_time.rb +1 -1
  112. data/lib/ruby_smb/field/string16.rb +5 -1
  113. data/lib/ruby_smb/gss/provider/authenticator.rb +42 -0
  114. data/lib/ruby_smb/gss/provider/ntlm.rb +303 -0
  115. data/lib/ruby_smb/gss/provider.rb +35 -0
  116. data/lib/ruby_smb/gss.rb +56 -63
  117. data/lib/ruby_smb/ntlm.rb +61 -0
  118. data/lib/ruby_smb/server/server_client/negotiation.rb +156 -0
  119. data/lib/ruby_smb/server/server_client/session_setup.rb +82 -0
  120. data/lib/ruby_smb/server/server_client.rb +162 -0
  121. data/lib/ruby_smb/server.rb +54 -0
  122. data/lib/ruby_smb/signing.rb +59 -0
  123. data/lib/ruby_smb/smb1/packet/negotiate_response.rb +11 -11
  124. data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +1 -1
  125. data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -1
  126. data/lib/ruby_smb/smb1/pipe.rb +4 -0
  127. data/lib/ruby_smb/smb2/negotiate_context.rb +18 -2
  128. data/lib/ruby_smb/smb2/packet/negotiate_request.rb +9 -0
  129. data/lib/ruby_smb/smb2/packet/negotiate_response.rb +0 -1
  130. data/lib/ruby_smb/smb2/packet/session_setup_response.rb +2 -2
  131. data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +1 -1
  132. data/lib/ruby_smb/smb2/pipe.rb +4 -0
  133. data/lib/ruby_smb/smb2.rb +3 -1
  134. data/lib/ruby_smb/version.rb +1 -1
  135. data/lib/ruby_smb.rb +2 -1
  136. data/spec/lib/ruby_smb/client_spec.rb +8 -11
  137. data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
  138. data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
  139. data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
  140. data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
  141. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
  142. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
  143. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
  144. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
  145. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
  146. data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
  147. data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
  148. data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
  149. data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
  150. data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
  151. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
  152. data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
  153. data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
  154. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
  155. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
  156. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
  157. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
  158. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
  159. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
  160. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
  161. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
  162. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
  163. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
  164. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
  165. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
  166. data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
  167. data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
  168. data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
  169. data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
  170. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
  171. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
  172. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
  173. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
  174. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
  175. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
  176. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
  177. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
  178. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
  179. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
  180. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
  181. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
  182. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
  183. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
  184. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
  185. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
  186. data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
  187. data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
  188. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
  189. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
  190. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
  191. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
  192. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
  193. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
  194. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
  195. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
  196. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
  197. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
  198. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
  199. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
  200. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
  201. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
  202. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
  203. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
  204. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
  205. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
  206. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
  207. data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
  208. data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
  209. data/spec/lib/ruby_smb/gss/provider/ntlm/account_spec.rb +32 -0
  210. data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +101 -0
  211. data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +32 -0
  212. data/spec/lib/ruby_smb/gss/provider/ntlm_spec.rb +113 -0
  213. data/spec/lib/ruby_smb/server/server_client_spec.rb +156 -0
  214. data/spec/lib/ruby_smb/server_spec.rb +32 -0
  215. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
  216. data/spec/lib/ruby_smb/smb2/negotiate_context_spec.rb +2 -2
  217. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
  218. data/spec/support/bin_helper.rb +9 -0
  219. data.tar.gz.sig +0 -0
  220. metadata +119 -6
  221. metadata.gz.sig +0 -0
  222. data/lib/ruby_smb/client/signing.rb +0 -64
  223. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
  224. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -2,51 +2,59 @@ module RubySMB
2
2
  module Dcerpc
3
3
  # The Bind PDU as defined in
4
4
  # [The bind PDU](http://pubs.opengroup.org/onlinepubs/9629399/chap12.htm#tagcjh_17_06_04_03)
5
- class PContElemT < BinData::Record
5
+ class PContElemT < Ndr::NdrStruct
6
+ default_parameter byte_align: 4
6
7
  endian :little
7
8
 
8
- uint16 :p_cont_id, label: 'Context ID'
9
- uint8 :n_transfer_syn, label: 'Number of transfer syntaxes', initial_value: 1
10
- uint8 :reserved
9
+ ndr_uint16 :p_cont_id, label: 'Context ID'
10
+ ndr_uint8 :n_transfer_syn, label: 'Number of transfer syntaxes', initial_value: 1
11
+ ndr_uint8 :reserved
11
12
  p_syntax_id_t :abstract_syntax, label: 'Abstract syntax',
12
13
  uuid: -> { endpoint::UUID },
13
14
  ver_major: -> { endpoint::VER_MAJOR },
14
15
  ver_minor: -> { endpoint::VER_MINOR }
15
- array :transfer_syntaxes, label: 'Transfer syntax', type: :p_syntax_id_t,
16
+ array :transfer_syntaxes, label: 'Transfer syntax', type: :p_syntax_id_t,
16
17
  initial_length: -> { n_transfer_syn },
17
18
  uuid: -> { Ndr::UUID },
18
19
  ver_major: -> { Ndr::VER_MAJOR },
19
- ver_minor: -> { Ndr::VER_MINOR }
20
+ ver_minor: -> { Ndr::VER_MINOR },
21
+ byte_align: 4
20
22
  end
21
23
 
22
- class PContListT < BinData::Record
24
+ class PContListT < Ndr::NdrStruct
25
+ default_parameter byte_align: 4
23
26
  endian :little
24
27
 
25
- uint8 :n_context_elem, label: 'Number of context elements', initial_value: -> { 1 }
26
- uint8 :reserved
27
- uint16 :reserved2
28
- array :p_cont_elem, label: 'Presentation context elements', type: :p_cont_elem_t,
28
+ ndr_uint8 :n_context_elem, label: 'Number of context elements', initial_value: -> { 1 }
29
+ ndr_uint8 :reserved
30
+ ndr_uint16 :reserved2
31
+ array :p_cont_elem, label: 'Presentation context elements', type: :p_cont_elem_t,
29
32
  initial_length: -> {n_context_elem},
30
- endpoint: -> {endpoint}
33
+ endpoint: -> {endpoint},
34
+ byte_align: 4
31
35
  end
32
36
 
33
37
  class Bind < BinData::Record
34
- endian :little
35
-
36
- pdu_header :pdu_header, label: 'PDU header'
38
+ PTYPE = PTypes::BIND
37
39
 
38
- uint16 :max_xmit_frag, label: 'max transmit frag size', initial_value: RubySMB::Dcerpc::MAX_XMIT_FRAG
39
- uint16 :max_recv_frag, label: 'max receive frag size', initial_value: RubySMB::Dcerpc::MAX_RECV_FRAG
40
- uint32 :assoc_group_id, label: 'ncarnation of client-server assoc group'
40
+ endian :little
41
41
 
42
+ # PDU Header
43
+ pdu_header :pdu_header, label: 'PDU header'
44
+ ndr_uint16 :max_xmit_frag, label: 'max transmit frag size', initial_value: RubySMB::Dcerpc::MAX_XMIT_FRAG
45
+ ndr_uint16 :max_recv_frag, label: 'max receive frag size', initial_value: RubySMB::Dcerpc::MAX_RECV_FRAG
46
+ ndr_uint32 :assoc_group_id, label: 'incarnation of client-server assoc group'
42
47
  p_cont_list_t :p_context_list, label: 'Presentation context list', endpoint: -> { endpoint }
43
- string :auth_verifier, label: 'Authentication verifier',
48
+
49
+ # Auth Verifier
50
+ sec_trailer :sec_trailer, onlyif: -> { pdu_header.auth_length > 0 }
51
+ string :auth_value,
44
52
  onlyif: -> { pdu_header.auth_length > 0 },
45
53
  read_length: -> { pdu_header.auth_length }
46
54
 
47
55
  def initialize_instance
48
56
  super
49
- pdu_header.ptype = RubySMB::Dcerpc::PTypes::BIND
57
+ pdu_header.ptype = PTYPE
50
58
  end
51
59
  end
52
60
  end
@@ -3,34 +3,39 @@ module RubySMB
3
3
  # The Bind ACK PDU as defined in
4
4
  # [The bind_ack PDU](http://pubs.opengroup.org/onlinepubs/9629399/chap12.htm#tagcjh_17_06_04_04)
5
5
 
6
- class PResultT < BinData::Record
6
+ class PResultT < Ndr::NdrStruct
7
+ default_parameter byte_align: 4
7
8
  endian :little
8
9
 
9
- uint16 :result, label: 'Presentation context negotiation results'
10
- uint16 :reason, label: 'Rejection reason'
11
- p_syntax_id_t :transfer_syntax, label: 'Presentation syntax ID',
12
- uuid: -> { Ndr::UUID },
10
+ ndr_uint16 :result, label: 'Presentation context negotiation results'
11
+ ndr_uint16 :reason, label: 'Rejection reason'
12
+ p_syntax_id_t :transfer_syntax, label: 'Presentation syntax ID',
13
+ uuid: -> { Ndr::UUID },
13
14
  ver_major: -> { Ndr::VER_MAJOR },
14
15
  ver_minor: -> { Ndr::VER_MINOR }
15
16
  end
16
17
 
17
- class PResultListT < BinData::Record
18
+ class PResultListT < Ndr::NdrStruct
19
+ default_parameter byte_align: 4
18
20
  endian :little
19
21
 
20
- uint8 :n_results, label: 'Number of results'
21
- uint8 :reserved
22
- uint16 :reserved2
23
- array :p_results, label: 'Results', type: :p_result_t, initial_length: -> { n_results }
22
+ ndr_uint8 :n_results, label: 'Number of results', initial_value: -> { p_results.size }
23
+ ndr_uint8 :reserved
24
+ ndr_uint16 :reserved2
25
+ array :p_results, label: 'Results', type: :p_result_t, initial_length: -> { n_results }, byte_align: 4
24
26
  end
25
27
 
26
- class PortAnyT < BinData::Record
28
+ class PortAnyT < Ndr::NdrStruct
29
+ default_parameter byte_align: 2
27
30
  endian :little
28
31
 
29
- uint16 :str_length, label: 'Length', initial_value: -> { port_spec.to_binary_s.size }
30
- stringz :port_spec, label: 'Port string spec'
32
+ ndr_uint16 :str_length, label: 'Length', initial_value: -> { port_spec.to_binary_s.size }
33
+ stringz :port_spec, label: 'Port string spec', byte_align: 2
31
34
  end
32
35
 
33
36
  class BindAck < BinData::Record
37
+ PTYPE = PTypes::BIND_ACK
38
+
34
39
  # Presentation context negotiation results
35
40
  ACCEPTANCE = 0
36
41
  USER_REJECTION = 1
@@ -44,27 +49,23 @@ module RubySMB
44
49
 
45
50
  endian :little
46
51
 
47
- pdu_header :pdu_header, label: 'PDU header'
48
-
49
- uint16 :max_xmit_frag, label: 'Max transmit frag size', initial_value: RubySMB::Dcerpc::MAX_XMIT_FRAG
50
- uint16 :max_recv_frag, label: 'Max receive frag size', initial_value: RubySMB::Dcerpc::MAX_RECV_FRAG
51
- uint32 :assoc_group_id, label: 'Association group ID'
52
- port_any_t :sec_addr, label: 'Secondary address'
53
- string :pad, length: -> { pad_length }
54
-
52
+ # PDU Header
53
+ pdu_header :pdu_header, label: 'PDU header'
54
+ ndr_uint16 :max_xmit_frag, label: 'Max transmit frag size', initial_value: RubySMB::Dcerpc::MAX_XMIT_FRAG
55
+ ndr_uint16 :max_recv_frag, label: 'Max receive frag size', initial_value: RubySMB::Dcerpc::MAX_RECV_FRAG
56
+ ndr_uint32 :assoc_group_id, label: 'Association group ID'
57
+ port_any_t :sec_addr, label: 'Secondary address'
55
58
  p_result_list_t :p_result_list, label: 'Presentation context result list'
56
- string :auth_verifier, label: 'Authentication verifier',
59
+
60
+ # Auth Verifier
61
+ sec_trailer :sec_trailer, onlyif: -> { pdu_header.auth_length > 0 }
62
+ string :auth_value,
57
63
  onlyif: -> { pdu_header.auth_length > 0 },
58
64
  read_length: -> { pdu_header.auth_length }
59
65
 
60
66
  def initialize_instance
61
67
  super
62
- pdu_header.ptype = RubySMB::Dcerpc::PTypes::BIND_ACK
63
- end
64
-
65
- def pad_length
66
- offset = (sec_addr.abs_offset + sec_addr.do_num_bytes) % 4
67
- (4 - offset) % 4
68
+ pdu_header.ptype = PTYPE
68
69
  end
69
70
  end
70
71
  end