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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-exploits
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri-query_params
@@ -30,98 +30,98 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0.beta1
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0.beta1
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ronin-code-sql
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0.beta1
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0.beta1
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ronin-payloads
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0.beta1
61
+ version: '0.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.0.beta1
68
+ version: '0.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ronin-vulns
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.1.0.beta1
75
+ version: '0.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.1.0.beta1
82
+ version: '0.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ronin-post_ex
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.1.0.beta1
89
+ version: '0.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.1.0.beta1
96
+ version: '0.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: ronin-core
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.1.0.beta1
103
+ version: '0.1'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.0.beta1
110
+ version: '0.1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ronin-repos
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.1.0.beta1
117
+ version: '0.1'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.1.0.beta1
124
+ version: '0.1'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -136,10 +136,13 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '2.0'
139
- description: ronin-exploits is a Ruby micro-framework for writing and running exploits.
140
- ronin-exploits allows one to write exploits as plain old Ruby classes. ronin-exploits
141
- can be distributed as Ruby files or as git repositories that can be installed using
142
- ronin-reps.
139
+ description: |
140
+ ronin-exploits is a Ruby micro-framework for writing and running exploits.
141
+ ronin-exploits allows one to write exploits as plain old Ruby classes.
142
+ ronin-exploits can be distributed as Ruby files or as git repositories that
143
+ can be installed using ronin-reps.
144
+
145
+ It's like a simpler version of Metasploit.
143
146
  email: postmodern.mod3@gmail.com
144
147
  executables:
145
148
  - ronin-exploits
@@ -244,61 +247,6 @@ files:
244
247
  - man/ronin-exploits.1
245
248
  - man/ronin-exploits.1.md
246
249
  - ronin-exploits.gemspec
247
- - spec/advisory_spec.rb
248
- - spec/cli/exploit_command_spec.rb
249
- - spec/cli/exploit_methods_spec.rb
250
- - spec/cli/ruby_shell_spec.rb
251
- - spec/client_side_web_vuln_spec.rb
252
- - spec/exploit_spec.rb
253
- - spec/exploits_spec.rb
254
- - spec/heap_overflow_spec.rb
255
- - spec/lfi_spec.rb
256
- - spec/loot/file_spec.rb
257
- - spec/loot_spec.rb
258
- - spec/memory_corruption_spec.rb
259
- - spec/metadata/arch_spec.rb
260
- - spec/metadata/cookie_param_spec.rb
261
- - spec/metadata/default_filename_spec.rb
262
- - spec/metadata/default_port_spec.rb
263
- - spec/metadata/header_name_spec.rb
264
- - spec/metadata/os_spec.rb
265
- - spec/metadata/shouts_spec.rb
266
- - spec/metadata/url_path_spec.rb
267
- - spec/metadata/url_query_param_spec.rb
268
- - spec/mixins/binary_spec.rb
269
- - spec/mixins/build_dir.rb
270
- - spec/mixins/file_builder_spec.rb
271
- - spec/mixins/format_string_spec.rb
272
- - spec/mixins/has_payload_spec.rb
273
- - spec/mixins/has_targets_spec.rb
274
- - spec/mixins/html_spec.rb
275
- - spec/mixins/http_spec.rb
276
- - spec/mixins/loot_spec.rb
277
- - spec/mixins/nops_spec.rb
278
- - spec/mixins/remote_tcp_spec.rb
279
- - spec/mixins/remote_udp_spec.rb
280
- - spec/mixins/seh_spec.rb
281
- - spec/mixins/stack_overflow_spec.rb
282
- - spec/mixins/text_spec.rb
283
- - spec/open_redirect_spec.rb
284
- - spec/params/base_url_spec.rb
285
- - spec/params/bind_host_spec.rb
286
- - spec/params/bind_port_spec.rb
287
- - spec/params/filename_spec.rb
288
- - spec/params/host_spec.rb
289
- - spec/params/port_spec.rb
290
- - spec/rfi_spec.rb
291
- - spec/seh_overflow_spec.rb
292
- - spec/spec_helper.rb
293
- - spec/sqli_spec.rb
294
- - spec/ssti_spec.rb
295
- - spec/stack_overflow_spec.rb
296
- - spec/target_spec.rb
297
- - spec/test_result_spec.rb
298
- - spec/use_after_free_spec.rb
299
- - spec/web_spec.rb
300
- - spec/web_vuln_spec.rb
301
- - spec/xss_spec.rb
302
250
  homepage: https://ronin-rb.dev/exploits/
