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,38 @@
1
+ RSpec.describe RubySMB::Server::Session do
2
+ let(:user_id) { 'WORKGROUP\RubySMB' }
3
+ subject(:session) { described_class.new(rand(0xffffffff), user_id: user_id) }
4
+
5
+ it { is_expected.to respond_to :id }
6
+ it { is_expected.to respond_to :key }
7
+ it { is_expected.to respond_to :signing_required }
8
+ it { is_expected.to respond_to :tree_connect_table }
9
+ it { is_expected.to respond_to :creation_time }
10
+
11
+ describe '#initialize' do
12
+ it 'starts with no signing required' do
13
+ expect(session.signing_required).to be_falsey
14
+ end
15
+
16
+ it 'starts with no tree connections' do
17
+ expect(session.tree_connect_table).to be_empty
18
+ end
19
+
20
+ it 'starts in the in progress state' do
21
+ expect(session.state).to be :in_progress
22
+ end
23
+ end
24
+
25
+ describe '#is_anonymous' do
26
+ it 'is false' do
27
+ expect(session.is_anonymous).to be_falsey
28
+ end
29
+
30
+ context 'when the identity is set to anonymous' do
31
+ let(:user_id) { RubySMB::Gss::Provider::IDENTITY_ANONYMOUS }
32
+
33
+ it 'is true' do
34
+ expect(session.is_anonymous).to be_truthy
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,61 @@
1
+ RSpec.describe RubySMB::Server::Share::Provider::Disk do
2
+ let(:name) { 'share' }
3
+ let(:path) { Dir.getwd }
4
+ subject(:share_provider) { described_class.new(name, path) }
5
+
6
+ it { is_expected.to respond_to :name }
7
+ it { is_expected.to respond_to :path }
8
+ it { is_expected.to respond_to :type }
9
+
10
+ describe '#TYPE' do
11
+ it 'is TYPE_DISK' do
12
+ expect(described_class::TYPE).to eq RubySMB::Server::Share::TYPE_DISK
13
+ end
14
+ end
15
+
16
+ describe '#initialize' do
17
+ it 'sets the name' do
18
+ expect(share_provider.name).to eq name
19
+ end
20
+
21
+ it 'sets the path' do
22
+ expect(share_provider.path).to be_a Pathname
23
+ expect(share_provider.path).to eq Pathname.new(path)
24
+ end
25
+
26
+ it 'sets the type correctly' do
27
+ expect(share_provider.type).to eq RubySMB::Server::Share::TYPE_DISK
28
+ end
29
+
30
+ it 'raises an ArgumentError for an invalid path' do
31
+ # __FILE__ is not a directory so it's invalid
32
+ expect { described_class.new(name, __FILE__) }.to raise_error(ArgumentError)
33
+ end
34
+ end
35
+ end
36
+
37
+ RSpec.describe RubySMB::Server::Share::Provider::Disk::Processor do
38
+ let(:session) { RubySMB::Server::Session.new(rand(0xffffffff)) }
39
+ let(:share_provider) { RubySMB::Server::Share::Provider::Disk.new('share', Dir.getwd) }
40
+ subject(:share_processor) { described_class.new(share_provider, nil, session) }
41
+
42
+ it { is_expected.to respond_to :provider }
43
+
44
+ describe '#maximal_access' do
45
+ # no path specified should be the root of the share
46
+ context 'with no path specified' do
47
+ let(:maximal_access) { share_processor.maximal_access }
48
+ it 'is a FileAccessMask' do
49
+ expect(maximal_access).to be_a RubySMB::SMB2::BitField::FileAccessMask
50
+ end
51
+
52
+ it 'marks the data as readable' do
53
+ expect(maximal_access.read_data).to eq 1
54
+ end
55
+
56
+ it 'marks the data attributes as readable' do
57
+ expect(maximal_access.read_attr).to eq 1
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,31 @@
1
+ RSpec.describe RubySMB::Server::Share::Provider::Pipe do
2
+ let(:name) { 'share' }
3
+ subject(:share_provider) { described_class.new(name) }
4
+
5
+ it { is_expected.to respond_to :name }
6
+ it { is_expected.to respond_to :type }
7
+
8
+ describe '#TYPE' do
9
+ it 'is TYPE_PIPE' do
10
+ expect(described_class::TYPE).to eq RubySMB::Server::Share::TYPE_PIPE
11
+ end
12
+ end
13
+
14
+ describe '#initialize' do
15
+ it 'sets the name' do
16
+ expect(share_provider.name).to eq name
17
+ end
18
+
19
+ it 'sets the type correctly' do
20
+ expect(share_provider.type).to eq RubySMB::Server::Share::TYPE_PIPE
21
+ end
22
+ end
23
+ end
24
+
25
+ RSpec.describe RubySMB::Server::Share::Provider::Pipe::Processor do
26
+ let(:session) { RubySMB::Server::Session.new(rand(0xffffffff)) }
27
+ let(:share_provider) { RubySMB::Server::Share::Provider::Pipe.new('share') }
28
+ subject(:share_processor) { described_class.new(share_provider, nil, session) }
29
+
30
+ it { is_expected.to respond_to :provider }
31
+ end
@@ -0,0 +1,13 @@
1
+ RSpec.describe RubySMB::Server::Share::Provider::Base do
2
+ let(:name) { 'share' }
3
+ subject(:share_provider) { described_class.new(name) }
4
+
5
+ it { is_expected.to respond_to :name }
6
+ it { is_expected.to respond_to :type }
7
+
8
+ describe '#initialize' do
9
+ it 'sets the name' do
10
+ expect(share_provider.name).to eq name
11
+ end
12
+ end
13
+ end
@@ -140,45 +140,26 @@ RSpec.describe RubySMB::SMB1::Pipe do
140
140
  expect(pipe.size_on_disk).to eq(nt_create_andx_response.parameter_block.allocation_size)
