diff --git a/lib/ronin/exploits/cli/commands/run.rb b/lib/ronin/exploits/cli/commands/run.rb index ae3b7ce2..7d9fbb31 100644 --- a/lib/ronin/exploits/cli/commands/run.rb +++ b/lib/ronin/exploits/cli/commands/run.rb @@ -51,7 +51,8 @@ module Commands # # -f, --file FILE The exploit file to load # -p, --param NAME=VALUE Sets a param - # -D, --dry-run Builds the exploit but does not launch it + # --dry-run Builds the exploit but does not launch it + # -T --test Runs only the exploit test # --payload-file FILE Load the payload from the given Ruby file # --read-payload FILE Reads the payload string from the file # --payload-string STRING Uses the raw payload string instead @@ -85,10 +86,13 @@ class Run < ExploitCommand include Core::CLI::Options::Param include Core::CLI::Logging include CommandKit::Printing::Indent + include Support::CLI::Printing # Exploit options - option :dry_run, short: '-D', - desc: 'Builds the exploit but does not launch it' + option :dry_run, desc: 'Builds the exploit but does not launch it' + + option :test_only, short: '-T', + desc: 'Runs only the exploit test' # Payload options option :payload_file, value: { @@ -273,7 +277,12 @@ def run(name=nil) validate_payload initialize_exploit validate_exploit - run_exploit + + if options[:test] + run_test + else + run_exploit + end if options[:irb] start_shell @@ -382,6 +391,24 @@ def run_exploit end end + # + # Run the exploit's test method, and print the result. + # + def run_test + case (result = @exploit.test) + when TestResult::Vulnerable + print_positive "Vulnerable: #{result}" + when TestResult::NotVulnerable + print_negative "NotVulnerable: #{result}" + when TestResult::Unknown + print_warning "Unknown: #{result}" + else + print_error "Unexpected result: #{result.inspect}" + end + + result + end + # # Starts an interactive ruby shell within the exploit object. # diff --git a/man/ronin-exploits-run.1.md b/man/ronin-exploits-run.1.md index e09dcef8..9745f773 100644 --- a/man/ronin-exploits-run.1.md +++ b/man/ronin-exploits-run.1.md @@ -25,9 +25,12 @@ Loads and runs an exploit. `-p`, `--param` *NAME*=*VALUE* : Sets a param for the exploit. -`-D`, `--dry-run` +`--dry-run` : Builds the exploit but does not launch it. +`-T`, `--test` +: Runs only the exploit test. + `--payload-file` *FILE* : Load the payload from the given Ruby file.