303
251
  licenses:
304
252
  - LGPL-3.0
@@ -327,57 +275,4 @@ rubygems_version: 3.3.26
327
275
  signing_key:
328
276
  specification_version: 4
329
277
  summary: A Ruby micro-framework for writing and running exploits and payloads.
330
- test_files:
331
- - spec/advisory_spec.rb
332
- - spec/cli/exploit_command_spec.rb
333
- - spec/cli/exploit_methods_spec.rb
334
- - spec/cli/ruby_shell_spec.rb
335
- - spec/client_side_web_vuln_spec.rb
336
- - spec/exploit_spec.rb
337
- - spec/exploits_spec.rb
338
- - spec/heap_overflow_spec.rb
339
- - spec/lfi_spec.rb
340
- - spec/loot/file_spec.rb
341
- - spec/loot_spec.rb
342
- - spec/memory_corruption_spec.rb
343
- - spec/metadata/arch_spec.rb
344
- - spec/metadata/cookie_param_spec.rb
345
- - spec/metadata/default_filename_spec.rb
346
- - spec/metadata/default_port_spec.rb
347
- - spec/metadata/header_name_spec.rb
348
- - spec/metadata/os_spec.rb
349
- - spec/metadata/shouts_spec.rb
350
- - spec/metadata/url_path_spec.rb
351
- - spec/metadata/url_query_param_spec.rb
352
- - spec/mixins/binary_spec.rb
353
- - spec/mixins/file_builder_spec.rb
354
- - spec/mixins/format_string_spec.rb
355
- - spec/mixins/has_payload_spec.rb
356
- - spec/mixins/has_targets_spec.rb
357
- - spec/mixins/html_spec.rb
358
- - spec/mixins/http_spec.rb
359
- - spec/mixins/loot_spec.rb
360
- - spec/mixins/nops_spec.rb
361
- - spec/mixins/remote_tcp_spec.rb
362
- - spec/mixins/remote_udp_spec.rb
363
- - spec/mixins/seh_spec.rb
364
- - spec/mixins/stack_overflow_spec.rb
365
- - spec/mixins/text_spec.rb
366
- - spec/open_redirect_spec.rb
367
- - spec/params/base_url_spec.rb
368
- - spec/params/bind_host_spec.rb
369
- - spec/params/bind_port_spec.rb
370
- - spec/params/filename_spec.rb
371
- - spec/params/host_spec.rb
372
- - spec/params/port_spec.rb
373
- - spec/rfi_spec.rb
374
- - spec/seh_overflow_spec.rb
375
- - spec/sqli_spec.rb
376
- - spec/ssti_spec.rb
377
- - spec/stack_overflow_spec.rb
378
- - spec/target_spec.rb
379
- - spec/test_result_spec.rb
380
- - spec/use_after_free_spec.rb
381
- - spec/web_spec.rb
382
- - spec/web_vuln_spec.rb
383
- - spec/xss_spec.rb
278
+ test_files: []
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/exploits/advisory'
3
-
4
- describe Ronin::Exploits::Advisory do
5
- let(:id) { 'CVE-2022-1234' }
6
- let(:url) { "https://nvd.nist.gov/vuln/detail/#{id}" }
7
-
8
- subject { described_class.new(id,url) }
9
-
10
- describe "#initialize" do
11
- context "when given only an id" do
12
- subject { described_class.new(id) }
13
-
14
- it "must set #id" do
15
- expect(subject.id).to eq(id)
16
- end
17
-
18
- it "must default #url to .url_for(id)" do
19
- expect(subject.url).to eq(described_class.url_for(id))
20
- end
21
- end
22
-
23
- context "when given an id and a url" do
24
- subject { described_class.new(id,url) }
25
-
26
- it "must set #id" do
27
- expect(subject.id).to eq(id)
28
- end
29
-
30
- it "must set #url" do
31
- expect(subject.url).to eq(url)
32
- end
33
- end
34
- end
35
-
36
- describe ".url_for" do
37
- subject { described_class }
38
-
39
- context "when given a CVE-YYYY-NNNN id" do
40
- let(:id) { 'CVE-2022-1234' }
41
-
42
- it "must return 'https://nvd.nist.gov/vuln/detail/CVE-YYYY-NNNN'" do
43
- expect(subject.url_for(id)).to eq(
44
- "https://nvd.nist.gov/vuln/detail/#{id}"
45
- )
46
- end
47
- end
48
-
49
- context "when given a GHSA-XXXX id" do
50
- let(:id) { 'GHSA-1234abcd' }
51
-
52
- it "must return 'https://github.com/advisories/GHSA-XXXX'" do
53
- expect(subject.url_for(id)).to eq("https://github.com/advisories/#{id}")
54
- end
55
- end
56
-
57
- context "when given any other kind of id" do
58
- let(:id) { 'XYZ-123' }
59
-
60
- it "must return nil" do
61
- expect(subject.url_for(id)).to be(nil)
62
- end
63
- end
64
- end
65
-
66
- describe "#to_s" do
67
- it "must return the advisory #id" do
68
- expect(subject.to_s).to eq(id)
69
- end
70
- end
71
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/exploits/cli/exploit_command'
3
- require 'ronin/exploits/exploit'
4
-
5
- describe Ronin::Exploits::CLI::ExploitCommand do
6
- module TestExploitCommand
7
- class TestExploit < Ronin::Exploits::Exploit
8
- register 'test_exploit_command'
9
- end
10
-
11
- class TestCommand < Ronin::Exploits::CLI::ExploitCommand
12
- end
13
- end
14
-
15
- let(:exploit_class) { TestExploitCommand::TestExploit }
16
- let(:command_class) { TestExploitCommand::TestCommand }
17
- subject { command_class.new }
18
-
19
- describe "#load_exploit" do
20
- let(:id) { exploit_class.id }
21
-
22
- before do
23
- expect(Ronin::Exploits).to receive(:load_class).with(id).and_return(exploit_class)
24
- end
25
-
26
- it "must load the exploit class and return the exploit class" do
27
- expect(subject.load_exploit(id)).to be(exploit_class)
28
- end
29
-
30
- it "must also set #exploit_class" do
31
- subject.load_exploit(id)
32
-
33
- expect(subject.exploit_class).to be(exploit_class)
34
- end
35
- end
36
-
37
- describe "#load_exploit_from" do
38
- let(:file) { "path/to/exploit/file.rb" }
39
-
40
- before do
41
- expect(Ronin::Exploits).to receive(:load_class_from_file).with(file).and_return(exploit_class)
42
- end
43
-
44
- it "must load the exploit class and return the exploit class" do
45
- expect(subject.load_exploit_from(file)).to be(exploit_class)
46
- end
47
-
48
- it "must also set #exploit_class" do
49
- subject.load_exploit_from(file)
50
-
51
- expect(subject.exploit_class).to be(exploit_class)
52
- end
53
- end
54
-
55
- describe "#initialize_exploit" do
56
- before { subject.load_exploit(exploit_class.id) }
57
-
58
- it "must initialize a new exploit object using #exploit_class" do
59
- expect(subject.initialize_exploit).to be_kind_of(exploit_class)
60
- end
61
-
62
- it "must also set #exploit" do
63
- subject.initialize_exploit
64
-
65
- expect(subject.exploit).to be_kind_of(exploit_class)
66
- end
67
- end
68
- end
@@ -1,208 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/exploits/cli/exploit_methods'
3
- require 'ronin/exploits/cli/command'
4
-
5
- describe Ronin::Exploits::CLI::ExploitMethods do
6
- module TestExploitMethods
7
- class TestCommand < Ronin::Exploits::CLI::Command
8
- include Ronin::Exploits::CLI::ExploitMethods
9
- end
10
- end
11
-
12
- let(:command_class) { TestExploitMethods::TestCommand }
13
- subject { command_class.new }
14
-
15
- describe "#load_exploit" do
16
- let(:exploit_id) { 'html/encode' }
17
-
18
- it "must call Exploits.load_class with the given ID" do
19
- expect(Ronin::Exploits).to receive(:load_class).with(exploit_id)
20
- expect(subject).to_not receive(:exit)
21
-
22
- subject.load_exploit(exploit_id)
23
- end
24
-
25
- context "when Ronin::Exploits::ClassNotfound is raised" do
26
- let(:message) { "class not found" }
27
- let(:exception) do
28
- Ronin::Exploits::ClassNotFound.new(message)
29
- end
30
-
31
- it "must print an error message and exit with an error code" do
32
- expect(Ronin::Exploits).to receive(:load_class).with(exploit_id).and_raise(exception)
33
- expect(subject).to receive(:exit).with(1)
34
-
35
- expect {
36
- subject.load_exploit(exploit_id)
37
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
38
- end
39
- end
40
-
41
- context "when another type of exception is raised" do
42
- let(:message) { "unexpected error" }
43
- let(:exception) { RuntimeError.new(message) }
44
-
45
- it "must print the exception, an error message, and exit with -1" do
46
- expect(Ronin::Exploits).to receive(:load_class).with(exploit_id).and_raise(exception)
47
- expect(subject).to receive(:print_exception).with(exception)
48
- expect(subject).to receive(:exit).with(-1)
49
-
50
- expect {
51
- subject.load_exploit(exploit_id)
52
- }.to output("#{subject.command_name}: an unhandled exception occurred while loading exploit #{exploit_id}#{$/}").to_stderr
53
- end
54
- end
55
- end
56
-
57
- describe "#load_exploit_from" do
58
- let(:file) { '/path/to/html/encode.rb' }
59
-
60
- it "must call Exploits.load_class with the given ID and file" do
61
- expect(Ronin::Exploits).to receive(:load_class_from_file).with(file)
62
- expect(subject).to_not receive(:exit)
63
-
64
- subject.load_exploit_from(file)
65
- end
66
-
67
- context "when Ronin::Exploits::ClassNotfound is raised" do
68
- let(:message) { "class not found" }
69
- let(:exception) do
70
- Ronin::Exploits::ClassNotFound.new(message)
71
- end
72
-
73
- it "must print an error message and exit with an error code" do
74
- expect(Ronin::Exploits).to receive(:load_class_from_file).with(file).and_raise(exception)
75
- expect(subject).to receive(:exit).with(1)
76
-
77
- expect {
78
- subject.load_exploit_from(file)
79
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
80
- end
81
- end
82
-
83
- context "when another type of exception is raised" do
84
- let(:message) { "unexpected error" }
85
- let(:exception) { RuntimeError.new(message) }
86
-
87
- it "must print the exception, an error message, and exit with -1" do
88
- expect(Ronin::Exploits).to receive(:load_class_from_file).with(file).and_raise(exception)
89
- expect(subject).to receive(:print_exception).with(exception)
90
- expect(subject).to receive(:exit).with(-1)
91
-
92
- expect {
93
- subject.load_exploit_from(file)
94
- }.to output(
95
- "#{subject.command_name}: an unhandled exception occurred while loading exploit from file #{file}#{$/}"
96
- ).to_stderr
97
- end
98
- end
99
- end
100
-
101
- describe "#initialie_exploit" do
102
- let(:exploit_id) { 'test' }
103
- let(:exploit_class) { double('Encoder class', id: exploit_id) }
104
-
105
- it "must return a new instance of the given exploit class" do
106
- expect(exploit_class).to receive(:new)
107
-
108
- subject.initialize_exploit(exploit_class)
109
- end
110
-
111
- context "when additional keyword arguments are given" do
112
- let(:kwargs) do
113
- {foo: 1, bar: 2}
114
- end
115
-
116
- it "must pass them to new()" do
117
- expect(exploit_class).to receive(:new).with(**kwargs)
118
-
119
- subject.initialize_exploit(exploit_class,**kwargs)
120
- end
121
- end
122
-
123
- context "when a Core::Params::ParamError is raised" do
124
- let(:message) { "param foo was not set" }
125
- let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
126
-
127
- it "must print an error message and exit with 1" do
128
- expect(exploit_class).to receive(:new).and_raise(exception)
129
- expect(subject).to receive(:exit).with(1)
130
-
131
- expect {
132
- subject.initialize_exploit(exploit_class)
133
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
134
- end
135
- end
136
-
137
- context "when another type of exception is raised" do
138
- let(:message) { "unexpected error" }
139
- let(:exception) { RuntimeError.new(message) }
140
-
141
- it "must print the exception, an error message, and exit with -1" do
142
- expect(exploit_class).to receive(:new).and_raise(exception)
143
- expect(subject).to receive(:print_exception).with(exception)
144
- expect(subject).to receive(:exit).with(-1)
145
-
146
- expect {
147
- subject.initialize_exploit(exploit_class)
148
- }.to output("#{subject.command_name}: an unhandled exception occurred while initializing exploit #{exploit_id}#{$/}").to_stderr
149
- end
150
- end
151
- end
152
-
153
- describe "#validate_exploit" do
154
- let(:exploit_id) { 'test' }
155
- let(:exploit) { double('Encoder instance', class_id: exploit_id) }
156
-
157
- it "must call #perform_validate on #exploit" do
158
- expect(exploit).to receive(:perform_validate)
159
-
160
- subject.validate_exploit(exploit)
161
- end
162
-
163
- context "when a Core::Params::ParamError is raised" do
164
- let(:message) { "param foo was not set" }
165
- let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
166
-
167
- it "must print an error message and exit with 1" do
168
- expect(exploit).to receive(:perform_validate).and_raise(exception)
169
- expect(subject).to receive(:exit).with(1)
170
-
171
- expect {
172
- subject.validate_exploit(exploit)
173
- }.to output("#{subject.command_name}: failed to validate the exploit #{exploit_id}: #{message}#{$/}").to_stderr
174
- end
175
- end
176
-
177
- context "when a Ronin::Exploits::ValidationError is raised" do
178
- let(:message) { "param foo was not set" }
179
- let(:exception) do
180
- Ronin::Exploits::ValidationError.new(message)
181
- end
182
-
183
- it "must print an error message and exit with 1" do
184
- expect(exploit).to receive(:perform_validate).and_raise(exception)
185
- expect(subject).to receive(:exit).with(1)
186
-
187
- expect {
188
- subject.validate_exploit(exploit)
189
- }.to output("#{subject.command_name}: failed to validate the exploit #{exploit_id}: #{message}#{$/}").to_stderr
190
- end
191
- end
192
-
193
- context "when another type of exception is raised" do
194
- let(:message) { "unexpected error" }
195
- let(:exception) { RuntimeError.new(message) }
196
-
197
- it "must print the exception, an error message, and exit with -1" do
198
- expect(exploit).to receive(:perform_validate).and_raise(exception)
199
- expect(subject).to receive(:print_exception).with(exception)
200
- expect(subject).to receive(:exit).with(-1)
201
-
202
- expect {
203
- subject.validate_exploit(exploit)
204
- }.to output("#{subject.command_name}: an unhandled exception occurred while validating the exploit #{exploit_id}#{$/}").to_stderr
205
- end
206
- end
207
- end
208
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/exploits/cli/ruby_shell'
3
-
4
- describe Ronin::Exploits::CLI::RubyShell do
5
- describe "#initialize" do
6
- it "must default #name to 'ronin-exploits'" do
7
- expect(subject.name).to eq('ronin-exploits')
8
- end
9
-
10
- it "must default #context to Ronin::Exploits" do
11
- expect(subject.context).to be(Ronin::Exploits)
12
- end
13
- end
14
- end