Land #9954, Add search filtering to the CSV output option
parent
37767e9d4c
commit
f4d9788454
|
@ -19,8 +19,9 @@ module Msf
|
||||||
CMD_USE_TIMEOUT = 3
|
CMD_USE_TIMEOUT = 3
|
||||||
|
|
||||||
@@search_opts = Rex::Parser::Arguments.new(
|
@@search_opts = Rex::Parser::Arguments.new(
|
||||||
"-h" => [ false, "Help banner."],
|
"-h" => [ false, "Help banner"],
|
||||||
"-S" => [ true, "Row search filter."],
|
"-o" => [ true, "Send output to a file in csv format"],
|
||||||
|
"-S" => [ true, "Search string for row filter"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def commands
|
def commands
|
||||||
|
@ -410,7 +411,12 @@ module Msf
|
||||||
end
|
end
|
||||||
|
|
||||||
def cmd_search_help
|
def cmd_search_help
|
||||||
print_line "Usage: search <keywords>"
|
print_line "Usage: search [ options ] <keywords>"
|
||||||
|
print_line
|
||||||
|
print_line "OPTIONS:"
|
||||||
|
print_line " -h Show this help information"
|
||||||
|
print_line " -o <file> Send output to a file in csv format"
|
||||||
|
print_line " -S <string> Search string for row filter"
|
||||||
print_line
|
print_line
|
||||||
print_line "Keywords:"
|
print_line "Keywords:"
|
||||||
{
|
{
|
||||||
|
@ -442,26 +448,29 @@ module Msf
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
match = ''
|
match = ''
|
||||||
search_term = nil
|
search_term = nil
|
||||||
|
output_file = nil
|
||||||
@@search_opts.parse(args) { |opt, idx, val|
|
@@search_opts.parse(args) { |opt, idx, val|
|
||||||
case opt
|
case opt
|
||||||
when "-t"
|
when "-S"
|
||||||
print_error("Deprecated option. Use type:#{val} instead")
|
|
||||||
cmd_search_help
|
|
||||||
return
|
|
||||||
when "-S", "--search"
|
|
||||||
search_term = val
|
search_term = val
|
||||||
when "-h"
|
when "-h"
|
||||||
cmd_search_help
|
cmd_search_help
|
||||||
return
|
return
|
||||||
when "-S"
|
when '-o'
|
||||||
search_term = val
|
output_file = val
|
||||||
else
|
else
|
||||||
match += val + " "
|
match += val + " "
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if match.empty? && search_term.nil?
|
||||||
|
print_error("Keywords or search argument required\n")
|
||||||
|
cmd_search_help
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
# Display the table of matches
|
# Display the table of matches
|
||||||
tbl = generate_module_table("Matching Modules", search_term)
|
tbl = generate_module_table("Matching Modules", search_term)
|
||||||
framework.search(match, logger: self).each do |m|
|
framework.search(match, logger: self).each do |m|
|
||||||
|
@ -472,7 +481,15 @@ module Msf
|
||||||
m.name
|
m.name
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
print_line(tbl.to_s)
|
|
||||||
|
if output_file
|
||||||
|
print_status("Wrote search results to #{output_file}")
|
||||||
|
::File.open(output_file, "wb") { |ofd|
|
||||||
|
ofd.write(tbl.to_csv)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
print_line(tbl.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -487,13 +504,6 @@ module Msf
|
||||||
return @@search_opts.fmt.keys
|
return @@search_opts.fmt.keys
|
||||||
end
|
end
|
||||||
|
|
||||||
case (words[-1])
|
|
||||||
when "-r"
|
|
||||||
return RankingName.sort.map{|r| r[1]}
|
|
||||||
when "-t"
|
|
||||||
return %w{auxiliary encoder exploit nop payload post}
|
|
||||||
end
|
|
||||||
|
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue