ruby_smb 2.0.2 → 2.0.3
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.tar.gz.sig +0 -0
- 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 +72 -43
- data/lib/ruby_smb/client/negotiation.rb +1 -0
- data/lib/ruby_smb/dcerpc.rb +2 -0
- data/lib/ruby_smb/dcerpc/error.rb +3 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +209 -44
- data/lib/ruby_smb/dcerpc/request.rb +13 -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/field/stringz16.rb +17 -1
- data/lib/ruby_smb/nbss/session_header.rb +4 -4
- data/lib/ruby_smb/smb1/file.rb +2 -10
- data/lib/ruby_smb/smb1/pipe.rb +2 -0
- data/lib/ruby_smb/smb2/file.rb +25 -17
- data/lib/ruby_smb/smb2/pipe.rb +3 -0
- data/lib/ruby_smb/smb2/tree.rb +9 -3
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +161 -60
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +1396 -77
- 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 +215 -41
- data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +10 -10
- data/spec/lib/ruby_smb/field/stringz16_spec.rb +12 -0
- data/spec/lib/ruby_smb/nbss/session_header_spec.rb +4 -11
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +7 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +60 -6
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +7 -0
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +35 -1
- metadata +72 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::CloseServiceHandleRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :h_sc_object }
|
5
|
+
|
6
|
+
it 'is little endian' do
|
7
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#h_sc_object' do
|
11
|
+
it 'is a ScRpcHandle structure' do
|
12
|
+
expect(packet.h_sc_object).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#initialize_instance' do
|
17
|
+
it 'sets #opnum to CLOSE_SERVICE_HANDLE constant' do
|
18
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CLOSE_SERVICE_HANDLE)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'reads its own binary representation and outputs the same packet' do
|
23
|
+
packet = described_class.new(
|
24
|
+
h_service: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'}
|
25
|
+
)
|
26
|
+
binary = packet.to_binary_s
|
27
|
+
expect(described_class.read(binary)).to eq(packet)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::CloseServiceHandleResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :h_sc_object }
|
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 '#h_sc_object' do
|
12
|
+
it 'is a ScRpcHandle structure' do
|
13
|
+
expect(packet.h_sc_object).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
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 CLOSE_SERVICE_HANDLE constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CLOSE_SERVICE_HANDLE)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
h_sc_object: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
32
|
+
error_status: 3
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::ControlServiceRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :h_service }
|
5
|
+
it { is_expected.to respond_to :dw_control }
|
6
|
+
|
7
|
+
it 'is little endian' do
|
8
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
describe '#h_service' do
|
13
|
+
it 'is a ScRpcHandle structure' do
|
14
|
+
expect(packet.h_service).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#dw_control' do
|
19
|
+
it 'is a 32-bit unsigned integer' do
|
20
|
+
expect(packet.dw_control).to be_a BinData::Uint32le
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#initialize_instance' do
|
25
|
+
it 'sets #opnum to CONTROL_SERVICE constant' do
|
26
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CONTROL_SERVICE)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'reads its own binary representation and outputs the same packet' do
|
31
|
+
packet = described_class.new(
|
32
|
+
h_service: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
33
|
+
dw_control: 3
|
34
|
+
)
|
35
|
+
binary = packet.to_binary_s
|
36
|
+
expect(described_class.read(binary)).to eq(packet)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::ControlServiceResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_service_status }
|
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 '#lp_service_status' do
|
12
|
+
it 'is a ServiceStatus structure' do
|
13
|
+
expect(packet.lp_service_status).to be_a RubySMB::Dcerpc::Svcctl::ServiceStatus
|
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 CONTROL_SERVICE constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CONTROL_SERVICE)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
service_status: RubySMB::Dcerpc::Svcctl::ServiceStatus.new(dw_service_type: 8, dw_current_state:2, dw_controls_accepted:1),
|
32
|
+
error_status: 3
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::SvcctlHandleW do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it 'is NdrLpStr subclass' do
|
5
|
+
expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrLpStr
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::OpenSCManagerWRequest do
|
10
|
+
subject(:packet) { described_class.new }
|
11
|
+
|
12
|
+
it { is_expected.to respond_to :lp_machine_name }
|
13
|
+
it { is_expected.to respond_to :pad1 }
|
14
|
+
it { is_expected.to respond_to :lp_database_name }
|
15
|
+
it { is_expected.to respond_to :pad2 }
|
16
|
+
it { is_expected.to respond_to :dw_desired_access }
|
17
|
+
|
18
|
+
it 'is little endian' do
|
19
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#lp_machine_name' do
|
23
|
+
it 'is a SvcctlHandleW structure' do
|
24
|
+
expect(packet.lp_machine_name).to be_a RubySMB::Dcerpc::Svcctl::SvcctlHandleW
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#pad1' do
|
29
|
+
it 'is a string' do
|
30
|
+
expect(packet.pad1).to be_a BinData::String
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should keep #lp_database_name 4-byte aligned' do
|
34
|
+
packet.lp_machine_name = "test"
|
35
|
+
expect(packet.lp_database_name.abs_offset % 4).to eq 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#lp_database_name' do
|
40
|
+
it 'is a NdrLpStr structure' do
|
41
|
+
expect(packet.lp_database_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#pad2' do
|
46
|
+
it 'is a string' do
|
47
|
+
expect(packet.pad1).to be_a BinData::String
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should keep #dw_desired_access 4-byte aligned' do
|
51
|
+
packet.lp_database_name = "test"
|
52
|
+
expect(packet.dw_desired_access.abs_offset % 4).to eq 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#dw_desired_access' do
|
57
|
+
it 'is a 32-bit unsigned integer' do
|
58
|
+
expect(packet.dw_desired_access).to be_a BinData::Uint32le
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#initialize_instance' do
|
63
|
+
it 'sets #opnum to OPEN_SC_MANAGER_W constant' do
|
64
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::OPEN_SC_MANAGER_W)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'reads its own binary representation and outputs the same packet' do
|
69
|
+
packet = described_class.new(
|
70
|
+
lp_machine_name: 'test',
|
71
|
+
lp_database_name: 'test2',
|
72
|
+
dw_desired_access: 3
|
73
|
+
)
|
74
|
+
binary = packet.to_binary_s
|
75
|
+
expect(described_class.read(binary)).to eq(packet)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::OpenSCManagerWResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_sc_handle }
|
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 '#lp_sc_handle' do
|
12
|
+
it 'is a ScRpcHandle structure' do
|
13
|
+
expect(packet.lp_sc_handle).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
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 OPEN_SC_MANAGER_W constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::OPEN_SC_MANAGER_W)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
lp_sc_handle: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
32
|
+
error_status: 3
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::OpenServiceWRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_sc_handle }
|
5
|
+
it { is_expected.to respond_to :lp_service_name }
|
6
|
+
it { is_expected.to respond_to :pad }
|
7
|
+
it { is_expected.to respond_to :dw_desired_access }
|
8
|
+
|
9
|
+
it 'is little endian' do
|
10
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
describe '#lp_sc_handle' do
|
15
|
+
it 'is a ScRpcHandle structure' do
|
16
|
+
expect(packet.lp_sc_handle).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#lp_service_name' do
|
21
|
+
it 'is a NdrString structure' do
|
22
|
+
expect(packet.lp_service_name).to be_a RubySMB::Dcerpc::Ndr::NdrString
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#pad' do
|
27
|
+
it 'is a string' do
|
28
|
+
expect(packet.pad).to be_a BinData::String
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should keep #dw_desired_access 4-byte aligned' do
|
32
|
+
packet.lp_service_name = "test"
|
33
|
+
expect(packet.dw_desired_access.abs_offset % 4).to eq 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#dw_desired_access' do
|
38
|
+
it 'is a 32-bit unsigned integer' do
|
39
|
+
expect(packet.dw_desired_access).to be_a BinData::Uint32le
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#initialize_instance' do
|
44
|
+
it 'sets #opnum to OPEN_SERVICE_W constant' do
|
45
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::OPEN_SERVICE_W)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'reads its own binary representation and outputs the same packet' do
|
50
|
+
packet = described_class.new(
|
51
|
+
lp_sc_handle: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
52
|
+
lp_service_name: 'test',
|
53
|
+
dw_desired_access: 3
|
54
|
+
)
|
55
|
+
binary = packet.to_binary_s
|
56
|
+
expect(described_class.read(binary)).to eq(packet)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::OpenServiceWResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :lp_sc_handle }
|
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 '#lp_sc_handle' do
|
12
|
+
it 'is a ScRpcHandle structure' do
|
13
|
+
expect(packet.lp_sc_handle).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
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 OPEN_SC_MANAGER_W constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::OPEN_SC_MANAGER_W)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
lp_sc_handle: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
32
|
+
error_status: 3
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::QueryServiceConfigWRequest do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :h_service }
|
5
|
+
it { is_expected.to respond_to :cb_buf_size }
|
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 '#h_service' do
|
12
|
+
it 'is a ScRpcHandle structure' do
|
13
|
+
expect(packet.h_service).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#cb_buf_size' do
|
18
|
+
it 'is a 32-bit unsigned integer' do
|
19
|
+
expect(packet.cb_buf_size).to be_a BinData::Uint32le
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#initialize_instance' do
|
24
|
+
it 'sets #opnum to QUERY_SERVICE_CONFIG_W constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::QUERY_SERVICE_CONFIG_W)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'reads its own binary representation and outputs the same packet' do
|
30
|
+
packet = described_class.new(
|
31
|
+
h_service: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
32
|
+
cb_buf_size: 3
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::LpBoundedDword8k do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it 'is BinData::Uint32le subclass' do
|
5
|
+
expect(described_class).to be < BinData::Uint32le
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::QueryServiceConfigW do
|
10
|
+
subject(:packet) { described_class.new }
|
11
|
+
|
12
|
+
it { is_expected.to respond_to :dw_service_type }
|
13
|
+
it { is_expected.to respond_to :dw_start_type }
|
14
|
+
it { is_expected.to respond_to :dw_error_control }
|
15
|
+
it { is_expected.to respond_to :lp_binary_path_name }
|
16
|
+
it { is_expected.to respond_to :lp_load_order_group }
|
17
|
+
it { is_expected.to respond_to :dw_tag_id }
|
18
|
+
it { is_expected.to respond_to :lp_dependencies }
|
19
|
+
it { is_expected.to respond_to :lp_service_start_name }
|
20
|
+
it { is_expected.to respond_to :lp_display_name }
|
21
|
+
|
22
|
+
it 'is little endian' do
|
23
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#dw_service_type' do
|
27
|
+
it 'is a 32-bit unsigned integer' do
|
28
|
+
expect(packet.dw_service_type).to be_a BinData::Uint32le
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#dw_start_type' do
|
33
|
+
it 'is a 32-bit unsigned integer' do
|
34
|
+
expect(packet.dw_start_type).to be_a BinData::Uint32le
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#dw_error_control' do
|
39
|
+
it 'is a 32-bit unsigned integer' do
|
40
|
+
expect(packet.dw_error_control).to be_a BinData::Uint32le
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#lp_binary_path_name' do
|
45
|
+
it 'is a NdrLpStr structure' do
|
46
|
+
expect(packet.lp_binary_path_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#lp_load_order_group' do
|
51
|
+
it 'is a NdrLpStr structure' do
|
52
|
+
expect(packet.lp_load_order_group).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#dw_tag_id' do
|
57
|
+
it 'is a 32-bit unsigned integer' do
|
58
|
+
expect(packet.dw_tag_id).to be_a BinData::Uint32le
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#lp_dependencies' do
|
63
|
+
it 'is a NdrLpStr structure' do
|
64
|
+
expect(packet.lp_dependencies).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#lp_service_start_name' do
|
69
|
+
it 'is a NdrLpStr structure' do
|
70
|
+
expect(packet.lp_service_start_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#lp_display_name' do
|
75
|
+
it 'is a NdrLpStr structure' do
|
76
|
+
expect(packet.lp_display_name).to be_a RubySMB::Dcerpc::Ndr::NdrLpStr
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'reads its own binary representation and outputs the same packet' do
|
81
|
+
packet = described_class.new(
|
82
|
+
dw_service_type: 3,
|
83
|
+
dw_start_type: 4,
|
84
|
+
dw_error_control: 5,
|
85
|
+
lp_binary_path_name: 'test',
|
86
|
+
lp_load_order_group: 'test2',
|
87
|
+
dw_tag_id: 3,
|
88
|
+
lp_dependencies: 'test3',
|
89
|
+
lp_service_start_name: 'test4',
|
90
|
+
lp_display_name: 'test5'
|
91
|
+
)
|
92
|
+
binary = packet.to_binary_s
|
93
|
+
expect(described_class.read(binary)).to eq(packet)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::QueryServiceConfigWResponse do
|
98
|
+
subject(:packet) { described_class.new }
|
99
|
+
|
100
|
+
it { is_expected.to respond_to :lp_service_config }
|
101
|
+
it { is_expected.to respond_to :pcb_bytes_needed }
|
102
|
+
it { is_expected.to respond_to :error_status }
|
103
|
+
|
104
|
+
it 'is little endian' do
|
105
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#lp_service_config' do
|
109
|
+
it 'is a QueryServiceConfigW structure' do
|
110
|
+
expect(packet.lp_service_config).to be_a RubySMB::Dcerpc::Svcctl::QueryServiceConfigW
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#pcb_bytes_needed' do
|
115
|
+
it 'is a LpBoundedDword8k structure' do
|
116
|
+
expect(packet.pcb_bytes_needed).to be_a RubySMB::Dcerpc::Svcctl::LpBoundedDword8k
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#error_status' do
|
121
|
+
it 'is a 32-bit unsigned integer' do
|
122
|
+
expect(packet.error_status).to be_a BinData::Uint32le
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#initialize_instance' do
|
127
|
+
it 'sets #opnum to QUERY_SERVICE_CONFIG_W constant' do
|
128
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::QUERY_SERVICE_CONFIG_W)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'reads its own binary representation and outputs the same packet' do
|
133
|
+
sc = RubySMB::Dcerpc::Svcctl::QueryServiceConfigW.new(
|
134
|
+
dw_service_type: 3,
|
135
|
+
dw_start_type: 4,
|
136
|
+
dw_error_control: 5,
|
137
|
+
lp_binary_path_name: 'test',
|
138
|
+
lp_load_order_group: 'test2',
|
139
|
+
dw_tag_id: 3,
|
140
|
+
lp_dependencies: 'test3',
|
141
|
+
lp_service_start_name: 'test4',
|
142
|
+
lp_display_name: 'test5'
|
143
|
+
)
|
144
|
+
packet = described_class.new(
|
145
|
+
lp_service_config: sc,
|
146
|
+
pcb_bytes_needed: 4,
|
147
|
+
error_status: 3
|
148
|
+
)
|
149
|
+
binary = packet.to_binary_s
|
150
|
+
expect(described_class.read(binary)).to eq(packet)
|
151
|
+
end
|
152
|
+
end
|