ruby_smb 1.0.5 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +3 -2
- data/Gemfile +6 -2
- data/README.md +35 -47
- 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 +29 -0
- data/examples/enum_registry_values.rb +31 -0
- data/examples/list_directory.rb +8 -6
- data/examples/negotiate.rb +51 -8
- data/examples/negotiate_with_netbios_service.rb +9 -5
- data/examples/net_share_enum_all.rb +6 -4
- data/examples/pipes.rb +13 -13
- data/examples/query_service_status.rb +64 -0
- data/examples/read_file.rb +8 -6
- data/examples/read_file_encryption.rb +56 -0
- data/examples/read_registry_key_value.rb +33 -0
- 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.rb +4 -1
- data/lib/ruby_smb/client.rb +239 -21
- data/lib/ruby_smb/client/authentication.rb +27 -8
- data/lib/ruby_smb/client/encryption.rb +62 -0
- data/lib/ruby_smb/client/negotiation.rb +154 -12
- data/lib/ruby_smb/client/signing.rb +19 -0
- data/lib/ruby_smb/client/tree_connect.rb +4 -4
- data/lib/ruby_smb/client/utils.rb +8 -7
- data/lib/ruby_smb/client/winreg.rb +46 -0
- data/lib/ruby_smb/crypto.rb +30 -0
- data/lib/ruby_smb/dcerpc.rb +40 -0
- data/lib/ruby_smb/dcerpc/bind.rb +2 -2
- data/lib/ruby_smb/dcerpc/bind_ack.rb +2 -2
- data/lib/ruby_smb/dcerpc/error.rb +6 -0
- data/lib/ruby_smb/dcerpc/ndr.rb +260 -16
- data/lib/ruby_smb/dcerpc/pdu_header.rb +1 -1
- data/lib/ruby_smb/dcerpc/request.rb +41 -9
- data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +34 -0
- data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +38 -0
- data/lib/ruby_smb/dcerpc/srvsvc.rb +10 -0
- data/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all.rb +9 -0
- 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 +421 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_request.rb +24 -0
- data/lib/ruby_smb/dcerpc/winreg/close_key_response.rb +27 -0
- 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 +45 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_key_response.rb +42 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +39 -0
- data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +36 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_request.rb +34 -0
- data/lib/ruby_smb/dcerpc/winreg/open_key_response.rb +25 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +43 -0
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_response.rb +35 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +27 -0
- data/lib/ruby_smb/dcerpc/winreg/query_info_key_response.rb +40 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +40 -0
- data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +57 -0
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +40 -0
- 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 +5 -4
- data/lib/ruby_smb/error.rb +28 -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/commands.rb +1 -1
- data/lib/ruby_smb/smb1/file.rb +8 -14
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_response.rb +2 -2
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/session_setup_response.rb +2 -2
- data/lib/ruby_smb/smb1/packet/write_andx_request.rb +1 -1
- data/lib/ruby_smb/smb1/pipe.rb +81 -3
- data/lib/ruby_smb/smb1/tree.rb +12 -3
- data/lib/ruby_smb/smb2/bit_field/session_flags.rb +2 -1
- data/lib/ruby_smb/smb2/bit_field/share_flags.rb +6 -4
- data/lib/ruby_smb/smb2/file.rb +51 -61
- data/lib/ruby_smb/smb2/negotiate_context.rb +108 -0
- data/lib/ruby_smb/smb2/packet.rb +2 -0
- data/lib/ruby_smb/smb2/packet/compression_transform_header.rb +41 -0
- data/lib/ruby_smb/smb2/packet/error_packet.rb +2 -4
- data/lib/ruby_smb/smb2/packet/negotiate_request.rb +51 -14
- data/lib/ruby_smb/smb2/packet/negotiate_response.rb +50 -4
- data/lib/ruby_smb/smb2/packet/transform_header.rb +84 -0
- data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +92 -6
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +8 -26
- data/lib/ruby_smb/smb2/pipe.rb +80 -3
- data/lib/ruby_smb/smb2/smb2_header.rb +1 -1
- data/lib/ruby_smb/smb2/tree.rb +32 -20
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +5 -3
- data/spec/lib/ruby_smb/client_spec.rb +1583 -102
- data/spec/lib/ruby_smb/crypto_spec.rb +25 -0
- data/spec/lib/ruby_smb/dcerpc/bind_ack_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/bind_spec.rb +2 -2
- data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +1729 -0
- data/spec/lib/ruby_smb/dcerpc/request_spec.rb +50 -7
- data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +161 -0
- data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +135 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc/net_share_enum_all_spec.rb +13 -0
- data/spec/lib/ruby_smb/dcerpc/srvsvc_spec.rb +60 -0
- 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/close_key_request_spec.rb +28 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/close_key_response_spec.rb +36 -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 +104 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_response_spec.rb +97 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +94 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +82 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_request_spec.rb +74 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_key_response_spec.rb +35 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +95 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_response_spec.rb +38 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_request_spec.rb +35 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_response_spec.rb +113 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +88 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +138 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +32 -0
- 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 +884 -0
- data/spec/lib/ruby_smb/dcerpc_spec.rb +81 -0
- data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +12 -12
- data/spec/lib/ruby_smb/error_spec.rb +59 -0
- 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/file_spec.rb +9 -1
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_legacy_response_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +216 -147
- data/spec/lib/ruby_smb/smb2/bit_field/session_flags_spec.rb +9 -0
- data/spec/lib/ruby_smb/smb2/bit_field/share_flags_spec.rb +27 -0
- data/spec/lib/ruby_smb/smb2/file_spec.rb +146 -68
- data/spec/lib/ruby_smb/smb2/negotiate_context_spec.rb +332 -0
- data/spec/lib/ruby_smb/smb2/packet/compression_transform_header_spec.rb +108 -0
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +3 -24
- data/spec/lib/ruby_smb/smb2/packet/negotiate_request_spec.rb +138 -3
- data/spec/lib/ruby_smb/smb2/packet/negotiate_response_spec.rb +120 -2
- data/spec/lib/ruby_smb/smb2/packet/transform_header_spec.rb +220 -0
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_request_spec.rb +339 -9
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_response_spec.rb +3 -30
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +226 -148
- data/spec/lib/ruby_smb/smb2/smb2_header_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +88 -9
- metadata +257 -81
- metadata.gz.sig +0 -0
- data/lib/ruby_smb/smb1/dcerpc.rb +0 -72
- data/lib/ruby_smb/smb2/dcerpc.rb +0 -75
@@ -0,0 +1,191 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::ChangeServiceConfigWRequest 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_service_type }
|
6
|
+
it { is_expected.to respond_to :dw_start_type }
|
7
|
+
it { is_expected.to respond_to :dw_error_control }
|
8
|
+
it { is_expected.to respond_to :lp_binary_path_name }
|
9
|
+
it { is_expected.to respond_to :pad1 }
|
10
|
+
it { is_expected.to respond_to :lp_load_order_group }
|
11
|
+
it { is_expected.to respond_to :pad2 }
|
12
|
+
it { is_expected.to respond_to :dw_tag_id }
|
13
|
+
it { is_expected.to respond_to :lp_dependencies }
|
14
|
+
it { is_expected.to respond_to :pad3 }
|
15
|
+
it { is_expected.to respond_to :dw_depend_size }
|
16
|
+
it { is_expected.to respond_to :lp_service_start_name }
|
17
|
+
it { is_expected.to respond_to :pad4 }
|
18
|
+
it { is_expected.to respond_to :lp_password }
|
19
|
+
it { is_expected.to respond_to :pad5 }
|
20
|
+
it { is_expected.to respond_to :dw_pw_size }
|
21
|
+
it { is_expected.to respond_to :lp_display_name }
|
22
|
+
|
23
|
+
it 'is little endian' do
|
24
|
+
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#h_service' do
|
28
|
+
it 'is a ScRpcHandle structure' do
|
29
|
+
expect(packet.h_service).to be_a RubySMB::Dcerpc::Svcctl::ScRpcHandle
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
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
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
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
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
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
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
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
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
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
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
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
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#lp_dependencies' do
|
92
|
+
it 'is a NdrLpByte structure' do
|
93
|
+
expect(packet.lp_dependencies).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
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
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
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
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
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
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#pad4' do
|
121
|
+
it 'is a string' do
|
122
|
+
expect(packet.pad1).to be_a BinData::String
|
123
|
+
end
|
124
|
+
|
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
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#lp_password' do
|
132
|
+
it 'is a NdrLpByte structure' do
|
133
|
+
expect(packet.lp_password).to be_a RubySMB::Dcerpc::Ndr::NdrLpByte
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#pad5' do
|
138
|
+
it 'is a string' do
|
139
|
+
expect(packet.pad1).to be_a BinData::String
|
140
|
+
end
|
141
|
+
|
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
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
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
|
151
|
+
end
|
152
|
+
|
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)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
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
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '#initialize_instance' do
|
166
|
+
it 'sets #opnum to CHANGE_SERVICE_CONFIG_W constant' do
|
167
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CHANGE_SERVICE_CONFIG_W)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'reads its own binary representation and outputs the same packet' do
|
172
|
+
packet = described_class.new(
|
173
|
+
h_service: {context_handle_attributes: 0, context_handle_uuid: '367abb81-9844-35f1-ad32-98f038001003'},
|
174
|
+
dw_service_type: 33,
|
175
|
+
dw_start_type: 3,
|
176
|
+
dw_error_control: 11,
|
177
|
+
lp_binary_path_name: 'test',
|
178
|
+
lp_load_order_group: 'test2',
|
179
|
+
dw_tag_id: 4,
|
180
|
+
lp_dependencies: [1,2],
|
181
|
+
dw_depend_size: 2,
|
182
|
+
lp_service_start_name: 'test3',
|
183
|
+
lp_password: [1,2,3],
|
184
|
+
dw_pw_size: 3,
|
185
|
+
lp_display_name: 'test4'
|
186
|
+
)
|
187
|
+
binary = packet.to_binary_s
|
188
|
+
expect(described_class.read(binary)).to eq(packet)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.describe RubySMB::Dcerpc::Svcctl::ChangeServiceConfigWResponse do
|
2
|
+
subject(:packet) { described_class.new }
|
3
|
+
|
4
|
+
it { is_expected.to respond_to :dw_tag_id }
|
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 '#dw_tag_id' do
|
12
|
+
it 'is a NdrLpDword structure' do
|
13
|
+
expect(packet.dw_tag_id).to be_a RubySMB::Dcerpc::Ndr::NdrLpDword
|
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 CHANGE_SERVICE_CONFIG_W constant' do
|
25
|
+
expect(packet.opnum).to eq(RubySMB::Dcerpc::Svcctl::CHANGE_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
|
+
dw_tag_id: 4,
|
32
|
+
error_status: 1
|
33
|
+
)
|
34
|
+
binary = packet.to_binary_s
|
35
|
+
expect(described_class.read(binary)).to eq(packet)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -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
|
+
|