Add cmd notes option to sort by column number

GSoC/Meterpreter_Web_Console
Matthew Kienow 2018-04-12 15:56:42 -04:00
parent 5b2bbe7432
commit 4e49b99783
No known key found for this signature in database
GPG Key ID: 40787F8B1EAC6E41
2 changed files with 9 additions and 1 deletions

View File

@ -923,6 +923,7 @@ class Db
print_line " -R,--rhosts Set RHOSTS from the results of the search"
print_line " -S,--search Search string to filter by"
print_line " -o,--output Save the notes to a csv file"
print_line " -O <column> Order rows by specified column number"
print_line
print_line "Examples:"
print_line " notes --add -t apps -n 'winzip' 10.1.1.34 10.1.20.41"
@ -970,6 +971,11 @@ class Db
search_term = args.shift
when '-o', '--output'
output_file = args.shift
when '-O'
if (order_by = args.shift.to_i - 1) < 0
print_error('Please specify a column number starting from 1')
return
end
when '-u', '--update' # TODO: This is currently undocumented because it's not officially supported.
mode = :update
when '-h', '--help'
@ -1043,7 +1049,8 @@ class Db
table = Rex::Text::Table.new(
'Header' => 'Notes',
'Indent' => 1,
'Columns' => ['Time', 'Host', 'Service', 'Port', 'Protocol', 'Type', 'Data']
'Columns' => ['Time', 'Host', 'Service', 'Port', 'Protocol', 'Type', 'Data'],
'SortIndex' => order_by
)
matched_note_ids = []

View File

@ -177,6 +177,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
" -R,--rhosts Set RHOSTS from the results of the search",
" -S,--search Search string to filter by",
" -o,--output Save the notes to a csv file",
" -O <column> Order rows by specified column number",
"Examples:",
" notes --add -t apps -n 'winzip' 10.1.1.34 10.1.20.41",
" notes -t smb.fingerprint 10.1.1.34 10.1.20.41",