lib/wmap/site_tracker.rb
# Retrieve and save unique sites information for the quarterly scan into a XML file
Retrieve and save unique sites information for the quarterly scan into a XML file
Retrieve and save unique sites information for the quarterly scan into a XML file
def save_uniq_sites_xml(file)
		puts "Save unique sites information into XML file: #{file}\nThis may take a long while as it go through lengthy self correctness check, please be patient ..."
		prime_sites=get_prim_uniq_sites
		builder = Nokogiri::XML::Builder.new do |xml|
			xml.root {
				xml.websites {
					prime_sites.each 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\twmap #{site}\n" unless @known_sites.key?(site)
						xml.site {
							xml.name site
							xml.ip_ @known_sites[site]['ip']
							xml.port_ @known_sites[site]['port']
							xml.status_ @known_sites[site]['status']
							xml.server_ @known_sites[site]['server']
							xml.fingerprint_ @known_sites[site]['md5']
							xml.redirection_ @known_sites[site]['redirection']
							xml.responsecode_ @known_sites[site]['code']
							xml.timestamp_ @known_sites[site]['timestamp']
						}
					end
				}
			}
		end
		puts builder.to_xml if @verbose
		f=File.new(file,'w')
		f.write(builder.to_xml)
		f.close
		puts "Done!"
		return true
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}"
		return false
	end
def save_uniq_sites_xml ( file ) puts "Save unique sites information into XML file: #{file}\nThis may take a long while as it go through lengthy self correctness check, please be patient ..." prime_sites = get_prim_uniq_sites builder = Nokogiri :: XML :: Builder . new do | xml | xml . root { xml . websites { prime_sites . each 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\twmap #{site}\n" unless @known_sites . key? ( site ) xml . site { xml . name site xml . ip_ @known_sites [ site ] [ 'ip' ] xml . port_ @known_sites [ site ] [ 'port' ] xml . status_ @known_sites [ site ] [ 'status' ] xml . server_ @known_sites [ site ] [ 'server' ] xml . fingerprint_ @known_sites [ site ] [ 'md5' ] xml . redirection_ @known_sites [ site ] [ 'redirection' ] xml . responsecode_ @known_sites [ site ] [ 'code' ] xml . timestamp_ @known_sites [ site ] [ 'timestamp' ] } end } } end puts builder . to_xml if @verbose f = File . new ( file , 'w' ) f . write ( builder . to_xml ) 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 XML file
Retrieve and save unique sites information for the quarterly scan into a XML file
file
<not_specific>