Skip to content

Commit

Permalink
Made case statements more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
rad10 committed Apr 27, 2024
1 parent b51d1b9 commit 15a9b59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions lib/msf/core/post/linux/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ def get_cpu_info
# @return [String]
#
def get_hostname
hostname = if command_exists?('uname')
cmd_exec('uname -n').to_s
else
read_file('/proc/sys/kernel/hostname').to_s.chomp
end
hostname =
if command_exists?('uname')
cmd_exec('uname -n').to_s
else
read_file('/proc/sys/kernel/hostname').to_s.chomp
end
report_host({ host: rhost, name: hostname })
hostname
rescue StandardError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ def initialize(info = {})
# Check we have all the prerequisites to perform the escape
def check
# Checking database if host has already been disclosed as a container
container_name = if active_db? && framework.db.workspace.hosts.where(address: session.session_host)&.first&.virtual_host
framework.db.workspace.hosts.where(address: session.session_host)&.first&.virtual_host
else
get_container_type
end
container_name =
if active_db? && framework.db.workspace.hosts.where(address: session.session_host)&.first&.virtual_host
framework.db.workspace.hosts.where(address: session.session_host)&.first&.virtual_host
else
get_container_type
end

unless %w[docker podman lxc].include?(container_name.downcase)
return Exploit::CheckCode::Unknown('Host does not appear to be container of any kind')
Expand Down

0 comments on commit 15a9b59

Please sign in to comment.