Skip to content

Msf::Module::Platform#find_platform: Match known platforms before search #20166

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
72 changes: 72 additions & 0 deletions lib/msf/core/module/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,78 @@ def self.find_platform(str)
# remove any whitespace and downcase
str = str.gsub(' ', '').downcase

# Match known platforms first, then fall back to string matching
case str
when 'windows', 'win'
return Msf::Module::Platform::Windows
when 'linux'
return Msf::Module::Platform::Linux
when 'unix'
return Msf::Module::Platform::Unix
when 'osx'
return Msf::Module::Platform::OSX
when 'solaris'
return Msf::Module::Platform::Solaris
when 'freebsd'
return Msf::Module::Platform::FreeBSD
when 'netware'
return Msf::Module::Platform::Netware
when 'bsd'
return Msf::Module::Platform::BSD
when 'openbsd'
return Msf::Module::Platform::OpenBSD
when 'android'
return Msf::Module::Platform::Android
when 'java'
return Msf::Module::Platform::Java
when 'r'
return Msf::Module::Platform::R
when 'ruby'
return Msf::Module::Platform::Ruby
when 'cisco'
return Msf::Module::Platform::Cisco
when 'juniper'
return Msf::Module::Platform::Juniper
when 'unifi'
return Msf::Module::Platform::Unifi
when 'brocade'
return Msf::Module::Platform::Brocade
when 'mikrotik'
return Msf::Module::Platform::Mikrotik
when 'arista'
return Msf::Module::Platform::Arista
when 'bsdi'
return Msf::Module::Platform::BSDi
when 'netbsd'
return Msf::Module::Platform::NetBSD
when 'aix'
return Msf::Module::Platform::AIX
when 'hpux'
return Msf::Module::Platform::HPUX
when 'irix'
return Msf::Module::Platform::Irix
when 'php'
return Msf::Module::Platform::PHP
when 'javascript'
return Msf::Module::Platform::JavaScript
when 'python'
return Msf::Module::Platform::Python
when 'nodejs'
return Msf::Module::Platform::NodeJS
when 'firefox'
return Msf::Module::Platform::Firefox
when 'mainframe'
return Msf::Module::Platform::Mainframe
when 'multi'
return Msf::Module::Platform::Multi
when 'hardware'
return Msf::Module::Platform::Hardware
when 'apple_ios'
return Msf::Module::Platform::Apple_iOS
when 'unknown'
return Msf::Module::Platform::Unknown
end

# Start at the base platform module
mod = ::Msf::Module::Platform

Expand Down
Loading