ruby_smb 2.0.11 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) 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 +28 -0
  5. data/examples/dump_secrets_from_sid.rb +207 -0
  6. data/examples/enum_domain_users.rb +75 -0
  7. data/examples/file_server.rb +76 -0
  8. data/examples/get_computer_info.rb +42 -0
  9. data/examples/query_service_status.rb +42 -4
  10. data/lib/ruby_smb/client.rb +3 -14
  11. data/lib/ruby_smb/create_actions.rb +21 -0
  12. data/lib/ruby_smb/dcerpc/bind.rb +28 -20
  13. data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
  14. data/lib/ruby_smb/dcerpc/client.rb +542 -0
  15. data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
  16. data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
  17. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
  18. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
  19. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
  20. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
  21. data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
  22. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
  23. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
  24. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
  25. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
  26. data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
  27. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
  28. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
  29. data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
  30. data/lib/ruby_smb/dcerpc/epm.rb +75 -0
  31. data/lib/ruby_smb/dcerpc/error.rb +17 -0
  32. data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
  33. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
  34. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
  35. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
  36. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
  37. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
  38. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
  39. data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
  40. data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
  41. data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
  42. data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
  43. data/lib/ruby_smb/dcerpc/request.rb +79 -32
  44. data/lib/ruby_smb/dcerpc/response.rb +45 -10
  45. data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
  46. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
  47. data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
  48. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
  49. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
  50. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
  51. data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
  52. data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
  53. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
  54. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
  55. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
  56. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
  57. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
  58. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
  59. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
  60. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
  61. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
  62. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
  63. data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
  64. data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
  65. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
  66. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
  67. data/lib/ruby_smb/dcerpc/samr.rb +613 -0
  68. data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
  69. data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
  70. data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
  71. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
  72. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
  73. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
  74. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
  75. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
  76. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
  77. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
  78. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
  79. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
  80. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
  81. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
  82. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
  83. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
  84. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
  85. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
  86. data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
  87. data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
  88. data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
  89. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
  90. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
  91. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
  92. data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
  93. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
  94. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
  95. data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
  96. data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
  97. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
  98. data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
  99. data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
  100. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
  101. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
  102. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
  103. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
  104. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
  105. data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
  106. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
  107. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
  108. data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
  109. data/lib/ruby_smb/dcerpc.rb +41 -11
  110. data/lib/ruby_smb/field/file_time.rb +1 -1
  111. data/lib/ruby_smb/field/nt_status.rb +20 -1
  112. data/lib/ruby_smb/field/string16.rb +5 -1
  113. data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +14 -0
  114. data/lib/ruby_smb/fscc/file_information/file_network_open_information.rb +22 -0
  115. data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +16 -0
  116. data/lib/ruby_smb/fscc/file_information.rb +29 -0
  117. data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +46 -0
  118. data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +19 -0
  119. data/lib/ruby_smb/fscc/file_system_information.rb +22 -0
  120. data/lib/ruby_smb/fscc.rb +1 -0
  121. data/lib/ruby_smb/generic_packet.rb +6 -0
  122. data/lib/ruby_smb/gss/provider/authenticator.rb +4 -0
  123. data/lib/ruby_smb/gss/provider/ntlm.rb +13 -3
  124. data/lib/ruby_smb/ntlm.rb +18 -2
  125. data/lib/ruby_smb/server/server_client/negotiation.rb +1 -2
  126. data/lib/ruby_smb/server/server_client/session_setup.rb +44 -33
  127. data/lib/ruby_smb/server/server_client/share_io.rb +28 -0
  128. data/lib/ruby_smb/server/server_client/tree_connect.rb +60 -0
  129. data/lib/ruby_smb/server/server_client.rb +214 -25
  130. data/lib/ruby_smb/server/session.rb +71 -0
  131. data/lib/ruby_smb/server/share/provider/disk.rb +437 -0
  132. data/lib/ruby_smb/server/share/provider/pipe.rb +27 -0
  133. data/lib/ruby_smb/server/share/provider/processor.rb +76 -0
  134. data/lib/ruby_smb/server/share/provider.rb +38 -0
  135. data/lib/ruby_smb/server/share.rb +11 -0
  136. data/lib/ruby_smb/server.rb +35 -3
  137. data/lib/ruby_smb/signing.rb +37 -11
  138. data/lib/ruby_smb/smb1/commands.rb +4 -0
  139. data/lib/ruby_smb/smb1/pipe.rb +4 -0
  140. data/lib/ruby_smb/smb1.rb +0 -1
  141. data/lib/ruby_smb/smb2/bit_field/smb2_header_flags.rb +2 -1
  142. data/lib/ruby_smb/smb2/commands.rb +4 -0
  143. data/lib/ruby_smb/smb2/create_context/request.rb +64 -0
  144. data/lib/ruby_smb/smb2/create_context/response.rb +62 -0
  145. data/lib/ruby_smb/smb2/create_context.rb +74 -22
  146. data/lib/ruby_smb/smb2/packet/create_request.rb +44 -11
  147. data/lib/ruby_smb/smb2/packet/create_response.rb +17 -3
  148. data/lib/ruby_smb/smb2/packet/query_directory_request.rb +1 -1
  149. data/lib/ruby_smb/smb2/packet/query_directory_response.rb +2 -2
  150. data/lib/ruby_smb/smb2/packet/query_info_request.rb +43 -0
  151. data/lib/ruby_smb/smb2/packet/query_info_response.rb +23 -0
  152. data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +1 -1
  153. data/lib/ruby_smb/smb2/packet/tree_disconnect_response.rb +1 -0
  154. data/lib/ruby_smb/smb2/packet.rb +2 -0
  155. data/lib/ruby_smb/smb2/pipe.rb +4 -0
  156. data/lib/ruby_smb/smb2.rb +11 -0
  157. data/lib/ruby_smb/smb_error.rb +110 -0
  158. data/lib/ruby_smb/version.rb +1 -1
  159. data/lib/ruby_smb.rb +2 -0
  160. data/ruby_smb.gemspec +1 -1
  161. data/spec/lib/ruby_smb/client_spec.rb +1 -2
  162. data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
  163. data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
  164. data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
  165. data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
  166. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
  167. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
  168. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
  169. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
  170. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
  171. data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
  172. data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
  173. data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
  174. data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
  175. data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
  176. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
  177. data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
  178. data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
  179. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
  180. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
  181. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
  182. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
  183. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
  184. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
  185. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
  186. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
  187. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
  188. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
  189. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
  190. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
  191. data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
  192. data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
  193. data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
  194. data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
  195. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
  196. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
  197. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
  198. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
  199. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
  200. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
  201. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
  202. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
  203. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
  204. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
  205. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
  206. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
  207. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
  208. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
  209. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
  210. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
  211. data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
  212. data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
  213. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
  214. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
  215. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
  216. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
  217. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
  218. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
  219. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
  220. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
  221. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
  222. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
  223. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
  224. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
  225. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
  226. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
  227. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
  228. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
  229. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
  230. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
  231. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
  232. data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
  233. data/spec/lib/ruby_smb/field/nt_status_spec.rb +6 -2
  234. data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
  235. data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +4 -0
  236. data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
  237. data/spec/lib/ruby_smb/server/server_client_spec.rb +36 -53
  238. data/spec/lib/ruby_smb/server/session_spec.rb +38 -0
  239. data/spec/lib/ruby_smb/server/share/provider/disk_spec.rb +61 -0
  240. data/spec/lib/ruby_smb/server/share/provider/pipe_spec.rb +31 -0
  241. data/spec/lib/ruby_smb/server/share/provider_spec.rb +13 -0
  242. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
  243. data/spec/lib/ruby_smb/smb2/bit_field/header_flags_spec.rb +8 -2
  244. data/spec/lib/ruby_smb/smb2/{create_context_spec.rb → create_context/create_context_request_spec.rb} +1 -1
  245. data/spec/lib/ruby_smb/smb2/packet/create_request_spec.rb +5 -5
  246. data/spec/lib/ruby_smb/smb2/packet/create_response_spec.rb +9 -5
  247. data/spec/lib/ruby_smb/smb2/packet/query_directory_response_spec.rb +3 -2
  248. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
  249. data/spec/support/bin_helper.rb +9 -0
  250. data.tar.gz.sig +2 -3
  251. metadata +129 -10
  252. metadata.gz.sig +0 -0
  253. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
  254. data/lib/ruby_smb/smb1/create_actions.rb +0 -20
  255. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -0,0 +1,110 @@
