rspec this
parent
a806b1aa5e
commit
094abdd093
|
@ -0,0 +1,133 @@
|
|||
require 'spec_helper'
|
||||
require 'msf/core'
|
||||
require 'msf/core/exploit/browser/server'
|
||||
|
||||
describe Msf::Exploit::Remote::BrowserExploitServer do
|
||||
|
||||
subject(:server) do
|
||||
mod = Msf::Exploit.allocate
|
||||
mod.extend described_class
|
||||
mod.send(:initialize, {})
|
||||
mod
|
||||
end
|
||||
|
||||
let(:mock_service) do
|
||||
mock_service = double("service")
|
||||
mock_service.stub(:server_name=)
|
||||
mock_service.stub(:add_resource)
|
||||
|
||||
mock_service
|
||||
end
|
||||
|
||||
before do
|
||||
Rex::ServiceManager.stub(:start => mock_service)
|
||||
end
|
||||
|
||||
describe ".get_module_resource" do
|
||||
it "should give me a URI to access the exploit page" do
|
||||
server.start_service
|
||||
ivar_exploit_page = server.instance_variable_get(:@exploit_receiver_page)
|
||||
module_resource = server.get_module_resource
|
||||
module_resource.should match(ivar_exploit_page)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".requirements" do
|
||||
it "should begin with an empty hash by default" do
|
||||
server.start_service
|
||||
ivar_requirements = server.instance_variable_get(:@requirements)
|
||||
ivar_requirements.should eq({})
|
||||
end
|
||||
|
||||
it "should have some requirements" do
|
||||
opts = {
|
||||
:source => /script|headers/i,
|
||||
:os_name => /win/i
|
||||
}
|
||||
|
||||
server.start_service
|
||||
server.requirements(opts)
|
||||
ivar_requirements = server.instance_variable_get(:@requirements)
|
||||
ivar_requirements.should eq(opts)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".has_bad_requirements?" do
|
||||
it "should not contain any bad requirements" do
|
||||
fake_profile = {
|
||||
"rMWwSAwBHLoESpHbEGbsv" => {
|
||||
:source => "script",
|
||||
:os_name => "Microsoft Windows",
|
||||
:os_flavor => "XP",
|
||||
:ua_name => "MSIE",
|
||||
:ua_ver => "8.0",
|
||||
:arch => "x86",
|
||||
:office => "null",
|
||||
:proxy => false,
|
||||
:language => "en-us",
|
||||
:tried => true
|
||||
}}
|
||||
|
||||
server.start_service
|
||||
server.has_bad_requirements?(fake_profile).should eq([])
|
||||
end
|
||||
|
||||
it "should have identify :os_name as a requirement not met" do
|
||||
fake_profile = {
|
||||
"rMWwSAwBHLoESpHbEGbsv" => {
|
||||
:os_name => "Linux"
|
||||
}}
|
||||
|
||||
server.start_service
|
||||
server.requirements({:os_name=>/win/i})
|
||||
baddies = server.has_bad_requirements?(fake_profile)
|
||||
baddies.should eq([:os_name])
|
||||
end
|
||||
end
|
||||
|
||||
describe ".init_profile" do
|
||||
it "should initialize an empety profile for tag 'random'" do
|
||||
server.start_service
|
||||
server.init_profile("random")
|
||||
ivar_target_profile = server.instance_variable_get(:@target_profiles).first
|
||||
ivar_target_profile['random'].should eq({})
|
||||
end
|
||||
end
|
||||
|
||||
describe ".get_profile" do
|
||||
it "should return nil when a profile isn't found" do
|
||||
server.start_service
|
||||
server.init_profile("random")
|
||||
p = server.get_profile("sinn3r")
|
||||
p.should eq(nil)
|
||||
end
|
||||
|
||||
it "should return a profile if found" do
|
||||
server.start_service
|
||||
server.init_profile("random")
|
||||
p = server.get_profile("random")
|
||||
p['random'].should_not eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".update_profile" do
|
||||
it "should update my target profile's :os_name information" do
|
||||
server.start_service
|
||||
server.init_profile("random")
|
||||
profile = server.get_profile("random")
|
||||
server.update_profile(profile, :os_name, 'Linux')
|
||||
profile = server.get_profile("random")
|
||||
os_name = profile['random'][:os_name]
|
||||
os_name.should eq('Linux')
|
||||
end
|
||||
end
|
||||
|
||||
describe ".get_detection_html" do
|
||||
it "should return the detection code that the client will get" do
|
||||
server.start_service
|
||||
html = server.get_detection_html
|
||||
html.should_not eq('')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue