|
253 | 253 | let(:wp_body) { nil }
|
254 | 254 | let(:wp_path) { '/test/' }
|
255 | 255 | let(:wp_fixed_version) { nil }
|
| 256 | + let(:wp_regex) { /(?:Version):\s*([0-9a-z.-]+)/i } |
256 | 257 |
|
257 | 258 | context 'when no file is found' do
|
258 | 259 | let(:wp_code) { 404 }
|
259 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Unknown) } |
| 260 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Unknown) } |
260 | 261 | end
|
261 | 262 |
|
262 | 263 | context 'when no version can be extracted from style' do
|
263 | 264 | let(:wp_code) { 200 }
|
264 | 265 | let(:wp_body) { 'invalid content' }
|
265 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Detected) } |
| 266 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Detected) } |
266 | 267 | end
|
267 | 268 |
|
268 | 269 | context 'when version from style has arbitrary leading whitespace' do
|
269 | 270 | let(:wp_code) { 200 }
|
270 | 271 | let(:wp_fixed_version) { '1.0.1' }
|
271 | 272 | let(:wp_body) { 'Version: 1.0.0' }
|
272 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
| 273 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
273 | 274 | let(:wp_body) { 'Version:1.0.0' }
|
274 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
| 275 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
275 | 276 | end
|
276 | 277 |
|
277 | 278 | context 'when installed version is vulnerable' do
|
278 | 279 | let(:wp_code) { 200 }
|
279 | 280 | let(:wp_fixed_version) { '1.0.1' }
|
280 | 281 | let(:wp_body) { 'Version: 1.0.0' }
|
281 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
| 282 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) } |
282 | 283 | end
|
283 | 284 |
|
284 | 285 | context 'when installed version is not vulnerable' do
|
285 | 286 | let(:wp_code) { 200 }
|
286 | 287 | let(:wp_fixed_version) { '1.0.1' }
|
287 | 288 | let(:wp_body) { 'Version: 1.0.2' }
|
288 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) } |
| 289 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) } |
289 | 290 | end
|
290 | 291 |
|
291 | 292 | context 'when installed version is vulnerable (version range)' do
|
292 | 293 | let(:wp_code) { 200 }
|
293 | 294 | let(:wp_fixed_version) { '1.0.2' }
|
294 | 295 | let(:wp_introd_version) { '1.0.0' }
|
295 | 296 | let(:wp_body) { 'Version: 1.0.1' }
|
296 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Appears) } |
| 297 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Appears) } |
297 | 298 | end
|
298 | 299 |
|
299 | 300 | context 'when installed version is older (version range)' do
|
300 | 301 | let(:wp_code) { 200 }
|
301 | 302 | let(:wp_fixed_version) { '1.0.1' }
|
302 | 303 | let(:wp_introd_version) { '1.0.0' }
|
303 | 304 | let(:wp_body) { 'Version: 0.0.9' }
|
304 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) } |
| 305 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) } |
305 | 306 | end
|
306 | 307 |
|
307 | 308 | context 'when installed version is newer (version range)' do
|
308 | 309 | let(:wp_code) { 200 }
|
309 | 310 | let(:wp_fixed_version) { '1.0.1' }
|
310 | 311 | let(:wp_introd_version) { '1.0.0' }
|
311 | 312 | let(:wp_body) { 'Version: 1.0.2' }
|
312 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) } |
| 313 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) } |
313 | 314 | end
|
314 | 315 |
|
315 | 316 | context 'when installed version is newer (text in version number)' do
|
316 | 317 | let(:wp_code) { 200 }
|
317 | 318 | let(:wp_fixed_version) { '1.5.3' }
|
318 | 319 | let(:wp_body) { 'Version: 2.0.0-beta1' }
|
319 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) } |
| 320 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex, wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) } |
320 | 321 | end
|
321 | 322 |
|
322 | 323 | context 'when all versions are vulnerable' do
|
323 | 324 | let(:wp_code) { 200 }
|
324 | 325 | let(:wp_body) { 'Version: 1.0.0' }
|
325 |
| - it { expect(subject.send(:check_version_from_custom_file, wp_path)).to be(Msf::Exploit::CheckCode::Appears) } |
| 326 | + it { expect(subject.send(:check_version_from_custom_file, wp_path, wp_regex)).to be(Msf::Exploit::CheckCode::Appears) } |
326 | 327 | end
|
327 | 328 | end
|
328 | 329 |
|
|
0 commit comments