#!/usr/bin/env ruby # the up to date program to refresh all local cache tables in one shot. Note it requires an uninterrupted Internet connection to perform the job. It also takes a long time so patient is needed. Lastly, don't forget to backup the existing 'data' folder before execute this command, cause any unexpected interruption may wreak havoc on the existing data file!!! require "wmap" puts Wmap.banner puts "Program to refresh the local data repository." Log_dir=File.dirname(__FILE__)+'/../logs/' Wmap.wlog("Execute the command: updateAll","updateAll",Log_dir+"wmap.log") abort "Incorrect program argument - no argument needed! Proper Usage: updateAll" unless ARGV.length==0 puts "You're about to update Wmap data repository. It'll take a long time. And the Internet connection must be un-interrupted during the process. You're also expected to backup the data folder before proceeding. Are you ready? (Yes/No)" STDOUT.flush answer=gets.chomp if answer =~ /yes/i puts "Start up to date process. Please be patient ..." else abort "You got it. Mission is successfully aborted. " end # Update sub-domain table sd=Wmap::DomainTracker::SubDomain.instance sd.update_from_host_store! subs=sd.known_internet_sub_domains.keys sd=nil # Update Domain table dm=Wmap::DomainTracker.instance domains=dm.known_internet_domains.keys dm=nil # Brute force sub-domains to detect sub-domain hosts bruter=Wmap::DnsBruter.new sub_hosts=bruter.brutes(subs).values.flatten hosts=bruter.brutes(domains).values.flatten # Update primary host store ph=Wmap::HostTracker::PrimaryHost.instance ph.update_from_site_store! ph.refresh_all ph.save! ph=nil # Update host store h=Wmap::HostTracker.instance h.refresh_all h.adds(sub_hosts) h.adds(hosts) h.save! h=nil # Update site store st=Wmap::SiteTracker.instance st.refresh_all dt=Wmap::SiteTracker::DeactivatedSite.instance ds=dt.known_sites.keys st.adds(ds) #double-check the de-activated sites in case the site is back on-line again st.save! st=nil dt=nil