ruby_smb 2.0.10 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/verify.yml +5 -16
  4. data/examples/auth_capture.rb +71 -0
  5. data/examples/dump_secrets_from_sid.rb +207 -0
  6. data/examples/enum_domain_users.rb +75 -0
  7. data/examples/get_computer_info.rb +42 -0
  8. data/examples/query_service_status.rb +42 -4
  9. data/lib/ruby_smb/client/negotiation.rb +1 -1
  10. data/lib/ruby_smb/client.rb +10 -20
  11. data/lib/ruby_smb/dcerpc/bind.rb +28 -20
  12. data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
  13. data/lib/ruby_smb/dcerpc/client.rb +542 -0
  14. data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
  15. data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
  16. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
  17. data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
  18. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
  19. data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
  20. data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
  21. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
  22. data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
  23. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
  24. data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
  25. data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
  26. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
  27. data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
  28. data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
  29. data/lib/ruby_smb/dcerpc/epm.rb +75 -0
  30. data/lib/ruby_smb/dcerpc/error.rb +17 -0
  31. data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
  32. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
  33. data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
  34. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
  35. data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
  36. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
  37. data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
  38. data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
  39. data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
  40. data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
  41. data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
  42. data/lib/ruby_smb/dcerpc/request.rb +79 -32
  43. data/lib/ruby_smb/dcerpc/response.rb +45 -10
  44. data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
  45. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
  46. data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
  47. data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
  48. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
  49. data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
  50. data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
  51. data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
  52. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
  53. data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
  54. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
  55. data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
  56. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
  57. data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
  58. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
  59. data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
  60. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
  61. data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
  62. data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
  63. data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
  64. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
  65. data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
  66. data/lib/ruby_smb/dcerpc/samr.rb +613 -0
  67. data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
  68. data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
  69. data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
  70. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
  71. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
  72. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
  73. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
  74. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
  75. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
  76. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
  77. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
  78. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
  79. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
  80. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
  81. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
  82. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
  83. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
  84. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
  85. data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
  86. data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
  87. data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
  88. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
  89. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
  90. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
  91. data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
  92. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
  93. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
  94. data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
  95. data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
  96. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
  97. data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
  98. data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
  99. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
  100. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
  101. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
  102. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
  103. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
  104. data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
  105. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
  106. data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
  107. data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
  108. data/lib/ruby_smb/dcerpc.rb +41 -11
  109. data/lib/ruby_smb/dialect.rb +45 -0
  110. data/lib/ruby_smb/dispatcher/base.rb +1 -1
  111. data/lib/ruby_smb/field/file_time.rb +1 -1
  112. data/lib/ruby_smb/field/string16.rb +5 -1
  113. data/lib/ruby_smb/gss/provider/authenticator.rb +42 -0
  114. data/lib/ruby_smb/gss/provider/ntlm.rb +303 -0
  115. data/lib/ruby_smb/gss/provider.rb +35 -0
  116. data/lib/ruby_smb/gss.rb +56 -63
  117. data/lib/ruby_smb/ntlm.rb +61 -0
  118. data/lib/ruby_smb/server/server_client/negotiation.rb +156 -0
  119. data/lib/ruby_smb/server/server_client/session_setup.rb +82 -0
  120. data/lib/ruby_smb/server/server_client.rb +162 -0
  121. data/lib/ruby_smb/server.rb +54 -0
  122. data/lib/ruby_smb/signing.rb +59 -0
  123. data/lib/ruby_smb/smb1/packet/negotiate_response.rb +11 -11
  124. data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +1 -1
  125. data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -1
  126. data/lib/ruby_smb/smb1/pipe.rb +4 -0
  127. data/lib/ruby_smb/smb2/negotiate_context.rb +18 -2
  128. data/lib/ruby_smb/smb2/packet/negotiate_request.rb +9 -0
  129. data/lib/ruby_smb/smb2/packet/negotiate_response.rb +0 -1
  130. data/lib/ruby_smb/smb2/packet/session_setup_response.rb +2 -2
  131. data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +1 -1
  132. data/lib/ruby_smb/smb2/pipe.rb +4 -0
  133. data/lib/ruby_smb/smb2.rb +3 -1
  134. data/lib/ruby_smb/version.rb +1 -1
  135. data/lib/ruby_smb.rb +2 -1
  136. data/spec/lib/ruby_smb/client_spec.rb +8 -11
  137. data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
  138. data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
  139. data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
  140. data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
  141. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
  142. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
  143. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
  144. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
  145. data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
  146. data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
  147. data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
  148. data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
  149. data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
  150. data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
  151. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
  152. data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
  153. data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
  154. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
  155. data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
  156. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
  157. data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
  158. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
  159. data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
  160. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
  161. data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
  162. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
  163. data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
  164. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
  165. data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
  166. data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
  167. data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
  168. data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
  169. data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
  170. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
  171. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
  172. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
  173. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
  174. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
  175. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
  176. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
  177. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
  178. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
  179. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
  180. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
  181. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
  182. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
  183. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
  184. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
  185. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
  186. data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
  187. data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
  188. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
  189. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
  190. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
  191. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
  192. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
  193. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
  194. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
  195. data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
  196. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
  197. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
  198. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
  199. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
  200. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
  201. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
  202. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
  203. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
  204. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
  205. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
  206. data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
  207. data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
  208. data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
  209. data/spec/lib/ruby_smb/gss/provider/ntlm/account_spec.rb +32 -0
  210. data/spec/lib/ruby_smb/gss/provider/ntlm/authenticator_spec.rb +101 -0
  211. data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +32 -0
  212. data/spec/lib/ruby_smb/gss/provider/ntlm_spec.rb +113 -0
  213. data/spec/lib/ruby_smb/server/server_client_spec.rb +156 -0
  214. data/spec/lib/ruby_smb/server_spec.rb +32 -0
  215. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
  216. data/spec/lib/ruby_smb/smb2/negotiate_context_spec.rb +2 -2
  217. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
  218. data/spec/support/bin_helper.rb +9 -0
  219. data.tar.gz.sig +0 -0
  220. metadata +119 -6
  221. metadata.gz.sig +0 -0
  222. data/lib/ruby_smb/client/signing.rb +0 -64
  223. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
  224. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -1,189 +1,228 @@
