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.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/examples/anonymous_auth.rb +3 -3
  5. data/examples/append_file.rb +10 -8
  6. data/examples/authenticate.rb +9 -5
  7. data/examples/delete_file.rb +8 -6
  8. data/examples/enum_registry_key.rb +5 -4
  9. data/examples/enum_registry_values.rb +5 -4
  10. data/examples/list_directory.rb +8 -6
  11. data/examples/negotiate_with_netbios_service.rb +9 -5
  12. data/examples/net_share_enum_all.rb +6 -4
  13. data/examples/pipes.rb +11 -12
  14. data/examples/query_service_status.rb +64 -0
  15. data/examples/read_file.rb +8 -6
  16. data/examples/read_registry_key_value.rb +6 -5
  17. data/examples/rename_file.rb +9 -7
  18. data/examples/tree_connect.rb +7 -5
  19. data/examples/write_file.rb +9 -7
  20. data/lib/ruby_smb/client.rb +72 -43
  21. data/lib/ruby_smb/client/negotiation.rb +1 -0
  22. data/lib/ruby_smb/dcerpc.rb +2 -0
  23. data/lib/ruby_smb/dcerpc/error.rb +3 -0
  24. data/lib/ruby_smb/dcerpc/ndr.rb +209 -44
  25. data/lib/ruby_smb/dcerpc/request.rb +13 -0
  26. data/lib/ruby_smb/dcerpc/rpc_security_attributes.rb +34 -0
  27. data/lib/ruby_smb/dcerpc/rrp_unicode_string.rb +9 -6
  28. data/lib/ruby_smb/dcerpc/svcctl.rb +479 -0
  29. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request.rb +48 -0
  30. data/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response.rb +26 -0
  31. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request.rb +25 -0
  32. data/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response.rb +26 -0
  33. data/lib/ruby_smb/dcerpc/svcctl/control_service_request.rb +26 -0
  34. data/lib/ruby_smb/dcerpc/svcctl/control_service_response.rb +26 -0
  35. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request.rb +35 -0
  36. data/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response.rb +23 -0
  37. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_request.rb +31 -0
  38. data/lib/ruby_smb/dcerpc/svcctl/open_service_w_response.rb +23 -0
  39. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request.rb +25 -0
  40. data/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response.rb +44 -0
  41. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_request.rb +23 -0
  42. data/lib/ruby_smb/dcerpc/svcctl/query_service_status_response.rb +27 -0
  43. data/lib/ruby_smb/dcerpc/svcctl/service_status.rb +25 -0
  44. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_request.rb +27 -0
  45. data/lib/ruby_smb/dcerpc/svcctl/start_service_w_response.rb +25 -0
  46. data/lib/ruby_smb/dcerpc/winreg.rb +98 -17
  47. data/lib/ruby_smb/dcerpc/winreg/create_key_request.rb +73 -0
  48. data/lib/ruby_smb/dcerpc/winreg/create_key_response.rb +36 -0
  49. data/lib/ruby_smb/dcerpc/winreg/enum_key_request.rb +1 -1
  50. data/lib/ruby_smb/dcerpc/winreg/enum_value_request.rb +1 -1
  51. data/lib/ruby_smb/dcerpc/winreg/enum_value_response.rb +1 -1
  52. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +4 -4
  53. data/lib/ruby_smb/dcerpc/winreg/query_info_key_request.rb +1 -1
  54. data/lib/ruby_smb/dcerpc/winreg/query_value_request.rb +7 -6
  55. data/lib/ruby_smb/dcerpc/winreg/query_value_response.rb +10 -10
  56. data/lib/ruby_smb/dcerpc/winreg/save_key_request.rb +37 -0
  57. data/lib/ruby_smb/dcerpc/winreg/save_key_response.rb +23 -0
  58. data/lib/ruby_smb/dispatcher/base.rb +1 -1
  59. data/lib/ruby_smb/dispatcher/socket.rb +1 -1
  60. data/lib/ruby_smb/field/stringz16.rb +17 -1
  61. data/lib/ruby_smb/nbss/session_header.rb +4 -4
  62. data/lib/ruby_smb/smb1/file.rb +2 -10
  63. data/lib/ruby_smb/smb1/pipe.rb +2 -0
  64. data/lib/ruby_smb/smb2/file.rb +25 -17
  65. data/lib/ruby_smb/smb2/pipe.rb +3 -0
  66. data/lib/ruby_smb/smb2/tree.rb +9 -3
  67. data/lib/ruby_smb/version.rb +1 -1
  68. data/spec/lib/ruby_smb/client_spec.rb +161 -60
  69. data/spec/lib/ruby_smb/dcerpc/ndr_spec.rb +1396 -77
  70. data/spec/lib/ruby_smb/dcerpc/rpc_security_attributes_spec.rb +161 -0
  71. data/spec/lib/ruby_smb/dcerpc/rrp_unicode_string_spec.rb +49 -12
  72. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_request_spec.rb +191 -0
  73. data/spec/lib/ruby_smb/dcerpc/svcctl/change_service_config_w_response_spec.rb +38 -0
  74. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_request_spec.rb +30 -0
  75. data/spec/lib/ruby_smb/dcerpc/svcctl/close_service_handle_response_spec.rb +38 -0
  76. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_request_spec.rb +39 -0
  77. data/spec/lib/ruby_smb/dcerpc/svcctl/control_service_response_spec.rb +38 -0
  78. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_request_spec.rb +78 -0
  79. data/spec/lib/ruby_smb/dcerpc/svcctl/open_sc_manager_w_response_spec.rb +38 -0
  80. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_request_spec.rb +59 -0
  81. data/spec/lib/ruby_smb/dcerpc/svcctl/open_service_w_response_spec.rb +38 -0
  82. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_request_spec.rb +38 -0
  83. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_config_w_response_spec.rb +152 -0
  84. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_request_spec.rb +30 -0
  85. data/spec/lib/ruby_smb/dcerpc/svcctl/query_service_status_response_spec.rb +38 -0
  86. data/spec/lib/ruby_smb/dcerpc/svcctl/service_status_spec.rb +72 -0
  87. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_request_spec.rb +46 -0
  88. data/spec/lib/ruby_smb/dcerpc/svcctl/start_service_w_response_spec.rb +30 -0
  89. data/spec/lib/ruby_smb/dcerpc/svcctl_spec.rb +512 -0
  90. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_request_spec.rb +110 -0
  91. data/spec/lib/ruby_smb/dcerpc/winreg/create_key_response_spec.rb +44 -0
  92. data/spec/lib/ruby_smb/dcerpc/winreg/enum_key_request_spec.rb +0 -4
  93. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_request_spec.rb +2 -2
  94. data/spec/lib/ruby_smb/dcerpc/winreg/enum_value_response_spec.rb +2 -2
  95. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +9 -4
  96. data/spec/lib/ruby_smb/dcerpc/winreg/query_info_key_request_spec.rb +0 -4
  97. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_request_spec.rb +17 -17
  98. data/spec/lib/ruby_smb/dcerpc/winreg/query_value_response_spec.rb +11 -23
  99. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_request_spec.rb +57 -0
  100. data/spec/lib/ruby_smb/dcerpc/winreg/save_key_response_spec.rb +22 -0
  101. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +215 -41
  102. data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +10 -10
  103. data/spec/lib/ruby_smb/field/stringz16_spec.rb +12 -0
  104. data/spec/lib/ruby_smb/nbss/session_header_spec.rb +4 -11
  105. data/spec/lib/ruby_smb/smb1/pipe_spec.rb +7 -0
  106. data/spec/lib/ruby_smb/smb2/file_spec.rb +60 -6
  107. data/spec/lib/ruby_smb/smb2/pipe_spec.rb +7 -0
  108. data/spec/lib/ruby_smb/smb2/tree_spec.rb +35 -1
  109. metadata +72 -2
  110. metadata.gz.sig +0 -0
