lib/wmap/site_tracker.rb
# Retrieve and save unique sites information for the quarterly scan into a plain local file
Retrieve and save unique sites information for the quarterly scan into a plain local file
Retrieve and save unique sites information for the quarterly scan into a plain local file
def save_uniq_sites(file)
		puts "Save unique sites information into a flat file: #{file}\nThis may take a long while as it go through a lengthy self correction check process, please be patient ..."
		prime_sites=get_prim_uniq_sites
		puts "Primary Sites: #{prime_sites}" if @verbose
		f=File.open(file,"w")
		f.write "Unique Sites Information Report\n"
		f.write "Site, IP, Port, Server, Hosting, Response Code, MD5, Redirect, Timestamps\n"
		prime_sites.map do |key|
			next if key.nil?
			site=key.strip
			raise "Unknown site: #{site}. You may need to add it into the site store first. Execute the following shell command before trying again: \n\wadd #{site}\n" unless @known_sites.key?(site)
			ip=@known_sites[site]['ip']
			port=@known_sites[site]['port']
			status=@known_sites[site]['status']
			server=@known_sites[site]['server']
			fp=@known_sites[site]['md5']
			loc=@known_sites[site]['redirection']
			res=@known_sites[site]['code']
			timestamp=@known_sites[site]['timestamp']
			f.write "#{site},#{ip},#{port},#{server},#{status},#{res},#{fp},#{loc},#{timestamp}\n"
		end
		f.close
		puts "Done!"
		return true  
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}"
		return false 
	end
def save_uniq_sites ( file ) puts "Save unique sites information into a flat file: #{file}\nThis may take a long while as it go through a lengthy self correction check process, please be patient ..." prime_sites = get_prim_uniq_sites puts "Primary Sites: #{prime_sites}" if @verbose f = File . open ( file , "w" ) f . write "Unique Sites Information Report\n" f . write "Site, IP, Port, Server, Hosting, Response Code, MD5, Redirect, Timestamps\n" prime_sites . map do | key | next if key . nil? site = key . strip raise "Unknown site: #{site}. You may need to add it into the site store first. Execute the following shell command before trying again: \n\wadd #{site}\n" unless @known_sites . key? ( site ) ip = @known_sites [ site ] [ 'ip' ] port = @known_sites [ site ] [ 'port' ] status = @known_sites [ site ] [ 'status' ] server = @known_sites [ site ] [ 'server' ] fp = @known_sites [ site ] [ 'md5' ] loc = @known_sites [ site ] [ 'redirection' ] res = @known_sites [ site ] [ 'code' ] timestamp = @known_sites [ site ] [ 'timestamp' ] f . write "#{site},#{ip},#{port},#{server},#{status},#{res},#{fp},#{loc},#{timestamp}\n" end f . close puts "Done!" return true rescue => ee puts "Exception on method #{__method__}: #{ee}" return false end
Retrieve and save unique sites information for the quarterly scan into a plain local file
Retrieve and save unique sites information for the quarterly scan into a plain local file
# success # fail
file
<not_specific>