Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable word wrapped rex tables by default #14670

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/msf/core/feature_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class FeatureManager
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',
Expand All @@ -32,6 +32,14 @@ class FeatureManager
#
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
Expand Down
5 changes: 4 additions & 1 deletion lib/msf/ui/console/command_dispatcher/creds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ def creds_search(*args)
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
}
Expand Down Expand Up @@ -483,7 +486,7 @@ def creds_search(*args)
"", # host
origin, # origin
"", # service
public_val,
public_val,
private_val,
realm_val,
human_val, #private type
Expand Down
3 changes: 3 additions & 0 deletions lib/msf/ui/console/command_dispatcher/modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,9 @@ def generate_module_table(type, search_terms = [], row_filter = nil) # :nodoc:
'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',
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/msf/ui/console/command_dispatcher/creds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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) }
Expand All @@ -48,14 +48,14 @@
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,
Expand All @@ -73,7 +73,7 @@
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end

Expand All @@ -85,7 +85,7 @@
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end

Expand All @@ -98,7 +98,7 @@
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' nonblank_pass Password '
' nonblank_pass Password'
])
end
end
Expand All @@ -111,7 +111,7 @@
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' nonblank_user Password '
' nonblank_user Password'
])
end
end
Expand Down Expand Up @@ -208,7 +208,7 @@
'',
'host origin service public private realm private_type JtR Format',
'---- ------ ------- ------ ------- ----- ------------ ----------',
' thisuser thispass Password '
' thisuser thispass Password'
])
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/msf/ui/console/command_dispatcher/db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@
"",
"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
Expand Down Expand Up @@ -267,8 +267,8 @@
"",
"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
Expand Down