add some options to most module_* tools, fixes #4341, thanks David Maloney!

git-svn-id: file:///home/svn/framework3/trunk@12880 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2011-06-07 00:20:21 +00:00
parent 4a0cecbc29
commit b4c4cc19c2
4 changed files with 439 additions and 91 deletions

View File

@ -14,6 +14,50 @@ require 'rex'
require 'msf/ui'
require 'msf/base'
sort=0
filter= 'All'
filters= ['All','Exploit','Payload','Post','NOP','Encoder','Auxiliary']
reg=0
regex= ''
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-s" => [ false, "Sort by Author instead of Module Type."],
"-r" => [ false, "Reverse Sort"],
"-f" => [ true, "Filter based on Module Type [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary] (Default = All)."],
"-x" => [ true, "String or RegEx to try and match against the Author Field"]
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module Author information."
puts "=========================================================="
puts opts.usage
exit
when "-s"
puts "Sorting by Author"
sort = 1
when "-r"
puts "Reverse Sorting"
sort = 2
when "-f"
unless filters.include?(val)
puts "Invalid Filter Supplied: #{val}"
puts "Please use one of these: [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary]"
exit
end
puts "Module Filter: #{val}"
filter = val
when "-x"
puts "Regex: #{val}"
reg=1
regex = val
end
}
Indent = ' '
# Initialize the simplified framework instance.
@ -27,48 +71,93 @@ tbl = Rex::Ui::Text::Table.new(
names = {}
$framework.payloads.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
tbl << [ 'payload/' + name, r ]
names[r]||=0; names[r]+=1
end
}
if filter=='Payload' or filter=='All'
$framework.payloads.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'payload/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
$framework.exploits.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
tbl << [ 'exploit/' + name, r ]
names[r]||=0; names[r]+=1
end
}
if filter=='Exploit' or filter=='All'
$framework.exploits.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'exploit/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
$framework.nops.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
tbl << [ 'nop/' + name, r ]
names[r]||=0; names[r]+=1
end
}
$framework.encoders.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
tbl << [ 'encoder/' + name, r ]
names[r]||=0; names[r]+=1
end
}
$framework.auxiliary.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
tbl << [ 'auxiliary/' + name, r ]
names[r]||=0; names[r]+=1
end
}
if filter=='NOP' or filter=='All'
$framework.nops.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'nop/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
if filter=='Encoder' or filter=='All'
$framework.encoders.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'encoder/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
if filter=='Auxiliary' or filter=='All'
$framework.auxiliary.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'auxiliary/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
if filter=='Post' or filter=='All'
$framework.post.each_module { |name, mod|
x = mod.new
x.author.each do |r|
r = r.to_s
if reg==0 or r=~/#{regex}/
tbl << [ 'post/' + name, r ]
names[r]||=0; names[r]+=1
end
end
}
end
if sort == 1
tbl.sort_rows(1)
end
if sort == 2
tbl.sort_rows(1)
tbl.rows.reverse
end
puts tbl.to_s

View File

@ -33,6 +33,53 @@ def lic_short(l)
end
end
sort=0
filter= 'All'
filters= ['All','Exploit','Payload','Post','NOP','Encoder','Auxiliary']
reg=0
regex= ''
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-s" => [ false, "Sort by License instead of Module Type."],
"-r" => [ false, "Reverse Sort"],
"-f" => [ true, "Filter based on Module Type [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary] (Default = All)."],
"-x" => [ true, "String or RegEx to try and match against the License Field"]
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module License information."
puts "=========================================================="
puts opts.usage
exit
when "-s"
puts "Sorting by License"
sort = 1
when "-r"
puts "Reverse Sorting"
sort = 2
when "-f"
unless filters.include?(val)
puts "Invalid Filter Supplied: #{val}"
puts "Please use one of these: [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary]"
exit
end
puts "Module Filter: #{val}"
filter = val
when "-x"
puts "Regex: #{val}"
reg=1
regex = val
end
}
Indent = ' '
# Initialize the simplified framework instance.
@ -47,25 +94,74 @@ tbl = Rex::Ui::Text::Table.new(
licenses = {}
$framework.payloads.each_module { |name, mod|
x = mod.new
tbl << [ lic_short(x.license), 'Payload', name ]
}
$framework.exploits.each_module { |name, mod|
x = mod.new
tbl << [ lic_short(x.license), 'Exploit', name ]
}
$framework.nops.each_module { |name, mod|
x = mod.new
tbl << [ lic_short(x.license), 'Nop', name ]
}
$framework.encoders.each_module { |name, mod|
x = mod.new
tbl << [ lic_short(x.license), 'Encoder', name ]
}
$framework.auxiliary.each_module { |name, mod|
x = mod.new
tbl << [ lic_short(x.license), 'Auxiliary', name ]
}
if filter=='Payload' or filter=='All'
$framework.payloads.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Payload', name ]
end
}
end
if filter=='Exploit' or filter=='All'
$framework.exploits.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Exploit', name ]
end
}
end
if filter=='NOP' or filter=='All'
$framework.nops.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Nop', name ]
end
}
end
if filter=='Encoder' or filter=='All'
$framework.encoders.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Encoder', name ]
end
}
end
if filter=='Auxiliary' or filter=='All'
$framework.auxiliary.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Auxiliary', name ]
end
}
end
if filter=='Post' or filter=='All'
$framework.post.each_module { |name, mod|
x = mod.new
lictype = lic_short(x.license)
if reg==0 or lictype=~/#{regex}/
tbl << [ lictype, 'Post', name ]
end
}
end
if sort == 1
tbl.sort_rows(0)
end
if sort == 2
tbl.sort_rows(1)
tbl.rows.reverse
end
puts tbl.to_s

