Ref #53 Typhoeus > 0.4.2 support
This commit is contained in:
@@ -48,26 +48,29 @@ shared_examples_for 'BruteForce' do
|
||||
passwords << password.strip unless password.strip[0, 1] == '#'
|
||||
end
|
||||
# Last status must be 302 to get full code coverage
|
||||
passwords.each do |_|
|
||||
stub_request(:any, @module.login_url).to_return(
|
||||
{ status: 200, body: 'login_error' },
|
||||
{ status: 0, body: 'no reponse' },
|
||||
{ status: 50, body: 'server error' },
|
||||
{ status: 999, body: 'invalid' },
|
||||
{ status: 302, body: 'FOUND!' }
|
||||
)
|
||||
passwords.each do |password|
|
||||
stub_request(:post, @module.login_url).
|
||||
to_return(
|
||||
{ status: 200, body: 'login_error' },
|
||||
{ status: 0, body: 'no reponse' },
|
||||
{ status: 500, body: 'server error' },
|
||||
{ status: 999, body: 'invalid' },
|
||||
{ status: 302, body: 'FOUND!' }
|
||||
)
|
||||
end
|
||||
|
||||
user = WpUser.new('admin', 1, nil)
|
||||
user = WpUser.new('admin', 1, nil)
|
||||
result = @module.brute_force([user], @wordlist)
|
||||
|
||||
result.length.should == 1
|
||||
result.should === [{ name: 'admin', password: 'root' }]
|
||||
end
|
||||
|
||||
it 'should cover the timeout branch and return an empty array' do
|
||||
stub_request(:any, @module.login_url).to_timeout
|
||||
user = WpUser.new('admin', 1, nil)
|
||||
result = @module.brute_force([user], @wordlist)
|
||||
stub_request(:post, @module.login_url).to_timeout
|
||||
|
||||
user = WpUser.new('admin', 1, nil)
|
||||
result = @module.brute_force([user], @wordlist)
|
||||
result.should == []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,8 +34,7 @@ shared_examples_for 'WpConfigBackup' do
|
||||
@config_backup_files.each do |backup_file|
|
||||
file_url = @module.uri.merge(URI.escape(backup_file)).to_s
|
||||
|
||||
stub_request(:get, file_url).
|
||||
to_return(status: 404, body: '')
|
||||
stub_request(:get, file_url).to_return(status: 404)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,8 +49,7 @@ shared_examples_for 'WpConfigBackup' do
|
||||
file_url = @module.uri.merge(URI.escape(backup_file)).to_s
|
||||
expected << file_url
|
||||
|
||||
stub_request(:get, file_url).
|
||||
to_return(status: 200, body: File.new(@fixtures_dir + '/wp-config.php'))
|
||||
stub_request_to_fixture(url: file_url, fixture: @fixtures_dir + '/wp-config.php')
|
||||
end
|
||||
|
||||
wp_config_backup = @module.config_backup
|
||||
@@ -67,8 +65,7 @@ shared_examples_for 'WpConfigBackup' do
|
||||
file_url = @module.uri.merge(URI.escape(backup_file)).to_s
|
||||
expected << file_url
|
||||
|
||||
stub_request(:get, file_url).
|
||||
to_return(status: 200, body: File.new(@fixtures_dir + '/wp-config.php'))
|
||||
stub_request_to_fixture(url: file_url, fixture: @fixtures_dir + '/wp-config.php')
|
||||
end
|
||||
|
||||
wp_config_backup = @module.config_backup
|
||||
|
||||
@@ -21,6 +21,14 @@ describe 'WebSite' do
|
||||
let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WEB_SITE_DIR }
|
||||
subject(:web_site) { WebSite.new('http://example.localhost/') }
|
||||
|
||||
before :all do
|
||||
Browser::reset
|
||||
Browser.instance(
|
||||
config_file: SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json',
|
||||
cache_ttl: 0
|
||||
)
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
its(:url) { should === 'http://example.localhost/' }
|
||||
end
|
||||
@@ -74,7 +82,7 @@ describe 'WebSite' do
|
||||
it 'should return the correct url : http://example.localhost/xmlrpc.php' do
|
||||
xmlrpc = 'http://example.localhost/xmlrpc.php'
|
||||
stub_request(:get, web_site.url).
|
||||
to_return(status: 200, body: '', headers: { 'X-Pingback' => xmlrpc})
|
||||
to_return(status: 200, headers: { 'X-Pingback' => xmlrpc })
|
||||
|
||||
web_site.xml_rpc_url.should === xmlrpc
|
||||
end
|
||||
@@ -88,7 +96,7 @@ describe 'WebSite' do
|
||||
describe '#has_xml_rpc?' do
|
||||
it 'should return true' do
|
||||
stub_request(:get, web_site.url).
|
||||
to_return(status: 200, body: '', headers: { 'X-Pingback' => 'xmlrpc'})
|
||||
to_return(status: 200, headers: { 'X-Pingback' => 'xmlrpc' })
|
||||
|
||||
web_site.should have_xml_rpc
|
||||
end
|
||||
|
||||
@@ -24,11 +24,11 @@ describe WpTarget do
|
||||
let(:target_url) { 'http://example.localhost/' }
|
||||
|
||||
before :each do
|
||||
Browser.reset
|
||||
Browser::reset
|
||||
@options =
|
||||
{
|
||||
config_file: SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json',
|
||||
cache_timeout: 0,
|
||||
cache_ttl: 0,
|
||||
wp_content_dir: 'wp-content',
|
||||
wp_plugins_dir: 'wp-content/plugins'
|
||||
}
|
||||
|
||||
@@ -39,9 +39,10 @@ class WpScanModuleSpec
|
||||
def initialize(target_url)
|
||||
@uri = URI.parse(add_trailing_slash(add_http_protocol(target_url)))
|
||||
|
||||
Browser::reset
|
||||
Browser.instance(
|
||||
config_file: SPEC_FIXTURES_CONF_DIR + '/browser/browser.conf.json',
|
||||
cache_timeout: 0
|
||||
cache_ttl: 0
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user