ruby_smb 2.0.12 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/verify.yml +1 -1
  4. data/examples/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/encrypting_file_system/efs_rpc_encrypt_file_srv_request.rb +20 -0
  28. data/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_response.rb +20 -0
  29. data/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_request.rb +21 -0
  30. data/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_response.rb +21 -0
  31. data/lib/ruby_smb/dcerpc/encrypting_file_system.rb +44 -0
  32. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
  33. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
  34. data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
  35. data/lib/ruby_smb/dcerpc/epm.rb +75 -0
  36. data/lib/ruby_smb/dcerpc/error.rb +17 -0
  37. data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
  38. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
  39. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
  40. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
  41. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
  42. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
  43. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
  44. data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
  45. data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
  46. data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
  47. data/lib/ruby_smb/dcerpc/print_system/rpc_add_printer_driver_ex_request.rb +22 -0
  48. data/lib/ruby_smb/dcerpc/print_system/rpc_add_printer_driver_ex_response.rb +20 -0
  49. data/lib/ruby_smb/dcerpc/print_system/rpc_enum_printer_drivers_request.rb +24 -0
  50. data/lib/ruby_smb/dcerpc/print_system/rpc_enum_printer_drivers_response.rb +23 -0
  51. data/lib/ruby_smb/dcerpc/print_system/rpc_get_printer_driver_directory_request.rb +24 -0
  52. data/lib/ruby_smb/dcerpc/print_system/rpc_get_printer_driver_directory_response.rb +22 -0
  53. data/lib/ruby_smb/dcerpc/print_system.rb +69 -0
  54. data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
  55. data/lib/ruby_smb/dcerpc/request.rb +79 -32
  56. data/lib/ruby_smb/dcerpc/response.rb +45 -10
  57. data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
  58. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
  59. data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
  60. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
  61. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
  62. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
  63. data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
  64. data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
  65. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
  66. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
  67. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
  68. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
  69. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
  70. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
  71. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
  72. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
  73. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
  74. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
  75. data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
  76. data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
  77. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
  78. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
  79. data/lib/ruby_smb/dcerpc/samr.rb +613 -0
  80. data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
  81. data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
  82. data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
  83. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
  84. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
  85. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
  86. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
  87. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
  88. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
  89. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
  90. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
  91. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
  92. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
  93. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
  94. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
  95. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
  96. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
  97. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
  98. data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
  99. data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
  100. data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
  101. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
  102. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
  103. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
  104. data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
  105. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
  106. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
  107. data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
  108. data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
  109. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
  110. data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
  111. data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
  112. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
  113. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
  114. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
  115. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
  116. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
  117. data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
  118. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
  119. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
  120. data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
  121. data/lib/ruby_smb/dcerpc.rb +43 -13
  122. data/lib/ruby_smb/field/file_time.rb +1 -1
  123. data/lib/ruby_smb/field/nt_status.rb +20 -1
  124. data/lib/ruby_smb/field/string16.rb +5 -1
  125. data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +14 -0
  126. data/lib/ruby_smb/fscc/file_information/file_network_open_information.rb +22 -0
  127. data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +16 -0
  128. data/lib/ruby_smb/fscc/file_information.rb +29 -0
  129. data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +46 -0
  130. data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +19 -0
  131. data/lib/ruby_smb/fscc/file_system_information.rb +22 -0
  132. data/lib/ruby_smb/fscc.rb +1 -0
  133. data/lib/ruby_smb/generic_packet.rb +6 -0
  134. data/lib/ruby_smb/gss/provider/authenticator.rb +4 -0
  135. data/lib/ruby_smb/gss/provider/ntlm.rb +13 -3
  136. data/lib/ruby_smb/ntlm.rb +18 -2
  137. data/lib/ruby_smb/server/server_client/negotiation.rb +0 -2
  138. data/lib/ruby_smb/server/server_client/session_setup.rb +43 -32
  139. data/lib/ruby_smb/server/server_client/share_io.rb +28 -0
  140. data/lib/ruby_smb/server/server_client/tree_connect.rb +60 -0
  141. data/lib/ruby_smb/server/server_client.rb +214 -24
  142. data/lib/ruby_smb/server/session.rb +71 -0
  143. data/lib/ruby_smb/server/share/provider/disk.rb +437 -0
  144. data/lib/ruby_smb/server/share/provider/pipe.rb +27 -0
  145. data/lib/ruby_smb/server/share/provider/processor.rb +76 -0
  146. data/lib/ruby_smb/server/share/provider.rb +38 -0
  147. data/lib/ruby_smb/server/share.rb +11 -0
  148. data/lib/ruby_smb/server.rb +35 -3
  149. data/lib/ruby_smb/signing.rb +37 -11
  150. data/lib/ruby_smb/smb1/commands.rb +4 -0
  151. data/lib/ruby_smb/smb1/pipe.rb +4 -0
  152. data/lib/ruby_smb/smb1.rb +0 -1
  153. data/lib/ruby_smb/smb2/bit_field/smb2_header_flags.rb +2 -1
  154. data/lib/ruby_smb/smb2/commands.rb +4 -0
  155. data/lib/ruby_smb/smb2/create_context/request.rb +64 -0
  156. data/lib/ruby_smb/smb2/create_context/response.rb +62 -0
  157. data/lib/ruby_smb/smb2/create_context.rb +74 -22
  158. data/lib/ruby_smb/smb2/packet/create_request.rb +44 -11
  159. data/lib/ruby_smb/smb2/packet/create_response.rb +17 -3
  160. data/lib/ruby_smb/smb2/packet/query_directory_request.rb +1 -1
  161. data/lib/ruby_smb/smb2/packet/query_directory_response.rb +2 -2
  162. data/lib/ruby_smb/smb2/packet/query_info_request.rb +43 -0
  163. data/lib/ruby_smb/smb2/packet/query_info_response.rb +23 -0
  164. data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +1 -1
  165. data/lib/ruby_smb/smb2/packet/tree_disconnect_response.rb +1 -0
  166. data/lib/ruby_smb/smb2/packet.rb +2 -0
  167. data/lib/ruby_smb/smb2/pipe.rb +4 -0
  168. data/lib/ruby_smb/smb2.rb +11 -0
  169. data/lib/ruby_smb/smb_error.rb +110 -0
  170. data/lib/ruby_smb/version.rb +1 -1
  171. data/lib/ruby_smb.rb +2 -0
  172. data/ruby_smb.gemspec +1 -1
  173. data/spec/lib/ruby_smb/client_spec.rb +1 -2
  174. data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
  175. data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
  176. data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
  177. data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
  178. data/spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_request_spec.rb +30 -0
  179. data/spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_encrypt_file_srv_response_spec.rb +30 -0
  180. data/spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_request_spec.rb +38 -0
  181. data/spec/lib/ruby_smb/dcerpc/encrypting_file_system/efs_rpc_open_file_raw_response_spec.rb +38 -0
  182. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
  183. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
  184. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
  185. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
  186. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
  187. data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
  188. data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
  189. data/spec/lib/ruby_smb/dcerpc/print_system/driver_container_spec.rb +41 -0
  190. data/spec/lib/ruby_smb/dcerpc/print_system/driver_info2_spec.rb +64 -0
  191. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_add_printer_driver_ex_request_spec.rb +59 -0
  192. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_add_printer_driver_ex_response_spec.rb +30 -0
  193. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_enum_printer_drivers_request_spec.rb +62 -0
  194. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_enum_printer_drivers_response_spec.rb +54 -0
  195. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_get_printer_driver_directory_request_spec.rb +62 -0
  196. data/spec/lib/ruby_smb/dcerpc/print_system/rpc_get_printer_driver_directory_response_spec.rb +46 -0
  197. data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
  198. data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
  199. data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
  200. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
  201. data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
  202. data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
  203. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
  204. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
  205. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
  206. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
  207. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
  208. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
  209. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
  210. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
  211. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
  212. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
  213. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
  214. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
  215. data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
  216. data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
  217. data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
  218. data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
  219. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
  220. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
  221. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
  222. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
  223. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
  224. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
  225. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
  226. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
  227. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
  228. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
  229. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
  230. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
  231. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
  232. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
  233. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
  234. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
  235. data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
  236. data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
  237. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
  238. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
  239. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
  240. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
  241. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
  242. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
  243. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
  244. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
  245. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
  246. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
  247. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
  248. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
  249. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
  250. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
  251. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
  252. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
  253. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
  254. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
  255. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
  256. data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
  257. data/spec/lib/ruby_smb/field/nt_status_spec.rb +6 -2
  258. data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
  259. data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +4 -0
  260. data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
  261. data/spec/lib/ruby_smb/server/server_client_spec.rb +36 -53
  262. data/spec/lib/ruby_smb/server/session_spec.rb +38 -0
  263. data/spec/lib/ruby_smb/server/share/provider/disk_spec.rb +61 -0
  264. data/spec/lib/ruby_smb/server/share/provider/pipe_spec.rb +31 -0
  265. data/spec/lib/ruby_smb/server/share/provider_spec.rb +13 -0
  266. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
  267. data/spec/lib/ruby_smb/smb2/bit_field/header_flags_spec.rb +8 -2
  268. data/spec/lib/ruby_smb/smb2/{create_context_spec.rb → create_context/create_context_request_spec.rb} +1 -1
  269. data/spec/lib/ruby_smb/smb2/packet/create_request_spec.rb +5 -5
  270. data/spec/lib/ruby_smb/smb2/packet/create_response_spec.rb +9 -5
  271. data/spec/lib/ruby_smb/smb2/packet/query_directory_response_spec.rb +3 -2
  272. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
  273. data/spec/support/bin_helper.rb +9 -0
  274. data.tar.gz.sig +0 -0
  275. metadata +165 -10
  276. metadata.gz.sig +0 -0
  277. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
  278. data/lib/ruby_smb/smb1/create_actions.rb +0 -20
  279. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -19,8 +19,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Request do
19
19
  end
20
20
 
21
21
  describe '#account_name' do
22
- it 'is a NdrString structure' do
23
- expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
22
+ it 'is a NdrConfVarWideStringz structure' do
23
+ expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
24
24
  end
25
25
  end
26
26
 
@@ -31,8 +31,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Request do
31
31
  end
32
32
 
33
33
  describe '#computer_name' do
34
- it 'is a NdrString structure' do
35
- expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
34
+ it 'is a NdrConfVarWideStringz structure' do
35
+ expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
36
36
  end
37
37
  end
38
38
 
@@ -19,8 +19,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Request do
19
19
  end
20
20
 
21
21
  describe '#account_name' do
22
- it 'is a NdrString structure' do
23
- expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
22
+ it 'is a NdrConfVarWideStringz structure' do
23
+ expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
24
24
  end
25
25
  end
26
26
 
@@ -31,8 +31,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Request do
31
31
  end
32
32
 
33
33
  describe '#computer_name' do
34
- it 'is a NdrString structure' do
35
- expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
34
+ it 'is a NdrConfVarWideStringz structure' do
35
+ expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
36
36
  end
37
37
  end
38
38
 
@@ -16,8 +16,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeRequest do
16
16
  end
17
17
 
18
18
  describe '#computer_name' do
