Module: Wmap
- Defined in:
- lib/wmap/utils/utils.rb,
lib/wmap.rb,
lib/wmap/utils/logger.rb,
lib/wmap/utils/url_magic.rb,
lib/wmap/utils/domain_root.rb,
lib/wmap/url_crawler/adware_tag.rb,
lib/wmap/domain_tracker/sub_domain.rb,
lib/wmap/host_tracker/primary_host.rb,
lib/wmap/site_tracker/deactivated_site.rb
Overview
Class to trace de-activated site. This is need for basic state tracking for our sites.
Defined Under Namespace
Modules: Utils Classes: CidrTracker, DnsBruter, DomainTracker, GeoIPTracker, GoogleSearchScraper, HostTracker, NetworkProfiler, PortScanner, SiteTracker, UrlChecker, UrlCrawler, Whois, WpTracker
Constant Summary collapse
- NAME =
"Wmap"- GEM =
"wmap"- VERSION =
File.dirname(__FILE__) + "/../version.txt"
Class Attribute Summary collapse
-
.known_internet_domains ⇒ Object
Returns the value of attribute known_internet_domains.
-
.verbose ⇒ Object
writeonly
Sets the attribute verbose.
Class Method Summary collapse
-
.banner ⇒ Object
Project banner in ASCII Art ‘soft’ format, courtesy to patorjk.com/software/taag/.
-
.check(url) ⇒ Object
URL checker - check the status of the remote URL.
-
.crawl(url) ⇒ Object
Crawler to search url contents for new sites.
- .data_dir(data_path) ⇒ Object
-
.dns_brute(domain) ⇒ Object
DNS Brute Forcer.
-
.domain_known?(domain) ⇒ Boolean
Domain Tracking - check with the trust domain seed file locally, to determine if it’s a new internet domain NOT to confuse with the Internet ‘whois’ lookup.
-
.domain_root(host) ⇒ Object
Retrieve root domain from a host.
-
.dump(file) ⇒ Object
Dump out the unique sites into a plain file.
-
.dump_xml(file) ⇒ Object
Dump out the unique sites into a XML file.
-
.geoip(host) ⇒ Object
GeoIP Tracking - check the host / IP against the GeoIP data repository, return the Geographic information if found.
-
.google ⇒ Object
Search the Google engines and sort out sites known by Google.
-
.host_known?(host) ⇒ Boolean
Host Tracking - check local hosts file to see if this is a hostname known from the host seed file NOT to confuse with a regular DNS lookup over the internet.
-
.ip_known?(ip) ⇒ Boolean
IP Tracking - check local hosts file to see if this is an IP known from the seed file NOT to confuse with a regular reverse DNS lookup over the internet.
-
.ip_trusted?(ip) ⇒ Boolean
Check if the IP is within the range of the known CIDR blocks.
-
.mutation(host) ⇒ Object
Host-name mutation for catch easily guessable hostname, i.e.
-
.print(site) ⇒ Object
Print a site’s full information from the repository.
-
.print_all ⇒ Object
Print a site’s full information from the repository.
-
.read_ver ⇒ Object
Simple parser for the project version file.
-
.refresh(site) ⇒ Object
Refresh the site information in the local data repository.
-
.refresh_all ⇒ Object
Refresh the site information in the local data repository.
-
.response_code(url) ⇒ Object
Check URL/Site response code.
-
.scan(host) ⇒ Object
Fast tcp port scanner on a single host or IP.
-
.scans(target_list) ⇒ Object
Fast multi-processes tcp port scanner on a list of targets.
-
.search(pattern) ⇒ Object
Search the site repository for all entries that match the pattern.
-
.sub_domain_known?(host) ⇒ Boolean
Sub-domain tracking - check local hosts file to see if the sub-domain is already known.
-
.track(host) ⇒ Object
CIDR Tracking - check the host against the local CIDR seed file, return the CIDR tracking path if found.
-
.whois(domain) ⇒ Object
whois query and sort the result into structured data.
-
.wlog(msg, agent, log_file) ⇒ Object
Log the information into file.
-
.wmap(seed) ⇒ Object
Explorer to discover and inventory web application / service automatically.
Class Attribute Details
.known_internet_domains ⇒ Object
Returns the value of attribute known_internet_domains.
37 38 39 |
# File 'lib/wmap.rb', line 37 def known_internet_domains @known_internet_domains end |
.verbose=(value) ⇒ Object (writeonly)
Sets the attribute verbose
38 39 40 |
# File 'lib/wmap.rb', line 38 def verbose=(value) @verbose = value end |
Class Method Details
.banner ⇒ Object
Project banner in ASCII Art ‘soft’ format, courtesy to patorjk.com/software/taag/
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/wmap.rb', line 59 def ver=read_ver art=",--. ,--. ,--. ,--. ,--. | | | | ,---. | |-. | `.' | ,--,--. ,---. ,---. ,---. ,--.--. | |.'.| || .-. :| .-. ' | |'.'| |' ,-. || .-. || .-. || .-. :| .--' | ,'. |\ --.| `-' | | | | |\ '-' || '-' '| '-' '\ --.| | '--' '--' `----' `---' `--' `--' `--`--'| |-' | |-' `----'`--' `--' `--' " string = "-"*80 + "\n" + art + "\n" + "Version: " + ver["version"] + "\tRelease Date: " + ver["date"] + "\nDesigned and developed by: " + ver["author"] + "\nEmail: " + ver["email"] + "\tLinkedIn: " + ver["linkedin"] + "\n" + "-"*80 end |
.check(url) ⇒ Object
URL checker - check the status of the remote URL
121 122 123 124 |
# File 'lib/wmap.rb', line 121 def check(url) checker=Wmap::UrlChecker.new(:verbose=>false) checker.url_worker(url) end |
.crawl(url) ⇒ Object
Crawler to search url contents for new sites
85 86 87 88 |
# File 'lib/wmap.rb', line 85 def crawl(url) crawler=Wmap::UrlCrawler.new crawler.crawl(url) end |
.data_dir(data_path) ⇒ Object
70 71 72 |
# File 'lib/wmap.rb', line 70 def data_dir(data_path) @data_dir=data_path.to_s end |
.dns_brute(domain) ⇒ Object
DNS Brute Forcer
185 186 187 188 |
# File 'lib/wmap.rb', line 185 def dns_brute(domain) bruter=Wmap::DnsBruter.new bruter.query(domain) end |
.domain_known?(domain) ⇒ Boolean
Domain Tracking - check with the trust domain seed file locally, to determine if it’s a new internet domain NOT to confuse with the Internet ‘whois’ lookup
139 140 141 142 143 144 145 146 147 |
# File 'lib/wmap.rb', line 139 def domain_known?(domain) tracker=Wmap::DomainTracker.instance if @data_dir tracker.data_dir=@data_dir tracker.domains_file=tracker.data_dir + "/" + "domains" tracker.load_domains_from_file(tracker.domains_file) end tracker.domain_known?(domain) end |
.domain_root(host) ⇒ Object
Retrieve root domain from a host
191 192 193 |
# File 'lib/wmap.rb', line 191 def domain_root(host) Wmap::Utils.get_domain_root(host) end |
.dump(file) ⇒ Object
Dump out the unique sites into a plain file
223 224 225 226 227 228 229 230 231 |
# File 'lib/wmap.rb', line 223 def dump(file) store=Wmap::SiteTracker.instance if @data_dir store.data_dir = @data_dir store.sites_file = searcher.data_dir + "/" + "sites" store.load_site_stores_from_file(searcher.sites_file) end store.save_uniq_sites(file) end |
.dump_xml(file) ⇒ Object
Dump out the unique sites into a XML file
234 235 236 237 238 239 240 241 242 |
# File 'lib/wmap.rb', line 234 def dump_xml(file) store=Wmap::SiteTracker.instance if @data_dir store.data_dir = @data_dir store.sites_file = searcher.data_dir + "/" + "sites" store.load_site_stores_from_file(searcher.sites_file) end store.save_uniq_sites_xml(file) end |
.geoip(host) ⇒ Object
GeoIP Tracking - check the host / IP against the GeoIP data repository, return the Geographic information if found
115 116 117 118 |
# File 'lib/wmap.rb', line 115 def geoip(host) tracker=Wmap::GeoIPTracker.new tracker.query(host) end |
.google ⇒ Object
Search the Google engines and sort out sites known by Google
269 270 271 |
# File 'lib/wmap.rb', line 269 def google sites=Wmap::GoogleSearchScraper.new.workers.keys end |
.host_known?(host) ⇒ Boolean
Host Tracking - check local hosts file to see if this is a hostname known from the host seed file NOT to confuse with a regular DNS lookup over the internet
151 152 153 154 155 156 157 158 159 |
# File 'lib/wmap.rb', line 151 def host_known?(host) tracker=Wmap::HostTracker.instance if @data_dir tracker.data_dir = data_dir tracker.hosts_file = tracker.data_dir + "/" + "hosts" tracker.load_known_hosts_from_file(tracker.hosts_file) end tracker.host_known?(host) end |
.ip_known?(ip) ⇒ Boolean
IP Tracking - check local hosts file to see if this is an IP known from the seed file NOT to confuse with a regular reverse DNS lookup over the internet
174 175 176 177 178 179 180 181 182 |
# File 'lib/wmap.rb', line 174 def ip_known?(ip) tracker=Wmap::HostTracker.instance if @data_dir tracker.data_dir = data_dir tracker.hosts_file = tracker.data_dir + "/" + "hosts" tracker.load_known_hosts_from_file(tracker.hosts_file) end tracker.ip_known?(ip) end |
.ip_trusted?(ip) ⇒ Boolean
Check if the IP is within the range of the known CIDR blocks
127 128 129 130 131 132 133 134 135 |
# File 'lib/wmap.rb', line 127 def ip_trusted?(ip) tracker=Wmap::CidrTracker.new if @data_dir tracker.data_dir=@data_dir tracker.cidr_seeds=tracker.data_dir + "/" + "cidrs" tracker.load_cidr_blks_from_file(tracker.cidr_seeds) end tracker.ip_trusted?(ip) end |
.mutation(host) ⇒ Object
Host-name mutation for catch easily guessable hostname, i.e. “ww1.example.com” => [“ww1,example.com”,“ww2.example.com”,…]
201 202 203 |
# File 'lib/wmap.rb', line 201 def mutation (host) Wmap::DnsBruter.new.hostname_mutation(host) end |
.print(site) ⇒ Object
Print a site’s full information from the repository
274 275 276 277 |
# File 'lib/wmap.rb', line 274 def print(site) searcher=Wmap::SiteTracker.instance searcher.print_site(site) end |
.print_all ⇒ Object
Print a site’s full information from the repository
280 281 282 283 284 285 286 287 288 |
# File 'lib/wmap.rb', line 280 def print_all searcher=Wmap::SiteTracker.instance if @data_dir searcher.data_dir = @data_dir searcher.sites_file = searcher.data_dir + "/" + "sites" searcher.load_site_stores_from_file(searcher.sites_file) end searcher.print_all_sites end |
.read_ver ⇒ Object
Simple parser for the project version file
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wmap.rb', line 41 def read_ver ver=Hash.new f=File.open(VERSION,'r') f.each do |line| line.chomp! case line when /^(\s)*#/ next when /\=/ entry=line.split("=").map! {|x| x.strip} ver[entry[0]]=entry[1] end end f.close return ver end |
.refresh(site) ⇒ Object
Refresh the site information in the local data repository
245 246 247 248 249 250 251 252 253 254 |
# File 'lib/wmap.rb', line 245 def refresh(site) store=Wmap::SiteTracker.instance if @data_dir store.data_dir = @data_dir store.sites_file = searcher.data_dir + "/" + "sites" store.load_site_stores_from_file(searcher.sites_file) end store.refresh(site) store.save! end |
.refresh_all ⇒ Object
Refresh the site information in the local data repository
257 258 259 260 261 262 263 264 265 266 |
# File 'lib/wmap.rb', line 257 def refresh_all store=Wmap::SiteTracker.instance if @data_dir store.data_dir = @data_dir store.sites_file = searcher.data_dir + "/" + "sites" store.load_site_stores_from_file(searcher.sites_file) end store.refresh_all store.save! end |
.response_code(url) ⇒ Object
Check URL/Site response code
206 207 208 209 |
# File 'lib/wmap.rb', line 206 def response_code(url) checker=Wmap::UrlChecker.new checker.response_code(url) end |
.scan(host) ⇒ Object
Fast tcp port scanner on a single host or IP
97 98 99 100 |
# File 'lib/wmap.rb', line 97 def scan(host) scanner=Wmap::PortScanner.new scanner.scan(host) end |
.scans(target_list) ⇒ Object
Fast multi-processes tcp port scanner on a list of targets
103 104 105 106 |
# File 'lib/wmap.rb', line 103 def scans(target_list) scanner=Wmap::PortScanner.new scanner.scans(target_list) end |
.search(pattern) ⇒ Object
Search the site repository for all entries that match the pattern
212 213 214 215 216 217 218 219 220 |
# File 'lib/wmap.rb', line 212 def search(pattern) searcher=Wmap::SiteTracker.instance if @data_dir searcher.data_dir = @data_dir searcher.sites_file = searcher.data_dir + "/" + "sites" searcher.load_site_stores_from_file(searcher.sites_file) end searcher.search(pattern) end |
.sub_domain_known?(host) ⇒ Boolean
Sub-domain tracking - check local hosts file to see if the sub-domain is already known
162 163 164 165 166 167 168 169 170 |
# File 'lib/wmap.rb', line 162 def sub_domain_known?(host) tracker=Wmap::HostTracker.instance if @data_dir tracker.data_dir = data_dir tracker.hosts_file = tracker.data_dir + "/" + "hosts" tracker.load_known_hosts_from_file(tracker.hosts_file) end tracker.sub_domain_known?(host) end |
.track(host) ⇒ Object
CIDR Tracking - check the host against the local CIDR seed file, return the CIDR tracking path if found
109 110 111 112 |
# File 'lib/wmap.rb', line 109 def track(host) tracker=Wmap::CidrTracker.new tracker.cidr_worker(host) end |
.whois(domain) ⇒ Object
whois query and sort the result into structured data
91 92 93 94 |
# File 'lib/wmap.rb', line 91 def whois(domain) whois=Wmap::Whois.new(:verbose=>false) whois.query(domain) end |
.wlog(msg, agent, log_file) ⇒ Object
Log the information into file
196 197 198 |
# File 'lib/wmap.rb', line 196 def wlog(msg,agent,log_file) Wmap::Utils.wlog(msg,agent,log_file) end |
.wmap(seed) ⇒ Object
Explorer to discover and inventory web application / service automatically
75 76 77 78 79 80 81 82 |
# File 'lib/wmap.rb', line 75 def wmap(seed) if @data_dir cmd = "bin/wmap" + " -d " + @data_dir + " -t " + seed else cmd="bin/wmap" + " -t " + seed end system(cmd) end |