1
+ require 'windows_error'
2
+
3
+ module RubySMB
4
+ # SMB Error codes as defined in
5
+ # [2.2.2.4 SMB Error Classes and Codes](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb/6ab6ca20-b404-41fd-b91a-2ed39e3762ea)
6
+ module SMBError
7
+ # Returns all the {WindowsError::ErrorCode} objects that match
8
+ # the return value supplied.
9
+ #
10
+ # @param [Integer] retval the return value you want the error code for
11
+ # @raise [ArgumentError] if something other than a Integer is supplied
12
+ # @return [Array<WindowsError::ErrorCode>] all Win32 ErrorCodes that matched
13
+ def self.find_by_retval(retval)
14
+ raise ArgumentError, "Invalid Return Code!" unless retval.kind_of? Integer
15
+ error_codes = []
16
+ self.constants.each do |constant_name|
17
+ error_code = self.const_get(constant_name)
18
+ if error_code == retval
19
+ error_codes << error_code
20
+ end
21
+ end
22
+ error_codes
23
+ end
24
+
25
+ #
26
+ # CONSTANTS
27
+ #
28
+
29
+ # (0x00000000) The client request is successful.
30
+ STATUS_SUCCESS = WindowsError::ErrorCode.new('STATUS_SUCCESS', 0x00000000, 'The client request is successful.')
31
+
32
+ # (0x00010002) An invalid SMB client request is received by the server.
33
+ STATUS_INVALID_SMB = WindowsError::ErrorCode.new('STATUS_INVALID_SMB', 0x00010002, 'An invalid SMB client request is received by the server.')
34
+
35
+ # (0x00050002) The client request received by the server contains an invalid TID value.
36
+ STATUS_SMB_BAD_TID = WindowsError::ErrorCode.new('STATUS_SMB_BAD_TID', 0x00050002, 'The client request received by the server contains an invalid TID value.')
37
+
38
+ # (0x00160002) The client request received by the server contains an unknown SMB command code.
39
+ STATUS_SMB_BAD_COMMAND = WindowsError::ErrorCode.new('STATUS_SMB_BAD_COMMAND', 0x00160002, 'The client request received by the server contains an unknown SMB command code.')
40
+
41
+ # (0x005B0002) The client request to the server contains an invalid UID value.
42
+ STATUS_SMB_BAD_UID = WindowsError::ErrorCode.new('STATUS_SMB_BAD_UID', 0x005B0002, 'The client request to the server contains an invalid UID value.')
43
+
44
+ # (0x00FB0002) The client request received by the server is for a non-standard SMB operation (for example, an SMB_COM_READ_MPX request on a non-disk share). The client SHOULD send another request with a different SMB command to perform this operation.
45
+ STATUS_SMB_USE_STANDARD = WindowsError::ErrorCode.new('STATUS_SMB_USE_STANDARD', 0x00FB0002, 'The client request received by the server is for a non-standard SMB operation (for example, an SMB_COM_READ_MPX request on a non-disk share). The client SHOULD send another request with a different SMB command to perform this operation.')
46
+
47
+ # (0x80000005) The data was too large to fit into the specified buffer.
48
+ STATUS_BUFFER_OVERFLOW = WindowsError::ErrorCode.new('STATUS_BUFFER_OVERFLOW', 0x80000005, 'The data was too large to fit into the specified buffer.')
49
+
50
+ # (0x80000006) No more files were found that match the file specification.
51
+ STATUS_NO_MORE_FILES = WindowsError::ErrorCode.new('STATUS_NO_MORE_FILES', 0x80000006, 'No more files were found that match the file specification.')
52
+
53
+ # (0x8000002D) The create operation stopped after reaching a symbolic link.
54
+ STATUS_STOPPED_ON_SYMLINK = WindowsError::ErrorCode.new('STATUS_STOPPED_ON_SYMLINK', 0x8000002D, 'The create operation stopped after reaching a symbolic link.')
55
+
56
+ # (0xC0000002) The requested operation is not implemented.
57
+ STATUS_NOT_IMPLEMENTED = WindowsError::ErrorCode.new('STATUS_NOT_IMPLEMENTED', 0xC0000002, 'The requested operation is not implemented.')
58
+
59
+ # (0xC000000D) The parameter specified in the request is not valid.
60
+ STATUS_INVALID_PARAMETER = WindowsError::ErrorCode.new('STATUS_INVALID_PARAMETER', 0xC000000D, 'The parameter specified in the request is not valid.')
61
+
62
+ # (0xC000000E) A device that does not exist was specified.
63
+ STATUS_NO_SUCH_DEVICE = WindowsError::ErrorCode.new('STATUS_NO_SUCH_DEVICE', 0xC000000E, 'A device that does not exist was specified.')
64
+
65
+ # (0xC0000010) The specified request is not a valid operation for the target device.
66
+ STATUS_INVALID_DEVICE_REQUEST = WindowsError::ErrorCode.new('STATUS_INVALID_DEVICE_REQUEST', 0xC0000010, 'The specified request is not a valid operation for the target device.')
67
+
68
+ # (0xC0000016) If extended security has been negotiated, then this error code can be returned in the SMB_COM_SESSION_SETUP_ANDX response from the server to indicate that additional authentication information is to be exchanged. See section 2.2.4.6 for details.
69
+ STATUS_MORE_PROCESSING_REQUIRED = WindowsError::ErrorCode.new('STATUS_MORE_PROCESSING_REQUIRED', 0xC0000016, 'If extended security has been negotiated, then this error code can be returned in the SMB_COM_SESSION_SETUP_ANDX response from the server to indicate that additional authentication information is to be exchanged. See section 2.2.4.6 for details.')
70
+
71
+ # (0xC0000022) The client did not have the required permission needed for the operation.
72
+ STATUS_ACCESS_DENIED = WindowsError::ErrorCode.new('STATUS_ACCESS_DENIED', 0xC0000022, 'The client did not have the required permission needed for the operation.')
73
+
74
+ # (0xC0000023) The buffer is too small to contain the entry. No information has been written to the buffer.
75
+ STATUS_BUFFER_TOO_SMALL = WindowsError::ErrorCode.new('STATUS_BUFFER_TOO_SMALL', 0xC0000023, 'The buffer is too small to contain the entry. No information has been written to the buffer.')
76
+
77
+ # (0xC0000034) The object name is not found.
78
+ STATUS_OBJECT_NAME_NOT_FOUND = WindowsError::ErrorCode.new('STATUS_OBJECT_NAME_NOT_FOUND', 0xC0000034, 'The object name is not found.')
79
+
80
+ # (0xC0000035) The object name already exists.
81
+ STATUS_OBJECT_NAME_COLLISION = WindowsError::ErrorCode.new('STATUS_OBJECT_NAME_COLLISION', 0xC0000035, 'The object name already exists.')
82
+
83
+ # (0xC000003A) The path to the directory specified was not found. This error is also returned on a create request if the operation requires the creation of more than one new directory level for the path specified.
84
+ STATUS_OBJECT_PATH_NOT_FOUND = WindowsError::ErrorCode.new('STATUS_OBJECT_PATH_NOT_FOUND', 0xC000003A, 'The path to the directory specified was not found. This error is also returned on a create request if the operation requires the creation of more than one new directory level for the path specified.')
85
+
86
+ # (0xC00000A5) A specified impersonation level is invalid. This error is also used to indicate that a required impersonation level was not provided.
87
+ STATUS_BAD_IMPERSONATION_LEVEL = WindowsError::ErrorCode.new('STATUS_BAD_IMPERSONATION_LEVEL', 0xC00000A5, 'A specified impersonation level is invalid. This error is also used to indicate that a required impersonation level was not provided.')
88
+
89
+ # (0xC00000B5) The specified I/O operation was not completed before the time-out period expired.
90
+ STATUS_IO_TIMEOUT = WindowsError::ErrorCode.new('STATUS_IO_TIMEOUT', 0xC00000B5, 'The specified I/O operation was not completed before the time-out period expired.')
91
+
92
+ # (0xC00000BA) The file that was specified as a target is a directory and the caller specified that it could be anything but a directory.
93
+ STATUS_FILE_IS_A_DIRECTORY = WindowsError::ErrorCode.new('STATUS_FILE_IS_A_DIRECTORY', 0xC00000BA, 'The file that was specified as a target is a directory and the caller specified that it could be anything but a directory.')
94
+
95
+ # (0xC00000BB) The client request is not supported.
96
+ STATUS_NOT_SUPPORTED = WindowsError::ErrorCode.new('STATUS_NOT_SUPPORTED', 0xC00000BB, 'The client request is not supported.')
97
+
98
+ # (0xC00000C9) The network name specified by the client has been deleted on the server. This error is returned if the client specifies an incorrect TID or the share on the server represented by the TID was deleted.
99
+ STATUS_NETWORK_NAME_DELETED = WindowsError::ErrorCode.new('STATUS_NETWORK_NAME_DELETED', 0xC00000C9, 'The network name specified by the client has been deleted on the server. This error is returned if the client specifies an incorrect TID or the share on the server represented by the TID was deleted.')
100
+
101
+ # (0xC0000203) The user session specified by the client has been deleted on the server. This error is returned by the server if the client sends an incorrect UID.
102
+ STATUS_USER_SESSION_DELETED = WindowsError::ErrorCode.new('STATUS_USER_SESSION_DELETED', 0xC0000203, 'The user session specified by the client has been deleted on the server. This error is returned by the server if the client sends an incorrect UID.')
103
+
104
+ # (0xC000035C) The client's session has expired; therefore, the client MUST re-authenticate to continue accessing remote resources.
105
+ STATUS_NETWORK_SESSION_EXPIRED = WindowsError::ErrorCode.new('STATUS_NETWORK_SESSION_EXPIRED', 0xC000035C, 'The client\'s session has expired; therefore, the client MUST re-authenticate to continue accessing remote resources.')
106
+
107
+ # (0xC000205A) The client has requested too many UID values from the server or the client already has an SMB session setup with this UID value.
108
+ STATUS_SMB_TOO_MANY_UIDS = WindowsError::ErrorCode.new('STATUS_SMB_TOO_MANY_UIDS', 0xC000205A, 'The client has requested too many UID values from the server or the client already has an SMB session setup with this UID value.')
109
+ end
110
+ end
@@ -1,3 +1,3 @@
1
1
  module RubySMB