19
- it 'is a NdrString structure' do
20
- expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
19
+ it 'is a NdrConfVarWideStringz structure' do
20
+ expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
21
21
  end
22
22
  end
23
23
 
@@ -15,8 +15,8 @@ RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeResponse do
15
15
  end
16
16
 
17
17
  describe '#error_status' do
18
- it 'is a 32-bit unsigned integer' do
19
- expect(packet.error_status).to be_a BinData::Uint32le
18
+ it 'is a NDR 32-bit unsigned integer' do
19
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
20
20
  end
21
21
  end
22
22
 
@@ -9,6 +9,10 @@ RSpec.describe RubySMB::Dcerpc::PSyntaxIdT do
9
9
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
10
10
  end
11
11
 
12
+ it 'has :byte_align parameter set to the expected value' do
13
+ expect(described_class.default_parameters[:byte_align]).to eq(4)
14
+ end
15
+
12
16
  describe '#if_uuid' do
13
17
  it 'is a Uuid' do
14
18
  expect(packet.if_uuid).to be_a RubySMB::Dcerpc::Uuid
@@ -16,16 +20,26 @@ RSpec.describe RubySMB::Dcerpc::PSyntaxIdT do
16
20
  end
17
21
 
18
22
  describe '#if_ver_major' do