@@ -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
+
@@ -13,10 +13,6 @@ RSpec.describe RubySMB::Dcerpc::RrpUnicodeString do
13
13
  it 'should be a 16-bit unsigned integer' do
14
14
  expect(packet.buffer_length).to be_a BinData::Uint16le
15
15
  end
16
-
17
- it 'is set to 0 when #buffer in empty' do
18
- expect(packet.buffer_length).to eq(0)
19
- end
20
16
  end
21
17
 
22
18
  describe '#maximum_length' do
@@ -54,23 +50,44 @@ RSpec.describe RubySMB::Dcerpc::RrpUnicodeString do
54
50
  expect(packet.maximum_length).to eq(('spec_test'.size + 1) * 2)
55
51
  end
56
52
 
57
- context 'when the value is 0' do
53
+ context 'when the value is :null' do
58
54
  it 'sets #buffer_length to 0' do
59
- packet.set(0)
55
+ packet.buffer_length = 33
56
+ packet.set(:null)
60
57
  expect(packet.buffer_length).to eq(0)
61
58
  end
62
59
 
63
- it 'sets #maximum_length to 0' do
64
- packet.set(0)
65
- expect(packet.maximum_length).to eq(0)
60
+ it 'does not set #maximum_length if it has already been set' do
61
+ packet.maximum_length = 33
62
+ packet.set(:null)
63
+ expect(packet.maximum_length).to eq(33)
64
+ end
65
+ end
66
+ end
67
+
68
+ describe '#read' do
69
+ context 'with a null pointer' do
70
+ it 'reads its own binary representation' do
71
+ raw = packet.to_binary_s
72
+ expect(described_class.read(raw)).to eq(packet)
73
+ expect(described_class.read(raw).to_binary_s).to eq(raw)
74
+ end
75
+ end
76
+
77
+ context 'with a normal string' do
78
+ it 'reads its own binary representation' do
79
+ packet.assign('my_test')
80
+ raw = packet.to_binary_s
81
+ expect(described_class.read(raw)).to eq(packet)
82
+ expect(described_class.read(raw).to_binary_s).to eq(raw)
66
83
  end