141
141
  end
142
142
 
143
- context 'with \'srvsvc\' filename' do
144
- it 'extends Srvsvc class' do
145
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: 'srvsvc')
146
- expect(pipe.respond_to?(:net_share_enum_all)).to be true
147
- end
148
- end
149
-
150
- context 'with \'\\srvsvc\' filename' do
151
- it 'extends Srvsvc class' do
152
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: '\\srvsvc')
153
- expect(pipe.respond_to?(:net_share_enum_all)).to be true
154
- end
155
- end
156
-
157
- context 'with \'winreg\' filename' do
158
- it 'extends Winreg class' do
159
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: 'winreg')
160
- expect(pipe.respond_to?(:has_registry_key?)).to be true
161
- end
162
- end
163
-
164
- context 'with \'\\winreg\' filename' do
165
- it 'extends Winreg class' do
166
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: '\\winreg')
167
- expect(pipe.respond_to?(:has_registry_key?)).to be true
168
- end
169
- end
170
-
171
- context 'with \'svcctl\' filename' do
172
- it 'extends svcctl class' do
173
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: 'svcctl')
174
- expect(pipe.respond_to?(:query_service_config)).to be true
143
+ {
144
+ netlogon: RubySMB::Dcerpc::Netlogon,
145
+ srvsvc: RubySMB::Dcerpc::Srvsvc,
146
+ svcctl: RubySMB::Dcerpc::Svcctl,
147
+ winreg: RubySMB::Dcerpc::Winreg,
148
+ samr: RubySMB::Dcerpc::Samr,
149
+ wkssvc: RubySMB::Dcerpc::Wkssvc
150
+ }.each do |endpoint, klass|
151
+ context "with \'#{endpoint}\' filename" do
152
+ it "extends #{klass} class" do
153
+ pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: endpoint.to_s)
154
+ expect(pipe).to be_a klass
155
+ end
175
156
  end
176
- end
177
157
 