19
- it 'should be a 16-bit unsigned integer' do
20
- expect(packet.if_ver_major).to be_a BinData::Uint16le
23
+ it 'should be a NdrUint16' do
24
+ expect(packet.if_ver_major).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
21
25
  end
22
26
  end
23
27
 
24
28
  describe '#if_ver_minor' do
25
- it 'should be a 16-bit unsigned integer' do
26
- expect(packet.if_ver_minor).to be_a BinData::Uint16le
29
+ it 'should be a NdrUint16' do
30
+ expect(packet.if_ver_minor).to be_a RubySMB::Dcerpc::Ndr::NdrUint16
27
31
  end
28
32
  end
29
33
 
34
+ it 'reads its own binary representation and output the same packet' do
35
+ packet = described_class.new(
36
+ if_uuid: '22fd0d58-357a-472d-9d03-5f19e09b3a92',
37
+ if_ver_major: rand(0xFF),
38
+ if_ver_minor: rand(0xFF)
39
+ )
40
+ binary = packet.to_binary_s
41
+ expect(described_class.read(binary)).to eq(packet)
42
+ end
43
+
30
44
  end
31
45
 
@@ -37,9 +37,20 @@ RSpec.describe RubySMB::Dcerpc::PDUHeader do
37
37
  end
38
38
 
39
39
  describe '#pfc_flags' do
40
+ subject(:pfc_flags) { packet.pfc_flags }
41
+
40
42
  it 'should be a custom structure' do
41
- expect(packet.pfc_flags).to be_a BinData::Struct
43
+ expect(pfc_flags).to be_a BinData::Struct
42
44
  end
45
+
46
+ it { is_expected.to respond_to :object_uuid }
47
+ it { is_expected.to respond_to :maybe }
48
+ it { is_expected.to respond_to :did_not_execute }
49
+ it { is_expected.to respond_to :conc_mpx }
50
+ it { is_expected.to respond_to :reserved_1 }
51
+ it { is_expected.to respond_to :support_header_sign }
52
+ it { is_expected.to respond_to :last_frag }
53
+ it { is_expected.to respond_to :first_frag }
43
54
  end
44
55
 
45
56
  describe '#packed_drep' do
@@ -79,6 +90,21 @@ RSpec.describe RubySMB::Dcerpc::PDUHeader do
79
90
  end
80
91
  end
81
92
 
93
+ it 'reads its own binary representation and output the same packet' do
94
+ packet = described_class.new(
95
+ rpc_vers: rand(0xFF),
96
+ rpc_vers_minor: rand(0xFF),
97
+ ptype: rand(0xFF),
98
+ pfc_flags: { support_header_sign: 1},
99
+ packed_drep: rand(0xFF),
100
+ frag_length: rand(0xFF),
101
+ auth_length: rand(0xFF),
102
+ call_id: rand(0xFF)
103
+ )
104
+ binary = packet.to_binary_s
105
+ expect(described_class.read(binary)).to eq(packet)
106
+ end
107
+
82
108
  end
83
109
 
84
110
 
