ruby_smb 2.0.12 → 2.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +1 -1
- data/examples/dump_secrets_from_sid.rb +207 -0
- data/examples/enum_domain_users.rb +75 -0
- data/examples/get_computer_info.rb +42 -0
- data/examples/query_service_status.rb +42 -4
- data/lib/ruby_smb/client.rb +3 -14
- data/lib/ruby_smb/dcerpc/bind.rb +28 -20
- data/lib/ruby_smb/dcerpc/bind_ack.rb +29 -28
- data/lib/ruby_smb/dcerpc/client.rb +542 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_bind_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_bind_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_request.rb +57 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_crack_names_response.rb +76 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_request.rb +46 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_domain_controller_info_response.rb +168 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_extensions.rb +56 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_request.rb +121 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_get_nc_changes_response.rb +118 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_unbind_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/drsr/drs_unbind_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/drsr.rb +909 -0
- data/lib/ruby_smb/dcerpc/epm/epm_ept_map_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/epm/epm_ept_map_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/epm/epm_twrt.rb +211 -0
- data/lib/ruby_smb/dcerpc/epm.rb +75 -0
- data/lib/ruby_smb/dcerpc/error.rb +17 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +1159 -297
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +3 -13
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +3 -3
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +3 -13
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +3 -11
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/netlogon.rb +5 -4
- data/lib/ruby_smb/dcerpc/p_syntax_id_t.rb +4 -3
- data/lib/ruby_smb/dcerpc/pdu_header.rb +7 -7
- data/lib/ruby_smb/dcerpc/ptypes.rb +1 -0
- data/lib/ruby_smb/dcerpc/request.rb +79 -32
- data/lib/ruby_smb/dcerpc/response.rb +45 -10
- data/lib/ruby_smb/dcerpc/rpc_auth3.rb +28 -0
- data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +11 -11
- data/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string.rb +118 -0
- data/lib/ruby_smb/dcerpc/samr/rpc_sid.rb +150 -0
- data/lib/ruby_smb/dcerpc/samr/samr_close_handle_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_close_handle_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_connect_request.rb +32 -0
- data/lib/ruby_smb/dcerpc/samr/samr_connect_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response.rb +55 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_request.rb +48 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_alias_membership_response.rb +38 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_get_groups_for_user_response.rb +48 -0
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_domain_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_domain_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_user_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/samr/samr_open_user_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/samr.rb +613 -0
- data/lib/ruby_smb/dcerpc/sec_trailer.rb +26 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +56 -79
- data/lib/ruby_smb/dcerpc/srvsvc.rb +27 -4
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +13 -25
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +4 -14
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +3 -11
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +12 -11
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +9 -8
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +3 -3
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/svcctl.rb +1 -3
- data/lib/ruby_smb/dcerpc/uuid.rb +3 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +2 -13
- data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +3 -3
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +3 -20
- data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +3 -20
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +5 -14
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +5 -14
- data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +1 -9
- data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +4 -3
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +5 -6
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +2 -2
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +9 -18
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +4 -14
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +7 -15
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +3 -1
- data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +0 -9
- data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg.rb +10 -14
- data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response.rb +88 -0
- data/lib/ruby_smb/dcerpc/wkssvc.rb +65 -0
- data/lib/ruby_smb/dcerpc.rb +41 -11
- data/lib/ruby_smb/field/file_time.rb +1 -1
- data/lib/ruby_smb/field/string16.rb +5 -1
- data/lib/ruby_smb/ntlm.rb +18 -2
- data/lib/ruby_smb/smb1/pipe.rb +4 -0
- data/lib/ruby_smb/smb2/pipe.rb +4 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +1 -2
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +69 -41
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +75 -21
- data/spec/lib/ruby_smb/dcerpc/client_spec.rb +714 -0
- data/spec/lib/ruby_smb/dcerpc/drsr_spec.rb +2169 -0
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +3792 -1373
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/p_syntax_id_t_spec.rb +18 -4
- data/spec/lib/ruby_smb/dcerpc/pdu_header_spec.rb +27 -1
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +76 -11
- data/spec/lib/ruby_smb/dcerpc/response_spec.rb +99 -9
- data/spec/lib/ruby_smb/dcerpc/rpc_auth3_spec.rb +75 -0
- data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +29 -28
- data/spec/lib/ruby_smb/dcerpc/rrp_rpc_unicode_string_spec.rb +340 -0
- data/spec/lib/ruby_smb/dcerpc/samr/rpc_sid_spec.rb +116 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_request_spec.rb +40 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_close_handle_response_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_request_spec.rb +56 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_connect_response_spec.rb +47 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_request_spec.rb +63 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_enumerate_users_in_domain_response_spec.rb +265 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_request_spec.rb +52 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_lookup_domain_in_sam_server_response_spec.rb +36 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_request_spec.rb +56 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_open_domain_response_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_request_spec.rb +48 -0
- data/spec/lib/ruby_smb/dcerpc/samr/samr_rid_to_sid_response_spec.rb +42 -0
- data/spec/lib/ruby_smb/dcerpc/samr_spec.rb +420 -0
- data/spec/lib/ruby_smb/dcerpc/sec_trailer_spec.rb +92 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +149 -110
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +21 -17
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +56 -79
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +19 -29
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +9 -15
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +22 -22
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +18 -14
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +5 -4
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +1 -5
- data/spec/lib/ruby_smb/dcerpc/uuid_spec.rb +15 -23
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +4 -41
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +4 -4
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +4 -52
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +4 -56
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +10 -34
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +10 -34
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +2 -26
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +17 -25
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +20 -44
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +8 -32
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +10 -22
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +4 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +0 -12
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +18 -47
- data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb +43 -0
- data/spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_response_spec.rb +410 -0
- data/spec/lib/ruby_smb/dcerpc/wkssvc_spec.rb +70 -0
- data/spec/lib/ruby_smb/field/string16_spec.rb +22 -0
- data/spec/lib/ruby_smb/gss/provider/ntlm/os_version_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +18 -37
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +18 -16
- data/spec/support/bin_helper.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +96 -5
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +0 -38
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +0 -135
@@ -0,0 +1,63 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateUsersInDomainRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :domain_handle }
|
5
|
+
it { is_expected.to respond_to :enumeration_context }
|
6
|
+
it { is_expected.to respond_to :user_account_control }
|
7
|
+
it { is_expected.to respond_to :prefered_maximum_length }
|
8
|
+
it { is_expected.to respond_to :opnum }
|
9
|
+
|
10
|
+
it 'is little endian' do
|
11
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
12
|
+
end
|
13
|
+
it 'is a BinData::Record' do
|
14
|
+
expect(packet).to be_a(BinData::Record)
|
15
|
+
end
|
16
|
+
describe '#domain_handle' do
|
17
|
+
it 'is a SamprHandle structure' do
|
18
|
+
expect(packet.domain_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '#enumeration_context' do
|
22
|
+
it 'is a NdrUint32 structure' do
|
23
|
+
expect(packet.enumeration_context).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '#user_account_control' do
|
27
|
+
it 'is a NdrUint32 structure' do
|
28
|
+
expect(packet.user_account_control).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe '#prefered_maximum_length' do
|
32
|
+
it 'is a NdrUint32 structure' do
|
33
|
+
expect(packet.prefered_maximum_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe '#initialize_instance' do
|
37
|
+
it 'sets #opnum to SAMR_ENUMERATE_USERS_IN_DOMAIN constant' do
|
38
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_ENUMERATE_USERS_IN_DOMAIN)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
it 'reads itself' do
|
42
|
+
new_packet = described_class.new({
|
43
|
+
domain_handle: {
|
44
|
+
context_handle_attributes: 0,
|
45
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
46
|
+
},
|
47
|
+
enumeration_context: 44,
|
48
|
+
user_account_control: 123,
|
49
|
+
prefered_maximum_length: 65535
|
50
|
+
})
|
51
|
+
expected_output = {
|
52
|
+
domain_handle: {
|
53
|
+
context_handle_attributes: 0,
|
54
|
+
context_handle_uuid: "fc873b90-d9a9-46a4-b9ea-f44bb1c272a7"
|
55
|
+
},
|
56
|
+
enumeration_context: 44,
|
57
|
+
user_account_control: 123,
|
58
|
+
prefered_maximum_length: 65535
|
59
|
+
}
|
60
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,265 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamprRidEnumeration do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :relative_id }
|
5
|
+
it { is_expected.to respond_to :name }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
it 'is a Ndr::NdrStruct' do
|
11
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrStruct)
|
12
|
+
end
|
13
|
+
it 'is four-byte aligned' do
|
14
|
+
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
15
|
+
end
|
16
|
+
describe '#relative_id' do
|
17
|
+
it 'is a NdrUint32 structure' do
|
18
|
+
expect(packet.relative_id).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '#name' do
|
22
|
+
it 'is a RpcUnicodeString structure' do
|
23
|
+
expect(packet.name).to be_a RubySMB::Dcerpc::RpcUnicodeString
|
24
|
+
end
|
25
|
+
end
|
26
|
+
it 'reads itself' do
|
27
|
+
new_packet = described_class.new(relative_id: 4, name: 'Test String')
|
28
|
+
expected_output = {
|
29
|
+
relative_id: 4,
|
30
|
+
name: {
|
31
|
+
buffer_length: 22,
|
32
|
+
maximum_length: 22,
|
33
|
+
buffer: "Test String".encode('utf-16le')
|
34
|
+
}
|
35
|
+
}
|
36
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamprRidEnumerationArray do
|
41
|
+
subject(:packet) { described_class.new }
|
42
|
+
|
43
|
+
it 'is a Ndr::NdrConfArray' do
|
44
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrConfArray)
|
45
|
+
end
|
46
|
+
it 'has element of type SamprRidEnumeration' do
|
47
|
+
packet << {relative_id: 4, name: ''}
|
48
|
+
expect(packet[0]).to be_a(RubySMB::Dcerpc::Samr::SamprRidEnumeration)
|
49
|
+
end
|
50
|
+
it 'reads itself' do
|
51
|
+
new_packet = described_class.new([
|
52
|
+
{relative_id: 4, name: 'Test1'},
|
53
|
+
{relative_id: 1, name: 'Test2'}
|
54
|
+
])
|
55
|
+
expected_output = [
|
56
|
+
{
|
57
|
+
relative_id: 4,
|
58
|
+
name: {
|
59
|
+
buffer_length: 10,
|
60
|
+
maximum_length: 10,
|
61
|
+
buffer: "Test1".encode('utf-16le')
|
62
|
+
}
|
63
|
+
},
|
64
|
+
{
|
65
|
+
relative_id: 1,
|
66
|
+
name: {
|
67
|
+
buffer_length: 10,
|
68
|
+
maximum_length: 10,
|
69
|
+
buffer: "Test2".encode('utf-16le')
|
70
|
+
}
|
71
|
+
}]
|
72
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
RSpec.describe RubySMB::Dcerpc::Samr::PsamprRidEnumerationArray do
|
77
|
+
subject(:packet) { described_class.new }
|
78
|
+
|
79
|
+
it 'is a SamprRidEnumerationArray' do
|
80
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Samr::SamprRidEnumerationArray)
|
81
|
+
end
|
82
|
+
it 'is a NdrPointer' do
|
83
|
+
expect(described_class).to be_a(RubySMB::Dcerpc::Ndr::PointerClassPlugin)
|
84
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::PointerPlugin)
|
85
|
+
end
|
86
|
+
it 'is four-byte aligned' do
|
87
|
+
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
88
|
+
end
|
89
|
+
it 'reads itself' do
|
90
|
+
new_packet = described_class.new([
|
91
|
+
{relative_id: 4, name: 'Test1'},
|
92
|
+
{relative_id: 1, name: 'Test2'}
|
93
|
+
])
|
94
|
+
expected_output = [
|
95
|
+
{
|
96
|
+
relative_id: 4,
|
97
|
+
name: {
|
98
|
+
buffer_length: 10,
|
99
|
+
maximum_length: 10,
|
100
|
+
buffer: "Test1".encode('utf-16le')
|
101
|
+
}
|
102
|
+
},
|
103
|
+
{
|
104
|
+
relative_id: 1,
|
105
|
+
name: {
|
106
|
+
buffer_length: 10,
|
107
|
+
maximum_length: 10,
|
108
|
+
buffer: "Test2".encode('utf-16le')
|
109
|
+
}
|
110
|
+
}]
|
111
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamprEnumerationBuffer do
|
116
|
+
subject(:packet) { described_class.new }
|
117
|
+
|
118
|
+
it { is_expected.to respond_to :entries_read }
|
119
|
+
it { is_expected.to respond_to :buffer }
|
120
|
+
|
121
|
+
it 'is little endian' do
|
122
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
123
|
+
end
|
124
|
+
it 'is a Ndr::NdrStruct' do
|
125
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrStruct)
|
126
|
+
end
|
127
|
+
it 'is four-byte aligned' do
|
128
|
+
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
129
|
+
end
|
130
|
+
describe '#entries_read' do
|
131
|
+
it 'is a NdrUint32 structure' do
|
132
|
+
expect(packet.entries_read).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
133
|
+
end
|
134
|
+
end
|
135
|
+
describe '#buffer' do
|
136
|
+
it 'is a PsamprRidEnumerationArray structure' do
|
137
|
+
expect(packet.buffer).to be_a RubySMB::Dcerpc::Samr::PsamprRidEnumerationArray
|
138
|
+
end
|
139
|
+
end
|
140
|
+
it 'reads itself' do
|
141
|
+
new_packet = described_class.new(
|
142
|
+
entries_read: 3,
|
143
|
+
buffer: [
|
144
|
+
{ relative_id: 500, name: "Administrator" },
|
145
|
+
{ relative_id: 501, name: "Guest" },
|
146
|
+
{ relative_id: 1001, name: "WIN-DP0M1BC768$" }
|
147
|
+
]
|
148
|
+
)
|
149
|
+
expected_output = {
|
150
|
+
entries_read: 3,
|
151
|
+
buffer: [
|
152
|
+
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Administrator".encode('utf-16le') }},
|
153
|
+
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "Guest".encode('utf-16le') }},
|
154
|
+
{relative_id: 1001, name: { buffer_length: 30, maximum_length: 30, buffer: "WIN-DP0M1BC768$".encode('utf-16le') }}
|
155
|
+
]
|
156
|
+
}
|
157
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
RSpec.describe RubySMB::Dcerpc::Samr::PsamprEnumerationBuffer do
|
162
|
+
subject(:packet) { described_class.new }
|
163
|
+
|
164
|
+
it 'is a SamprEnumerationBuffer' do
|
165
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Samr::SamprEnumerationBuffer)
|
166
|
+
end
|
167
|
+
it 'is a NdrPointer' do
|
168
|
+
expect(described_class).to be_a(RubySMB::Dcerpc::Ndr::PointerClassPlugin)
|
169
|
+
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::PointerPlugin)
|
170
|
+
end
|
171
|
+
it 'is four-byte aligned' do
|
172
|
+
expect(packet.eval_parameter(:byte_align)).to eq(4)
|
173
|
+
end
|
174
|
+
it 'reads itself' do
|
175
|
+
new_packet = described_class.new(
|
176
|
+
entries_read: 3,
|
177
|
+
buffer: [
|
178
|
+
{ relative_id: 500, name: "Administrator" },
|
179
|
+
{ relative_id: 501, name: "Guest" },
|
180
|
+
{ relative_id: 1001, name: "WIN-DP0M1BC768$" }
|
181
|
+
]
|
182
|
+
)
|
183
|
+
expected_output = {
|
184
|
+
entries_read: 3,
|
185
|
+
buffer: [
|
186
|
+
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Administrator".encode('utf-16le') }},
|
187
|
+
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "Guest".encode('utf-16le') }},
|
188
|
+
{relative_id: 1001, name: { buffer_length: 30, maximum_length: 30, buffer: "WIN-DP0M1BC768$".encode('utf-16le') }}
|
189
|
+
]
|
190
|
+
}
|
191
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrEnumerateUsersInDomainResponse do
|
196
|
+
subject(:packet) { described_class.new }
|
197
|
+
|
198
|
+
it { is_expected.to respond_to :enumeration_context }
|
199
|
+
it { is_expected.to respond_to :buffer }
|
200
|
+
it { is_expected.to respond_to :count_returned }
|
201
|
+
it { is_expected.to respond_to :error_status }
|
202
|
+
it { is_expected.to respond_to :opnum }
|
203
|
+
|
204
|
+
it 'is little endian' do
|
205
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
206
|
+
end
|
207
|
+
it 'is a BinData::Record' do
|
208
|
+
expect(packet).to be_a(BinData::Record)
|
209
|
+
end
|
210
|
+
describe '#enumeration_context' do
|
211
|
+
it 'is a NdrUint32 structure' do
|
212
|
+
expect(packet.enumeration_context).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
213
|
+
end
|
214
|
+
end
|
215
|
+
describe '#buffer' do
|
216
|
+
it 'is a PsamprEnumerationBuffer structure' do
|
217
|
+
expect(packet.buffer).to be_a RubySMB::Dcerpc::Samr::PsamprEnumerationBuffer
|
218
|
+
end
|
219
|
+
end
|
220
|
+
describe '#count_returned' do
|
221
|
+
it 'is a NdrUint32 structure' do
|
222
|
+
expect(packet.count_returned).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
223
|
+
end
|
224
|
+
end
|
225
|
+
describe '#error_status' do
|
226
|
+
it 'is a NdrUint32 structure' do
|
227
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
228
|
+
end
|
229
|
+
end
|
230
|
+
describe '#initialize_instance' do
|
231
|
+
it 'sets #opnum to SAMR_ENUMERATE_USERS_IN_DOMAIN constant' do
|
232
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_ENUMERATE_USERS_IN_DOMAIN)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
it 'reads itself' do
|
236
|
+
new_packet = described_class.new(
|
237
|
+
enumeration_context: 0,
|
238
|
+
buffer: {
|
239
|
+
entries_read: 3,
|
240
|
+
buffer: [
|
241
|
+
{ relative_id: 500, name: "Administrator" },
|
242
|
+
{ relative_id: 501, name: "Guest" },
|
243
|
+
{ relative_id: 1001, name: "WIN-DP0M1BC768$" }
|
244
|
+
]
|
245
|
+
},
|
246
|
+
count_returned: 3,
|
247
|
+
error_status: 0
|
248
|
+
)
|
249
|
+
expected_output = {
|
250
|
+
enumeration_context: 0,
|
251
|
+
buffer: {
|
252
|
+
entries_read: 3,
|
253
|
+
buffer: [
|
254
|
+
{relative_id: 500, name: { buffer_length: 26, maximum_length: 26, buffer: "Administrator".encode('utf-16le') }},
|
255
|
+
{relative_id: 501, name: { buffer_length: 10, maximum_length: 10, buffer: "Guest".encode('utf-16le') }},
|
256
|
+
{relative_id: 1001, name: { buffer_length: 30, maximum_length: 30, buffer: "WIN-DP0M1BC768$".encode('utf-16le') }}
|
257
|
+
]
|
258
|
+
},
|
259
|
+
count_returned: 3,
|
260
|
+
error_status: 0
|
261
|
+
}
|
262
|
+
expect(packet.read(new_packet.to_binary_s)).to eq(expected_output)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrLookupDomainInSamServerRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_handle }
|
5
|
+
it { is_expected.to respond_to :name }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
describe '#server_handle' do
|
15
|
+
it 'is a SamprHandle structure' do
|
16
|
+
expect(packet.server_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#name' do
|
20
|
+
it 'is a RpcUnicodeString structure' do
|
21
|
+
expect(packet.name).to be_a RubySMB::Dcerpc::RpcUnicodeString
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it 'reads itself' do
|
30
|
+
new_class = described_class.new(
|
31
|
+
server_handle: {
|
32
|
+
context_handle_attributes: 0,
|
33
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
34
|
+
},
|
35
|
+
name: 'Test Server Name'
|
36
|
+
)
|
37
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
38
|
+
{
|
39
|
+
server_handle: {
|
40
|
+
context_handle_attributes: 0,
|
41
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
42
|
+
},
|
43
|
+
name: {
|
44
|
+
buffer_length: 32,
|
45
|
+
maximum_length: 32,
|
46
|
+
buffer: 'Test Server Name'.encode('utf-16le')
|
47
|
+
}
|
48
|
+
}
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrLookupDomainInSamServerResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :domain_id }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
describe '#domain_id' do
|
15
|
+
it 'is a PrpcSid structure' do
|
16
|
+
expect(packet.domain_id).to be_a RubySMB::Dcerpc::Samr::PrpcSid
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#error_status' do
|
20
|
+
it 'is a NdrUint32 structure' do
|
21
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_LOOKUP_DOMAIN_IN_SAM_SERVER)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it 'reads itself' do
|
30
|
+
new_class = described_class.new(domain_id: 'S-1-5-21-419547006-9459028-4093171872-500', error_status: 2)
|
31
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
32
|
+
{domain_id: 'S-1-5-21-419547006-9459028-4093171872-500', error_status: 2}
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrOpenDomainRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_handle }
|
5
|
+
it { is_expected.to respond_to :desired_access }
|
6
|
+
it { is_expected.to respond_to :domain_id }
|
7
|
+
it { is_expected.to respond_to :opnum }
|
8
|
+
|
9
|
+
it 'is little endian' do
|
10
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
11
|
+
end
|
12
|
+
it 'is a BinData::Record' do
|
13
|
+
expect(packet).to be_a(BinData::Record)
|
14
|
+
end
|
15
|
+
describe '#server_handle' do
|
16
|
+
it 'is a SamprHandle structure' do
|
17
|
+
expect(packet.server_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe '#desired_access' do
|
21
|
+
it 'is a NdrUint32 structure' do
|
22
|
+
expect(packet.desired_access).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe '#domain_id' do
|
26
|
+
it 'is a RpcSid structure' do
|
27
|
+
expect(packet.domain_id).to be_a RubySMB::Dcerpc::Samr::RpcSid
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
it 'sets #opnum to SAMR_OPEN_DOMAIN constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_OPEN_DOMAIN)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
it 'reads itself' do
|
36
|
+
new_class = described_class.new(
|
37
|
+
server_handle: {
|
38
|
+
context_handle_attributes: 0,
|
39
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
40
|
+
},
|
41
|
+
desired_access: 555,
|
42
|
+
domain_id: 'S-1-5-21-419547006-9459028-4093171872-500'
|
43
|
+
)
|
44
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
45
|
+
{
|
46
|
+
server_handle: {
|
47
|
+
context_handle_attributes: 0,
|
48
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
49
|
+
},
|
50
|
+
desired_access: 555,
|
51
|
+
domain_id: 'S-1-5-21-419547006-9459028-4093171872-500'
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrOpenDomainResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :domain_handle }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
describe '#domain_handle' do
|
15
|
+
it 'is a SamprHandle structure' do
|
16
|
+
expect(packet.domain_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#error_status' do
|
20
|
+
it 'is a NdrUint32 structure' do
|
21
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to SAMR_OPEN_DOMAIN constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_OPEN_DOMAIN)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it 'reads itself' do
|
30
|
+
new_class = described_class.new(
|
31
|
+
domain_handle: {
|
32
|
+
context_handle_attributes: 0,
|
33
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
34
|
+
},
|
35
|
+
error_status: 2
|
36
|
+
)
|
37
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
38
|
+
{
|
39
|
+
domain_handle: {
|
40
|
+
context_handle_attributes: 0,
|
41
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
42
|
+
},
|
43
|
+
error_status: 2
|
44
|
+
}
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrRidToSidRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :object_handle }
|
5
|
+
it { is_expected.to respond_to :rid }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
describe '#object_handle' do
|
15
|
+
it 'is a SamprHandle structure' do
|
16
|
+
expect(packet.object_handle).to be_a RubySMB::Dcerpc::Samr::SamprHandle
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#rid' do
|
20
|
+
it 'is a NdrUint32 structure' do
|
21
|
+
expect(packet.rid).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to SAMR_RID_TO_SID constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_RID_TO_SID)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it 'reads itself' do
|
30
|
+
new_class = described_class.new(
|
31
|
+
object_handle: {
|
32
|
+
context_handle_attributes: 0,
|
33
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
34
|
+
},
|
35
|
+
rid: 502
|
36
|
+
)
|
37
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
38
|
+
{
|
39
|
+
object_handle: {
|
40
|
+
context_handle_attributes: 0,
|
41
|
+
context_handle_uuid: '2ef54a87-e29e-4d24-90e9-9da49b94449e'
|
42
|
+
},
|
43
|
+
rid: 502
|
44
|
+
}
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Samr::SamrRidToSidResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :sid }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
it { is_expected.to respond_to :opnum }
|
7
|
+
|
8
|
+
it 'is little endian' do
|
9
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
10
|
+
end
|
11
|
+
it 'is a BinData::Record' do
|
12
|
+
expect(packet).to be_a(BinData::Record)
|
13
|
+
end
|
14
|
+
describe '#sid' do
|
15
|
+
it 'is a PrpcSid structure' do
|
16
|
+
expect(packet.sid).to be_a RubySMB::Dcerpc::Samr::PrpcSid
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe '#error_status' do
|
20
|
+
it 'is a NdrUint32 structure' do
|
21
|
+
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to SAMR_RID_TO_SID constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Samr::SAMR_RID_TO_SID)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
it 'reads itself' do
|
30
|
+
new_class = described_class.new(
|
31
|
+
sid: 'S-1-5-21-419547006-9459028-4093171872-500',
|
32
|
+
error_status: 2
|
33
|
+
)
|
34
|
+
expect(packet.read(new_class.to_binary_s)).to eq(
|
35
|
+
{
|
36
|
+
sid: 'S-1-5-21-419547006-9459028-4093171872-500',
|
37
|
+
error_status: 2
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|