178
- context 'with \'\\svcctl\' filename' do
179
- it 'extends svcctl class' do
180
- pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: '\\svcctl')
181
- expect(pipe.respond_to?(:query_service_config)).to be true
158
+ context "with \'\\#{endpoint}\' filename" do
159
+ it "extends #{klass} class" do
160
+ pipe = described_class.new(tree: tree, response: nt_create_andx_response, name: "\\#{endpoint.to_s}")
161
+ expect(pipe).to be_a klass
162
+ end
182
163
  end
183
164
  end
184
165
  end
@@ -44,8 +44,14 @@ RSpec.describe RubySMB::SMB2::BitField::Smb2HeaderFlags do
44
44
  end
45
45
 
46
46
  describe '#reserved3' do
47
- it 'should be a 4-bit field per the SMB spec' do
48
- expect(flags.reserved3).to be_a BinData::Bit4
47
+ it 'should be a 1-bit field per the SMB spec' do
48
+ expect(flags.reserved3).to be_a BinData::Bit1
49
+ end
50
+ end
51
+
52
+ describe '#priority' do
53
+ it 'should be a 3-bit field per the SMB spec' do
54
+ expect(flags.priority).to be_a BinData::Bit3
49
55
  end
50
56
  end
51
57
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe RubySMB::SMB2::CreateContext do
3
+ RSpec.describe RubySMB::SMB2::CreateContext::CreateContextRequest do
4
4
  subject(:struct) { described_class.new }
5
5
 
6
6
  it { is_expected.to respond_to :next_offset }
@@ -80,22 +80,22 @@ RSpec.describe RubySMB::SMB2::Packet::CreateRequest do
80
80
  expect(packet.name_offset).to eq packet.name.abs_offset
81
81
  end
82
82
 
83
- it 'tracks the offset to #context in #context_offset' do
84
- expect(packet.context_offset).to eq packet.context.abs_offset
83
+ it 'tracks the offset to #context in #contexts_offset' do
84
+ expect(packet.contexts_offset).to eq packet.contexts.abs_offset
85
85
  end
86
86
 
87
87
  it 'tracks the length of #name in #name_length' do
88
88
  expect(packet.name_length).to eq packet.name.length
89
89
  end
90
90
 
91
- it 'tracks the length of #context in #context_length' do
92
- expect(packet.context_length).to eq packet.context.do_num_bytes
91
+ it 'tracks the length of #context in #contexts_length' do
92
+ expect(packet.contexts_length).to eq packet.contexts.do_num_bytes
93
93
  end
94
94
 
95
95
  describe '#name' do
96
96
  it 'encodes any input into UTF-16LE' do
97
97
  packet.name = 'Hello'
98
- expect(packet.name.to_binary_s).to eq "H\x00e\x00l\x00l\x00o\x00"
98
+ expect(packet.name.to_binary_s { |name| name.abs_offset = 0; name.write_now! }).to eq "H\x00e\x00l\x00l\x00o\x00"
99
99
  end
100
100
  end
101
101
  end
@@ -54,11 +54,15 @@ RSpec.describe RubySMB::SMB2::Packet::CreateResponse do
54
54
  expect(packet.file_id).to be_a RubySMB::Field::Smb2Fileid
55
55
  end
56
56
 
57
- it 'tracks the offset to #context in #context_offset' do
58
- expect(packet.context_offset).to eq packet.context.abs_offset
59
- end
57
+ describe '#contexts' do
58
+ # with no context, the offset and length should be 0
59
+ # see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/d166aa9e-0b53-410e-b35e-3933d8131927
60
+ it 'should have the contexts_offset set to 0' do
61
+ expect(packet.contexts_offset).to eq 0
62
+ end
60
63
 
61
- it 'tracks the length of #context in #context_length' do
62
- expect(packet.context_length).to eq packet.context.do_num_bytes
64
+ it 'should have the contexts_length set to ' do
65
+ expect(packet.contexts_length).to eq 0
66
+ end
63
67
  end
64
68
  end