View File

@ -14,6 +14,64 @@ require 'rex'
require 'msf/ui'
require 'msf/base'
sort=0
filter= 'All'
filters= ['All','Exploit','Payload','Post','NOP','Encoder','Auxiliary']
types = ['All','URL','CVE','OSVDB','BID','MSB','NSS','US-CERT-VU']
type='All'
reg=0
regex= ''
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-s" => [ false, "Sort by Reference instead of Module Type."],
"-r" => [ false, "Reverse Sort"],
"-f" => [ true, "Filter based on Module Type [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary] (Default = All)."],
"-t" => [ true, "Type of Reference to sort by [All,URL,CVE,OSVDB,BID,MSB,NSS,US-CERT-VU]"],
"-x" => [ true, "String or RegEx to try and match against the Reference Field"]
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module Reference information."
puts "=========================================================="
puts opts.usage
exit
when "-s"
puts "Sorting by License"
sort = 1
when "-r"
puts "Reverse Sorting"
sort = 2
when "-f"
unless filters.include?(val)
puts "Invalid Filter Supplied: #{val}"
puts "Please use one of these: [All,Exploit,Payload,Post,NOP,Encoder,Auxiliary]"
exit
end
puts "Module Filter: #{val}"
filter = val
when "-t"
unless types.include?(val)
puts "Invalid Type Supplied: #{val}"
puts "Please use one of these: [All,URL,CVE,OSVDB,BID,MSB,NSS,US-CERT-VU]"
exit
end
puts "Type: #{val}"
type = val
when "-x"
puts "Regex: #{val}"
reg=1
regex = val
end
}
puts "Type: #{type}"
Indent = ' '
# Initialize the simplified framework instance.
@ -25,37 +83,99 @@ tbl = Rex::Ui::Text::Table.new(
'Columns' => [ 'Module', 'Reference' ]
)
$framework.payloads.each_module { |name, mod|
x = mod.new
x.references.each do |r|
tbl << [ 'payload/' + name, r.ctx_id + '-' + r.ctx_val ]
end
}
if filter=='Payload' or filter=='All'
$framework.payloads.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'payload/' + name, ref ]
end
end
end
}
end
$framework.exploits.each_module { |name, mod|
x = mod.new
x.references.each do |r|
tbl << [ 'exploit/' + name, r.ctx_id + '-' + r.ctx_val ]
end
}
if filter=='Exploit' or filter=='All'
$framework.exploits.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'exploit/' + name, ref ]
end
end
end
}
end
if filter=='NOP' or filter=='All'
$framework.nops.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'nop/' + name, ref ]
end
end
end
}
end
if filter=='Encoder' or filter=='All'
$framework.encoders.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'encoder/' + name, ref ]
end
end
end
}
end
if filter=='Auxiliary' or filter=='All'
$framework.auxiliary.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'auxiliary/' + name, ref ]
end
end
end
}
end
if filter=='Post' or filter=='All'
$framework.post.each_module { |name, mod|
x = mod.new
x.references.each do |r|
if type=='All' or type==r.ctx_id
ref = r.ctx_id + '-' + r.ctx_val
if reg==0 or ref=~/#{regex}/
tbl << [ 'post/' + name, ref ]
end
end
end
}
end
if sort == 1
tbl.sort_rows(1)
end
if sort == 2
tbl.sort_rows(1)
tbl.rows.reverse
end
$framework.nops.each_module { |name, mod|
x = mod.new
x.references.each do |r|
tbl << [ 'nop/' + name, r.ctx_id + '-' + r.ctx_val ]
end
}
$framework.encoders.each_module { |name, mod|
x = mod.new
x.references.each do |r|
tbl << [ 'encoder/' + name, r.ctx_id + '-' + r.ctx_val ]
end
}
$framework.auxiliary.each_module { |name, mod|
x = mod.new
x.references.each do |r|
tbl << [ 'auxiliary/' + name, r.ctx_id + '-' + r.ctx_val ]
end
}
puts tbl.to_s

View File

@ -14,6 +14,37 @@ require 'rex'
require 'msf/ui'
require 'msf/base'
sort=0
fil = 0
filter = ""
opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-s" => [ false, "Sort by Target instead of Module Type."],
"-r" => [ false, "Reverse Sort"],
"-x" => [ true, "String or RegEx to try and match against the Targets field"]
)
opts.parse(ARGV) { |opt, idx, val|
case opt
when "-h"
puts "\nMetasploit Script for Displaying Module Target information."
puts "=========================================================="
puts opts.usage
exit
when "-s"
puts "Sorting by Target"
sort = 1
when "-r"
puts "Reverse Sorting"
sort = 2
when "-x"
puts "Filter: #{val}"
filter = val
fil=1
end
}
Indent = ' '
# Initialize the simplified framework instance.
@ -30,8 +61,20 @@ all_modules = $framework.exploits
all_modules.each_module { |name, mod|
x = mod.new
x.targets.each do |targ|
tbl << [ x.fullname, targ.name ]
if fil==0 or targ.name=~/#{filter}/
tbl << [ x.fullname, targ.name ]
end
end
}
if sort == 1
tbl.sort_rows(1)
end
if sort == 2
tbl.sort_rows(1)
tbl.rows.reverse
end
puts tbl.to_s