67
84
  end
68
85
  end
69
86
  end
70
87
 
71
88
  RSpec.describe RubySMB::Dcerpc::PrrpUnicodeString do
72
- it 'is NdrTopLevelFullPointer subclass' do
73
- expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrTopLevelFullPointer
89
+ it 'is NdrPointer subclass' do
90
+ expect(described_class).to be < RubySMB::Dcerpc::Ndr::NdrPointer
74
91
  end
75
92
 
76
93
  subject(:packet) { described_class.new }
@@ -87,12 +104,32 @@ RSpec.describe RubySMB::Dcerpc::PrrpUnicodeString do
87
104
  end
88
105
 
89
106
  it 'exists if superclass #referent_identifier is not zero' do
107
+ packet.referent_id = 0xCCCC
90
108
  expect(packet.referent?).to be true
91
109
  end
92
110
 
93
111
  it 'does not exist if superclass #referent_identifier is zero' do
94
- packet.referent_identifier = 0
112
+ packet.referent_id = 0
95
113
  expect(packet.referent?).to be false
96
114
  end
97
115
  end
116
+
117
+ describe '#read' do
118
+ context 'with a null pointer' do
119
+ it 'reads its own binary representation' do
120
+ raw = packet.to_binary_s
121
+ expect(described_class.read(raw)).to eq(packet)
122
+ expect(described_class.read(raw).to_binary_s).to eq(raw)
123
+ end
124
+ end
125
+
126
+ context 'with a normal string' do
127
+ it 'reads its own binary representation' do
128
+ packet.assign('my_test')
129
+ raw = packet.to_binary_s
130
+ expect(described_class.read(raw)).to eq(packet)
131
+ expect(described_class.read(raw).to_binary_s).to eq(raw)
132
+ end
133
+ end
134
+ end
98
135
  end
@@ -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
+