ronin-exploits 1.0.0.beta2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/README.md +29 -13
  4. data/gemspec.yml +10 -8
  5. data/lib/ronin/exploits/cli/commands/new.rb +1 -1
  6. data/lib/ronin/exploits/cli/commands/run.rb +55 -5
  7. data/lib/ronin/exploits/exploit.rb +7 -5
  8. data/lib/ronin/exploits/lfi.rb +1 -1
  9. data/lib/ronin/exploits/metadata/arch.rb +1 -1
  10. data/lib/ronin/exploits/metadata/default_filename.rb +1 -1
  11. data/lib/ronin/exploits/metadata/default_port.rb +1 -1
  12. data/lib/ronin/exploits/mixins/file_builder.rb +2 -2
  13. data/lib/ronin/exploits/mixins/nops.rb +1 -1
  14. data/lib/ronin/exploits/params/base_url.rb +1 -1
  15. data/lib/ronin/exploits/version.rb +1 -1
  16. data/ronin-exploits.gemspec +2 -1
  17. metadata +24 -129
  18. data/spec/advisory_spec.rb +0 -71
  19. data/spec/cli/exploit_command_spec.rb +0 -68
  20. data/spec/cli/exploit_methods_spec.rb +0 -208
  21. data/spec/cli/ruby_shell_spec.rb +0 -14
  22. data/spec/client_side_web_vuln_spec.rb +0 -117
  23. data/spec/exploit_spec.rb +0 -538
  24. data/spec/exploits_spec.rb +0 -8
  25. data/spec/heap_overflow_spec.rb +0 -14
  26. data/spec/lfi_spec.rb +0 -162
  27. data/spec/loot/file_spec.rb +0 -131
  28. data/spec/loot_spec.rb +0 -138
  29. data/spec/memory_corruption_spec.rb +0 -22
  30. data/spec/metadata/arch_spec.rb +0 -82
  31. data/spec/metadata/cookie_param_spec.rb +0 -67
  32. data/spec/metadata/default_filename_spec.rb +0 -62
  33. data/spec/metadata/default_port_spec.rb +0 -62
  34. data/spec/metadata/header_name_spec.rb +0 -67
  35. data/spec/metadata/os_spec.rb +0 -164
  36. data/spec/metadata/shouts_spec.rb +0 -100
  37. data/spec/metadata/url_path_spec.rb +0 -67
  38. data/spec/metadata/url_query_param_spec.rb +0 -67
  39. data/spec/mixins/binary_spec.rb +0 -129
  40. data/spec/mixins/build_dir.rb +0 -66
  41. data/spec/mixins/file_builder_spec.rb +0 -67
  42. data/spec/mixins/format_string_spec.rb +0 -44
  43. data/spec/mixins/has_payload_spec.rb +0 -333
  44. data/spec/mixins/has_targets_spec.rb +0 -434
  45. data/spec/mixins/html_spec.rb +0 -772
  46. data/spec/mixins/http_spec.rb +0 -1227
  47. data/spec/mixins/loot_spec.rb +0 -20
  48. data/spec/mixins/nops_spec.rb +0 -165
  49. data/spec/mixins/remote_tcp_spec.rb +0 -217
  50. data/spec/mixins/remote_udp_spec.rb +0 -217
  51. data/spec/mixins/seh_spec.rb +0 -89
  52. data/spec/mixins/stack_overflow_spec.rb +0 -87
  53. data/spec/mixins/text_spec.rb +0 -43
  54. data/spec/open_redirect_spec.rb +0 -71
  55. data/spec/params/base_url_spec.rb +0 -71
  56. data/spec/params/bind_host_spec.rb +0 -34
  57. data/spec/params/bind_port_spec.rb +0 -35
  58. data/spec/params/filename_spec.rb +0 -77
  59. data/spec/params/host_spec.rb +0 -34
  60. data/spec/params/port_spec.rb +0 -77
  61. data/spec/rfi_spec.rb +0 -107
  62. data/spec/seh_overflow_spec.rb +0 -18
  63. data/spec/spec_helper.rb +0 -8
  64. data/spec/sqli_spec.rb +0 -306
  65. data/spec/ssti_spec.rb +0 -121
  66. data/spec/stack_overflow_spec.rb +0 -18
  67. data/spec/target_spec.rb +0 -92
  68. data/spec/test_result_spec.rb +0 -32
  69. data/spec/use_after_free_spec.rb +0 -14
  70. data/spec/web_spec.rb +0 -12
  71. data/spec/web_vuln_spec.rb +0 -854
  72. data/spec/xss_spec.rb +0 -69
@@ -1,1227 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/exploits/mixins/http'
3
- require 'ronin/exploits/exploit'
4
-
5
- describe Ronin::Exploits::Mixins::HTTP do
6
- module TestMixinsHTTP
7
- class TestExploit < Ronin::Exploits::Exploit
8
- include Ronin::Exploits::Mixins::HTTP
9
- end
10
-
11
- class TestExploitWithDefaultHeaders < Ronin::Exploits::Exploit
12
- include Ronin::Exploits::Mixins::HTTP
13
-
14
- def http_headers
15
- {'X-Foo' => 'bar'}
16
- end
17
- end
18
- end
19
-
20
- let(:test_class) { TestMixinsHTTP::TestExploit }
21
-
22
- describe ".included" do
23
- subject { test_class }
24
-
25
- it "must define a 'http_proxy' param" do
26
- expect(subject.params[:http_proxy]).to_not be_nil
27
- expect(subject.params[:http_proxy].desc).to eq("The HTTP proxy to use")
28
- end
29
-
30
- it "must define a 'user_agent' param" do
31
- expect(subject.params[:user_agent]).to_not be_nil
32
- expect(subject.params[:user_agent].type).to be_kind_of(Ronin::Core::Params::Types::Enum)
33
- expect(subject.params[:user_agent].type.values).to eq(
34
- [
35
- :random,
36
- :chrome,
37
- :firefox,
38
- :safari,
39
- :linux,
40
- :macos,
41
- :windows,
42
- :iphone,
43
- :ipad,
44
- :android
45
- ] + Ronin::Support::Network::HTTP::UserAgents::ALIASES.keys
46
- )
47
- expect(subject.params[:user_agent].desc).to eq("The HTTP User-Agent to select")
48
- end
49
-
50
- it "must define a 'raw_user_agent' param" do
51
- expect(subject.params[:raw_user_agent]).to_not be_nil
52
- expect(subject.params[:raw_user_agent].desc).to eq("The raw HTTP User-Agent string to use")
53
- end
54
- end
55
-
56
- let(:base_url) { URI.parse("https://www.example.com/base") }
57
-
58
- subject do
59
- test_class.new(params: {base_url: base_url})
60
- end
61
-
62
- describe "#http_proxy" do
63
- let(:proxy) { 'http://example.com:8080' }
64
-
65
- subject do
66
- test_class.new(params: {base_url: base_url, http_proxy: proxy})
67
- end
68
-
69
- it "must return params[:http_proxy]" do
70
- expect(subject.http_proxy).to be(subject.params[:http_proxy])
71
- end
72
- end
73
-
74
- describe "#http_headers" do
75
- it "must return an empty Hash by default" do
76
- expect(subject.http_headers).to eq({})
77
- end
78
- end
79
-
80
- describe "#http_user_agent" do
81
- context "when params[:user_agent] is set" do
82
- let(:user_agent) { :random }
83
-
84
- subject do
85
- test_class.new(
86
- params: {
87
- base_url: base_url,
88
- user_agent: user_agent
89
- }
90
- )
91
- end
92
-
93
- it "must return params[:user_agent]" do
94
- expect(subject.http_user_agent).to be(subject.params[:user_agent])
95
- end
96
- end
97
-
98
- context "when params[:raw_user_agent] is set" do
99
- let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
100
-
101
- subject do
102
- test_class.new(
103
- params: {
104
- base_url: base_url,
105
- raw_user_agent: raw_user_agent
106
- }
107
- )
108
- end
109
-
110
- it "must return params[:raw_user_agent]" do
111
- expect(subject.http_user_agent).to be(
112
- subject.params[:raw_user_agent]
113
- )
114
- end
115
- end
116
-
117
- context "when both params[:user_agent] and params[:raw_user_agent] are set" do
118
- let(:user_agent) { :random }
119
- let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
120
-
121
- subject do
122
- test_class.new(
123
- params: {
124
- base_url: base_url,
125
- user_agent: user_agent,
126
- raw_user_agent: raw_user_agent
127
- }
128
- )
129
- end
130
-
131
- it "must return params[:raw_user_agent]" do
132
- expect(subject.http_user_agent).to be(
133
- subject.params[:raw_user_agent]
134
- )
135
- end
136
- end
137
- end
138
-
139
- describe "#http_cookie" do
140
- context "when the http_cookie param is set" do
141
- let(:cookie) { "foo=1; bar=2" }
142
-
143
- subject do
144
- test_class.new(
145
- params: {
146
- base_url: base_url,
147
- http_cookie: cookie
148
- }
149
- )
150
- end
151
-
152
- it "must return params[:http_cookie]" do
153
- expect(subject.http_cookie).to eq(cookie)
154
- end
155
- end
156
- end
157
-
158
- let(:proxy) { URI('https://proxy.example.com:8080') }
159
- let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
160
- let(:cookie) { "foo=1; bar=2" }
161
- let(:user) { 'bob' }
162
- let(:password) { 'secret' }
163
-
164
- subject do
165
- test_class.new(
166
- params: {
167
- base_url: base_url,
168
- http_proxy: proxy,
169
- raw_user_agent: raw_user_agent,
170
- http_cookie: cookie,
171
- http_user: user,
172
- http_password: password
173
- }
174
- )
175
- end
176
-
177
- describe "#http" do
178
- it "must call Ronin::Support::Network::HTTP.connect_uri with #params[:base_url], proxy: #http_proxy, headers: #http_headers, user_agent: #http_user_agent, cookie: #http_cookie, user: #http_user, password: #http_password" do
179
- expect(Ronin::Support::Network::HTTP).to receive(:connect_uri).with(
180
- subject.params[:base_url], proxy: subject.http_proxy,
181
- headers: subject.http_headers,
182
- user_agent: subject.http_user_agent,
183
- cookie: subject.http_cookie,
184
- user: subject.http_user,
185
- password: subject.http_password
186
- )
187
-
188
- subject.http
189
- end
190
-
191
- it "must return a Ronin::Support::Network::HTTP instance" do
192
- expect(subject.http).to be_kind_of(Ronin::Support::Network::HTTP)
193
- end
194
-
195
- it "must return the same instance each time" do
196
- expect(subject.http).to be(subject.http)
197
- end
198
-
199
- context "when #http_headers is overriden" do
200
- let(:test_class) { TestMixinsHTTP::TestExploitWithDefaultHeaders }
201
-
202
- it "must initialize #http.headers to the value of #http_headers" do
203
- expect(subject.http.headers).to eq(subject.http_headers)
204
- end
205
- end
206
- end
207
-
208
- describe "#http_request" do
209
- context "when given a request method and a path" do
210
- let(:request_method) { :get }
211
- let(:path) { '/foo' }
212
-
213
- it "must call #http.request with the request method and path" do
214
- expect(subject.http).to receive(:request).with(request_method,path)
215
-
216
- subject.http_request(request_method,path)
217
- end
218
-
219
- context "when debug messages are enabled" do
220
- before { Ronin::Support::CLI::Printing.debug = true }
221
-
222
- it "must print a debugging message" do
223
- url = subject.url_for(path)
224
-
225
- allow(subject.http).to receive(:request).with(
226
- request_method, path
227
- )
228
-
229
- expect(subject).to receive(:print_debug).with(
230
- "Sending #{request_method.upcase} request to #{url} ..."
231
- )
232
-
233
- subject.http_request(request_method,path)
234
- end
235
-
236
- after { Ronin::Support::CLI::Printing.debug = false }
237
- end
238
- end
239
- end
240
-
241
- describe "#http_response_status" do
242
- context "when given a request method and a path" do
243
- let(:request_method) { :get }
244
- let(:path) { '/foo' }
245
-
246
- it "must call #http.response_status with the request method and path" do
247
- expect(subject.http).to receive(:response_status).with(
248
- request_method, path
249
- )
250
-
251
- subject.http_response_status(request_method,path)
252
- end
253
-
254
- context "when debug messages are enabled" do
255
- before { Ronin::Support::CLI::Printing.debug = true }
256
-
257
- it "must print a debugging message" do
258
- url = subject.url_for(path)
259
-
260
- allow(subject.http).to receive(:response_status).with(
261
- request_method, path
262
- )
263
-
264
- expect(subject).to receive(:print_debug).with(
265
- "Checking response status for #{request_method.upcase} #{url} ..."
266
- )
267
-
268
- subject.http_response_status(request_method,path)
269
- end
270
-
271
- after { Ronin::Support::CLI::Printing.debug = false }
272
- end
273
- end
274
- end
275
-
276
- describe "#http_ok?" do
277
- context "when given a path" do
278
- let(:path) { '/foo' }
279
-
280
- it "must call #http.ok? with :head and the path" do
281
- expect(subject.http).to receive(:ok?).with(:head,path)
282
-
283
- subject.http_ok?(path)
284
- end
285
-
286
- context "when debug messages are enabled" do
287
- before { Ronin::Support::CLI::Printing.debug = true }
288
-
289
- it "must print a debugging message" do
290
- url = subject.url_for(path)
291
-
292
- allow(subject.http).to receive(:ok?).with(:head,path)
293
-
294
- expect(subject).to receive(:print_debug).with(
295
- "Checking if response status for HEAD #{url} is 200 ..."
296
- )
297
-
298
- subject.http_ok?(path)
299
- end
300
-
301
- after { Ronin::Support::CLI::Printing.debug = false }
302
- end
303
- end
304
-
305
- context "when given a request method and a path" do
306
- let(:request_method) { :get }
307
- let(:path) { '/foo' }
308
-
309
- it "must call #http.ok? with the request method and the path" do
310
- expect(subject.http).to receive(:ok?).with(request_method,path)
311
-
312
- subject.http_ok?(request_method,path)
313
- end
314
-
315
- context "when debug messages are enabled" do
316
- before { Ronin::Support::CLI::Printing.debug = true }
317
-
318
- it "must print a debugging message" do
319
- url = subject.url_for(path)
320
-
321
- allow(subject.http).to receive(:ok?).with(request_method,path)
322
-
323
- expect(subject).to receive(:print_debug).with(
324
- "Checking if response status for #{request_method.upcase} #{url} is 200 ..."
325
- )
326
-
327
- subject.http_ok?(request_method,path)
328
- end
329
-
330
- after { Ronin::Support::CLI::Printing.debug = false }
331
- end
332
- end
333
- end
334
-
335
- describe "#http_response_headers" do
336
- context "when given a path" do
337
- let(:request_method) { :get }
338
- let(:path) { '/foo' }
339
-
340
- it "must call #http.ok? with :head and the path" do
341
- expect(subject.http).to receive(:response_headers).with(:head,path)
342
-
343
- subject.http_response_headers(path)
344
- end
345
-
346
- context "when debug messages are enabled" do
347
- before { Ronin::Support::CLI::Printing.debug = true }
348
-
349
- it "must print a debugging message" do
350
- url = subject.url_for(path)
351
-
352
- allow(subject.http).to receive(:response_headers).with(:head,path)
353
-
354
- expect(subject).to receive(:print_debug).with(
355
- "Requesting response headers for HEAD #{url} ..."
356
- )
357
-
358
- subject.http_response_headers(path)
359
- end
360
-
361
- after { Ronin::Support::CLI::Printing.debug = false }
362
- end
363
- end
364
-
365
- context "when given a request method and a path" do
366
- let(:request_method) { :get }
367
- let(:path) { '/foo' }
368
-
369
- it "must call #http.ok? with the request method and the path" do
370
- expect(subject.http).to receive(:response_headers).with(
371
- request_method, path
372
- )
373
-
374
- subject.http_response_headers(request_method,path)
375
- end
376
-
377
- context "when debug messages are enabled" do
378
- before { Ronin::Support::CLI::Printing.debug = true }
379
-
380
- it "must print a debugging message" do
381
- url = subject.url_for(path)
382
-
383
- allow(subject.http).to receive(:response_headers).with(
384
- request_method, path
385
- )
386
-
387
- expect(subject).to receive(:print_debug).with(
388
- "Requesting response headers for #{request_method.upcase} #{url} ..."
389
- )
390
-
391
- subject.http_response_headers(request_method,path)
392
- end
393
-
394
- after { Ronin::Support::CLI::Printing.debug = false }
395
- end
396
- end
397
- end
398
-
399
- describe "#http_server_header" do
400
- context "when given a path" do
401
- let(:path) { '/foo' }
402
-
403
- it "must call #http.server_header with the path and method: :head" do
404
- expect(subject.http).to receive(:server_header).with(
405
- path, method: :head
406
- )
407
-
408
- subject.http_server_header(path)
409
- end
410
-
411
- context "when debug messages are enabled" do
412
- before { Ronin::Support::CLI::Printing.debug = true }
413
-
414
- it "must print a debugging message" do
415
- url = subject.url_for(path)
416
-
417
- allow(subject.http).to receive(:server_header).with(
418
- path, method: :head
419
- )
420
-
421
- expect(subject).to receive(:print_debug).with(
422
- "Requesting the 'Server' header for HEAD #{url} ..."
423
- )
424
-
425
- subject.http_server_header(path)
426
- end
427
-
428
- after { Ronin::Support::CLI::Printing.debug = false }
429
- end
430
- end
431
-
432
- context "when given a path and the method: keyword argument" do
433
- let(:request_method) { :get }
434
- let(:path) { '/foo' }
435
-
436
- it "must call #http.server_header with the path and the method: keyword argument" do
437
- expect(subject.http).to receive(:server_header).with(
438
- path, method: request_method
439
- )
440
-
441
- subject.http_server_header(path, method: request_method)
442
- end
443
-
444
- context "when debug messages are enabled" do
445
- before { Ronin::Support::CLI::Printing.debug = true }
446
-
447
- it "must print a debugging message" do
448
- url = subject.url_for(path)
449
-
450
- allow(subject.http).to receive(:server_header).with(
451
- path, method: request_method
452
- )
453
-
454
- expect(subject).to receive(:print_debug).with(
455
- "Requesting the 'Server' header for #{request_method.upcase} #{url} ..."
456
- )
457
-
458
- subject.http_server_header(path, method: request_method)
459
- end
460
-
461
- after { Ronin::Support::CLI::Printing.debug = false }
462
- end
463
- end
464
- end
465
-
466
- describe "#http_powered_by_header" do
467
- context "when given a path" do
468
- let(:path) { '/foo' }
469
-
470
- it "must call #http.powered_by_header with the path and method: :head" do
471
- expect(subject.http).to receive(:powered_by_header).with(
472
- path, method: :head
473
- )
474
-
475
- subject.http_powered_by_header(path)
476
- end
477
-
478
- context "when debug messages are enabled" do
479
- before { Ronin::Support::CLI::Printing.debug = true }
480
-
481
- it "must print a debugging message" do
482
- url = subject.url_for(path)
483
-
484
- allow(subject.http).to receive(:powered_by_header).with(
485
- path, method: :head
486
- )
487
-
488
- expect(subject).to receive(:print_debug).with(
489
- "Requesting the 'X-Powered-By' header for HEAD #{url} ..."
490
- )
491
-
492
- subject.http_powered_by_header(path)
493
- end
494
-
495
- after { Ronin::Support::CLI::Printing.debug = false }
496
- end
497
- end
498
-
499
- context "when given a path and a method: keyword argument" do
500
- let(:request_method) { :get }
501
- let(:path) { '/foo' }
502
-
503
- it "must call #http.powered_by_header with the path and the method: keyword argument" do
504
- expect(subject.http).to receive(:powered_by_header).with(
505
- path, method: request_method,
506
- )
507
-
508
- subject.http_powered_by_header(path, method: request_method)
509
- end
510
-
511
- context "when debug messages are enabled" do
512
- before { Ronin::Support::CLI::Printing.debug = true }
513
-
514
- it "must print a debugging message" do
515
- url = subject.url_for(path)
516
-
517
- allow(subject.http).to receive(:powered_by_header).with(
518
- path, method: request_method
519
- )
520
-
521
- expect(subject).to receive(:print_debug).with(
522
- "Requesting the 'X-Powered-By' header for #{request_method.upcase} #{url} ..."
523
- )
524
-
525
- subject.http_powered_by_header(path, method: request_method)
526
- end
527
-
528
- after { Ronin::Support::CLI::Printing.debug = false }
529
- end
530
- end
531
- end
532
-
533
- describe "#http_response_body" do
534
- context "when given a path" do
535
- let(:path) { '/foo' }
536
-
537
- it "must call #http.response_body with :head and the path" do
538
- expect(subject.http).to receive(:response_body).with(:get,path)
539
-
540
- subject.http_response_body(path)
541
- end
542
-
543
- context "when debug messages are enabled" do
544
- before { Ronin::Support::CLI::Printing.debug = true }
545
-
546
- it "must print a debugging message" do
547
- url = subject.url_for(path)
548
-
549
- allow(subject.http).to receive(:response_body).with(
550
- :get, path
551
- )
552
-
553
- expect(subject).to receive(:print_debug).with(
554
- "Requesting response body for GET #{url} ..."
555
- )
556
-
557
- subject.http_response_body(path)
558
- end
559
-
560
- after { Ronin::Support::CLI::Printing.debug = false }
561
- end
562
- end
563
-
564
- context "when given a request method and a path" do
565
- let(:request_method) { :head }
566
- let(:path) { '/foo' }
567
-
568
- it "must call #http.response_body with request method and the path" do
569
- expect(subject.http).to receive(:response_body).with(
570
- request_method, path
571
- )
572
-
573
- subject.http_response_body(request_method,path)
574
- end
575
-
576
- context "when debug messages are enabled" do
577
- before { Ronin::Support::CLI::Printing.debug = true }
578
-
579
- it "must print a debugging message" do
580
- url = subject.url_for(path)
581
-
582
- allow(subject.http).to receive(:response_body).with(
583
- request_method, path
584
- )
585
-
586
- expect(subject).to receive(:print_debug).with(
587
- "Requesting response body for #{request_method.upcase} #{url} ..."
588
- )
589
-
590
- subject.http_response_body(request_method,path)
591
- end
592
-
593
- after { Ronin::Support::CLI::Printing.debug = false }
594
- end
595
- end
596
- end
597
-
598
- describe "#http_copy" do
599
- context "when given a path" do
600
- let(:path) { '/foo' }
601
-
602
- it "must call #http.copy with the path" do
603
- expect(subject.http).to receive(:copy).with(path)
604
-
605
- subject.http_copy(path)
606
- end
607
-
608
- context "when debug messages are enabled" do
609
- before { Ronin::Support::CLI::Printing.debug = true }
610
-
611
- it "must print a debugging message" do
612
- url = subject.url_for(path)
613
-
614
- allow(subject.http).to receive(:copy).with(path)
615
-
616
- expect(subject).to receive(:print_debug).with(
617
- "Requesting COPY #{url} ..."
618
- )
619
-
620
- subject.http_copy(path)
621
- end
622
-
623
- after { Ronin::Support::CLI::Printing.debug = false }
624
- end
625
- end
626
- end
627
-
628
- describe "#http_delete" do
629
- context "when given a path" do
630
- let(:path) { '/foo' }
631
-
632
- it "must call #http.delete with the path" do
633
- expect(subject.http).to receive(:delete).with(path)
634
-
635
- subject.http_delete(path)
636
- end
637
-
638
- context "when debug messages are enabled" do
639
- before { Ronin::Support::CLI::Printing.debug = true }
640
-
641
- it "must print a debugging message" do
642
- url = subject.url_for(path)
643
-
644
- allow(subject.http).to receive(:delete).with(path)
645
-
646
- expect(subject).to receive(:print_debug).with(
647
- "Requesting DELETE #{url} ..."
648
- )
649
-
650
- subject.http_delete(path)
651
- end
652
-
653
- after { Ronin::Support::CLI::Printing.debug = false }
654
- end
655
- end
656
- end
657
-
658
- describe "#http_get" do
659
- context "when given a path" do
660
- let(:path) { '/foo' }
661
-
662
- it "must call #http.get with the path" do
663
- expect(subject.http).to receive(:get).with(path)
664
-
665
- subject.http_get(path)
666
- end
667
-
668
- context "when debug messages are enabled" do
669
- before { Ronin::Support::CLI::Printing.debug = true }
670
-
671
- it "must print a debugging message" do
672
- url = subject.url_for(path)
673
-
674
- allow(subject.http).to receive(:get).with(path)
675
-
676
- expect(subject).to receive(:print_debug).with(
677
- "Requesting GET #{url} ..."
678
- )
679
-
680
- subject.http_get(path)
681
- end
682
-
683
- after { Ronin::Support::CLI::Printing.debug = false }
684
- end
685
- end
686
- end
687
-
688
- describe "#http_get_headers" do
689
- context "when given a path" do
690
- let(:path) { '/foo' }
691
-
692
- it "must call #http.get_headers with the path" do
693
- expect(subject.http).to receive(:get_headers).with(path)
694
-
695
- subject.http_get_headers(path)
696
- end
697
-
698
- context "when debug messages are enabled" do
699
- before { Ronin::Support::CLI::Printing.debug = true }
700
-
701
- it "must print a debugging message" do
702
- url = subject.url_for(path)
703
-
704
- allow(subject.http).to receive(:get_headers).with(path)
705
-
706
- expect(subject).to receive(:print_debug).with(
707
- "Requesting headers for GET #{url} ..."
708
- )
709
-
710
- subject.http_get_headers(path)
711
- end
712
-
713
- after { Ronin::Support::CLI::Printing.debug = false }
714
- end
715
- end
716
- end
717
-
718
- describe "#http_get_cookies" do
719
- context "when given a path" do
720
- let(:path) { '/foo' }
721
-
722
- it "must call #http.get_cookies with the path" do
723
- expect(subject.http).to receive(:get_cookies).with(path)
724
-
725
- subject.http_get_cookies(path)
726
- end
727
-
728
- context "when debug messages are enabled" do
729
- before { Ronin::Support::CLI::Printing.debug = true }
730
-
731
- it "must print a debugging message" do
732
- url = subject.url_for(path)
733
-
734
- allow(subject.http).to receive(:get_cookies).with(path)
735
-
736
- expect(subject).to receive(:print_debug).with(
737
- "Getting cookies for #{url} ..."
738
- )
739
-
740
- subject.http_get_cookies(path)
741
- end
742
-
743
- after { Ronin::Support::CLI::Printing.debug = false }
744
- end
745
- end
746
- end
747
-
748
- describe "#http_get_body" do
749
- context "when given a path" do
750
- let(:path) { '/foo' }
751
-
752
- it "must call #http.get_body with the path" do
753
- expect(subject.http).to receive(:get_body).with(path)
754
-
755
- subject.http_get_body(path)
756
- end
757
-
758
- context "when debug messages are enabled" do
759
- before { Ronin::Support::CLI::Printing.debug = true }
760
-
761
- it "must print a debugging message" do
762
- url = subject.url_for(path)
763
-
764
- allow(subject.http).to receive(:get_body).with(path)
765
-
766
- expect(subject).to receive(:print_debug).with(
767
- "Requesting body for GET #{url} ..."
768
- )
769
-
770
- subject.http_get_body(path)
771
- end
772
-
773
- after { Ronin::Support::CLI::Printing.debug = false }
774
- end
775
- end
776
- end
777
-
778
- describe "#http_head" do
779
- context "when given a path" do
780
- let(:path) { '/foo' }
781
-
782
- it "must call #http.head with the path" do
783
- expect(subject.http).to receive(:head).with(path)
784
-
785
- subject.http_head(path)
786
- end
787
-
788
- context "when debug messages are enabled" do
789
- before { Ronin::Support::CLI::Printing.debug = true }
790
-
791
- it "must print a debugging message" do
792
- url = subject.url_for(path)
793
-
794
- allow(subject.http).to receive(:head).with(path)
795
-
796
- expect(subject).to receive(:print_debug).with(
797
- "Requesting HEAD #{url} ..."
798
- )
799
-
800
- subject.http_head(path)
801
- end
802
-
803
- after { Ronin::Support::CLI::Printing.debug = false }
804
- end
805
- end
806
- end
807
-
808
- describe "#http_lock" do
809
- context "when given a path" do
810
- let(:path) { '/foo' }
811
-
812
- it "must call #http.lock with the path" do
813
- expect(subject.http).to receive(:lock).with(path)
814
-
815
- subject.http_lock(path)
816
- end
817
-
818
- context "when debug messages are enabled" do
819
- before { Ronin::Support::CLI::Printing.debug = true }
820
-
821
- it "must print a debugging message" do
822
- url = subject.url_for(path)
823
-
824
- allow(subject.http).to receive(:lock).with(path)
825
-
826
- expect(subject).to receive(:print_debug).with(
827
- "Requesting LOCK #{url} ..."
828
- )
829
-
830
- subject.http_lock(path)
831
- end
832
-
833
- after { Ronin::Support::CLI::Printing.debug = false }
834
- end
835
- end
836
- end
837
-
838
- describe "#http_mkcol" do
839
- context "when given a path" do
840
- let(:path) { '/foo' }
841
-
842
- it "must call #http.mkcol with the path" do
843
- expect(subject.http).to receive(:mkcol).with(path)
844
-
845
- subject.http_mkcol(path)
846
- end
847
-
848
- context "when debug messages are enabled" do
849
- before { Ronin::Support::CLI::Printing.debug = true }
850
-
851
- it "must print a debugging message" do
852
- url = subject.url_for(path)
853
-
854
- allow(subject.http).to receive(:mkcol).with(path)
855
-
856
- expect(subject).to receive(:print_debug).with(
857
- "Requesting MKCOL #{url} ..."
858
- )
859
-
860
- subject.http_mkcol(path)
861
- end
862
-
863
- after { Ronin::Support::CLI::Printing.debug = false }
864
- end
865
- end
866
- end
867
-
868
- describe "#http_move" do
869
- context "when given a path" do
870
- let(:path) { '/foo' }
871
-
872
- it "must call #http.move with the path" do
873
- expect(subject.http).to receive(:move).with(path)
874
-
875
- subject.http_move(path)
876
- end
877
-
878
- context "when debug messages are enabled" do
879
- before { Ronin::Support::CLI::Printing.debug = true }
880
-
881
- it "must print a debugging message" do
882
- url = subject.url_for(path)
883
-
884
- allow(subject.http).to receive(:move).with(path)
885
-
886
- expect(subject).to receive(:print_debug).with(
887
- "Requesting MOVE #{url} ..."
888
- )
889
-
890
- subject.http_move(path)
891
- end
892
-
893
- after { Ronin::Support::CLI::Printing.debug = false }
894
- end
895
- end
896
- end
897
-
898
- describe "#http_options" do
899
- context "when given a path" do
900
- let(:path) { '/foo' }
901
-
902
- it "must call #http.options with the path" do
903
- expect(subject.http).to receive(:options).with(path)
904
-
905
- subject.http_options(path)
906
- end
907
-
908
- context "when debug messages are enabled" do
909
- before { Ronin::Support::CLI::Printing.debug = true }
910
-
911
- it "must print a debugging message" do
912
- url = subject.url_for(path)
913
-
914
- allow(subject.http).to receive(:options).with(path)
915
-
916
- expect(subject).to receive(:print_debug).with(
917
- "Requesting OPTIONS #{url} ..."
918
- )
919
-
920
- subject.http_options(path)
921
- end
922
-
923
- after { Ronin::Support::CLI::Printing.debug = false }
924
- end
925
- end
926
- end
927
-
928
- describe "#http_allowed_methods" do
929
- context "when given a path" do
930
- let(:path) { '/foo' }
931
-
932
- it "must call #http.allowed_methods with the path" do
933
- expect(subject.http).to receive(:allowed_methods).with(path)
934
-
935
- subject.http_allowed_methods(path)
936
- end
937
-
938
- context "when debug messages are enabled" do
939
- before { Ronin::Support::CLI::Printing.debug = true }
940
-
941
- it "must print a debugging message" do
942
- url = subject.url_for(path)
943
-
944
- allow(subject.http).to receive(:allowed_methods).with(path)
945
-
946
- expect(subject).to receive(:print_debug).with(
947
- "Checking allowed HTTP methods for #{url} ..."
948
- )
949
-
950
- subject.http_allowed_methods(path)
951
- end
952
-
953
- after { Ronin::Support::CLI::Printing.debug = false }
954
- end
955
- end
956
- end
957
-
958
- describe "#http_patch" do
959
- context "when given a path" do
960
- let(:path) { '/foo' }
961
-
962
- it "must call #http.patch with the path" do
963
- expect(subject.http).to receive(:patch).with(path)
964
-
965
- subject.http_patch(path)
966
- end
967
-
968
- context "when debug messages are enabled" do
969
- before { Ronin::Support::CLI::Printing.debug = true }
970
-
971
- it "must print a debugging message" do
972
- url = subject.url_for(path)
973
-
974
- allow(subject.http).to receive(:patch).with(path)
975
-
976
- expect(subject).to receive(:print_debug).with(
977
- "Requesting PATCH #{url} ..."
978
- )
979
-
980
- subject.http_patch(path)
981
- end
982
-
983
- after { Ronin::Support::CLI::Printing.debug = false }
984
- end
985
- end
986
- end
987
-
988
- describe "#http_post" do
989
- context "when given a path" do
990
- let(:path) { '/foo' }
991
-
992
- it "must call #http.post with the path" do
993
- expect(subject.http).to receive(:post).with(path)
994
-
995
- subject.http_post(path)
996
- end
997
-
998
- context "when debug messages are enabled" do
999
- before { Ronin::Support::CLI::Printing.debug = true }
1000
-
1001
- it "must print a debugging message" do
1002
- url = subject.url_for(path)
1003
-
1004
- allow(subject.http).to receive(:post).with(path)
1005
-
1006
- expect(subject).to receive(:print_debug).with(
1007
- "Requesting POST #{url} ..."
1008
- )
1009
-
1010
- subject.http_post(path)
1011
- end
1012
-
1013
- after { Ronin::Support::CLI::Printing.debug = false }
1014
- end
1015
- end
1016
- end
1017
-
1018
- describe "#http_post_headers" do
1019
- context "when given a path" do
1020
- let(:path) { '/foo' }
1021
-
1022
- it "must call #http.post_headers with the path" do
1023
- expect(subject.http).to receive(:post_headers).with(path)
1024
-
1025
- subject.http_post_headers(path)
1026
- end
1027
-
1028
- context "when debug messages are enabled" do
1029
- before { Ronin::Support::CLI::Printing.debug = true }
1030
-
1031
- it "must print a debugging message" do
1032
- url = subject.url_for(path)
1033
-
1034
- allow(subject.http).to receive(:post_headers).with(path)
1035
-
1036
- expect(subject).to receive(:print_debug).with(
1037
- "Requesting response headers for POST #{url} ..."
1038
- )
1039
-
1040
- subject.http_post_headers(path)
1041
- end
1042
-
1043
- after { Ronin::Support::CLI::Printing.debug = false }
1044
- end
1045
- end
1046
- end
1047
-
1048
- describe "#http_post_body" do
1049
- context "when given a path" do
1050
- let(:path) { '/foo' }
1051
-
1052
- it "must call #http.post_body with the path" do
1053
- expect(subject.http).to receive(:post_body).with(path)
1054
-
1055
- subject.http_post_body(path)
1056
- end
1057
-
1058
- context "when debug messages are enabled" do
1059
- before { Ronin::Support::CLI::Printing.debug = true }
1060
-
1061
- it "must print a debugging message" do
1062
- url = subject.url_for(path)
1063
-
1064
- allow(subject.http).to receive(:post_body).with(path)
1065
-
1066
- expect(subject).to receive(:print_debug).with(
1067
- "Requesting response body for POST #{url} ..."
1068
- )
1069
-
1070
- subject.http_post_body(path)
1071
- end
1072
-
1073
- after { Ronin::Support::CLI::Printing.debug = false }
1074
- end
1075
- end
1076
- end
1077
-
1078
- describe "#http_propfind" do
1079
- context "when given a path" do
1080
- let(:path) { '/foo' }
1081
-
1082
- it "must call #http.propfind with the path" do
1083
- expect(subject.http).to receive(:propfind).with(path)
1084
-
1085
- subject.http_propfind(path)
1086
- end
1087
-
1088
- context "when debug messages are enabled" do
1089
- before { Ronin::Support::CLI::Printing.debug = true }
1090
-
1091
- it "must print a debugging message" do
1092
- url = subject.url_for(path)
1093
-
1094
- allow(subject.http).to receive(:propfind).with(path)
1095
-
1096
- expect(subject).to receive(:print_debug).with(
1097
- "Requesting PROPFIND #{url} ..."
1098
- )
1099
-
1100
- subject.http_propfind(path)
1101
- end
1102
-
1103
- after { Ronin::Support::CLI::Printing.debug = false }
1104
- end
1105
- end
1106
- end
1107
-
1108
- describe "#http_proppatch" do
1109
- context "when given a path" do
1110
- let(:path) { '/foo' }
1111
-
1112
- it "must call #http.proppatch with the path" do
1113
- expect(subject.http).to receive(:proppatch).with(path)
1114
-
1115
- subject.http_proppatch(path)
1116
- end
1117
-
1118
- context "when debug messages are enabled" do
1119
- before { Ronin::Support::CLI::Printing.debug = true }
1120
-
1121
- it "must print a debugging message" do
1122
- url = subject.url_for(path)
1123
-
1124
- expect(subject.http).to receive(:proppatch).with(path)
1125
-
1126
- expect(subject).to receive(:print_debug).with(
1127
- "Requesting PROPPATCH #{url} ..."
1128
- )
1129
-
1130
- subject.http_proppatch(path)
1131
- end
1132
-
1133
- after { Ronin::Support::CLI::Printing.debug = false }
1134
- end
1135
- end
1136
- end
1137
-
1138
- describe "#http_put" do
1139
- context "when given a path" do
1140
- let(:path) { '/foo' }
1141
-
1142
- it "must call #http.put with the path" do
1143
- expect(subject.http).to receive(:put).with(path)
1144
-
1145
- subject.http_put(path)
1146
- end
1147
-
1148
- context "when debug messages are enabled" do
1149
- before { Ronin::Support::CLI::Printing.debug = true }
1150
-
1151
- it "must print a debugging message" do
1152
- url = subject.url_for(path)
1153
-
1154
- allow(subject.http).to receive(:put).with(path)
1155
-
1156
- expect(subject).to receive(:print_debug).with(
1157
- "Requesting PUT #{url} ..."
1158
- )
1159
-
1160
- subject.http_put(path)
1161
- end
1162
-
1163
- after { Ronin::Support::CLI::Printing.debug = false }
1164
- end
1165
- end
1166
- end
1167
-
1168
- describe "#http_trace" do
1169
- context "when given a path" do
1170
- let(:path) { '/foo' }
1171
-
1172
- it "must call #http.trace with the path" do
1173
- expect(subject.http).to receive(:trace).with(path)
1174
-
1175
- subject.http_trace(path)
1176
- end
1177
-
1178
- context "when debug messages are enabled" do
1179
- before { Ronin::Support::CLI::Printing.debug = true }
1180
-
1181
- it "must print a debugging message" do
1182
- url = subject.url_for(path)
1183
-
1184
- allow(subject.http).to receive(:trace).with(path)
1185
-
1186
- expect(subject).to receive(:print_debug).with(
1187
- "Requesting TRACE #{url} ..."
1188
- )
1189
-
1190
- subject.http_trace(path)
1191
- end
1192
-
1193
- after { Ronin::Support::CLI::Printing.debug = false }
1194
- end
1195
- end
1196
- end
1197
-
1198
- describe "#http_unlock" do
1199
- context "when given a path" do
1200
- let(:path) { '/foo' }
1201
-
1202
- it "must call #http.unlock with the path" do
1203
- expect(subject.http).to receive(:unlock).with(path)
1204
-
1205
- subject.http_unlock(path)
1206
- end
1207
-
1208
- context "when debug messages are enabled" do
1209
- before { Ronin::Support::CLI::Printing.debug = true }
1210
-
1211
- it "must print a debugging message" do
1212
- url = subject.url_for(path)
1213
-
1214
- allow(subject.http).to receive(:unlock).with(path)
1215
-
1216
- expect(subject).to receive(:print_debug).with(
1217
- "Requesting UNLOCK #{url} ..."
1218
- )
1219
-
1220
- subject.http_unlock(path)
1221
- end
1222
-
1223
- after { Ronin::Support::CLI::Printing.debug = false }
1224
- end
1225
- end
1226
- end
1227
- end