@@ -0,0 +1,41 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::DriverContainer do
2
+ subject(:struct) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :level }
5
+ it { is_expected.to respond_to :tag }
6
+ it { is_expected.to respond_to :driver_info }
7
+
8
+ it 'is little endian' do
9
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
10
+ end
11
+
12
+ describe '#level' do
13
+ it 'is a NdrUint32' do
14
+ expect(struct.level).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
15
+ end
16
+ end
17
+
18
+ describe '#tag' do
19
+ it 'is a NdrUint32' do
20
+ expect(struct.tag).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
21
+ end
22
+ end
23
+
24
+ it 'reads its own binary representation and outputs the same struct' do
25
+ struct = described_class.new(
26
+ level: 2,
27
+ tag: 0,
28
+ driver_info: RubySMB::Dcerpc::PrintSystem::DriverInfo2.new(
29
+ c_version: 0,
30
+ p_name: 'p_name',
31
+ p_environment: 'p_environment',
32
+ p_driver_path: 'p_driver_path',
33
+ p_data_file: 'p_data_file',
34
+ p_config_file: 'p_config_file'
35
+ )
36
+ )
37
+ binary = struct.to_binary_s
38
+ expect(described_class.read(binary)).to eq(struct)
39
+ end
40
+ end
41
+
@@ -0,0 +1,64 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::DriverInfo2 do
2
+ subject(:struct) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :c_version }
5
+ it { is_expected.to respond_to :p_name }
6
+ it { is_expected.to respond_to :p_environment }
7
+ it { is_expected.to respond_to :p_driver_path }
8
+ it { is_expected.to respond_to :p_data_file }
9
+ it { is_expected.to respond_to :p_config_file }
10
+
11
+ it 'is little endian' do
12
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
13
+ end
14
+
15
+ describe '#c_version' do
16
+ it 'is a NdrUint32' do
17
+ expect(struct.c_version).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
18
+ end
19
+ end
20
+
21
+ describe '#p_name' do
22
+ it 'is a NdrWideStringzPtr' do
23
+ expect(struct.p_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
24
+ end
25
+ end
26
+
27
+ describe '#p_environment' do
28
+ it 'is a NdrWideStringzPtr' do
29
+ expect(struct.p_environment).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
30
+ end
31
+ end
32
+
33
+ describe '#p_driver_path' do
34
+ it 'is a NdrWideStringzPtr' do
35
+ expect(struct.p_driver_path).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
36
+ end
37
+ end
38
+
39
+ describe '#p_data_file' do
40
+ it 'is a NdrWideStringzPtr' do
41
+ expect(struct.p_data_file).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
42
+ end
43
+ end
44
+
45
+ describe '#p_config_file' do
46
+ it 'is a NdrWideStringzPtr' do
47
+ expect(struct.p_config_file).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
48
+ end
49
+ end
50
+
51
+ it 'reads its own binary representation and outputs the same struct' do
52
+ struct = described_class.new(
53
+ c_version: 0,
54
+ p_name: 'p_name',
55
+ p_environment: 'p_environment',
56
+ p_driver_path: 'p_driver_path',
57
+ p_data_file: 'p_data_file',
58
+ p_config_file: 'p_config_file'
59
+ )
60
+ binary = struct.to_binary_s
61
+ expect(described_class.read(binary)).to eq(struct)
62
+ end
63
+ end
64
+
@@ -0,0 +1,59 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcAddPrinterDriverExRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :p_name }
5
+ it { is_expected.to respond_to :p_driver_container }
6
+ it { is_expected.to respond_to :dw_file_copy_flags }
7
+
8
+ it 'is little endian' do
9
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
10
+ end
11
+
12
+ describe '#p_name' do
13
+ it 'is a NdrWideStringzPtr' do
14
+ expect(packet.p_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
15
+ end
16
+ end
17
+
18
+ describe '#p_driver_container' do
19
+ it 'is a DriverContainer structure' do
20
+ expect(packet.p_driver_container).to be_a RubySMB::Dcerpc::PrintSystem::DriverContainer
21
+ end
22
+ end
23
+
24
+ describe '#dw_file_copy_flags' do
25
+ it 'is a NdrUint32' do
26
+ expect(packet.dw_file_copy_flags).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
27
+ end
28
+ end
29
+
30
+ describe '#initialize_instance' do
31
+ it 'sets #opnum to RPC_ADD_PRINTER_DRIVER_EX constant' do
32
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_ADD_PRINTER_DRIVER_EX)
33
+ end
34
+ end
35
+
36
+ it 'reads its own binary representation and outputs the same packet' do
37
+ packet = described_class.new(
38
+ p_name: 'p_name',
39
+ p_driver_container: RubySMB::Dcerpc::PrintSystem::DriverContainer.new(
40
+ RubySMB::Dcerpc::PrintSystem::DriverContainer.new(
41
+ level: 2,
42
+ tag: 2,
43
+ driver_info: RubySMB::Dcerpc::PrintSystem::DriverInfo2.new(
44
+ c_version: 0,
45
+ p_name: 'p_name',
46
+ p_environment: 'p_environment',
47
+ p_driver_path: 'p_driver_path',
48
+ p_data_file: 'p_data_file',
49
+ p_config_file: 'p_config_file'
50
+ )
51
+ )
52
+ ),
53
+ dw_file_copy_flags: 0
54
+ )
55
+ binary = packet.to_binary_s
56
+ expect(described_class.read(binary)).to eq(packet)
57
+ end
58
+ end
59
+
@@ -0,0 +1,30 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcAddPrinterDriverExResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :error_status }
5
+
6
+ it 'is little endian' do
7
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
8
+ end
9
+
10
+ describe '#error_status' do
11
+ it 'is a NdrUint32' do
12
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
13
+ end
14
+ end
15
+
16
+ describe '#initialize_instance' do
17
+ it 'sets #opnum to RPC_ADD_PRINTER_DRIVER_EX constant' do
18
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_ADD_PRINTER_DRIVER_EX)
19
+ end
20
+ end
21
+
22
+ it 'reads its own binary representation and outputs the same packet' do
23
+ packet = described_class.new(
24
+ error_status: 0
25
+ )
26
+ binary = packet.to_binary_s
27
+ expect(described_class.read(binary)).to eq(packet)
28
+ end
29
+ end
30
+
@@ -0,0 +1,62 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcEnumPrinterDriversRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :p_name }
5
+ it { is_expected.to respond_to :p_environment }
6
+ it { is_expected.to respond_to :level }
7
+ it { is_expected.to respond_to :p_drivers }
8
+ it { is_expected.to respond_to :cb_buf }
9
+
10
+ it 'is little endian' do
11
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
12
+ end
13
+
14
+ describe '#p_name' do
15
+ it 'is a NdrWideStringzPtr' do
16
+ expect(packet.p_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
17
+ end
18
+ end
19
+
20
+ describe '#p_environment' do
21
+ it 'is a NdrWideStringzPtr' do
22
+ expect(packet.p_environment).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
23
+ end
24
+ end
25
+
26
+ describe '#level' do
27
+ it 'is a NdrUint32' do
28
+ expect(packet.level).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
29
+ end
30
+ end
31
+
32
+ describe '#p_drivers' do
33
+ it 'is a RprnByteArrayPtr' do
34
+ expect(packet.p_drivers).to be_a RubySMB::Dcerpc::PrintSystem::RprnByteArrayPtr
35
+ end
36
+ end
37
+
38
+ describe '#cb_buf' do
39
+ it 'is a NdrUint32' do
40
+ expect(packet.cb_buf).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
41
+ end
42
+ end
43
+
44
+ describe '#initialize_instance' do
45
+ it 'sets #opnum to RPC_ENUM_PRINTER_DRIVERS constant' do
46
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_ENUM_PRINTER_DRIVERS)
47
+ end
48
+ end
49
+
50
+ it 'reads its own binary representation and outputs the same packet' do
51
+ packet = described_class.new(
52
+ p_name: 'p_name',
53
+ p_environment: 'p_environment',
54
+ level: 0,
55
+ p_drivers: [0, 1, 2],
56
+ cb_buf: 0
57
+ )
58
+ binary = packet.to_binary_s
59
+ expect(described_class.read(binary)).to eq(packet)
60
+ end
61
+ end
62
+
@@ -0,0 +1,54 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcEnumPrinterDriversResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :p_drivers }
5
+ it { is_expected.to respond_to :pcb_needed }
6
+ it { is_expected.to respond_to :pc_returned }
7
+ it { is_expected.to respond_to :error_status }
8
+
9
+ it 'is little endian' do
10
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
11
+ end
12
+
13
+ describe '#p_drivers' do
14
+ it 'is a RprnByteArrayPtr' do
15
+ expect(packet.p_drivers).to be_a RubySMB::Dcerpc::PrintSystem::RprnByteArrayPtr
16
+ end
17
+ end
18
+
19
+ describe '#pcb_needed' do
20
+ it 'is a NdrUint32' do
21
+ expect(packet.pcb_needed).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
22
+ end
23
+ end
24
+
25
+ describe '#pc_returned' do
26
+ it 'is a NdrUint32' do
27
+ expect(packet.pc_returned).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
28
+ end
29
+ end
30
+
31
+ describe '#error_status' do
32
+ it 'is a NdrUint32' do
33
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
34
+ end
35
+ end
36
+
37
+ describe '#initialize_instance' do
38
+ it 'sets #opnum to RPC_ENUM_PRINTER_DRIVERS constant' do
39
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_ENUM_PRINTER_DRIVERS)
40
+ end
41
+ end
42
+
43
+ it 'reads its own binary representation and outputs the same packet' do
44
+ packet = described_class.new(
45
+ p_drivers: [0, 1, 2],
46
+ pcb_needed: 0,
47
+ pc_returned: 0,
48
+ error_status: 0
49
+ )
50
+ binary = packet.to_binary_s
51
+ expect(described_class.read(binary)).to eq(packet)
52
+ end
53
+ end
54
+
@@ -0,0 +1,62 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcGetPrinterDriverDirectoryRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :p_name }
5
+ it { is_expected.to respond_to :p_environment }
6
+ it { is_expected.to respond_to :level}
7
+ it { is_expected.to respond_to :p_driver_directory }
8
+ it { is_expected.to respond_to :cb_buf }
9
+
10
+ it 'is little endian' do
11
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
12
+ end
13
+
14
+ describe '#p_name' do
15
+ it 'is a NdrWideStringzPtr' do
16
+ expect(packet.p_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
17
+ end
18
+ end
19
+
20
+ describe '#p_environment' do
21
+ it 'is a NdrWideStringzPtr' do
22
+ expect(packet.p_environment).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
23
+ end
24
+ end
25
+
26
+ describe '#level' do
27
+ it 'is a NdrUint32' do
28
+ expect(packet.level).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
29
+ end
30
+ end
31
+
32
+ describe '#p_driver_directory' do
33
+ it 'is a RprnByteArrayPtr' do
34
+ expect(packet.p_driver_directory).to be_a RubySMB::Dcerpc::PrintSystem::RprnByteArrayPtr
35
+ end
36
+ end
37
+
38
+ describe '#cb_buf' do
39
+ it 'is a NdrUint32' do
40
+ expect(packet.cb_buf).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
41
+ end
42
+ end
43
+
44
+ describe '#initialize_instance' do
45
+ it 'sets #opnum to RPC_GET_PRINTER_DRIVER_DIRECTORY constant' do
46
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_GET_PRINTER_DRIVER_DIRECTORY)
47
+ end
48
+ end
49
+
50
+ it 'reads its own binary representation and outputs the same packet' do
51
+ packet = described_class.new(
52
+ p_name: 'p_name',
53
+ p_environment: 'p_environment',
54
+ level: 0,
55
+ p_driver_directory: [0, 1, 2],
56
+ cb_buf: 0
57
+ )
58
+ binary = packet.to_binary_s
59
+ expect(described_class.read(binary)).to eq(packet)
60
+ end
61
+ end
62
+
@@ -0,0 +1,46 @@
1
+ RSpec.describe RubySMB::Dcerpc::PrintSystem::RpcGetPrinterDriverDirectoryResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :p_driver_directory }
5
+ it { is_expected.to respond_to :pcb_needed }
6
+ it { is_expected.to respond_to :error_status }
7
+
8
+ it 'is little endian' do
9
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
10
+ end
11
+
12
+ describe '#p_driver_directory' do
13
+ it 'is a RprnByteArrayPtr' do
14
+ expect(packet.p_driver_directory).to be_a RubySMB::Dcerpc::PrintSystem::RprnByteArrayPtr
15
+ end
16
+ end
17
+
18
+ describe '#pcb_needed' do
19
+ it 'is a NdrUint32' do
20
+ expect(packet.pcb_needed).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
21
+ end
22
+ end
23
+
24
+ describe '#error_status' do
25
+ it 'is a NdrUint32' do
26
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
27
+ end
28
+ end
29
+
30
+ describe '#initialize_instance' do
31
+ it 'sets #opnum to RPC_GET_PRINTER_DRIVER_DIRECTORY constant' do
32
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::PrintSystem::RPC_GET_PRINTER_DRIVER_DIRECTORY)
33
+ end
34
+ end
35
+
36
+ it 'reads its own binary representation and outputs the same packet' do
37
+ packet = described_class.new(
38
+ p_driver_directory: [0, 1, 2],
39
+ pcb_needed: 0,
40
+ error_status: 0
41
+ )
42
+ binary = packet.to_binary_s
43
+ expect(described_class.read(binary)).to eq(packet)
44
+ end
45
+ end
46
+