This commit is contained in:
erwanlr
2020-06-08 20:13:18 +02:00
parent 5de9084901
commit b909856933
2 changed files with 14 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ module WPScan
# @return [ Hash ]
def potential_urls(opts = {})
urls = {}
domain_name = PublicSuffix.domain(target.uri.host)[/(^[\w|-]+)/, 1]
domain_name = (PublicSuffix.domain(target.uri.host) || target.uri.host)[/(^[\w|-]+)/, 1]
File.open(opts[:list]).each_with_index do |path, index|
path.gsub!('{domain_name}', domain_name)

View File

@@ -12,7 +12,7 @@ describe WPScan::Finders::DbExports::KnownLocations do
allow(target).to receive(:sub_dir).and_return(false)
end
it 'replace {domain_name} by its value' do
it 'replaces {domain_name} by its value' do
expect(finder.potential_urls(opts).keys).to eql %w[
http://ex.lo/aa/ex.sql
http://ex.lo/aa/wordpress.sql
@@ -27,7 +27,7 @@ describe WPScan::Finders::DbExports::KnownLocations do
context "when #{sub_domain} sub-domain" do
let(:url) { "https://#{sub_domain}.domain.tld" }
it 'replace {domain_name} by its correct value' do
it 'replaces {domain_name} by its correct value' do
expect(finder.potential_urls(opts).keys).to include "#{url}/domain.sql"
end
end
@@ -36,7 +36,7 @@ describe WPScan::Finders::DbExports::KnownLocations do
context 'when multi-level tlds' do
let(:url) { 'https://something.com.tr' }
it 'replace {domain_name} by its correct value' do
it 'replaces {domain_name} by its correct value' do
expect(finder.potential_urls(opts).keys).to include 'https://something.com.tr/something.sql'
end
end
@@ -44,7 +44,7 @@ describe WPScan::Finders::DbExports::KnownLocations do
context 'when multi-level tlds and sub-domain' do
let(:url) { 'https://dev.something.com.tr' }
it 'replace {domain_name} by its correct value' do
it 'replaces {domain_name} by its correct value' do
expect(finder.potential_urls(opts).keys).to include 'https://dev.something.com.tr/something.sql'
end
end
@@ -52,10 +52,18 @@ describe WPScan::Finders::DbExports::KnownLocations do
context 'when some weird stuff' do
let(:url) { 'https://098f6bcd4621d373cade4e832627b4f6.aa-bb-ccc-dd.domain-test.com' }
it 'replace {domain_name} by its correct value' do
it 'replaces {domain_name} by its correct value' do
expect(finder.potential_urls(opts).keys).to include "#{url}/domain-test.sql"
end
end
context 'when a non standard URL host' do
let(:url) { 'http://dc-2' }
it 'replaces {domain_name} by its correct value' do
expect(finder.potential_urls(opts).keys).to include "#{url}/dc-2.sql"
end
end
end
describe '#aggressive' do