@@ -43,22 +43,79 @@ def wordpress_version
43
43
# Checks a readme for a vulnerable version
44
44
#
45
45
# @param [String] plugin_name The name of the plugin
46
- # @param [String] fixed_version The version the vulnerability was fixed in
46
+ # @param [String] fixed_version Optional, the version the vulnerability was fixed in
47
47
# @param [String] vuln_introduced_version Optional, the version the vulnerability was introduced
48
48
#
49
49
# @return [ Msf::Exploit::CheckCode ]
50
- def check_plugin_version_from_readme ( plugin_name , fixed_version , vuln_introduced_version = nil )
50
+ def check_plugin_version_from_readme ( plugin_name , fixed_version = nil , vuln_introduced_version = nil )
51
51
check_version_from_readme ( :plugin , plugin_name , fixed_version , vuln_introduced_version )
52
52
end
53
53
54
+ # Checks the style.css file for a vulnerable version
55
+ #
56
+ # @param [String] theme_name The name of the theme
57
+ # @param [String] fixed_version Optional, the version the vulnerability was fixed in
58
+ # @param [String] vuln_introduced_version Optional, the version the vulnerability was introduced
59
+ #
60
+ # @return [ Msf::Exploit::CheckCode ]
61
+ def check_theme_version_from_style ( theme_name , fixed_version = nil , vuln_introduced_version = nil )
62
+ style_uri = normalize_uri ( wordpress_url_themes , theme_name , 'style.css' )
63
+ res = send_request_cgi (
64
+ 'uri' => style_uri ,
65
+ 'method' => 'GET'
66
+ )
67
+
68
+ # No style.css file present
69
+ return Msf ::Exploit ::CheckCode ::Unknown if res . nil? || res . code != 200
70
+
71
+ # Try to extract version from style.css
72
+ # Example line:
73
+ # Version: 1.5.2
74
+ version = res . body . to_s [ /(?:Version):\s *([0-9a-z.-]+)/i , 1 ]
75
+
76
+ # style.css present, but no version number
77
+ return Msf ::Exploit ::CheckCode ::Detected if version . nil?
78
+
79
+ vprint_status ( "#{ peer } - Found version #{ version } of the theme" )
80
+
81
+ if fixed_version . nil?
82
+ if vuln_introduced_version . nil?
83
+ # All versions are vulnerable
84
+ return Msf ::Exploit ::CheckCode ::Appears
85
+ elsif Gem ::Version . new ( version ) >= Gem ::Version . new ( vuln_introduced_version )
86
+ # Newer or equal to the version it was introduced
87
+ return Msf ::Exploit ::CheckCode ::Appears
88
+ else
89
+ return Msf ::Exploit ::CheckCode ::Safe
90
+ end
91
+ else
92
+ # Version older than fixed version
93
+ if Gem ::Version . new ( version ) < Gem ::Version . new ( fixed_version )
94
+ if vuln_introduced_version . nil?
95
+ # All previous versions are vulnerable
96
+ return Msf ::Exploit ::CheckCode ::Appears
97
+ # vuln_introduced_version provided, check if version is newer
98
+ elsif Gem ::Version . new ( version ) >= Gem ::Version . new ( vuln_introduced_version )
99
+ return Msf ::Exploit ::CheckCode ::Appears
100
+ else
101
+ # Not in range, nut vulnerable
102
+ return Msf ::Exploit ::CheckCode ::Safe
103
+ end
104
+ # version newer than fixed version
105
+ else
106
+ return Msf ::Exploit ::CheckCode ::Safe
107
+ end
108
+ end
109
+ end
110
+
54
111
# Checks a readme for a vulnerable version
55
112
#
56
113
# @param [String] theme_name The name of the theme
57
- # @param [String] fixed_version The version the vulnerability was fixed in
114
+ # @param [String] fixed_version Optional, the version the vulnerability was fixed in
58
115
# @param [String] vuln_introduced_version Optional, the version the vulnerability was introduced
59
116
#
60
117
# @return [ Msf::Exploit::CheckCode ]
61
- def check_theme_version_from_readme ( theme_name , fixed_version , vuln_introduced_version = nil )
118
+ def check_theme_version_from_readme ( theme_name , fixed_version = nil , vuln_introduced_version = nil )
62
119
check_version_from_readme ( :theme , theme_name , fixed_version , vuln_introduced_version )
63
120
end
64
121
@@ -114,21 +171,33 @@ def check_version_from_readme(type, name, fixed_version, vuln_introduced_version
114
171
115
172
vprint_status ( "#{ peer } - Found version #{ version } of the #{ type } " )
116
173
117
- # Version older than fixed version
118
- if Gem ::Version . new ( version ) < Gem ::Version . new ( fixed_version )
174
+ if fixed_version . nil?
119
175
if vuln_introduced_version . nil?
120
176
# All versions are vulnerable
121
177
return Msf ::Exploit ::CheckCode ::Appears
122
- # vuln_introduced_version provided, check if version is newer
123
178
elsif Gem ::Version . new ( version ) >= Gem ::Version . new ( vuln_introduced_version )
179
+ # Newer or equal to the version it was introduced
124
180
return Msf ::Exploit ::CheckCode ::Appears
125
181
else
126
- # Not in range, nut vulnerable
127
182
return Msf ::Exploit ::CheckCode ::Safe
128
183
end
129
- # version newer than fixed version
130
184
else
131
- return Msf ::Exploit ::CheckCode ::Safe
185
+ # Version older than fixed version
186
+ if Gem ::Version . new ( version ) < Gem ::Version . new ( fixed_version )
187
+ if vuln_introduced_version . nil?
188
+ # All versions are vulnerable
189
+ return Msf ::Exploit ::CheckCode ::Appears
190
+ # vuln_introduced_version provided, check if version is newer
191
+ elsif Gem ::Version . new ( version ) >= Gem ::Version . new ( vuln_introduced_version )
192
+ return Msf ::Exploit ::CheckCode ::Appears
193
+ else
194
+ # Not in range, nut vulnerable
195
+ return Msf ::Exploit ::CheckCode ::Safe
196
+ end
197
+ # version newer than fixed version
198
+ else
199
+ return Msf ::Exploit ::CheckCode ::Safe
200
+ end
132
201
end
133
202
end
134
203
end
0 commit comments