ronin-exploits 1.0.0.beta2 → 1.0.0.beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/README.md +4 -0
  4. data/gemspec.yml +3 -1
  5. data/lib/ronin/exploits/cli/commands/run.rb +55 -5
  6. data/lib/ronin/exploits/version.rb +1 -1
  7. data/ronin-exploits.gemspec +2 -1
  8. metadata +10 -115
  9. data/spec/advisory_spec.rb +0 -71
  10. data/spec/cli/exploit_command_spec.rb +0 -68
  11. data/spec/cli/exploit_methods_spec.rb +0 -208
  12. data/spec/cli/ruby_shell_spec.rb +0 -14
  13. data/spec/client_side_web_vuln_spec.rb +0 -117
  14. data/spec/exploit_spec.rb +0 -538
  15. data/spec/exploits_spec.rb +0 -8
  16. data/spec/heap_overflow_spec.rb +0 -14
  17. data/spec/lfi_spec.rb +0 -162
  18. data/spec/loot/file_spec.rb +0 -131
  19. data/spec/loot_spec.rb +0 -138
  20. data/spec/memory_corruption_spec.rb +0 -22
  21. data/spec/metadata/arch_spec.rb +0 -82
  22. data/spec/metadata/cookie_param_spec.rb +0 -67
  23. data/spec/metadata/default_filename_spec.rb +0 -62
  24. data/spec/metadata/default_port_spec.rb +0 -62
  25. data/spec/metadata/header_name_spec.rb +0 -67
  26. data/spec/metadata/os_spec.rb +0 -164
  27. data/spec/metadata/shouts_spec.rb +0 -100
  28. data/spec/metadata/url_path_spec.rb +0 -67
  29. data/spec/metadata/url_query_param_spec.rb +0 -67
  30. data/spec/mixins/binary_spec.rb +0 -129
  31. data/spec/mixins/build_dir.rb +0 -66
  32. data/spec/mixins/file_builder_spec.rb +0 -67
  33. data/spec/mixins/format_string_spec.rb +0 -44
  34. data/spec/mixins/has_payload_spec.rb +0 -333
  35. data/spec/mixins/has_targets_spec.rb +0 -434
  36. data/spec/mixins/html_spec.rb +0 -772
  37. data/spec/mixins/http_spec.rb +0 -1227
  38. data/spec/mixins/loot_spec.rb +0 -20
  39. data/spec/mixins/nops_spec.rb +0 -165
  40. data/spec/mixins/remote_tcp_spec.rb +0 -217
  41. data/spec/mixins/remote_udp_spec.rb +0 -217
  42. data/spec/mixins/seh_spec.rb +0 -89
  43. data/spec/mixins/stack_overflow_spec.rb +0 -87
  44. data/spec/mixins/text_spec.rb +0 -43
  45. data/spec/open_redirect_spec.rb +0 -71
  46. data/spec/params/base_url_spec.rb +0 -71
  47. data/spec/params/bind_host_spec.rb +0 -34
  48. data/spec/params/bind_port_spec.rb +0 -35
  49. data/spec/params/filename_spec.rb +0 -77
  50. data/spec/params/host_spec.rb +0 -34
  51. data/spec/params/port_spec.rb +0 -77
  52. data/spec/rfi_spec.rb +0 -107
  53. data/spec/seh_overflow_spec.rb +0 -18
  54. data/spec/spec_helper.rb +0 -8
  55. data/spec/sqli_spec.rb +0 -306
  56. data/spec/ssti_spec.rb +0 -121
  57. data/spec/stack_overflow_spec.rb +0 -18
  58. data/spec/target_spec.rb +0 -92
  59. data/spec/test_result_spec.rb +0 -32
  60. data/spec/use_after_free_spec.rb +0 -14
  61. data/spec/web_spec.rb +0 -12
  62. data/spec/web_vuln_spec.rb +0 -854
  63. data/spec/xss_spec.rb +0 -69
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b7d601e1580ea5719c365a686d579659df4deb60d77eff285d74ac1280d93b3
4
- data.tar.gz: 87e9cef6168d40862c0442aabdaaa69d51563cbae6ff93abb8a3c4c0ef0b6704
3
+ metadata.gz: 850efd0369626bc57a83bf7d51ab1d8fc471bfe1472feee5720c80d7f064fdb5
4
+ data.tar.gz: b185d3383dc0549dd4aa9aa5e9df990a9554081028fb4cf2e49fd47332ffba7a
5
5
  SHA512:
6
- metadata.gz: 37e77fed488fdcfed0357d792738b3bb231cbeae749631291aa12544a8b225ca14fe548cf70985ae88d9946f5e1f8ead8c1d0078d486fa4d0ed837b33fca9aa6
7
- data.tar.gz: e032ca57e0b63ca63b93e79d6479c631a8939eaa5406d4d4d68bafebfd5b16ffdfc5e6f58f245440036ec0f2869937709c84cf915ce78e10efc4fb03c0bcc303
6
+ metadata.gz: 958a1be608668de05fd28d2baeb44d1e7be1765cae684a4110a3183d92647582e6d51921ea24347a562685750717faf5e6e33d62102947f7f11afa3c9b8e7d3b
7
+ data.tar.gz: 8dbb0fc9782bced0ea57d49f9f65181ee752776c52ae31f437c368affecbb7a44e288c4e6568ea030d48ee1afde343b3c2cef56d9c9ad2e0c66af68519e216ab
@@ -21,6 +21,7 @@ jobs:
21
21
  uses: ruby/setup-ruby@v1
22
22
  with:
23
23
  ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
24
25
  - name: Install libsqlite3
25
26
  run: |
26
27
  sudo apt update -y && \
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/ronin-rb/ronin-exploits/actions/workflows/ruby.yml/badge.svg)](https://github.com/ronin-rb/ronin-exploits/actions/workflows/ruby.yml)
4
4
  [![Code Climate](https://codeclimate.com/github/ronin-rb/ronin-exploits.svg)](https://codeclimate.com/github/ronin-rb/ronin-exploits)
5
+ [![Gem Version](https://badge.fury.io/rb/ronin-exploits.svg)](https://badge.fury.io/rb/ronin-exploits)
5
6
 
6
7
  * [Source](https://github.com/ronin-rb/ronin-exploits)
7
8
  * [Issues](https://github.com/ronin-rb/ronin-exploits/issues)
@@ -17,6 +18,9 @@ ronin-exploits allows one to write exploits as plain old Ruby classes.
17
18
  ronin-exploits can be distributed as Ruby files or as git repositories that can
18
19
  be installed using [ronin-repos].
19
20
 
21
+ **tl;dr** It's like a simpler version of
22
+ [Metasploit](https://www.metasploit.com/).
23
+
20
24
  ronin-exploits is part of the [ronin-rb] project, a [Ruby] toolkit for security
21
25
  research and development.
22
26
 
data/gemspec.yml CHANGED
@@ -1,11 +1,13 @@
1
1
  name: ronin-exploits
2
2
  summary: A Ruby micro-framework for writing and running exploits and payloads.
3
- description:
3
+ description: |
4
4
  ronin-exploits is a Ruby micro-framework for writing and running exploits.
5
5
  ronin-exploits allows one to write exploits as plain old Ruby classes.
6
6
  ronin-exploits can be distributed as Ruby files or as git repositories that
7
7
  can be installed using ronin-reps.
8
8
 
9
+ It's like a simpler version of Metasploit.
10
+
9
11
  license: LGPL-3.0
10
12
  authors: Postmodern
11
13
  email: postmodern.mod3@gmail.com
@@ -118,7 +118,11 @@ module Ronin
118
118
  type: /\A[^=\s]+=.+\z/,
119
119
  usage: 'NAME=VALUE'
120
120
  },
121
- desc: 'Sets a param on the payload'
121
+ desc: 'Sets a param on the payload' do |param|
122
+ name, value = param.split('=',2)
123
+
124
+ @payload_params[name.to_sym] = value
125
+ end
122
126
 
123
127
  # Encoder options
124
128
  option :encoder_file, value: {
@@ -228,6 +232,7 @@ module Ronin
228
232
 
229
233
  @load_encoders = []
230
234
  @encoder_params = Hash.new { |hash,key| hash[key] = {} }
235
+ @payload_params = {}
231
236
  @target_kwargs = {}
232
237
  end
233
238
 
@@ -244,6 +249,7 @@ module Ronin
244
249
  load_payload
245
250
  initialize_encoders
246
251
  initialize_payload
252
+ validate_payload
247
253
  initialize_exploit
248
254
  validate_exploit
249
255
  run_exploit
@@ -257,6 +263,10 @@ module Ronin
257
263
  perform_cleanup
258
264
  end
259
265
 
266
+ #
267
+ # Loads the payload encoder classes specified by `--encoder` or
268
+ # `--encoder-file`.
269
+ #
260
270
  def load_encoders
261
271
  @encoder_classes = @load_encoders.map do |(type,value)|
262
272
  case type
@@ -266,12 +276,20 @@ module Ronin
266
276
  end
267
277
  end
268
278
 
279
+ #
280
+ # Initializes the payload encoders specified by `--encoder` or
281
+ # `--encoder-file`.
282
+ #
269
283
  def initialize_encoders
270
284
  @encoders = @encoder_classes.map do |encoder_class|
271
285
  encoder_class.new(params: @encoder_params[encoder_class.id])
272
286
  end
273
287
  end
274
288
 
289
+ #
290
+ # Loads the payload class specified by `--payload` or
291
+ # `--payload-file`.
292
+ #
275
293
  def load_payload
276
294
  @payload_class = if options[:payload]
277
295
  super(options[:payload])
@@ -280,6 +298,10 @@ module Ronin
280
298
  end
281
299
  end
282
300
 
301
+ #
302
+ # Initializes the payload specified by `--payload`, `--payload-file`,
303
+ # `--read-payload`, or `--payload-string`.
304
+ #
283
305
  def initialize_payload
284
306
  @payload = if @payload_class
285
307
  super(@payload_class, params: @payload_params,
@@ -291,6 +313,16 @@ module Ronin
291
313
  end
292
314
  end
293
315
 
316
+ #
317
+ # Validates the payload.
318
+ #
319
+ def validate_payload
320
+ super(@payload)
321
+ end
322
+
323
+ #
324
+ # Initializes the exploit.
325
+ #
294
326
  def initialize_exploit
295
327
  kwargs = {params: @params}
296
328
 
@@ -309,13 +341,16 @@ module Ronin
309
341
  super(**kwargs)
310
342
  end
311
343
 
344
+ #
345
+ # Runs the exploit.
346
+ #
312
347
  def run_exploit
313
348
  log_info "Running exploit #{@exploit.class_id} ..."
314
349
 
315
350
  begin
316
351
  @exploit.exploit(dry_run: options[:dry_run])
317
352
  rescue ExploitError => error
318
- print_error("failed to run exploit #{@exploit.class_id}: #{error.message}")
353
+ print_error "failed to run exploit #{@exploit.class_id}: #{error.message}"
319
354
  exit(1)
320
355
  rescue => error
321
356
  print_exception(error)
@@ -324,6 +359,9 @@ module Ronin
324
359
  end
325
360
  end
326
361
 
362
+ #
363
+ # Starts an interactive ruby shell within the exploit object.
364
+ #
327
365
  def start_shell
328
366
  log_info "Exploit #{@exploit.class_id} launched!"
329
367
  log_info "Starting interactive Ruby shell ..."
@@ -331,12 +369,15 @@ module Ronin
331
369
  RubyShell.start(name: @exploit_class.name, context: @exploit)
332
370
  end
333
371
 
372
+ #
373
+ # Performs the post-exploitation stage.
374
+ #
334
375
  def post_exploitation
335
376
  if @exploit_class.include?(Mixins::HasPayload) &&
336
377
  @exploit.payload.kind_of?(Ronin::Payloads::Payload) &&
337
- @exploit.payload.kind_of?(Ronin::Payloads::Mixins::PostExt)
378
+ @exploit.payload.kind_of?(Ronin::Payloads::Mixins::PostEx)
338
379
  unless @exploit.payload.session
339
- print_error("payload (#{@exploit.payload.class_id}) did not create a post-exploitation session")
380
+ print_error "payload (#{@exploit.payload.class_id}) did not create a post-exploitation session"
340
381
 
341
382
  perform_cleanup
342
383
  eixt(1)
@@ -349,6 +390,9 @@ module Ronin
349
390
  end
350
391
  end
351
392
 
393
+ #
394
+ # Prints any loot collected by the exploit.
395
+ #
352
396
  def print_loot
353
397
  unless @exploit.loot.empty?
354
398
  log_info "Exploit found the following loot:"
@@ -372,15 +416,21 @@ module Ronin
372
416
  end
373
417
  end
374
418
 
419
+ #
420
+ # Saves the collected loot to the `--save-loot` directory.
421
+ #
375
422
  def save_loot
376
423
  @exploit.loot.save(options.fetch(:save_loot))
377
424
  end
378
425
 
426
+ #
427
+ # Performs the cleanup stage of the exploit.
428
+ #
379
429
  def perform_cleanup
380
430
  begin
381
431
  @exploit.perform_cleanup
382
432
  rescue ExploitError => error
383
- print_error("failed to cleanup exploit #{@exploit.class_id}: #{error.message}")
433
+ print_error "failed to cleanup exploit #{@exploit.class_id}: #{error.message}"
384
434
  exit(1)
385
435
  rescue => error
386
436
  print_exception(error)
@@ -21,6 +21,6 @@
21
21
  module Ronin
22
22
  module Exploits
23
23
  # ronin-exploits version
24
- VERSION = '1.0.0.beta2'
24
+ VERSION = '1.0.0.beta3'
25
25
  end
26
26
  end
@@ -27,6 +27,8 @@ Gem::Specification.new do |gem|
27
27
  gem.files = `git ls-files`.split($/)
28
28
  gem.files = glob[gemspec['files']] if gemspec['files']
29
29
  gem.files += Array(gemspec['generated_files'])
30
+ # exclude test files from the packages gem
31
+ gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
30
32
 
31
33
  gem.executables = gemspec.fetch('executables') do
32
34
  glob['bin/*'].map { |path| File.basename(path) }
@@ -34,7 +36,6 @@ Gem::Specification.new do |gem|
34
36
  gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
35
37
 
36
38
  gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
37
- gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
38
39
  gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
39
40
 
40
41
  gem.require_paths = Array(gemspec.fetch('require_paths') {
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.beta3
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-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri-query_params
@@ -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