warn the user to update his DB files
This commit is contained in:
@@ -31,6 +31,7 @@ LOCAL_FILES_FILE = File.join(DATA_DIR, 'local_vulnerable_files.xml')
|
||||
WP_VERSIONS_XSD = File.join(DATA_DIR, 'wp_versions.xsd')
|
||||
LOCAL_FILES_XSD = File.join(DATA_DIR, 'local_vulnerable_files.xsd')
|
||||
USER_AGENTS_FILE = File.join(DATA_DIR, 'user-agents.txt')
|
||||
LAST_UPDATE_FILE = File.join(DATA_DIR, '.last_update')
|
||||
|
||||
WPSCAN_VERSION = '2.7'
|
||||
|
||||
@@ -78,6 +79,13 @@ def missing_db_file?
|
||||
false
|
||||
end
|
||||
|
||||
def update_required?
|
||||
return true unless File.exist?(LAST_UPDATE_FILE)
|
||||
content = File.read(LAST_UPDATE_FILE)
|
||||
date = Time.parse(content) rescue Time.parse("2000-01-01")
|
||||
return date < 5.days.ago
|
||||
end
|
||||
|
||||
# Define colors
|
||||
def colorize(text, color_code)
|
||||
if $COLORSWITCH
|
||||
|
||||
@@ -112,5 +112,8 @@ class DbUpdater
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# write last_update date to file
|
||||
File.write(LAST_UPDATE_FILE, Time.now)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ def puts(o = '')
|
||||
temp = o.gsub(/\e\[\d+m/, '') # remove color for logging
|
||||
File.open(LOG_FILE, 'a+') { |f| f.puts(temp) }
|
||||
end
|
||||
|
||||
|
||||
super(o)
|
||||
end
|
||||
|
||||
@@ -106,3 +106,16 @@ class Numeric
|
||||
s.sub(/\.?0*$/, ' ' + units[e])
|
||||
end
|
||||
end
|
||||
|
||||
# time calculations
|
||||
class Fixnum
|
||||
SECONDS_IN_DAY = 24 * 60 * 60
|
||||
|
||||
def days
|
||||
self * SECONDS_IN_DAY
|
||||
end
|
||||
|
||||
def ago
|
||||
Time.now - self
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user