@@ -30,8 +30,9 @@ RSpec.describe RubySMB::SMB2::Packet::QueryDirectoryResponse do
30
30
  expect(packet.structure_size).to eq 9
31
31
  end
32
32
 
33
- it 'has an offset pointer to the buffer field' do
34
- expect(packet.buffer_offset).to eq packet.buffer.abs_offset
33
+ it 'has an offset pointer of 0 for an empty buffer field' do
34
+ expect(packet.buffer).to be_empty
35
+ expect(packet.buffer_offset).to eq 0
35
36
  end
36
37
 
37
38
  it 'has a length value for the buffer field' do
@@ -146,24 +146,26 @@ RSpec.describe RubySMB::SMB2::Pipe do
146
146
  expect(pipe.size_on_disk).to eq(create_response.allocation_size)
147
147
  end
148
148
 
149
- context 'with \'srvsvc\' filename' do
150
- it 'extends Srvsvc class' do
151
- pipe = described_class.new(tree: tree, response: create_response, name: 'srvsvc')
152
- expect(pipe.respond_to?(:net_share_enum_all)).to be true
153
- end
154
- end
155
-
156
- context 'with \'winreg\' filename' do
157
- it 'extends Winreg class' do
158
- pipe = described_class.new(tree: tree, response: create_response, name: 'winreg')
159
- expect(pipe.respond_to?(:has_registry_key?)).to be true
149
+ {
150
+ netlogon: RubySMB::Dcerpc::Netlogon,
151
+ srvsvc: RubySMB::Dcerpc::Srvsvc,
152
+ svcctl: RubySMB::Dcerpc::Svcctl,
153
+ winreg: RubySMB::Dcerpc::Winreg,
154
+ samr: RubySMB::Dcerpc::Samr,
155
+ wkssvc: RubySMB::Dcerpc::Wkssvc
156
+ }.each do |endpoint, klass|
157
+ context "with \'#{endpoint}\' filename" do
158
+ it "extends #{klass} class" do
159
+ pipe = described_class.new(tree: tree, response: create_response, name: endpoint.to_s)
160
+ expect(pipe).to be_a klass
161
+ end
160
162
  end
161
- end
162
163
 
163
- context 'with \'svcctl\' filename' do
164
- it 'extends svcctl class' do
165
- pipe = described_class.new(tree: tree, response: create_response, name: 'svcctl')
166
- expect(pipe.respond_to?(:query_service_config)).to be true
164
+ context "with \'\\#{endpoint}\' filename" do
165
+ it "extends #{klass} class" do
166
+ pipe = described_class.new(tree: tree, response: create_response, name: "\\#{endpoint.to_s}")
167
+ expect(pipe).to be_a klass
168
+ end
167
169
  end
168
170
  end
169
171
  end
@@ -0,0 +1,9 @@
1
+ class String
2
+ def hexlify
3
+ self.b.bytes.map {|c| "%02x" % c.ord}.join
4
+ end
5
+
6
+ def unhexlify
7
+ self.chars.each_slice(2).map {|c| c.join.to_i(16).chr}.join
8
+ end
9
+ end
data.tar.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- )��3PIco�!�r
2
- �.6� �;�D�H��r�� �Ɔ��#L�0�l��ǀ�ҫ��������p3����¡� ڥ P!�ˢA��b�$"�h�h<�Z\L�ӕ@��@E��oJ�U��[E�v{E=-���l���'~����\^�g? ���ǰQ���5l�:�� [Г��|��oy����`��Y�&[�!�jI���c6��<�Gec
3
- nMj
1
+ �˾I}��XdH���t�7q��jc�m<�����ֿ��v���:�HK0��s� 2��ǃ�� O���@EH5�F��T�<2����]���}.@��E2�O."}��=�+�N�A��̀�M:�H7D���~|c�q��ݽ�^��
2
+ �f3_�6���7�YX�w %�:𦅎G������`�8�G1������G \�k9�%꒰��S��Sr�����h�,^ۺ3����V���TIh*�>J��!>,