1
- RSpec.describe RubySMB::Dcerpc::Srvsvc::NetShareEnumAll do
2
- subject(:packet) { described_class.new(host: '1.2.3.4') }
3
-
4
- it { is_expected.to respond_to :referent_id }
5
- it { is_expected.to respond_to :max_count }
6
- it { is_expected.to respond_to :offset }
7
- it { is_expected.to respond_to :actual_count }
8
- it { is_expected.to respond_to :server_unc }
9
- it { is_expected.to respond_to :pad }
10
- it { is_expected.to respond_to :level }
11
- it { is_expected.to respond_to :ctr }
12
- it { is_expected.to respond_to :ctr_referent_id }
13
- it { is_expected.to respond_to :ctr_count }
14
- it { is_expected.to respond_to :pointer_to_array }
15
- it { is_expected.to respond_to :max_buffer }
16
- it { is_expected.to respond_to :resume_referent_id }
1
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::NetShareEnumAllRequest do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :server_name }
5
+ it { is_expected.to respond_to :info_struct }
6
+ it { is_expected.to respond_to :prefered_maximum_length }
17
7
  it { is_expected.to respond_to :resume_handle }
18
- it { is_expected.to respond_to :opnum }
19
8
 
20
9
  it 'is little endian' do
21
10
  expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
22
11
  end
23
12
 
24
- context 'when \'host\' parameter is not provided' do
25
- it 'raises an ArgumentError' do
26
- expect { described_class.new }.to raise_error(ArgumentError)
13
+ describe '#server_name' do
14
+ it 'is a SrvsvcHandle' do
15
+ expect(packet.server_name).to be_a RubySMB::Dcerpc::Srvsvc::SrvsvcHandle
16
+ end
17
+ end
18
+
19
+ describe '#info_struct' do
20
+ it 'is a LpshareEnumStruct' do
21
+ expect(packet.info_struct).to be_a RubySMB::Dcerpc::Srvsvc::LpshareEnumStruct
27
22
  end
28
23
  end
29
24
 
