mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-05 14:57:30 +01:00
Land #6518, more useful msfvenom messages
Adds support for -l n(op) and similar.
This commit is contained in:
commit
5b16f45d33
111
msfvenom
111
msfvenom
@ -1,20 +1,22 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
# -*- coding: binary -*-
|
# -*- coding: binary -*-
|
||||||
|
|
||||||
msfbase = __FILE__
|
if __FILE__ == $0
|
||||||
while File.symlink?(msfbase)
|
|
||||||
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
||||||
end
|
|
||||||
|
|
||||||
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
|
msfbase = __FILE__
|
||||||
require 'msfenv'
|
while File.symlink?(msfbase)
|
||||||
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
||||||
|
end
|
||||||
|
|
||||||
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
|
||||||
|
require 'msfenv'
|
||||||
|
|
||||||
require 'rex'
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
||||||
require 'msf/ui'
|
|
||||||
require 'msf/base'
|
require 'rex'
|
||||||
require 'msf/core/payload_generator'
|
require 'msf/ui'
|
||||||
|
require 'msf/base'
|
||||||
|
require 'msf/core/payload_generator'
|
||||||
|
|
||||||
|
|
||||||
class MsfVenomError < StandardError; end
|
class MsfVenomError < StandardError; end
|
||||||
@ -54,7 +56,7 @@ require 'msf/core/payload_generator'
|
|||||||
opts = {}
|
opts = {}
|
||||||
datastore = {}
|
datastore = {}
|
||||||
opt = OptionParser.new
|
opt = OptionParser.new
|
||||||
banner = "MsfVenom - a Metasploit standalone payload generator.\n"
|
banner = "MsfVenom - a Metasploit standalone payload generator.\n"
|
||||||
banner << "Also a replacement for msfpayload and msfencode.\n"
|
banner << "Also a replacement for msfpayload and msfencode.\n"
|
||||||
banner << "Usage: #{$0} [options] <var=val>"
|
banner << "Usage: #{$0} [options] <var=val>"
|
||||||
opt.banner = banner
|
opt.banner = banner
|
||||||
@ -220,13 +222,13 @@ require 'msf/core/payload_generator'
|
|||||||
def dump_payloads
|
def dump_payloads
|
||||||
init_framework(:module_types => [ ::Msf::MODULE_PAYLOAD ])
|
init_framework(:module_types => [ ::Msf::MODULE_PAYLOAD ])
|
||||||
tbl = Rex::Ui::Text::Table.new(
|
tbl = Rex::Ui::Text::Table.new(
|
||||||
'Indent' => 4,
|
'Indent' => 4,
|
||||||
'Header' => "Framework Payloads (#{framework.stats.num_payloads} total)",
|
'Header' => "Framework Payloads (#{framework.stats.num_payloads} total)",
|
||||||
'Columns' =>
|
'Columns' =>
|
||||||
[
|
[
|
||||||
"Name",
|
"Name",
|
||||||
"Description"
|
"Description"
|
||||||
])
|
])
|
||||||
|
|
||||||
framework.payloads.each_module { |name, mod|
|
framework.payloads.each_module { |name, mod|
|
||||||
tbl << [ name, mod.new.description.split.join(' ') ]
|
tbl << [ name, mod.new.description.split.join(' ') ]
|
||||||
@ -238,14 +240,14 @@ require 'msf/core/payload_generator'
|
|||||||
def dump_encoders(arch = nil)
|
def dump_encoders(arch = nil)
|
||||||
init_framework(:module_types => [ ::Msf::MODULE_ENCODER ])
|
init_framework(:module_types => [ ::Msf::MODULE_ENCODER ])
|
||||||
tbl = Rex::Ui::Text::Table.new(
|
tbl = Rex::Ui::Text::Table.new(
|
||||||
'Indent' => 4,
|
'Indent' => 4,
|
||||||
'Header' => "Framework Encoders" + ((arch) ? " (architectures: #{arch})" : ""),
|
'Header' => "Framework Encoders" + ((arch) ? " (architectures: #{arch})" : ""),
|
||||||
'Columns' =>
|
'Columns' =>
|
||||||
[
|
[
|
||||||
"Name",
|
"Name",
|
||||||
"Rank",
|
"Rank",
|
||||||
"Description"
|
"Description"
|
||||||
])
|
])
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
|
||||||
framework.encoders.each_module(
|
framework.encoders.each_module(
|
||||||
@ -261,13 +263,13 @@ require 'msf/core/payload_generator'
|
|||||||
def dump_nops
|
def dump_nops
|
||||||
init_framework(:module_types => [ ::Msf::MODULE_NOP ])
|
init_framework(:module_types => [ ::Msf::MODULE_NOP ])
|
||||||
tbl = Rex::Ui::Text::Table.new(
|
tbl = Rex::Ui::Text::Table.new(
|
||||||
'Indent' => 4,
|
'Indent' => 4,
|
||||||
'Header' => "Framework NOPs (#{framework.stats.num_nops} total)",
|
'Header' => "Framework NOPs (#{framework.stats.num_nops} total)",
|
||||||
'Columns' =>
|
'Columns' =>
|
||||||
[
|
[
|
||||||
"Name",
|
"Name",
|
||||||
"Description"
|
"Description"
|
||||||
])
|
])
|
||||||
|
|
||||||
framework.nops.each_module { |name, mod|
|
framework.nops.each_module { |name, mod|
|
||||||
tbl << [ name, mod.new.description.split.join(' ') ]
|
tbl << [ name, mod.new.description.split.join(' ') ]
|
||||||
@ -278,8 +280,6 @@ require 'msf/core/payload_generator'
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __FILE__ == $0
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
generator_opts = parse_args(ARGV)
|
generator_opts = parse_args(ARGV)
|
||||||
rescue MsfVenomError, Msf::OptionValidateError => e
|
rescue MsfVenomError, Msf::OptionValidateError => e
|
||||||
@ -290,28 +290,21 @@ if __FILE__ == $0
|
|||||||
if generator_opts[:list]
|
if generator_opts[:list]
|
||||||
generator_opts[:list].each do |mod|
|
generator_opts[:list].each do |mod|
|
||||||
case mod.downcase
|
case mod.downcase
|
||||||
when "payloads"
|
when "payloads", "payload", "p"
|
||||||
$stdout.puts dump_payloads
|
$stdout.puts dump_payloads
|
||||||
when "encoders"
|
when "encoders", "encoder", "e"
|
||||||
$stdout.puts dump_encoders(generator_opts[:arch])
|
$stdout.puts dump_encoders(generator_opts[:arch])
|
||||||
when "nops"
|
when "nops", "nop", "n"
|
||||||
$stdout.puts dump_nops
|
$stdout.puts dump_nops
|
||||||
when "all"
|
when "all"
|
||||||
# Init here so #dump_payloads doesn't create a framework with
|
# Init here so #dump_payloads doesn't create a framework with
|
||||||
# only payloads, etc.
|
# only payloads, etc.
|
||||||
init_framework
|
init_framework
|
||||||
$stdout.puts dump_payloads
|
$stdout.puts dump_payloads
|
||||||
$stdout.puts dump_encoders
|
$stdout.puts dump_encoders
|
||||||
$stdout.puts dump_nops
|
$stdout.puts dump_nops
|
||||||
else
|
else
|
||||||
if mod == 'payload'
|
$stderr.puts "Invalid module type. These are valid: payloads, encoders, nops, all"
|
||||||
question = ". Do you mean 'payloads'?"
|
|
||||||
elsif mod == 'encoder'
|
|
||||||
question = ". Do you mean 'encoders'?"
|
|
||||||
elsif mod == 'nop'
|
|
||||||
quesetion = ". Do you mean 'nops'?"
|
|
||||||
end
|
|
||||||
$stderr.puts "Invalid module type#{question}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
exit(0)
|
exit(0)
|
||||||
@ -340,7 +333,7 @@ if __FILE__ == $0
|
|||||||
generator_opts[:cli] = true
|
generator_opts[:cli] = true
|
||||||
|
|
||||||
begin
|
begin
|
||||||
venom_generator = Msf::PayloadGenerator.new(generator_opts)
|
venom_generator = Msf::PayloadGenerator.new(generator_opts)
|
||||||
payload = venom_generator.generate_payload
|
payload = venom_generator.generate_payload
|
||||||
rescue ::Exception => e
|
rescue ::Exception => e
|
||||||
elog("#{e.class} : #{e.message}\n#{e.backtrace * "\n"}")
|
elog("#{e.class} : #{e.message}\n#{e.backtrace * "\n"}")
|
||||||
|
Loading…
Reference in New Issue
Block a user