Skip to content

Commit 7875feb

Browse files
authored
Merge pull request rapid7#20166 from bcoles/msf-module-platform
Msf::Module::Platform#find_platform: Match known platforms before search
2 parents b251fc1 + 8d534e3 commit 7875feb

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

lib/msf/core/module/platform.rb

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,78 @@ def self.find_platform(str)
5353
# remove any whitespace and downcase
5454
str = str.gsub(' ', '').downcase
5555

56+
# Match known platforms first, then fall back to string matching
57+
case str
58+
when 'windows', 'win'
59+
return Msf::Module::Platform::Windows
60+
when 'linux'
61+
return Msf::Module::Platform::Linux
62+
when 'unix'
63+
return Msf::Module::Platform::Unix
64+
when 'osx'
65+
return Msf::Module::Platform::OSX
66+
when 'solaris'
67+
return Msf::Module::Platform::Solaris
68+
when 'freebsd'
69+
return Msf::Module::Platform::FreeBSD
70+
when 'netware'
71+
return Msf::Module::Platform::Netware
72+
when 'bsd'
73+
return Msf::Module::Platform::BSD
74+
when 'openbsd'
75+
return Msf::Module::Platform::OpenBSD
76+
when 'android'
77+
return Msf::Module::Platform::Android
78+
when 'java'
79+
return Msf::Module::Platform::Java
80+
when 'r'
81+
return Msf::Module::Platform::R
82+
when 'ruby'
83+
return Msf::Module::Platform::Ruby
84+
when 'cisco'
85+
return Msf::Module::Platform::Cisco
86+
when 'juniper'
87+
return Msf::Module::Platform::Juniper
88+
when 'unifi'
89+
return Msf::Module::Platform::Unifi
90+
when 'brocade'
91+
return Msf::Module::Platform::Brocade
92+
when 'mikrotik'
93+
return Msf::Module::Platform::Mikrotik
94+
when 'arista'
95+
return Msf::Module::Platform::Arista
96+
when 'bsdi'
97+
return Msf::Module::Platform::BSDi
98+
when 'netbsd'
99+
return Msf::Module::Platform::NetBSD
100+
when 'aix'
101+
return Msf::Module::Platform::AIX
102+
when 'hpux'
103+
return Msf::Module::Platform::HPUX
104+
when 'irix'
105+
return Msf::Module::Platform::Irix
106+
when 'php'
107+
return Msf::Module::Platform::PHP
108+
when 'javascript'
109+
return Msf::Module::Platform::JavaScript
110+
when 'python'
111+
return Msf::Module::Platform::Python
112+
when 'nodejs'
113+
return Msf::Module::Platform::NodeJS
114+
when 'firefox'
115+
return Msf::Module::Platform::Firefox
116+
when 'mainframe'
117+
return Msf::Module::Platform::Mainframe
118+
when 'multi'
119+
return Msf::Module::Platform::Multi
120+
when 'hardware'
121+
return Msf::Module::Platform::Hardware
122+
when 'apple_ios'
123+
return Msf::Module::Platform::Apple_iOS
124+
when 'unknown'
125+
return Msf::Module::Platform::Unknown
126+
end
127+
56128
# Start at the base platform module
57129
mod = ::Msf::Module::Platform
58130

0 commit comments

Comments
 (0)