Enable word wrapped rex tables by default

This commit is contained in:
Alan Foster 2021-01-28 10:24:01 +00:00
parent 7b7f1a2637
commit f3ce9082b6
No known key found for this signature in database
GPG Key ID: 3BD4FA3818818F04
5 changed files with 29 additions and 15 deletions

View File

@ -16,9 +16,9 @@ module Msf
WRAPPED_TABLES = 'wrapped_tables'
DEFAULTS = [
{
name: 'wrapped_tables',
name: WRAPPED_TABLES,
description: 'When enabled Metasploit will wordwrap all tables to fit into the available terminal width',
default_value: false
default_value: true
}.freeze,
{
name: 'RHOST_HTTP_URL',
@ -32,6 +32,14 @@ module Msf
#
def initialize
@flag_lookup = DEFAULTS.each_with_object({}) do |feature, acc|
if feature[:name] == WRAPPED_TABLES
if feature[:default_value] == true
Rex::Text::Table.wrap_tables!
else
Rex::Text::Table.unwrap_tables!
end
end
key = feature[:name]
acc[key] = feature.dup
end

View File

@ -432,6 +432,9 @@ class Creds
svcs.flatten!
tbl_opts = {
'Header' => "Credentials",
# For now, don't perform any word wrapping on the cred table as it breaks the workflow of
# copying credentials and pasting them into applications
'Width' => ::BigDecimal::INFINITY,
'Columns' => cred_table_columns,
'SearchTerm' => search_term
}
@ -483,7 +486,7 @@ class Creds
"", # host
origin, # origin
"", # service
public_val,
public_val,
private_val,
realm_val,
human_val, #private type

View File

@ -1301,6 +1301,9 @@ module Msf
'Prefix' => "\n",
'Postfix' => "\n",
'SearchTerm' => row_filter,
# For now, don't perform any word wrapping on the search table as it breaks the workflow of
# copying module names in conjunction with the `use <paste-buffer>` command
'Width' => ::BigDecimal::INFINITY,
'Columns' => [
'#',
'Name',

View File

@ -34,7 +34,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
let(:nonblank_password) { 'nonblank_pass' }
let!(:origin) { FactoryBot.create(:metasploit_credential_origin_import) }
let!(:priv) { FactoryBot.create(:metasploit_credential_password, data: password) }
let!(:pub) { FactoryBot.create(:metasploit_credential_username, username: username) }
let!(:blank_pub) { blank_pub = FactoryBot.create(:metasploit_credential_blank_username) }
@ -48,14 +48,14 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
public: pub,
realm: nil,
workspace: framework.db.workspace)
FactoryBot.create(:metasploit_credential_core,
origin: origin,
private: nonblank_priv,
public: blank_pub,
realm: nil,
workspace: framework.db.workspace)
FactoryBot.create(:metasploit_credential_core,
origin: origin,
private: blank_priv,
@ -73,7 +73,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end
@ -85,7 +85,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end
@ -98,7 +98,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' nonblank_pass Password '
' nonblank_pass Password'
])
end
end
@ -111,7 +111,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' nonblank_user Password '
' nonblank_user Password'
])
end
end
@ -208,7 +208,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Creds do
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end
end

View File

@ -234,8 +234,8 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
"",
"host port proto name state info",
"---- ---- ----- ---- ----- ----",
"192.168.0.1 1024 udp service1 open ",
"192.168.0.1 1025 tcp service2 open "
"192.168.0.1 1024 udp service1 open",
"192.168.0.1 1025 tcp service2 open"
]
end
end
@ -267,8 +267,8 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
"",
"host port proto name state info",
"---- ---- ----- ---- ----- ----",
"192.168.0.2 1025 snmp open ",
"192.168.0.2 1026 snmp open "
"192.168.0.2 1025 snmp open",
"192.168.0.2 1026 snmp open"
]
}
end