wmap 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +141 -0
  3. data/LICENSE.txt +15 -0
  4. data/README.rdoc +98 -0
  5. data/TODO +13 -0
  6. data/bin/deprime +21 -0
  7. data/bin/distrust +38 -0
  8. data/bin/googleBot +23 -0
  9. data/bin/prime +21 -0
  10. data/bin/refresh +26 -0
  11. data/bin/run_tests +16 -0
  12. data/bin/spiderBot +26 -0
  13. data/bin/trust +38 -0
  14. data/bin/updateAll +57 -0
  15. data/bin/wadd +25 -0
  16. data/bin/wadds +26 -0
  17. data/bin/wcheck +28 -0
  18. data/bin/wdel +25 -0
  19. data/bin/wdump +21 -0
  20. data/bin/wmap +151 -0
  21. data/bin/wscan +32 -0
  22. data/data/cidrs +2 -0
  23. data/data/deactivated_sites +1 -0
  24. data/data/domains +2 -0
  25. data/data/hosts +1 -0
  26. data/data/prime_hosts +1 -0
  27. data/data/sites +2 -0
  28. data/data/sub_domains +2 -0
  29. data/demos/bruter.rb +27 -0
  30. data/demos/dns_brutes.rb +28 -0
  31. data/demos/filter_cidr.rb +18 -0
  32. data/demos/filter_crawls.rb +5 -0
  33. data/demos/filter_domain.rb +25 -0
  34. data/demos/filter_geoip.rb +26 -0
  35. data/demos/filter_known_services.rb +59 -0
  36. data/demos/filter_netinfo.rb +23 -0
  37. data/demos/filter_prime.rb +25 -0
  38. data/demos/filter_profiler.rb +3 -0
  39. data/demos/filter_redirection.rb +19 -0
  40. data/demos/filter_site.rb +40 -0
  41. data/demos/filter_siteip.rb +31 -0
  42. data/demos/filter_status.rb +17 -0
  43. data/demos/filter_timestamp.rb +23 -0
  44. data/demos/filter_url.rb +19 -0
  45. data/demos/new_fnd.rb +66 -0
  46. data/demos/nmap_parser.pl +138 -0
  47. data/demos/site_format.rb +18 -0
  48. data/demos/whois_domain.rb +78 -0
  49. data/dicts/GeoIP.dat +0 -0
  50. data/dicts/GeoIPASNum.dat +0 -0
  51. data/dicts/GeoLiteCity.dat +0 -0
  52. data/dicts/ccsld.txt +2646 -0
  53. data/dicts/cctld.txt +243 -0
  54. data/dicts/gtld.txt +25 -0
  55. data/dicts/hostnames-dict.big +1402 -0
  56. data/dicts/hostnames-dict.txt +101 -0
  57. data/lib/wmap/cidr_tracker.rb +327 -0
  58. data/lib/wmap/dns_bruter.rb +308 -0
  59. data/lib/wmap/domain_tracker/sub_domain.rb +142 -0
  60. data/lib/wmap/domain_tracker.rb +342 -0
  61. data/lib/wmap/geoip_tracker.rb +72 -0
  62. data/lib/wmap/google_search_scraper.rb +177 -0
  63. data/lib/wmap/host_tracker/primary_host.rb +130 -0
  64. data/lib/wmap/host_tracker.rb +550 -0
  65. data/lib/wmap/network_profiler.rb +144 -0
  66. data/lib/wmap/port_scanner.rb +208 -0
  67. data/lib/wmap/site_tracker/deactivated_site.rb +85 -0
  68. data/lib/wmap/site_tracker.rb +937 -0
  69. data/lib/wmap/url_checker.rb +314 -0
  70. data/lib/wmap/url_crawler.rb +381 -0
  71. data/lib/wmap/utils/domain_root.rb +184 -0
  72. data/lib/wmap/utils/logger.rb +53 -0
  73. data/lib/wmap/utils/url_magic.rb +343 -0
  74. data/lib/wmap/utils/utils.rb +333 -0
  75. data/lib/wmap/whois.rb +76 -0
  76. data/lib/wmap.rb +227 -0
  77. data/logs/wmap.log +17 -0
  78. data/ruby_whois_patches/base_cocca2.rb +149 -0
  79. data/ruby_whois_patches/kero.yachay.pe.rb +120 -0
  80. data/ruby_whois_patches/whois.PublicDomainRegistry.com.rb +124 -0
  81. data/ruby_whois_patches/whois.above.com.rb +61 -0
  82. data/ruby_whois_patches/whois.adamsnames.tc.rb +107 -0
  83. data/ruby_whois_patches/whois.aeda.net.ae.rb +105 -0
  84. data/ruby_whois_patches/whois.ai.rb +112 -0
  85. data/ruby_whois_patches/whois.arnes.si.rb +121 -0
  86. data/ruby_whois_patches/whois.ascio.com.rb +91 -0
  87. data/ruby_whois_patches/whois.cnnic.cn.rb +123 -0
  88. data/ruby_whois_patches/whois.corporatedomains.com.rb +67 -0
  89. data/ruby_whois_patches/whois.crsnic.net.rb +108 -0
  90. data/ruby_whois_patches/whois.denic.de.rb +174 -0
  91. data/ruby_whois_patches/whois.dk-hostmaster.dk.rb +120 -0
  92. data/ruby_whois_patches/whois.dns.be.rb +134 -0
  93. data/ruby_whois_patches/whois.dns.lu.rb +129 -0
  94. data/ruby_whois_patches/whois.dns.pl.rb +150 -0
  95. data/ruby_whois_patches/whois.dns.pt.rb +119 -0
  96. data/ruby_whois_patches/whois.domain.kg.rb +126 -0
  97. data/ruby_whois_patches/whois.domainregistry.my.rb +123 -0
  98. data/ruby_whois_patches/whois.domreg.lt.rb +110 -0
  99. data/ruby_whois_patches/whois.dot.tk.rb +140 -0
  100. data/ruby_whois_patches/whois.hkirc.hk.rb +121 -0
  101. data/ruby_whois_patches/whois.isnic.is.rb +130 -0
  102. data/ruby_whois_patches/whois.je.rb +119 -0
  103. data/ruby_whois_patches/whois.jprs.jp.rb +137 -0
  104. data/ruby_whois_patches/whois.kenic.or.ke.rb +140 -0
  105. data/ruby_whois_patches/whois.markmonitor.com.rb +118 -0
  106. data/ruby_whois_patches/whois.melbourneit.com.rb +58 -0
  107. data/ruby_whois_patches/whois.nic.as.rb +96 -0
  108. data/ruby_whois_patches/whois.nic.at.rb +109 -0
  109. data/ruby_whois_patches/whois.nic.ch.rb +141 -0
  110. data/ruby_whois_patches/whois.nic.cl.rb +117 -0
  111. data/ruby_whois_patches/whois.nic.ec.rb +157 -0
  112. data/ruby_whois_patches/whois.nic.im.rb +120 -0
  113. data/ruby_whois_patches/whois.nic.it.rb +170 -0
  114. data/ruby_whois_patches/whois.nic.lv.rb +116 -0
  115. data/ruby_whois_patches/whois.nic.ly.rb +127 -0
  116. data/ruby_whois_patches/whois.nic.mu.rb +27 -0
  117. data/ruby_whois_patches/whois.nic.mx.rb +123 -0
  118. data/ruby_whois_patches/whois.nic.net.sa.rb +111 -0
  119. data/ruby_whois_patches/whois.nic.or.kr.rb +101 -0
  120. data/ruby_whois_patches/whois.nic.tel.rb +129 -0
  121. data/ruby_whois_patches/whois.nic.tr.rb +133 -0
  122. data/ruby_whois_patches/whois.nic.us.rb +129 -0
  123. data/ruby_whois_patches/whois.nic.ve.rb +135 -0
  124. data/ruby_whois_patches/whois.norid.no.rb +127 -0
  125. data/ruby_whois_patches/whois.pandi.or.id.rb +118 -0
  126. data/ruby_whois_patches/whois.psi-usa.info.rb +63 -0
  127. data/ruby_whois_patches/whois.registro.br.rb +109 -0
  128. data/ruby_whois_patches/whois.registrygate.com.rb +55 -0
  129. data/ruby_whois_patches/whois.rrpproxy.net.rb +61 -0
  130. data/ruby_whois_patches/whois.sgnic.sg.rb +130 -0
  131. data/ruby_whois_patches/whois.srs.net.nz.rb +166 -0
  132. data/ruby_whois_patches/whois.tucows.com.rb +70 -0
  133. data/ruby_whois_patches/whois.twnic.net.tw.rb +133 -0
  134. data/settings/discovery_ports +24 -0
  135. data/settings/google_keywords.txt +9 -0
  136. data/settings/google_locator.txt +23 -0
  137. data/test/domain_tracker_test.rb +31 -0
  138. data/test/utils_test.rb +168 -0
  139. data/version.txt +13 -0
  140. data/wmap.gemspec +49 -0
  141. metadata +202 -0
data/demos/new_fnd.rb ADDED
@@ -0,0 +1,66 @@
1
+ ###################
2
+ # Simple lookup function to check if a DMP vuln finding is new found
3
+ #
4
+ # Usage: ruby new_fnd.rb [old cweid:url pairs] [new cweid.url pair]
5
+ # sample input row: "297,https://157.83.142.100/"
6
+ # Example: ruby new_fnd.rb oldkeys.csv newkeys.csv > new.csv
7
+
8
+ require "wmap"
9
+
10
+ @verbose=false
11
+
12
+ def load_keys (file)
13
+ puts "Load the key map from file: #{file}" if @verbose
14
+ host_tracker=Wmap::HostTracker.new
15
+ my_keys=Hash.new
16
+ #begin
17
+ f_old=File.open(file)
18
+ f_old.each_line do |line|
19
+ entry=line.chomp.split(',')
20
+
21
+ abort "Error loading entry: #{entry}" if entry.size < 2
22
+ url=entry[1]
23
+ cveid=entry[0].to_s
24
+ host=host_tracker.url_2_host(url)
25
+ ip=String.new
26
+ if host_tracker.is_fqdn?(host)
27
+ ip=host_tracker.local_host_2_ip(host)
28
+ else
29
+ ip=host
30
+ end
31
+ unless host_tracker.is_ip?(ip)
32
+ ip=host_tracker.host_2_ip(ip)
33
+ end
34
+ url.sub!(host,ip) unless ip.nil?
35
+ entry=cveid+","+url
36
+ my_keys[entry]=true unless my_keys.key?(entry)
37
+ puts "Finishing loading key: #{entry}" if @verbose
38
+ end
39
+ f_old.close
40
+ host_tracker=nil
41
+ return my_keys
42
+ #rescue => ee
43
+ # abort "Error on method #{__method__}: #{ee}" if @verbose
44
+ #end
45
+ end
46
+
47
+ old_keys=load_keys(ARGV[0])
48
+ my_tracker=Wmap::HostTracker.new
49
+ f_new=File.open(ARGV[1],'r')
50
+ f_new.each_line do |line|
51
+ ent=line.chomp.split(',')
52
+ cve=ent[0]
53
+ url=ent[1]
54
+ host=my_tracker.url_2_host(url)
55
+ ip=my_tracker.local_host_2_ip(host)
56
+ url.sub!(host,ip) unless ip.nil?
57
+ entry=cve+","+url
58
+ if old_keys.key?(entry)
59
+ puts "#{entry},No"
60
+ else
61
+ puts "#{entry},Yes"
62
+ end
63
+ end
64
+ f_new.close
65
+ my_tracker=nil
66
+ #puts new_keys.keys.count
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/perl
2
+ ########################################################################
3
+ # Functional Description:
4
+ #
5
+ # nmap.pl is designed to be a quick nmap port discovery parser for web_discovery
6
+ # the program input is NMAP discovery result XML file, the program output
7
+ # is a list of websites that ready for wmap modules
8
+ #
9
+ # For usage information, type in the following command:
10
+ # $ nmap_parser.pl -h
11
+ #
12
+ ########################################################################
13
+ # Designed and developed by: Yang Li
14
+ #
15
+ # Change History:
16
+ # Last modification: 08/21/2013
17
+ # Version 0.1
18
+ use Getopt::Long qw/:config bundling_override no_ignore_case/;
19
+ use Nmap::Parser;
20
+
21
+ my $ver="0.1", $author="Yang Li"; # Program Version and Author
22
+ my $verbose; # Verbose mode for Maverick
23
+ my %opts;
24
+ GetOptions(
25
+ \%opts,
26
+ 'help|h|?' => sub { &print_help and exit 0; }, # Print help
27
+ 'version|v:s' => sub { &print_banner; exit 0;}, # Print program version information
28
+ 'file|f:s', # Program input file (.xml, .nmap)
29
+ 'output|o:s', # Optional, program output result file
30
+ 'verbose+' => \$verbose, # Optional, program verbose mode for debugging
31
+ 'vv+' => \$verbose, # Same as "-verbose", abbreviation "-vv"
32
+ );
33
+
34
+ sub parse_nmap_terse () {
35
+ #
36
+ ## Parse nmap result in xml format. Only open ports are kept. Web services are further filtered out
37
+ #
38
+ # Check if the optional command switch "-output" is defined, and get ready for it if so.
39
+ if (defined $opts{output}) { open (OUT, ">", $opts{output}) || die " Can't open the file 8: $opts{output} : $!\n"; }
40
+ my $np=new Nmap::Parser;
41
+ $np->parsefile($opts{file});
42
+ my @HOST=$np->all_hosts("up"); # List of 'up' hosts
43
+ if (defined $opts{output}) {
44
+ print OUT "\nTable of Found Open Ports\n";
45
+ print OUT"IP Port Status Service OS Hostname\n";
46
+ for my $up_host (@HOST){
47
+ $os = $up_host->os_sig; $osname=$os->name;
48
+ my $ip=$up_host->addr; my $hostname=$up_host->hostname();
49
+ print OUT "$ip\t\t\t\t$osname\t$hostname,\n"; # Addr: $up_host->addr, OS: $up_host->os_sig\n";
50
+ my @p_tcp=$up_host->tcp_open_ports;
51
+ my @p_udp=$up_host->udp_open_ports;
52
+ foreach(@p_tcp) { # Print list of open tcp ports
53
+ my $state=$up_host->tcp_port_state($_);
54
+ my $svc = $up_host->tcp_service($_);
55
+ my $svc_name = $svc->name;
56
+ print OUT "\t$_\/tcp\t$state\t$svc_name\n";
57
+ }
58
+ foreach(@p_udp) { # Print list of open udp ports
59
+ my $state=$up_host->udp_port_state($_);
60
+ my $svc = $up_host->udp_service($_);
61
+ my $svc_name = $svc->name;
62
+ print OUT "\t$_\/udp\t$state\t$svc_name\n";
63
+ }
64
+ }
65
+ } else { # Redirect to stdout if '-output' command switch is not defined
66
+ print "List of found web services:\n";
67
+ #print "IP Port Status Service OS Hostname\n";
68
+ for my $up_host (@HOST){
69
+ $os = $up_host->os_sig; $osname=$os->name;
70
+ my $ip=$up_host->addr; my $hostname=$up_host->hostname();
71
+ #print "$ip\t\t\t\t$osname\t$hostname,\n"; # addr: $up_host->addr, OS: $up_host->os_sig\n";
72
+ my @p_tcp=$up_host->tcp_open_ports;
73
+ my @p_udp=$up_host->udp_open_ports;
74
+ foreach(@p_tcp) { # Print list of open tcp ports
75
+ my $port=$_;
76
+ my $state=$up_host->tcp_port_state($_);
77
+ my $svc = $up_host->tcp_service($_);
78
+ my $svc_name = $svc->name;
79
+ if ($svc_name =~ /https/i) {
80
+ if ($hostname) {
81
+ print "https://$hostname:$port/\n";
82
+ } else {
83
+ print "https://$ip:$port/\n";
84
+ }
85
+ } elsif ($svc_name =~ /http/i) {
86
+ if ($hostname) {
87
+ print "http://$hostname:$port/\n";
88
+ } else {
89
+ print "http://$ip:$port/\n"
90
+ }
91
+ }
92
+ #print "\t$_\/tcp\t$state\t$svc_name\n";
93
+ }
94
+ foreach(@p_udp) { # Print list of open udp ports
95
+ my $port=$_;
96
+ my $state=$up_host->udp_port_state($_);
97
+ my $svc = $up_host->udp_service($_);
98
+ my $svc_name = $svc->name;
99
+ if ($svc_name =~ /https/i) {
100
+ if ($hostname) {
101
+ print "https://$hostname:$port/\n";
102
+ } else {
103
+ print "https://$ip:$port/\n";
104
+ }
105
+ } elsif ($svc_name =~ /http/i) {
106
+ if ($hostname) {
107
+ print "http://$hostname:$port/\n";
108
+ } else {
109
+ print "http://$ip:$port/\n";
110
+ }
111
+ }
112
+ #print "\t$_\/udp\t$state\t$svc_name\n";
113
+ }
114
+ }
115
+ }
116
+ if (defined $opts{output}) {
117
+ close (OUT);
118
+ print "Done dumping out open ports table from $opts{file} to: $opts{output}.\n";
119
+ }
120
+ undef $np;
121
+ }
122
+
123
+ sub print_help {
124
+ my $header= "#" x 80;
125
+ print "$header\n nmap result quick parser.\n$header\n";
126
+ print "Usage: perl nmap.pl -f [nmap xml file] > [result file with found web services]\n";
127
+ print "Version: $ver, Developed by: $author\n"
128
+
129
+ }
130
+
131
+
132
+ ############################################################
133
+ # Main Program start here
134
+ ############################################################
135
+
136
+ &print_help;
137
+ unless ($opts{file}) { print "Error: unknown program input. Please check your file again. \n"; exit 1; }
138
+ parse_nmap_terse ();
@@ -0,0 +1,18 @@
1
+ # filter to detect unknown internet domain
2
+ # Input is a list of URLs
3
+ # Output is an internet domain list that not currently tracked by the domain tracker
4
+
5
+ require "wmap"
6
+
7
+ k=Wmap::SiteTracker.new
8
+ f=File.open(ARGV[0],'r')
9
+ f.each do |line|
10
+ url=line.chomp.strip.downcase
11
+ if k.is_url?(url)
12
+ puts k.url_2_site(url)
13
+ else
14
+ puts url
15
+ end
16
+ end
17
+ f.close
18
+ k=nil
@@ -0,0 +1,78 @@
1
+ # Automated whois lookup for a list of valid domains
2
+ # Usage: ruby whois_domain.rb [file_hosts]
3
+ # Input file format: one line for each host (FQDN)
4
+ # Output file format: good old CSV format, with whois response parsed and sorted into structured fields.
5
+ require "wmap"
6
+
7
+ puts Wmap.banner
8
+ dis=Wmap::DomainTracker.new
9
+ dis.verbose=false
10
+ puts "Domain Whois Lookup Summary Report"
11
+ puts "Host | Domain | Primary Domain Name Server | Registrant Name | Registrant Oraganization | Registrant Address | Registrant Zip | Registrant City | Registrant State | Registration Country | Registration Contact Phone | Registration Contact Email | Technical Contact Name | Technical Contact Organization | Technical Contact Country | Technical Contract Phone | Technical Contact Email | Admin Contact Name | Admin Contact Organization | Domain Availability"
12
+ f_hosts = File.open(ARGV[0], 'r')
13
+ f_hosts.each do |line|
14
+ #next if line.chomp =~ /\d+\.\d+\.\d+\.\d+/
15
+ begin
16
+ host=line.chomp.split(',')[0]
17
+ #url=line.chomp.split(',')[0]
18
+ #host=dis.url_2_host(url)
19
+ domain=dis.domain_root(host)
20
+ record=Hash.new
21
+ if domain.nil?
22
+ puts "#{line.chomp} | Domain Unknown"
23
+ # elsif dis.domain_known?(domain)
24
+ # next
25
+ else
26
+ result=Wmap.whois(domain)
27
+ puts result if dis.verbose
28
+ record['ns'] = result.nameservers.first unless result.nameservers.nil?
29
+ unless result.registrant_contacts.nil?
30
+ result.registrant_contacts.each do |contact_r|
31
+ record['r_name']=contact_r['name']
32
+ record['r_org']=contact_r['organization']
33
+ record['r_addr']=contact_r['address'].gsub(/\n/,',').gsub(/\r/,' ') unless contact_r['address'].nil?
34
+ record['r_zip']=contact_r['zip']
35
+ record['r_city']=contact_r['city']
36
+ record['r_state']=contact_r['state']
37
+ record['r_country']=contact_r['country_code']
38
+ record['r_phone']=contact_r['phone']
39
+ record['r_email']=contact_r['email']
40
+ end
41
+ end
42
+ unless result.technical_contacts.nil?
43
+ result.technical_contacts.each do |contact_t|
44
+ record['t_name']=contact_t['name']
45
+ record['t_org']=contact_t['organization']
46
+ record['t_country']=contact_t['country_code']
47
+ record['t_phone']=contact_t['phone']
48
+ record['t_email']=contact_t['email']
49
+ end
50
+ end
51
+ unless result.admin_contacts.nil?
52
+ result.admin_contacts.each do |contact_a|
53
+ record['a_name']=contact_a['name']
54
+ record['a_org']=contact_a['organization']
55
+ end
56
+ end
57
+ if result.available?
58
+ record['availability']="true"
59
+ else
60
+ record['availability']="false"
61
+ end
62
+ end
63
+ print "#{line.chomp} | #{domain} | "
64
+ if record.nil?
65
+ print " | Failure to parse the whois response. Please add it manually. "
66
+ else
67
+ print record['ns'], '|'
68
+ print record['r_name'], ' | ', record['r_org'],' | ', record['r_addr'],' | ', record['r_zip'],' | ', record['r_city'],' | ', record['r_state'],' | ', record['r_country'],' | ', record['r_phone'],' | ', record['r_email']
69
+ print ' | ', record['t_name'], ' | ', record['t_org'],' | ', record['t_country'],' | ', record['t_phone'],' | ', record['t_email']
70
+ print ' | ', record['a_name'], ' | ', record['a_org'],' | ', record['availability']
71
+ end
72
+ print "\n"
73
+ rescue => ee
74
+ puts "#{line.chomp} | #{domain} | #{ee}"
75
+ end
76
+ end
77
+ f_hosts.close
78
+ dis=nil
data/dicts/GeoIP.dat ADDED
Binary file
Binary file
Binary file