Re-worked off-line update only as a fall back (when possible)

This commit is contained in:
g0tmi1k
2018-05-14 15:12:20 +01:00
parent 9450ba6cc5
commit e41aab3a80

View File

@@ -87,52 +87,41 @@ def main
# Check if database needs upgrade (if its older than 5 days) and we are not running in --batch mode # Check if database needs upgrade (if its older than 5 days) and we are not running in --batch mode
# Also no need to check if the user supplied the --update switch # Also no need to check if the user supplied the --update switch
if update_required? and not wpscan_options.batch and not wpscan_options.update if update_required? and not wpscan_options.batch and not wpscan_options.update
# Banner # Banner
puts puts
puts notice('It seems like you have not updated the database for some time') puts notice('It seems like you have not updated the database for some time')
puts notice("Last database update: #{date.strftime('%Y-%m-%d')}") unless date.nil? puts notice("Last database update: #{date.strftime('%Y-%m-%d')}") unless date.nil?
# User prompt # User prompt
print '[?] Do you want to update now? [Y]es [N]o [A]bort, default: [N] > ' print '[?] Do you want to update now? [Y]es [N]o [A]bort update, default: [N] > '
if (input = Readline.readline) =~ /^a/i if (input = Readline.readline) =~ /^a/i
puts 'Scan aborted' puts 'Update aborted'
exit(1)
elsif input =~ /^y/i elsif input =~ /^y/i
wpscan_options.update = true wpscan_options.update = true
end end
# Is there a database to go on with? # Is there a database to go on with?
if missing_db_files? and not wpscan_options.update if missing_db_files? and not wpscan_options.update
puts critical('You can not run a scan without any databases') # Check for data.zip
exit(1) if has_db_zip?
puts notice('Extracting the Database ...')
# Extract data.zip
extract_db_zip
puts notice('Extraction completed')
# Missing, so can't go on!
else
puts critical('You can not run a scan without any databases')
exit(1)
end
end end
end end
# Should we update? # Should we update?
if wpscan_options.update if wpscan_options.update
online_update = true puts notice('Updating the Database ...')
DbUpdater.new(DATA_DIR).update(wpscan_options.verbose)
# Check for data.zip puts notice('Update completed')
if has_db_zip?
# User prompt
print '[?] Use the latest on-line database? Or use the off-line copy? [O]n-line O[f]f-line [A]bort update, default: [O] > '
if (input = Readline.readline) =~ /^a/i
puts 'Update aborted'
elsif input =~ /^f/i
online_update = false
end
end
if online_update
puts notice('Updating the Database ...')
DbUpdater.new(DATA_DIR).update(wpscan_options.verbose)
puts notice('Update completed')
else
puts notice('Extracting the Database ...')
extract_db_zip
puts notice('Extraction completed')
end
# Exit program if only option --update is used # Exit program if only option --update is used
exit(0) unless wpscan_options.url exit(0) unless wpscan_options.url