2
- VERSION = '2.0.11'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
data/lib/ruby_smb.rb CHANGED
@@ -12,6 +12,7 @@ require 'windows_error/nt_status'
12
12
  # [[MS-SMB2] Server Message Block (SMB) Protocol Versions 2 and 3](https://msdn.microsoft.com/en-us/library/cc246482.aspx)
13
13
  module RubySMB
14
14
  require 'ruby_smb/error'
15
+ require 'ruby_smb/create_actions'
15
16
  require 'ruby_smb/dispositions'
16
17
  require 'ruby_smb/impersonation_levels'
17
18
  require 'ruby_smb/gss'
@@ -28,4 +29,5 @@ module RubySMB
28
29
  require 'ruby_smb/compression'
29
30
  require 'ruby_smb/server'
30
31
  require 'ruby_smb/dialect'
32
+ require 'ruby_smb/smb_error'
31
33
  end
data/ruby_smb.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'yard'
35
35
 
36
36
  spec.add_runtime_dependency 'rubyntlm'
37
- spec.add_runtime_dependency 'windows_error'
37
+ spec.add_runtime_dependency 'windows_error', '>= 0.1.3'
38
38
  spec.add_runtime_dependency 'bindata'
39
39
  spec.add_runtime_dependency 'openssl-ccm'
