ruby_smb 2.0.1 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/examples/anonymous_auth.rb +3 -3
- data/examples/append_file.rb +10 -8
- data/examples/authenticate.rb +9 -5
- data/examples/delete_file.rb +8 -6
- data/examples/enum_registry_key.rb +5 -4
- data/examples/enum_registry_values.rb +5 -4
- data/examples/list_directory.rb +8 -6
- data/examples/negotiate_with_netbios_service.rb +9 -5
- data/examples/net_share_enum_all.rb +6 -4
- data/examples/pipes.rb +11 -12
- data/examples/query_service_status.rb +64 -0
- data/examples/read_file.rb +8 -6
- data/examples/read_registry_key_value.rb +6 -5
- data/examples/rename_file.rb +9 -7
- data/examples/tree_connect.rb +7 -5
- data/examples/write_file.rb +9 -7
- data/lib/ruby_smb/client.rb +81 -48
- data/lib/ruby_smb/client/authentication.rb +5 -10
- data/lib/ruby_smb/client/echo.rb +2 -4
- data/lib/ruby_smb/client/negotiation.rb +21 -14
- data/lib/ruby_smb/client/tree_connect.rb +2 -4
- data/lib/ruby_smb/client/utils.rb +16 -10
- data/lib/ruby_smb/client/winreg.rb +1 -1
- data/lib/ruby_smb/dcerpc.rb +4 -0
- data/lib/ruby_smb/dcerpc/error.rb +3 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +306 -44
- data/lib/ruby_smb/dcerpc/netlogon.rb +101 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request.rb +28 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/request.rb +19 -0
- data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +34 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +9 -6
- data/lib/ruby_smb/dcerpc/svcctl.rb +479 -0
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +48 -0
- data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +26 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +35 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +31 -0
- data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +44 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_request.rb +23 -0
- data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +27 -0
- data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +25 -0
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/winreg.rb +98 -17
- data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +73 -0
- data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +36 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +4 -4
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +7 -6
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +10 -10
- data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +37 -0
- data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +23 -0
- data/lib/ruby_smb/dispatcher/base.rb +1 -1
- data/lib/ruby_smb/dispatcher/socket.rb +1 -1
- data/lib/ruby_smb/error.rb +21 -5
- data/lib/ruby_smb/field/stringz16.rb +17 -1
- data/lib/ruby_smb/generic_packet.rb +11 -1
- data/lib/ruby_smb/nbss/session_header.rb +4 -4
- data/lib/ruby_smb/smb1/file.rb +10 -25
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +1 -2
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +1 -13
- data/lib/ruby_smb/smb1/pipe.rb +8 -6
- data/lib/ruby_smb/smb1/tree.rb +13 -9
- data/lib/ruby_smb/smb2/file.rb +33 -33
- data/lib/ruby_smb/smb2/pipe.rb +9 -6
- data/lib/ruby_smb/smb2/tree.rb +21 -11
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +195 -101
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +1396 -77
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_authenticate3_response_spec.rb +53 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_request_spec.rb +69 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_password_set2_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_request_spec.rb +45 -0
- data/spec/lib/ruby_smb/dcerpc/netlogon/netr_server_req_challenge_response_spec.rb +37 -0
- data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +161 -0
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +49 -12
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +191 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +39 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +78 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +59 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +152 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_request_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +72 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +46 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +30 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +512 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +110 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +44 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +0 -4
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +9 -4
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_request_spec.rb +0 -4
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +17 -17
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +11 -23
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +57 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +22 -0
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +227 -41
- data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +10 -10
- data/spec/lib/ruby_smb/error_spec.rb +34 -5
- data/spec/lib/ruby_smb/field/stringz16_spec.rb +12 -0
- data/spec/lib/ruby_smb/generic_packet_spec.rb +7 -0
- data/spec/lib/ruby_smb/nbss/session_header_spec.rb +4 -11
- data/spec/lib/ruby_smb/smb1/file_spec.rb +2 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +0 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/open2_response_spec.rb +0 -5
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +0 -6
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +30 -5
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +22 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +61 -9
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +9 -5
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +58 -1
- metadata +91 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Request do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :account_name }
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
8
|
+
it { is_expected.to respond_to :client_credential }
|
9
|
+
it { is_expected.to respond_to :flags }
|
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 '#primary_name' do
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#account_name' do
|
22
|
+
it 'is a NdrString structure' do
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#secure_channel_type' do
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#computer_name' do
|
34
|
+
it 'is a NdrString structure' do
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#client_credential' do
|
40
|
+
it 'is a NetlogonCredential structure' do
|
41
|
+
expect(packet.client_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#flags' do
|
46
|
+
it 'is a 32-bit unsigned integer' do
|
47
|
+
expect(packet.flags).to be_a BinData::Uint32le
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#initialize_instance' do
|
52
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
58
|
+
packet = described_class.new(
|
59
|
+
primary_name: 'primary_name',
|
60
|
+
account_name: 'account_name',
|
61
|
+
secure_channel_type: 0,
|
62
|
+
computer_name: 'computer_name',
|
63
|
+
client_credential: "\x00" * 8,
|
64
|
+
flags: rand(0xffffffff)
|
65
|
+
)
|
66
|
+
binary = packet.to_binary_s
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerAuthenticate3Response do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_credential }
|
5
|
+
it { is_expected.to respond_to :negotiate_flags }
|
6
|
+
it { is_expected.to respond_to :account_rid }
|
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 '#server_credential' do
|
14
|
+
it 'is a NetlogonCredential structure' do
|
15
|
+
expect(packet.server_credential).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#negotiate_flags' do
|
20
|
+
it 'is a 32-bit unsigned integer' do
|
21
|
+
expect(packet.negotiate_flags).to be_a BinData::Uint32le
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#account_rid' do
|
26
|
+
it 'is a 32-bit unsigned integer' do
|
27
|
+
expect(packet.account_rid).to be_a BinData::Uint32le
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#error_status' do
|
32
|
+
it 'is a 32-bit unsigned integer' do
|
33
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#initialize_instance' do
|
38
|
+
it 'sets #opnum to NETR_SERVER_AUTHENTICATE3 constant' do
|
39
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_AUTHENTICATE3)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'reads its own binary representation and outputs the same packet' do
|
44
|
+
packet = described_class.new(
|
45
|
+
server_credential: "\x00" * 8,
|
46
|
+
negotiate_flags: rand(0xffffffff),
|
47
|
+
account_rid: rand(0xffffffff),
|
48
|
+
error_status: rand(0xffffffff)
|
49
|
+
)
|
50
|
+
binary = packet.to_binary_s
|
51
|
+
expect(described_class.read(binary)).to eq(packet)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Request do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :account_name }
|
6
|
+
it { is_expected.to respond_to :secure_channel_type }
|
7
|
+
it { is_expected.to respond_to :computer_name }
|
8
|
+
it { is_expected.to respond_to :authenticator }
|
9
|
+
it { is_expected.to respond_to :clear_new_password }
|
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 '#primary_name' do
|
16
|
+
it 'is a LogonsrvHandle structure' do
|
17
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#account_name' do
|
22
|
+
it 'is a NdrString structure' do
|
23
|
+
expect(packet.account_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#secure_channel_type' do
|
28
|
+
it 'is a NetlogonSecureChannelType enum' do
|
29
|
+
expect(packet.secure_channel_type).to be_a RubySMB::Dcerpc::Netlogon::NetlogonSecureChannelType
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#computer_name' do
|
34
|
+
it 'is a NdrString structure' do
|
35
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#authenticator' do
|
40
|
+
it 'is a NetlogonAuthenticator structure' do
|
41
|
+
expect(packet.authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#clear_new_password' do
|
46
|
+
it 'is a NdrFixedByteArray structure' do
|
47
|
+
expect(packet.clear_new_password).to be_a RubySMB::Dcerpc::Ndr::NdrFixedByteArray
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#initialize_instance' do
|
52
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
53
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'reads its own binary representation and outputs the same packet' do
|
58
|
+
packet = described_class.new(
|
59
|
+
primary_name: 'primary_name',
|
60
|
+
account_name: 'account_name',
|
61
|
+
secure_channel_type: 0,
|
62
|
+
computer_name: 'computer_name',
|
63
|
+
authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
64
|
+
clear_new_password: "\x00" * 516
|
65
|
+
)
|
66
|
+
binary = packet.to_binary_s
|
67
|
+
expect(described_class.read(binary)).to eq(packet)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerPasswordSet2Response do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :return_authenticator }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#return_authenticator' do
|
12
|
+
it 'is a NetlogonAuthenticator structure' do
|
13
|
+
expect(packet.return_authenticator).to be_a RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#error_status' do
|
18
|
+
it 'is a 32-bit unsigned integer' do
|
19
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize_instance' do
|
24
|
+
it 'sets #opnum to NETR_SERVER_PASSWORD_SET2 constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_PASSWORD_SET2)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
return_authenticator: RubySMB::Dcerpc::Netlogon::NetlogonAuthenticator.new,
|
32
|
+
error_status: rand(0xffffffff)
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :primary_name }
|
5
|
+
it { is_expected.to respond_to :computer_name }
|
6
|
+
it { is_expected.to respond_to :client_challenge }
|
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 '#primary_name' do
|
13
|
+
it 'is a LogonsrvHandle structure' do
|
14
|
+
expect(packet.primary_name).to be_a RubySMB::Dcerpc::Netlogon::LogonsrvHandle
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#computer_name' do
|
19
|
+
it 'is a NdrString structure' do
|
20
|
+
expect(packet.computer_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#client_challenge' do
|
25
|
+
it 'is a NetlogonCredential structure' do
|
26
|
+
expect(packet.client_challenge).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#initialize_instance' do
|
31
|
+
it 'sets #opnum to NETR_SERVER_REQ_CHALLENGE constant' do
|
32
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_REQ_CHALLENGE)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'reads its own binary representation and outputs the same packet' do
|
37
|
+
packet = described_class.new(
|
38
|
+
primary_name: 'primary_name',
|
39
|
+
computer_name: 'computer_name',
|
40
|
+
client_challenge: "\x00" * 8,
|
41
|
+
)
|
42
|
+
binary = packet.to_binary_s
|
43
|
+
expect(described_class.read(binary)).to eq(packet)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Netlogon::NetrServerReqChallengeResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :server_challenge }
|
5
|
+
it { is_expected.to respond_to :error_status }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#server_challenge' do
|
12
|
+
it 'is a NetlogonCredential structure' do
|
13
|
+
expect(packet.server_challenge).to be_a RubySMB::Dcerpc::Netlogon::NetlogonCredential
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#error_status' do
|
18
|
+
it 'is a 32-bit unsigned integer' do
|
19
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize_instance' do
|
24
|
+
it 'sets #opnum to NETR_SERVER_REQ_CHALLENGE constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Netlogon::NETR_SERVER_REQ_CHALLENGE)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
server_challenge: "\x00" * 8,
|
32
|
+
error_status: rand(0xffffffff)
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::RpcSecurityDescriptor do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_security_descriptor }
|
5
|
+
it { is_expected.to respond_to :cb_in_security_descriptor }
|
6
|
+
it { is_expected.to respond_to :cb_out_security_descriptor }
|
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 '#lp_security_descriptor' do
|
13
|
+
it 'should be a NdrLpByteArray structure' do
|
14
|
+
expect(packet.lp_security_descriptor).to be_a RubySMB::Dcerpc::Ndr::NdrLpByteArray
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#cb_in_security_descriptor' do
|
19
|
+
it 'should be a 32-bit unsigned integer' do
|
20
|
+
expect(packet.cb_in_security_descriptor).to be_a BinData::Uint32le
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#cb_out_security_descriptor' do
|
25
|
+
it 'should be a 32-bit unsigned integer' do
|
26
|
+
expect(packet.cb_out_security_descriptor).to be_a BinData::Uint32le
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#read' do
|
31
|
+
context 'with a null pointer' do
|
32
|
+
it 'reads its own binary representation' do
|
33
|
+
raw = packet.to_binary_s
|
34
|
+
expect(described_class.read(raw)).to eq(packet)
|
35
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with a normal RpcSecurityAttributes structure' do
|
40
|
+
it 'reads its own binary representation' do
|
41
|
+
packet.lp_security_descriptor = RubySMB::Dcerpc::Ndr::NdrLpByteArray.new([1, 2, 3])
|
42
|
+
packet.cb_in_security_descriptor = 90
|
43
|
+
packet.cb_out_security_descriptor = 33
|
44
|
+
raw = packet.to_binary_s
|
45
|
+
expect(described_class.read(raw)).to eq(packet)
|
46
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
RSpec.describe RubySMB::Dcerpc::RpcSecurityAttributes do
|
53
|
+
subject(:packet) { described_class.new }
|
54
|
+
|
55
|
+
it { is_expected.to respond_to :n_length }
|
56
|
+
it { is_expected.to respond_to :rpc_security_descriptor }
|
57
|
+
it { is_expected.to respond_to :b_inheritHandle }
|
58
|
+
|
59
|
+
it 'is little endian' do
|
60
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#n_length' do
|
64
|
+
it 'should be a 32-bit unsigned integer' do
|
65
|
+
expect(packet.n_length).to be_a BinData::Uint32le
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#rpc_security_descriptor' do
|
70
|
+
it 'should be a RpcSecurityDescriptor structure' do
|
71
|
+
expect(packet.rpc_security_descriptor).to be_a RubySMB::Dcerpc::RpcSecurityDescriptor
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#b_inheritHandle' do
|
76
|
+
it 'should be a 8-bit unsigned integer' do
|
77
|
+
expect(packet.b_inheritHandle).to be_a BinData::Uint8
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#read' do
|
82
|
+
context 'with a null pointer' do
|
83
|
+
it 'reads its own binary representation' do
|
84
|
+
raw = packet.to_binary_s
|
85
|
+
expect(described_class.read(raw)).to eq(packet)
|
86
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'with a normal RpcSecurityAttributes structure' do
|
91
|
+
it 'reads its own binary representation' do
|
92
|
+
packet.n_length = 3
|
93
|
+
packet.rpc_security_descriptor = RubySMB::Dcerpc::RpcSecurityDescriptor.new
|
94
|
+
packet.rpc_security_descriptor.lp_security_descriptor = [1, 2, 3]
|
95
|
+
packet.rpc_security_descriptor.cb_in_security_descriptor = 33
|
96
|
+
packet.rpc_security_descriptor.cb_out_security_descriptor = 22
|
97
|
+
packet.b_inheritHandle = 90
|
98
|
+
raw = packet.to_binary_s
|
99
|
+
expect(described_class.read(raw)).to eq(packet)
|
100
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
RSpec.describe RubySMB::Dcerpc::PrpcSecurityAttributes do
|
107
|
+
it 'is NdrPointer subclass' do
|
108
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrPointer
|
109
|
+
end
|
110
|
+
|
111
|
+
subject(:packet) { described_class.new }
|
112
|
+
|
113
|
+
it { is_expected.to respond_to :referent }
|
114
|
+
|
115
|
+
it 'is little endian' do
|
116
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#referent' do
|
120
|
+
it 'should be a RpcSecurityAttributes structure' do
|
121
|
+
expect(packet.referent).to be_a RubySMB::Dcerpc::RpcSecurityAttributes
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'exists if superclass #referent_id is not zero' do
|
125
|
+
packet.referent_id = 0xCCCC
|
126
|
+
expect(packet.referent?).to be true
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'does not exist if superclass #referent_id is zero' do
|
130
|
+
packet.referent_id = 0
|
131
|
+
expect(packet.referent?).to be false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#read' do
|
136
|
+
context 'with a null pointer' do
|
137
|
+
it 'reads its own binary representation' do
|
138
|
+
raw = packet.to_binary_s
|
139
|
+
expect(described_class.read(raw)).to eq(packet)
|
140
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'with a normal RpcSecurityAttributes structure' do
|
145
|
+
it 'reads its own binary representation' do
|
146
|
+
struct = RubySMB::Dcerpc::RpcSecurityAttributes.new
|
147
|
+
struct.n_length = 5
|
148
|
+
struct.rpc_security_descriptor = RubySMB::Dcerpc::RpcSecurityDescriptor.new
|
149
|
+
struct.rpc_security_descriptor.lp_security_descriptor = [1, 2, 3]
|
150
|
+
struct.rpc_security_descriptor.cb_in_security_descriptor = 33
|
151
|
+
struct.rpc_security_descriptor.cb_out_security_descriptor = 22
|
152
|
+
struct.b_inheritHandle = 4
|
153
|
+
packet.set(struct)
|
154
|
+
raw = packet.to_binary_s
|
155
|
+
expect(described_class.read(raw)).to eq(packet)
|
156
|
+
expect(described_class.read(raw).to_binary_s).to eq(raw)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|