diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index 46c93e2179..65fd6eac6b 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -5,19 +5,20 @@ module CommandDispatcher class Exploit + include Msf::Ui::Console::ModuleCommandDispatcher + @@exploit_opts = Rex::Parser::Arguments.new( "-e" => [ true, "The payload encoder to use. If none is specified, ENCODER is used." ], "-h" => [ false, "Help banner." ], "-n" => [ true, "The NOP generator to use. If none is specified, NOP is used." ], "-o" => [ true, "A comma separated list of options in VAR=VAL format." ], "-p" => [ true, "The payload to use. If none is specified, PAYLOAD is used." ], - "-t" => [ true, "The target index to use." ], + "-t" => [ true, "The target index to use. If none is specified, TARGET is used." ], "-z" => [ true, "Do not interact with the session after successful exploitation." ]) - include Msf::Ui::Console::ModuleCommandDispatcher - def commands { + "check" => "Check to see if a target is vulnerable", "exploit" => "Launch an exploit attempt", } end @@ -26,10 +27,49 @@ class Exploit "Exploit" end + # + # Checks to see if a target is vulnerable + # + def cmd_check(*args) + begin + code = mod.check + + if (code) + stat = '[*]' + + if (code == Msf::Exploit::CheckCode::Vulnerable) + stat = '[+]' + end + + print_line(stat + ' ' + code[1]) + else + print_error( + "Check failed: The state could not be determined.") + end + rescue + log_error("Check failed: #{$!}.") + end + end + # # Launches an exploitation attempt # def cmd_exploit(*args) + payload = mod.datastore['PAYLOAD'] + encoder = mod.datastore['ENCODER'] + target = mod.datastore['TARGET'] + nop = mod.datastore['NOP'] + + @@exploit_opts.parse(args) { |opt, idx, val| + case opt + when '-h' + print( + "Usage: exploit [options]\n\n" + + "Launches an exploitation attempt.\n" + + @@exploit_opts.usage) + return false + end + } end end diff --git a/lib/msf/ui/console/command_dispatcher/nop.rb b/lib/msf/ui/console/command_dispatcher/nop.rb index 4322e20d8b..a10c1998cb 100644 --- a/lib/msf/ui/console/command_dispatcher/nop.rb +++ b/lib/msf/ui/console/command_dispatcher/nop.rb @@ -7,13 +7,13 @@ module CommandDispatcher class Nop + include Msf::Ui::Console::ModuleCommandDispatcher + @@generate_opts = Rex::Parser::Arguments.new( "-b" => [ true, "The list of characters to avoid: '\\x00\\xff'" ], "-h" => [ false, "Help banner." ], "-t" => [ true, "The output type: ruby, perl, c, or raw." ]) - include Msf::Ui::Console::ModuleCommandDispatcher - def commands { "generate" => "Generates a NOP sled", diff --git a/lib/msf/ui/console/command_dispatcher/payload.rb b/lib/msf/ui/console/command_dispatcher/payload.rb index 18994fd613..ec2a597989 100644 --- a/lib/msf/ui/console/command_dispatcher/payload.rb +++ b/lib/msf/ui/console/command_dispatcher/payload.rb @@ -7,6 +7,8 @@ module CommandDispatcher class Payload + include Msf::Ui::Console::ModuleCommandDispatcher + @@generate_opts = Rex::Parser::Arguments.new( "-b" => [ true, "The list of characters to avoid: '\\x00\\xff'" ], "-e" => [ true, "The name of the encoder module to use." ], @@ -15,8 +17,6 @@ class Payload "-s" => [ true, "NOP sled length." ], "-t" => [ true, "The output type: ruby, perl, c, or raw." ]) - include Msf::Ui::Console::ModuleCommandDispatcher - def commands { "generate" => "Generates a payload", diff --git a/modules/exploits/test/multi/aggressive.rb b/modules/exploits/test/multi/aggressive.rb index c4cc313ff4..48dca662e7 100644 --- a/modules/exploits/test/multi/aggressive.rb +++ b/modules/exploits/test/multi/aggressive.rb @@ -31,6 +31,10 @@ class Exploits::Test::Multi::Aggressive < Msf::Exploit::Remote 'DefaultTarget' => 0)) end + def check + return Exploit::CheckCode::Vulnerable + end + def exploit end