40
40
  spec.add_runtime_dependency 'openssl-cmac'
@@ -126,8 +126,7 @@ RSpec.describe RubySMB::Client do
126
126
  expect(password).to eq(password)
127
127
  expect(opt[:workstation]).to eq(local_workstation)
128
128
  expect(opt[:domain]).to eq(domain)
129
- flags = Net::NTLM::Client::DEFAULT_FLAGS |
130
- Net::NTLM::FLAGS[:TARGET_INFO] | 0x02000000 ^ Net::NTLM::FLAGS[:OEM]
129
+ flags = RubySMB::NTLM::DEFAULT_CLIENT_FLAGS
131
130
  expect(opt[:flags]).to eq(flags)
132
131
  end
133
132
 
@@ -7,7 +7,8 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
7
7
  it { is_expected.to respond_to :assoc_group_id }
8
8
  it { is_expected.to respond_to :sec_addr }
9
9
  it { is_expected.to respond_to :p_result_list }
10
- it { is_expected.to respond_to :auth_verifier }
10
+ it { is_expected.to respond_to :sec_trailer }
11
+ it { is_expected.to respond_to :auth_value }
11
12
 
12
13
  it 'is little endian' do
13
14
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
@@ -26,8 +27,8 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
26
27
  end
27
28
 
