diff --git a/lib/wpscan/web_site.rb b/lib/wpscan/web_site.rb index a377e5e8..5db6c0f1 100644 --- a/lib/wpscan/web_site.rb +++ b/lib/wpscan/web_site.rb @@ -5,6 +5,7 @@ require 'web_site/interesting_headers' require 'web_site/robots_txt' require 'web_site/security_txt' require 'web_site/sitemap' +require 'web_site/sql_file_export' class WebSite include WebSite::HumansTxt @@ -12,6 +13,7 @@ class WebSite include WebSite::RobotsTxt include WebSite::SecurityTxt include WebSite::Sitemap + include WebSite::SqlFileExport attr_reader :uri diff --git a/lib/wpscan/web_site/sql_file_export.rb b/lib/wpscan/web_site/sql_file_export.rb new file mode 100644 index 00000000..ba511eeb --- /dev/null +++ b/lib/wpscan/web_site/sql_file_export.rb @@ -0,0 +1,32 @@ +# encoding: UTF-8 + +class WebSite + module SqlFileExport + + # Checks if a .sql file exists + # @return [ Array ] + def sql_file_export + backup_files = [] + + self.sql_file_export_urls.each do |url| + response = Browser.get(url) + backup_files << url if response.code == 200 && response.body =~ /INSERT INTO/ + end + + backup_files + end + + # Gets a .sql export file URL + # @return [ Array ] + def sql_file_export_urls + urls = [] + files = ["#{@uri.host[/(^[\w|-]+)/,1]}.sql", 'backup.sql', 'database.sql', 'dump.sql'] + + files.each do |file| + urls << @uri.clone.merge(file).to_s + end + + urls + end + end +end diff --git a/wpscan.rb b/wpscan.rb index b186ad18..1e9c1261 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -255,6 +255,12 @@ def main end end + unless wp_target.sql_file_export.empty? + wp_target.sql_file_export.each do |file| + puts critical("SQL export file found: #{file}") + end + end + code = get_http_status(wp_target.humans_url) if code == 200 puts info("humans.txt available under: #{wp_target.humans_url} [HTTP #{code}]")