Skip to content

Commit 00c4d70

Browse files
committed
Update rspec to include new functionality
Added a new test for testing when all versions of a plugin are vulnerable and added tests for checking theme versions from the style.css file
1 parent 3669fb6 commit 00c4d70

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

spec/lib/msf/http/wordpress/version_spec.rb

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,97 @@
145145
it { expect(subject.send(:check_version_from_readme, :plugin, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) }
146146
end
147147

148+
context 'when all versions are vulnerable' do
149+
let(:wp_code) { 200 }
150+
let(:wp_body) { 'Stable tag: 1.0.0' }
151+
it { expect(subject.send(:check_version_from_readme, :plugin, 'name')).to be(Msf::Exploit::CheckCode::Appears) }
152+
end
153+
end
154+
155+
describe '#check_theme_version_from_style' do
156+
before :each do
157+
allow(subject).to receive(:send_request_cgi) do |opts|
158+
res = Rex::Proto::Http::Response.new
159+
res.code = wp_code
160+
res.body = wp_body
161+
res
162+
end
163+
end
164+
165+
let(:wp_code) { 200 }
166+
let(:wp_body) { nil }
167+
let(:wp_fixed_version) { nil }
168+
169+
context 'when no style is found' do
170+
let(:wp_code) { 404 }
171+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Unknown) }
172+
end
173+
174+
context 'when no version can be extracted from style' do
175+
let(:wp_code) { 200 }
176+
let(:wp_body) { 'invalid content' }
177+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Detected) }
178+
end
179+
180+
context 'when version from style has arbitrary leading whitespace' do
181+
let(:wp_code) { 200 }
182+
let(:wp_fixed_version) { '1.0.1' }
183+
let(:wp_body) { 'Version: 1.0.0' }
184+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) }
185+
let(:wp_body) { 'Version:1.0.0' }
186+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) }
187+
end
188+
189+
context 'when installed version is vulnerable' do
190+
let(:wp_code) { 200 }
191+
let(:wp_fixed_version) { '1.0.1' }
192+
let(:wp_body) { 'Version: 1.0.0' }
193+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Appears) }
194+
end
195+
196+
context 'when installed version is not vulnerable' do
197+
let(:wp_code) { 200 }
198+
let(:wp_fixed_version) { '1.0.1' }
199+
let(:wp_body) { 'Version: 1.0.2' }
200+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) }
201+
end
202+
203+
context 'when installed version is vulnerable (version range)' do
204+
let(:wp_code) { 200 }
205+
let(:wp_fixed_version) { '1.0.2' }
206+
let(:wp_introd_version) { '1.0.0' }
207+
let(:wp_body) { 'Version: 1.0.1' }
208+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Appears) }
209+
end
210+
211+
context 'when installed version is older (version range)' do
212+
let(:wp_code) { 200 }
213+
let(:wp_fixed_version) { '1.0.1' }
214+
let(:wp_introd_version) { '1.0.0' }
215+
let(:wp_body) { 'Version: 0.0.9' }
216+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) }
217+
end
218+
219+
context 'when installed version is newer (version range)' do
220+
let(:wp_code) { 200 }
221+
let(:wp_fixed_version) { '1.0.1' }
222+
let(:wp_introd_version) { '1.0.0' }
223+
let(:wp_body) { 'Version: 1.0.2' }
224+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version, wp_introd_version)).to be(Msf::Exploit::CheckCode::Safe) }
225+
end
226+
227+
context 'when installed version is newer (text in version number)' do
228+
let(:wp_code) { 200 }
229+
let(:wp_fixed_version) { '1.5.3' }
230+
let(:wp_body) { 'Version: 2.0.0-beta1' }
231+
it { expect(subject.send(:check_theme_version_from_style, 'name', wp_fixed_version)).to be(Msf::Exploit::CheckCode::Safe) }
232+
end
233+
234+
context 'when all versions are vulnerable' do
235+
let(:wp_code) { 200 }
236+
let(:wp_body) { 'Version: 1.0.0' }
237+
it { expect(subject.send(:check_theme_version_from_style, 'name')).to be(Msf::Exploit::CheckCode::Appears) }
238+
end
148239
end
149240

150241
end

0 commit comments

Comments
 (0)