28
29
  describe '#max_xmit_frag' do
29
- it 'should be a 16-bit unsigned integer' do
30
- expect(packet.max_xmit_frag).to be_a BinData::Uint16le
30
+ it 'should be a NdrUint16' do
31
+ expect(packet.max_xmit_frag).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
31
32
  end
32
33
 
33
34
  it 'should have a default value of 0xFFFF' do
@@ -36,8 +37,8 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
36
37
  end
37
38
 
38
39
  describe '#max_recv_frag' do
39
- it 'should be a 16-bit unsigned integer' do
40
- expect(packet.max_recv_frag).to be_a BinData::Uint16le
40
+ it 'should be a NdrUint16' do
41
+ expect(packet.max_recv_frag).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
41
42
  end
42
43
 
43
44
  it 'should have a default value of 0xFFFF' do
@@ -46,15 +47,8 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
46
47
  end
47
48
 
48
49
  describe '#assoc_group_id' do
49
- it 'should be a 32-bit unsigned integer' do
50
- expect(packet.assoc_group_id).to be_a BinData::Uint32le
51
- end
52
- end
53
-
54
- describe '#pad' do
55
- it 'should keep #p_result_list 4-byte aligned' do
56
- packet.sec_addr.port_spec = "test"
57
- expect(packet.p_result_list.abs_offset % 4).to eq 0
50
+ it 'should be a NdrUint32' do
51
+ expect(packet.assoc_group_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
58
52
  end
59
53
  end
60
54
 
@@ -64,45 +58,49 @@ RSpec.describe RubySMB::Dcerpc::BindAck do
64
58
  end
65
59
  end
66
60
 
67
- describe '#auth_verifier' do
68
- it 'should be a string' do
69
- expect(packet.auth_verifier).to be_a BinData::String
61
+ describe '#sec_trailer' do
62
+ it 'should be a SecTrailer structure' do
63
+ expect(packet.sec_trailer).to be_a RubySMB::Dcerpc::SecTrailer
70
64
  end
71
65
 
72
66
  it 'should not exist if the #auth_length PDU header field is 0' do
73
67
  packet.pdu_header.auth_length = 0
74
- expect(packet.auth_verifier?).to be false
68
+ expect(packet.sec_trailer?).to be false
75
69
  end
76
70
 
77
71
  it 'should exist only if the #auth_length PDU header field is greater than 0' do
78
72
  packet.pdu_header.auth_length = 10
79
- expect(packet.auth_verifier?).to be true
73
+ expect(packet.sec_trailer?).to be true
80
74
  end
75
+ end
81
76
 
82
- it 'reads #auth_length bytes' do
83
- auth_verifier = '12345678'
84
- packet.pdu_header.auth_length = 6
85
- packet.auth_verifier.read(auth_verifier)
86
- expect(packet.auth_verifier).to eq(auth_verifier[0,6])
77
+ describe '#auth_value' do
78
+ it 'should be a string' do
79
+ expect(packet.auth_value).to be_a BinData::String
87
80
  end
88
- end
89
81
 
90
- describe '#pad_length' do
91
- it 'returns 0 when #p_result_list is already 4-byte aligned' do
92
- packet.sec_addr.port_spec = 'align'
93
- expect(packet.pad_length).to eq 0
82
+ it 'should not exist if the #auth_length PDU header field is 0' do
83
+ packet.pdu_header.auth_length = 0
84
+ expect(packet.auth_value?).to be false
94
85
  end
95
86
 
96
- it 'returns 2 when #p_result_list is only 2-byte aligned' do
97
- packet.sec_addr.port_spec = 'align' + 'AA'
98
- expect(packet.pad_length).to eq 2
87
+ it 'should exist only if the #auth_length PDU header field is greater than 0' do
88
+ packet.pdu_header.auth_length = 10
89
+ expect(packet.auth_value?).to be true
90
+ end
91
+
92
+ it 'reads #auth_length bytes' do
93
+ auth_value = '12345678'
94
+ packet.pdu_header.auth_length = 6
95
+ packet.auth_value.read(auth_value)
96
+ expect(packet.auth_value).to eq(auth_value[0,6])
99
97
  end
100
98
  end
101
99
 
102
100
  it 'reads its own binary representation and output the same packet' do
103
101
  packet.sec_addr.port_spec = "port spec"
104
102
  packet.p_result_list.n_results = 2
105
- packet.auth_verifier = '123456'
103
+ packet.auth_value = '123456'
106
104
  packet.pdu_header.auth_length = 6
107
105
  binary = packet.to_binary_s
108
106
  expect(described_class.read(binary)).to eq(packet)
@@ -119,9 +117,13 @@ RSpec.describe RubySMB::Dcerpc::PortAnyT do
119
117
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
120
118
  end
121
119
 
120
+ it 'has a default alignment of 2 bytes' do
121
+ expect(described_class.default_parameters[:byte_align]).to eq 2
122
+ end
123
+
122
124
  describe '#str_length' do
123
- it 'should be a 16-bit unsigned integer' do
124
- expect(packet.str_length).to be_a BinData::Uint16le
125
+ it 'should be a NdrUint16' do
126
+ expect(packet.str_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
125
127
  end
126
128
 
127
129
  it 'should be the size of #port_spec string, including the NULL terminator' do
@@ -148,15 +150,33 @@ RSpec.describe RubySMB::Dcerpc::PResultListT do
148
150
  subject(:packet) { described_class.new }
149
151
 
150
152
  it { is_expected.to respond_to :n_results }
153
+ it { is_expected.to respond_to :reserved }
154
+ it { is_expected.to respond_to :reserved2 }
151
155
  it { is_expected.to respond_to :p_results }
152
156
 
153
157
  it 'is little endian' do
154
158
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
155
159
  end
156
160
 
161
+ it 'has a default alignment of 4 bytes' do
162
+ expect(described_class.default_parameters[:byte_align]).to eq 4
163
+ end
164
+
157
165
  describe '#n_results' do
158
- it 'should be a 8-bit unsigned integer' do
159
- expect(packet.n_results).to be_a BinData::Uint8
166
+ it 'should be a NdrUint8' do
167
+ expect(packet.n_results).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
168
+ end
169
+ end
170
+
171
+ describe '#reserved' do
172
+ it 'should be a NdrUint8' do
173
+ expect(packet.reserved).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
174
+ end
175
+ end
176
+
177
+ describe '#reserved2' do
178
+ it 'should be a NdrUint16' do
179
+ expect(packet.reserved2).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
160
180
  end
161
181
  end
162
182
 
@@ -172,6 +192,10 @@ RSpec.describe RubySMB::Dcerpc::PResultListT do
172
192
  packet.n_results = n_elements
173
193
  expect(packet.p_results.size).to eq n_elements
174
194
  end
195
+
196
+ it 'has a default alignment of 4 bytes' do
197
+ expect(packet.p_results.get_parameter(:byte_align)).to eq 4
198
+ end
175
199
  end
176
200
 
177
201
  it 'reads its own binary representation and output the same packet' do
@@ -192,15 +216,19 @@ RSpec.describe RubySMB::Dcerpc::PResultT do
192
216
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
193
217
  end
194
218
 
219
+ it 'has a default alignment of 4 bytes' do
220
+ expect(described_class.default_parameters[:byte_align]).to eq 4
221
+ end
222
+
195
223
  describe '#result' do
196
- it 'should be a 16-bit unsigned integer' do
197
- expect(packet.result).to be_a BinData::Uint16le
224
+ it 'should be a NdrUint16' do
225
+ expect(packet.result).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
198
226
  end
199
227
  end
200
228
 
201
229
  describe '#reason' do
202
- it 'should be a 16-bit unsigned integer' do
203
- expect(packet.reason).to be_a BinData::Uint16le
230
+ it 'should be a NdrUint16' do
231
+ expect(packet.reason).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
204
232
  end
205
233
  end
206
234
 
@@ -17,7 +17,8 @@ RSpec.describe RubySMB::Dcerpc::Bind do
17
17
  it { is_expected.to respond_to :max_recv_frag }
18
18
  it { is_expected.to respond_to :assoc_group_id }
19
19
  it { is_expected.to respond_to :p_context_list }
20
- it { is_expected.to respond_to :auth_verifier }
20
+ it { is_expected.to respond_to :sec_trailer }
21
+ it { is_expected.to respond_to :auth_value }
21
22
 
22
23
  it 'is little endian' do
23
24
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
@@ -36,8 +37,8 @@ RSpec.describe RubySMB::Dcerpc::Bind do
36
37
  end
37
38
 
38
39
  describe '#max_xmit_frag' do
39
- it 'should be a 16-bit unsigned integer' do
40
- expect(packet.max_xmit_frag).to be_a BinData::Uint16le
40
+ it 'should be NdrUint16' do
41
+ expect(packet.max_xmit_frag).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
41
42
  end
42
43
 
43
44
  it 'should have a default value of 0xFFFF' do
@@ -46,8 +47,8 @@ RSpec.describe RubySMB::Dcerpc::Bind do
46
47
  end
47
48
 
48
49
  describe '#max_recv_frag' do
49
- it 'should be a 16-bit unsigned integer' do
50
- expect(packet.max_recv_frag).to be_a BinData::Uint16le
50
+ it 'should be NdrUint16' do
51
+ expect(packet.max_recv_frag).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
51
52
  end
52
53
 
53
54
  it 'should have a default value of 0xFFFF' do
@@ -56,8 +57,8 @@ RSpec.describe RubySMB::Dcerpc::Bind do
56
57
  end
57
58
 
58
59
  describe '#assoc_group_id' do
59
- it 'should be a 32-bit unsigned integer' do
60
- expect(packet.assoc_group_id).to be_a BinData::Uint32le
60
+ it 'should be NdrUint32' do
61
+ expect(packet.assoc_group_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
61
62
  end
62
63
  end
63
64
 
@@ -71,32 +72,48 @@ RSpec.describe RubySMB::Dcerpc::Bind do
71
72
  end
72
73
  end
73
74
 
74
- describe '#auth_verifier' do
75
+ describe '#sec_trailer' do
76
+ it 'should be SecTrailer structure' do
77
+ expect(packet.sec_trailer).to be_a RubySMB::Dcerpc::SecTrailer
78
+ end
79
+
80
+ it 'should not exist if the #auth_length PDU header field is 0' do
81
+ packet.pdu_header.auth_length = 0
82
+ expect(packet.sec_trailer?).to be false
83
+ end
84
+
85
+ it 'should exist only if the #auth_length PDU header field is greater than 0' do
86
+ packet.pdu_header.auth_length = 10
87
+ expect(packet.sec_trailer?).to be true
88
+ end
89
+ end
90
+
91
+ describe '#auth_value' do
75
92
  it 'should be a string' do
76
- expect(packet.auth_verifier).to be_a BinData::String
93
+ expect(packet.auth_value).to be_a BinData::String
77
94
  end
78
95
 
79
96
  it 'should not exist if the #auth_length PDU header field is 0' do
80
97
  packet.pdu_header.auth_length = 0
81
- expect(packet.auth_verifier?).to be false
98
+ expect(packet.auth_value?).to be false
82
99
  end
83
100
 
84
101
  it 'should exist only if the #auth_length PDU header field is greater than 0' do
85
102
  packet.pdu_header.auth_length = 10
86
- expect(packet.auth_verifier?).to be true
103
+ expect(packet.auth_value?).to be true
87
104
  end
88
105
 
89
106
  it 'reads #auth_length bytes' do
90
- auth_verifier = '12345678'
107
+ auth_value = '12345678'
91
108
  packet.pdu_header.auth_length = 6
92
- packet.auth_verifier.read(auth_verifier)
93
- expect(packet.auth_verifier).to eq(auth_verifier[0,6])
109
+ packet.auth_value.read(auth_value)
110
+ expect(packet.auth_value).to eq(auth_value[0,6])
94
111
  end
95
112
  end
96
113
 
97
114
  it 'reads its own binary representation and output the same packet' do
98
115
  packet = described_class.new(endpoint: endpoint)
99
- packet.auth_verifier = '123456'
116
+ packet.auth_value = '123456'
100
117
  packet.pdu_header.auth_length = 6
101
118
  binary = packet.to_binary_s
102
119
  expect(described_class.read(binary)).to eq(packet)
@@ -118,15 +135,21 @@ RSpec.describe RubySMB::Dcerpc::PContListT do
118
135
  subject(:packet) { described_class.new }
119
136
 
120
137
  it { is_expected.to respond_to :n_context_elem }
138
+ it { is_expected.to respond_to :reserved }
139
+ it { is_expected.to respond_to :reserved2 }
121
140
  it { is_expected.to respond_to :p_cont_elem }
122
141
 
123
142
  it 'is little endian' do
124
143
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
125
144
  end
126
145
 
146
+ it 'has a default alignment of 4 bytes' do
147
+ expect(described_class.default_parameters[:byte_align]).to eq 4
148
+ end
149
+
127
150
  describe '#n_context_elem' do
128
- it 'should be a 8-bit unsigned integer' do
129
- expect(packet.n_context_elem).to be_a BinData::Uint8
151
+ it 'should be NdrUint8' do
152
+ expect(packet.n_context_elem).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
130
153
  end
131
154
 
132
155
  it 'should have the default value 1' do
@@ -134,6 +157,18 @@ RSpec.describe RubySMB::Dcerpc::PContListT do
134
157
  end
135
158
  end
136
159
 
160
+ describe '#reserved' do
161
+ it 'should be NdrUint8' do
162
+ expect(packet.reserved).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
163
+ end
164
+ end
165
+
166
+ describe '#reserved2' do
167
+ it 'should be NdrUint16' do
168
+ expect(packet.reserved2).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
169
+ end
170
+ end
171
+
137
172
  describe '#p_cont_elem' do
138
173
  it 'should be an array of type PContElemT' do
139
174
  expect(packet.p_cont_elem).to be_a BinData::Array
@@ -150,6 +185,10 @@ RSpec.describe RubySMB::Dcerpc::PContListT do
150
185
  it 'should have an #endpoint parameter' do
151
186
  expect(packet.p_cont_elem.has_parameter?(:endpoint)).to be true
152
187
  end
188
+
189
+ it 'has a default alignment of 4 bytes' do
190
+ expect(packet.p_cont_elem.get_parameter(:byte_align)).to eq 4
191
+ end
153
192
  end
154
193
 
155
194
  it 'reads its own binary representation and output the same packet' do
@@ -175,6 +214,7 @@ RSpec.describe RubySMB::Dcerpc::PContElemT do
175
214
 
176
215
  it { is_expected.to respond_to :p_cont_id }
177
216
  it { is_expected.to respond_to :n_transfer_syn }
217
+ it { is_expected.to respond_to :reserved }
178
218
  it { is_expected.to respond_to :abstract_syntax }
179
219
  it { is_expected.to respond_to :transfer_syntaxes }
180
220
 
@@ -182,15 +222,19 @@ RSpec.describe RubySMB::Dcerpc::PContElemT do
182
222
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
183
223
  end
184
224
 
225
+ it 'has a default alignment of 4 bytes' do
226
+ expect(described_class.default_parameters[:byte_align]).to eq 4
227
+ end
228
+
185
229
  describe '#p_cont_id' do
186
- it 'should be a 16-bit unsigned integer' do
187
- expect(packet.p_cont_id).to be_a BinData::Uint16le
230
+ it 'should be NdrUint16' do
231
+ expect(packet.p_cont_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
188
232
  end
189
233
  end
190
234
 
191
235
  describe '#n_transfer_syn' do
192
- it 'should be a 8-bit unsigned integer' do
193
- expect(packet.n_transfer_syn).to be_a BinData::Uint8
236
+ it 'should be NdrUint8' do
237
+ expect(packet.n_transfer_syn).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
194
238
  end
195
239
 
196
240
  it 'should have the default value 1' do
@@ -198,6 +242,12 @@ RSpec.describe RubySMB::Dcerpc::PContElemT do
198
242
  end
199
243
  end
200
244
 
245
+ describe '#reserved' do
246
+ it 'should be NdrUint8' do
247
+ expect(packet.reserved).to be_a RubySMB::Dcerpc::Ndr::NdrUint8
248
+ end
249
+ end
250
+
201
251
  describe '#abstract_syntax' do
202
252
  it 'should be a PSyntaxIdT structure' do
203
253
  expect(packet.abstract_syntax).to be_a RubySMB::Dcerpc::PSyntaxIdT
@@ -251,6 +301,10 @@ RSpec.describe RubySMB::Dcerpc::PContElemT do
251
301
  expect(packet.transfer_syntaxes[0].if_ver_major).to eq RubySMB::Dcerpc::Ndr::VER_MAJOR
252
302
  expect(packet.transfer_syntaxes[0].if_ver_minor).to eq RubySMB::Dcerpc::Ndr::VER_MINOR
253
303
  end
304
+
305
+ it 'has a default alignment of 4 bytes' do
306
+ expect(packet.transfer_syntaxes.get_parameter(:byte_align)).to eq 4
307
+ end
254
308
  end
255
309
 
256
310
  it 'reads its own binary representation and output the same packet' do