30
- describe '#referent_id' do
31
- it 'should be a 32-bit unsigned integer' do
32
- expect(packet.referent_id).to be_a BinData::Uint32le
25
+ describe '#prefered_maximum_length' do
26
+ it 'is a NdrUint32' do
27
+ expect(packet.prefered_maximum_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
33
28
  end
34
29
 
35
- it 'should have a default value of 1' do
36
- expect(packet.referent_id).to eq 1
30
+ it 'has a default value of 0xFFFFFFFF' do
31
+ expect(packet.prefered_maximum_length).to eq(0xFFFFFFFF)
37
32
  end
38
33
  end
39
34
 
40
- describe '#max_count' do
41
- it 'should be a 32-bit unsigned integer' do
42
- expect(packet.max_count).to be_a BinData::Uint32le
35
+ describe '#resume_handle' do
36
+ it 'is a NdrUint32Ptr' do
37
+ expect(packet.resume_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
43
38
  end
44
39
 
45
- it 'should be the number of unicode characters in the #server_unc field' do
46
- expect(packet.max_count).to eq(packet.server_unc.do_num_bytes / 2)
40
+ it 'has a default value of 0' do
41
+ expect(packet.resume_handle).to eq(0)
47
42
  end
48
43
  end
49
44
 
50
- describe '#offset' do
51
- it 'should be a 32-bit unsigned integer' do
52
- expect(packet.offset).to be_a BinData::Uint32le
45
+ describe '#initialize_instance' do
46
+ it 'sets #opnum to NET_SHARE_ENUM_ALL constant' do
47
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL)
53
48
  end
49
+ end
50
+ end
54
51
 
55
- it 'should have a default value of 0' do
56
- expect(packet.offset).to eq 0
57
- end
52
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::NetShareEnumAllResponse do
53
+ subject(:packet) { described_class.new }
54
+
55
+ it { is_expected.to respond_to :info_struct }
56
+ it { is_expected.to respond_to :total_entries }
57
+ it { is_expected.to respond_to :resume_handle }
58
+ it { is_expected.to respond_to :error_status }
59
+
60
+ it 'is little endian' do
61
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
58
62
  end
59
63
 
60
- describe '#actual_count' do
61
- it 'should be a 32-bit unsigned integer' do
62
- expect(packet.actual_count).to be_a BinData::Uint32le
64
+ describe '#info_struct' do
65
+ it 'is a LpshareEnumStruct' do
66
+ expect(packet.info_struct).to be_a RubySMB::Dcerpc::Srvsvc::LpshareEnumStruct
63
67
  end
68
+ end
64
69
 
65
- it 'should be the same value than #max_count' do
66
- expect(packet.actual_count).to eq(packet.max_count)
70
+ describe '#total_entries' do
71
+ it 'is a NdrUint32' do
72
+ expect(packet.total_entries).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
67
73
  end
68
74
  end
69
75
 
70
- describe '#server_unc' do
71
- it 'is a Stringz16' do
72
- expect(packet.server_unc).to be_a RubySMB::Field::Stringz16
76
+ describe '#resume_handle' do
77
+ it 'is a NdrUint32Ptr' do
78
+ expect(packet.resume_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
73
79
  end
80
+ end
74
81
 
75
- it 'uses the #host parameter value to create the UNC unicode string' do
76
- expect(packet.server_unc).to eq("\\\\#{"1.2.3.4".encode('utf-8')}".encode('utf-16le'))
82
+ describe '#error_status' do
83
+ it 'is a NdrUint32' do
84
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
77
85
  end
78
86
  end
79
87
 
80
- describe '#pad' do
81
- it 'should keep #level 4-byte aligned' do
82
- expect(packet.level.abs_offset % 4).to eq 0
88
+ describe '#initialize_instance' do
89
+ it 'sets #opnum to NET_SHARE_ENUM_ALL constant' do
90
+ expect(packet.opnum).to eq(RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL)
83
91
  end
84
92
  end
93
+ end
94
+
95
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::LpshareEnumStruct do
96
+ it 'is a NdrStruct' do
97
+ expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrStruct
98
+ end
99
+
100
+ subject(:packet) { described_class.new }
101
+
102
+ it { is_expected.to respond_to :level }
103
+ it { is_expected.to respond_to :switch_value }
104
+ it { is_expected.to respond_to :share_info }
85
105
 
86
106
  describe '#level' do
87
- it 'should be a 32-bit unsigned integer' do
88
- expect(packet.level).to be_a BinData::Uint32le
107
+ it 'is a NdrUint32' do
108
+ expect(packet.level).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
89
109
  end
90
110
 
91
- it 'should have a default value of 1' do
111
+ it 'has a default value of 1' do
92
112
  expect(packet.level).to eq 1
93
113
  end
94
114
  end
95
115
 
96
- describe '#ctr' do
97
- it 'should be a 32-bit unsigned integer' do
98
- expect(packet.ctr).to be_a BinData::Uint32le
116
+ describe '#switch_value' do
117
+ it 'is a NdrUint32' do
118
+ expect(packet.switch_value).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
99
119
  end
100
120
 
101
- it 'should have a default value of 1' do
102
- expect(packet.ctr).to eq 1
121
+ it 'has a default value set to the #level value' do
122
+ expect(packet.switch_value).to eq packet.level
103
123
  end
104
- end
105
124
 
106
- describe '#ctr_referent_id' do
107
- it 'should be a 32-bit unsigned integer' do
108
- expect(packet.ctr_referent_id).to be_a BinData::Uint32le
109
- end
110
-
111
- it 'should have a default value of 1' do
112
- expect(packet.ctr_referent_id).to eq 1
125
+ it 'is an hidden field' do
126
+ expect(packet.snapshot).to_not have_key(:switch_value)
113
127
  end
114
128
  end
115
129
 
116
- describe '#ctr_count' do
117
- it 'should be a 32-bit unsigned integer' do
118
- expect(packet.ctr_count).to be_a BinData::Uint32le
130
+ describe '#share_info' do
131
+ it 'is a BinData::Choice' do
132
+ expect(packet.share_info).to be_a BinData::Choice
119
133
  end
120
134
 
121
- it 'should have a default value of 0' do
122
- expect(packet.ctr_count).to eq 0
135
+ it 'selects a structure according to :level value and set the default value' do
136
+ expect(packet.share_info.snapshot).to eq({ entries_read: 0, buffer: :null })
137
+ # Trying to with a non existing enum value, since only Level 1 is implemented so far
138
+ packet.level = 0
139
+ expect { packet.share_info.snapshot }.to raise_error(IndexError)
123
140
  end
124
141
  end
142
+ end
125
143
 
126
- describe '#pointer_to_array' do
127
- it 'should be a 32-bit unsigned integer' do
128
- expect(packet.pointer_to_array).to be_a BinData::Uint32le
129
- end
144
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::LpshareInfo1Container do
145
+ it 'is a ShareInfo1Container' do
146
+ expect(described_class).to be < RubySMB::Dcerpc::Srvsvc::ShareInfo1Container
147
+ end
148
+ it 'is a NDR pointer' do
149
+ expect(described_class.new).to be_a RubySMB::Dcerpc::Ndr::PointerPlugin
150
+ end
151
+ end
130
152
 
131
- it 'should have a default value of 0' do
132
- expect(packet.pointer_to_array).to eq 0
133
- end
153
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::ShareInfo1Container do
154
+ it 'is a NdrStruct' do
155
+ expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrStruct
134
156
  end
135
157
 
136
- describe '#max_buffer' do
137
- it 'should be a 32-bit unsigned integer' do
138
- expect(packet.max_buffer).to be_a BinData::Uint32le
139
- end
158
+ subject(:packet) { described_class.new }
159
+
160
+ it { is_expected.to respond_to :entries_read }
161
+ it { is_expected.to respond_to :buffer }
140
162
 
141
- it 'should have a default value of 4294967295' do
142
- expect(packet.max_buffer).to eq 4294967295
163
+ describe '#entries_read' do
164
+ it 'is a NdrUint32' do
165
+ expect(packet.entries_read).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
143
166
  end
144
167
  end
145
168
 
146
- describe '#resume_referent_id' do
147
- it 'should be a 32-bit unsigned integer' do
148
- expect(packet.resume_referent_id).to be_a BinData::Uint32le
169
+ describe '#buffer' do
170
+ it 'is a LpshareInfo1' do
171
+ expect(packet.buffer).to be_a RubySMB::Dcerpc::Srvsvc::LpshareInfo1
149
172
  end
173
+ end
174
+ end
150
175
 
151
- it 'should have a default value of 1' do
152
- expect(packet.resume_referent_id).to eq 1
153
- end
176
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::LpshareInfo1 do
177
+ it 'is a ShareInfo1' do
178
+ expect(described_class).to be < RubySMB::Dcerpc::Srvsvc::ShareInfo1
179
+ end
180
+ it 'is a NDR pointer' do
181
+ expect(described_class.new).to be_a RubySMB::Dcerpc::Ndr::PointerPlugin
154
182
  end
183
+ end
155
184
 
156
- describe '#resume_handle' do
157
- it 'should be a 32-bit unsigned integer' do
158
- expect(packet.resume_handle).to be_a BinData::Uint32le
159
- end
185
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::ShareInfo1 do
186
+ it 'is a NdrConfArray' do
187
+ expect(described_class.new).to be_a RubySMB::Dcerpc::Ndr::NdrConfArray
188
+ end
189
+ it 'contains element of type ShareInfo1Element' do
190
+ expect(described_class.default_parameters[:type]).to eq(:share_info1_element)
191
+ end
192
+ end
160
193
 
161
- it 'should have a default value of 0' do
162
- expect(packet.resume_handle).to eq 0
163
- end
194
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::ShareInfo1Element do
195
+ it 'is a NdrStruct' do
196
+ expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrStruct
164
197
  end
165
198
 
166
- describe '#initialize_instance' do
167
- it 'sets #opnum to REG_CLOSE_KEY constant' do
168
- expect(packet.opnum).to eq(RubySMB::Dcerpc::Srvsvc::NET_SHARE_ENUM_ALL)
199
+ subject(:packet) { described_class.new }
200
+
201
+ it { is_expected.to respond_to :shi1_netname }
202
+ it { is_expected.to respond_to :shi1_type }
203
+ it { is_expected.to respond_to :shi1_remark }
204
+
205
+ describe '#shi1_netname' do
206
+ it 'is a NdrConfVarWideStringz' do
207
+ expect(packet.shi1_netname).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
169
208
  end
170
209
  end
171
210
 
172
- describe '#pad_length' do
173
- it 'returns 0 when #level is already 4-byte aligned' do
174
- expect(packet.pad_length).to eq 0
211
+ describe '#shi1_type' do
212
+ it 'is a NdrUint32' do
213
+ expect(packet.shi1_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
175
214
  end
215
+ end
176
216
 
177
- it 'returns 2 when #level is only 2-byte aligned' do
178
- packet.server_unc = packet.server_unc + 'A'.encode('utf-16le')
179
- expect(packet.pad_length).to eq 2
217
+ describe '#shi1_remark' do
218
+ it 'is a NdrConfVarWideStringz' do
219
+ expect(packet.shi1_remark).to be_a RubySMB::Dcerpc::Ndr::NdrConfVarWideStringz
180
220
  end
181
221
  end
222
+ end
182
223
 
183
- describe 'class method self.parse_response' do
184
- # TODO: this class method will be refactored to use proper BinData NDR
185
- # fields once they are ready (see https://github.com/rapid7/ruby_smb/issues/124)
224
+ RSpec.describe RubySMB::Dcerpc::Srvsvc::SrvsvcHandle do
225
+ it 'is a NdrWideStringzPtr' do
226
+ expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrWideStringzPtr
186
227
  end
187
228
  end
188
-
189
-
@@ -11,20 +11,30 @@ RSpec.describe RubySMB::Dcerpc::Srvsvc do
11
11
  let(:host) { '1.2.3.4' }
12
12
  let(:request_packet) { double('NetShareEnumAll request packet') }
13
13
  let(:dcerpc_response) { double('DCERPC response') }
14
+ let(:response) { double('NetShareEnumAllResponse') }
14
15
  let(:shares) do
15
16
  [
16
- ["C$", "DISK", "Default share"],
17
- ["Shared", "DISK", ""],
18
- ["IPC$", "IPC", "Remote IPC"],
19
- ["ADMIN$", "DISK", "Remote Admin"]
17
+ RubySMB::Dcerpc::Srvsvc::ShareInfo1Element.new({:shi1_netname=>'C$', :shi1_type=>0, :shi1_remark=>'Default share'}),
18
+ RubySMB::Dcerpc::Srvsvc::ShareInfo1Element.new({:shi1_netname=>'Shared', :shi1_type=>0, :shi1_remark=>''}),
19
+ RubySMB::Dcerpc::Srvsvc::ShareInfo1Element.new({:shi1_netname=>'IPC$', :shi1_type=>2147483651, :shi1_remark=>'Remote IPC'}),
20
+ RubySMB::Dcerpc::Srvsvc::ShareInfo1Element.new({:shi1_netname=>'ADMIN$', :shi1_type=>2147483648, :shi1_remark=>'Remote Admin'})
21
+ ]
22
+ end
23
+ let(:result) do
24
+ [
25
+ {name: 'C$', type: 'DISK', comment: 'Default share'},
26
+ {name: 'Shared', type: 'DISK', comment: ''},
27
+ {name: 'IPC$', type: 'IPC|SPECIAL', comment: 'Remote IPC'},
28
+ {name: 'ADMIN$', type: 'DISK|SPECIAL', comment: 'Remote Admin'}
20
29
  ]
21
30
  end
22
31
 
23
32
  before :example do
24
33
  allow(srvsvc).to receive(:bind)
25
- allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to receive(:new).and_return(request_packet)
34
+ allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAllRequest).to receive(:new).and_return(request_packet)
26
35
  allow(srvsvc).to receive(:dcerpc_request).and_return(dcerpc_response)
27
- allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to receive(:parse_response).and_return(shares)
36
+ allow(RubySMB::Dcerpc::Srvsvc::NetShareEnumAllResponse).to receive(:read).and_return(response)
37
+ allow(response).to receive_message_chain(:info_struct, :share_info, :buffer).and_return(shares)
28
38
  end
29
39
 
30
40
  it 'calls #bind with the expected arguments' do
@@ -32,9 +42,9 @@ RSpec.describe RubySMB::Dcerpc::Srvsvc do
32
42
  expect(srvsvc).to have_received(:bind).with(endpoint: RubySMB::Dcerpc::Srvsvc)
33
43
  end
34
44
 
35
- it 'creates the expected NetShareEnumAll packet' do
45
+ it 'creates the expected NetShareEnumAllRequest packet' do
36
46
  srvsvc.net_share_enum_all(host)
37
- expect(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to have_received(:new).with(host: host)
47
+ expect(RubySMB::Dcerpc::Srvsvc::NetShareEnumAllRequest).to have_received(:new).with(server_name: "\\\\#{host}")
38
48
  end
39
49
 
40
50
  it 'calls #request with the expected arguments' do
@@ -42,19 +52,13 @@ RSpec.describe RubySMB::Dcerpc::Srvsvc do
42
52
  expect(srvsvc).to have_received(:dcerpc_request).with(request_packet)
43
53
  end
44
54
 
45
- it 'parse the response with NetShareEnumAll #parse_response method' do
55
+ it 'parse the response with NetShareEnumAllResponse' do
46
56
  srvsvc.net_share_enum_all(host)
47
- expect(RubySMB::Dcerpc::Srvsvc::NetShareEnumAll).to have_received(:parse_response).with(dcerpc_response)
57
+ expect(RubySMB::Dcerpc::Srvsvc::NetShareEnumAllResponse).to have_received(:read).with(dcerpc_response)
48
58
  end
49
59
 
50
60
  it 'returns the remote shares' do
51
- output = [
52
- {:name=>"C$", :type=>"DISK", :comment=>"Default share"},
53
- {:name=>"Shared", :type=>"DISK", :comment=>""},
54
- {:name=>"IPC$", :type=>"IPC", :comment=>"Remote IPC"},
55
- {:name=>"ADMIN$", :type=>"DISK", :comment=>"Remote Admin"},
56
- ]
57
- expect(srvsvc.net_share_enum_all(host)).to eq(output)
61
+ expect(srvsvc.net_share_enum_all(host)).to eq(result)
58
62
  end
59
63
  end
60
64
  end
@@ -6,17 +6,12 @@ RSpec.describe RubySMB::Dcerpc::Svcctl::ChangeServiceConfigWRequest do
6
6
  it { is_expected.to respond_to :dw_start_type }
7
7
  it { is_expected.to respond_to :dw_error_control }
8
8
  it { is_expected.to respond_to :lp_binary_path_name }
9
- it { is_expected.to respond_to :pad1 }
10
9
  it { is_expected.to respond_to :lp_load_order_group }
11
- it { is_expected.to respond_to :pad2 }
12
10
  it { is_expected.to respond_to :dw_tag_id }
13
11
  it { is_expected.to respond_to :lp_dependencies }
14
- it { is_expected.to respond_to :pad3 }
15
12
  it { is_expected.to respond_to :dw_depend_size }
16
13
  it { is_expected.to respond_to :lp_service_start_name }
17
- it { is_expected.to respond_to :pad4 }
18
14
  it { is_expected.to respond_to :lp_password }
19
- it { is_expected.to respond_to :pad5 }
20
15
  it { is_expected.to respond_to :dw_pw_size }
21
16
  it { is_expected.to respond_to :lp_display_name }
22
17
 
@@ -31,134 +26,116 @@ RSpec.describe RubySMB::Dcerpc::Svcctl::ChangeServiceConfigWRequest do
31
26
  end
32
27
 
33
28
  describe '#dw_service_type' do
34
- it 'is a 32-bit unsigned integer' do
35
- expect(packet.dw_service_type).to be_a BinData::Uint32le
29
+ it 'is a NdrUint32' do
30
+ expect(packet.dw_service_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
36
31
  end
37
32
  end
38
33
 
39
34
  describe '#dw_start_type' do
40
- it 'is a 32-bit unsigned integer' do
41
- expect(packet.dw_start_type).to be_a BinData::Uint32le
35
+ it 'is a NdrUint32' do
36
+ expect(packet.dw_start_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
42
37
  end
43
38
  end
44
39
 
45
40
  describe '#dw_start_type' do
46
- it 'is a 32-bit unsigned integer' do
47
- expect(packet.dw_start_type).to be_a BinData::Uint32le
41
+ it 'is a NdrUint32' do
42
+ expect(packet.dw_start_type).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
48
43
  end
49
44
  end
50
45
 
51
46
  describe '#lp_binary_path_name' do
52
- it 'is a NdrLpStr structure' do
53
- expect(packet.lp_binary_path_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
54
- end
55
- end
56
-
57
- describe '#pad1' do
58
- it 'is a string' do
59
- expect(packet.pad1).to be_a BinData::String
60
- end
61
-
62
- it 'should keep #lp_load_order_group 4-byte aligned' do
63
- packet.lp_binary_path_name = "test"
64
- expect(packet.lp_load_order_group.abs_offset % 4).to eq 0
47
+ it 'is a NdrWideStringPtr structure' do
48
+ expect(packet.lp_binary_path_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringPtr
65
49
  end
66
50
  end
67
51
 
68
52
  describe '#lp_load_order_group' do
69
- it 'is a NdrLpStr structure' do
70
- expect(packet.lp_load_order_group).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
71
- end
72
- end
73
-
74
- describe '#pad2' do
75
- it 'is a string' do
76
- expect(packet.pad1).to be_a BinData::String
77
- end
78
-
79
- it 'should keep #dw_tag_id 4-byte aligned' do
80
- packet.lp_load_order_group = "test"
81
- expect(packet.dw_tag_id.abs_offset % 4).to eq 0
53
+ it 'is a NdrWideStringPtr structure' do
54
+ expect(packet.lp_load_order_group).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringPtr
82
55
  end
83
56
  end
84
57
 
85
58
  describe '#dw_tag_id' do
86
- it 'is a NdrLpDword structure' do
87
- expect(packet.dw_tag_id).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
59
+ it 'is a NdrUint32Ptr structure' do
60
+ expect(packet.dw_tag_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
88
61
  end
89
62
  end
90
63
 
91
64
  describe '#lp_dependencies' do
92
- it 'is a NdrLpByte structure' do
93
- expect(packet.lp_dependencies).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
65
+ it 'is a Ndr::NdrConfArray of Uint8 elements' do
66
+ expect(packet.lp_dependencies).to be_a RubySMB::Dcerpc::Ndr::NdrConfArray
67
+ expect(packet.lp_dependencies[0]).to be_a BinData::Uint8
94
68
  end
95
69
  end
96
70
 
97
- describe '#pad3' do
98
- it 'is a string' do
99
- expect(packet.pad1).to be_a BinData::String
100
- end
101
-
102
- it 'should keep #dw_depend_size 4-byte aligned' do
103
- packet.lp_dependencies = [1, 2, 3, 4]
104
- expect(packet.dw_depend_size.abs_offset % 4).to eq 0
71
+ describe '#dw_depend_size' do
72
+ it 'is a NdrUint32' do
73
+ expect(packet.dw_depend_size).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
105
74
  end
106
75
  end
107
76
 
108
- describe '#dw_depend_size' do
109
- it 'is a 32-bit unsigned integer' do
110
- expect(packet.dw_depend_size).to be_a BinData::Uint32le
77
+ describe '#lp_service_start_name' do
78
+ it 'is a NdrWideStringPtr structure' do
79
+ expect(packet.lp_service_start_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringPtr
111
80
  end
112
81
  end
113
82
 
114
- describe '#lp_service_start_name' do
115
- it 'is a NdrLpStr structure' do
116
- expect(packet.lp_service_start_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
83
+ describe '#lp_password' do
84
+ it 'is a Ndr::NdrConfArray of Uint8 elements' do
85
+ expect(packet.lp_password).to be_a RubySMB::Dcerpc::Ndr::NdrConfArray
86
+ expect(packet.lp_password[0]).to be_a BinData::Uint8
117
87
  end
118
88
  end
119
89
 
120
- describe '#pad4' do
121
- it 'is a string' do
122
- expect(packet.pad1).to be_a BinData::String
90
+ describe '#dw_pw_size' do
91
+ it 'is a NdrUint32' do
92
+ expect(packet.dw_pw_size).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
123
93
  end
124
94
 
125
- it 'should keep #lp_password 4-byte aligned' do
126
- packet.lp_service_start_name = "test"
127
- expect(packet.lp_password.abs_offset % 4).to eq 0
95
+ it 'is set to the number of elements in #lp_password array' do
96
+ packet.lp_password = [1, 2, 3, 4, 5]
97
+ expect(packet.dw_pw_size).to eq(5)
128
98
  end
129
99
  end
130
100
 
131
- describe '#lp_password' do
132
- it 'is a NdrLpByte structure' do
133
- expect(packet.lp_password).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
101
+ describe '#lp_display_name' do
102
+ it 'is a NdrWideStringPtr structure' do
103
+ expect(packet.lp_display_name).to be_a RubySMB::Dcerpc::Ndr::NdrWideStringPtr
134
104
  end
135
105
  end
136
106
 
137
- describe '#pad5' do
138
- it 'is a string' do
139
- expect(packet.pad1).to be_a BinData::String
107
+ it 'should keep #lp_load_order_group 4-byte aligned' do
108
+ 5.times do |i|
109
+ packet.lp_binary_path_name = "A" * i
110
+ expect(packet.lp_load_order_group.abs_offset % 4).to eq 0
140
111
  end
112
+ end
141
113
 
142
- it 'should keep #dw_pw_size 4-byte aligned' do
143
- packet.lp_password = [1, 2, 3, 4]
144
- expect(packet.dw_pw_size.abs_offset % 4).to eq 0
114
+ it 'should keep #dw_tag_id 4-byte aligned' do
115
+ 5.times do |i|
116
+ packet.lp_load_order_group = "A" * i
117
+ expect(packet.dw_tag_id.abs_offset % 4).to eq 0
145
118
  end
146
119
  end
147
120
 
148
- describe '#dw_pw_size' do
149
- it 'is a 32-bit unsigned integer' do
150
- expect(packet.dw_pw_size).to be_a BinData::Uint32le
121
+ it 'should keep #dw_depend_size 4-byte aligned' do
122
+ 5.times do |i|
123
+ packet.lp_dependencies = [1] * i
124
+ expect(packet.dw_depend_size.abs_offset % 4).to eq 0
151
125
  end
126
+ end
152
127
 
153
- it 'has a value set to #lp_password.max_count' do
154
- packet.lp_password.max_count = 33
155
- expect(packet.dw_pw_size).to eq(33)
128
+ it 'should keep #lp_password 4-byte aligned' do
129
+ 5.times do |i|
130
+ packet.lp_service_start_name = "A" * i
131
+ expect(packet.lp_password.abs_offset % 4).to eq 0
156
132
  end
157
133
  end
158
134
 
159
- describe '#lp_display_name' do
160
- it 'is a NdrLpStr structure' do
161
- expect(packet.lp_display_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
135
+ it 'should keep #dw_pw_size 4-byte aligned' do
136
+ 5.times do |i|
137
+ packet.lp_password = [1] * i
138
+ expect(packet.dw_pw_size.abs_offset % 4).to eq 0
162
139
  end
163
140
  end
164
141
 
@@ -9,14 +9,14 @@ RSpec.describe RubySMB::Dcerpc::Svcctl::ChangeServiceConfigWResponse do
9
9
  end
10
10
 
11
11
  describe '#dw_tag_id' do
12
- it 'is a NdrLpDword structure' do
13
- expect(packet.dw_tag_id).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
12
+ it 'is a NdrUint32Ptr structure' do
13
+ expect(packet.dw_tag_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr
14
14
  end
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 NdrUint32' do
19
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
20
20
  end
21
21
  end
22
22
 
@@ -15,8 +15,8 @@ RSpec.describe RubySMB::Dcerpc::Svcctl::CloseServiceHandleResponse 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 NdrUint32' do
19
+ expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
20
20
  end
21
21
  end
22
22