wmap 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f2042c146724dcfa9852bcb1920a2d9baded35fb8ba589d3af277277d678d36
4
- data.tar.gz: d0ae5c5f90a4707eddbb91119b71ae2e9dc1c9ace6631e3f66e03d892ef3d8f1
3
+ metadata.gz: d6489f1302aecc4bc426c93c2e4f0a717e7f908186eee6ded623b3b0dbb10c0f
4
+ data.tar.gz: dc7875e566e929991dc9adce78db8dd5a47bc2643f745cea2c7b5a69f85ad8fb
5
5
  SHA512:
6
- metadata.gz: 2a543f31d23e42604a0c86445eb3c2b469485527c0897a7495a8d74f593be19a1e915cf38e8ae03246012d5bb21734f8d2f93b0180863383a3a5260030fb1336
7
- data.tar.gz: 830a9645c9633f0cd396cf9dfc40654a902ad3275ec37870f2fa1e06f64365bf9e0229f5acb0972af8569497c253e13d88b87c5d86710d324cb1510e3cd6679c
6
+ metadata.gz: d0520926107547b5870dd20a0fc9bbc4fdd8900708602e79db47edb37e1a9e0c82c4f98ea115c5a2d8c910c366d3ec1e91819f0cac5e83d52c3fac91f28a9cc9
7
+ data.tar.gz: 6358585417331756374da3f4a45a4a658cd4e59a5237bce9d2c8a0b8026683c678e49eac8f1b3e49a6f4359a2d9f8e1eb30d057424b801358f10a077f81fcd05
@@ -36,139 +36,129 @@ module Wmap
36
36
 
37
37
  # load the known tag signatures into an instance variable
38
38
  def load_from_file (file, lc=true)
39
- begin
40
- puts "Loading data file: #{file}" if @verbose
41
- data_store=Hash.new
42
- f = File.open(file, 'r')
43
- f.each_line do |line|
44
- puts "Processing line: #{line}" if @verbose
45
- line=line.chomp.strip
46
- next if line.nil?
47
- next if line.empty?
48
- next if line =~ /^\s*#/
49
- line=line.downcase if lc==true
50
- entry=line.split(',')
51
- if data_store.key?(entry[0])
52
- next
53
- else
54
- data_store[entry[0]]=entry[1].strip
55
- end
39
+ puts "Loading data file: #{file}" if @verbose
40
+ data_store=Hash.new
41
+ f = File.open(file, 'r')
42
+ f.each_line do |line|
43
+ puts "Processing line: #{line}" if @verbose
44
+ line=line.chomp.strip
45
+ next if line.nil?
46
+ next if line.empty?
47
+ next if line =~ /^\s*#/
48
+ line=line.downcase if lc==true
49
+ entry=line.split(',')
50
+ if data_store.key?(entry[0])
51
+ next
52
+ else
53
+ data_store[entry[0]]=entry[1].strip
54
+ end
56
55
 
57
- end
58
- f.close
59
- return data_store
60
- rescue => ee
61
- puts "Exception on method #{__method__}: #{ee}" if @verbose
62
- return nil
63
- end
56
+ end
57
+ f.close
58
+ return data_store
59
+ rescue => ee
60
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
61
+ return nil
64
62
  end
65
63
 
66
64
  # load the known tag store cache into an instance variable
67
65
  def load_tag_from_file (file, lc=true)
68
- begin
69
- puts "Loading tag data file: #{file}" if @verbose
70
- data_store=Hash.new
71
- f = File.open(file, 'r')
72
- f.each_line do |line|
73
- puts "Processing line: #{line}" if @verbose
74
- line=line.chomp.strip
75
- next if line.nil?
76
- next if line.empty?
77
- next if line =~ /^\s*#/
78
- line=line.downcase if lc==true
79
- entry=line.split(',')
80
- if data_store.key?(entry[0])
81
- next
82
- else
83
- data_store[entry[0]]=[entry[1].strip, entry[2].strip, entry[3]]
84
- end
85
- end
86
- f.close
87
- return data_store
88
- rescue => ee
89
- puts "Exception on method #{__method__}: #{ee}" if @verbose
90
- return nil
91
- end
66
+ puts "Loading tag data file: #{file}" if @verbose
67
+ data_store=Hash.new
68
+ f = File.open(file, 'r')
69
+ f.each_line do |line|
70
+ puts "Processing line: #{line}" if @verbose
71
+ line=line.chomp.strip
72
+ next if line.nil?
73
+ next if line.empty?
74
+ next if line =~ /^\s*#/
75
+ line=line.downcase if lc==true
76
+ entry=line.split(',')
77
+ if data_store.key?(entry[0])
78
+ next
79
+ else
80
+ data_store[entry[0]]=[entry[1].strip, entry[2].strip, entry[3], entry[4]]
81
+ end
82
+ end
83
+ f.close
84
+ return data_store
85
+ rescue => ee
86
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
87
+ return nil
92
88
  end
93
89
 
94
90
  # Save the current tag store hash table into a file
95
91
  def save_to_file!(file_tag=@tag_file, tags=@tag_store)
96
- begin
97
- puts "Saving the current wordpress site table from memory to file: #{file_tag} ..." if @verbose
98
- timestamp=Time.now
99
- f=File.open(file_tag, 'w')
100
- f.write "# Local tag file created by class #{self.class} method #{__method__} at: #{timestamp}\n"
101
- f.write "# Site, Landing URL, Detected Adware Tag, Tag Version, Tag Description\n"
102
- tags.each do |key, val|
103
- f.write "#{key}, #{val[0]}, #{val[1]}, #{val[2]}, #{val[3]}\n"
104
- end
105
- f.close
106
- puts "Tag store cache table is successfully saved: #{file_tag}"
107
- rescue => ee
108
- puts "Exception on method #{__method__}: #{ee}" if @verbose
109
- end
92
+ puts "Saving the current wordpress site table from memory to file: #{file_tag} ..." if @verbose
93
+ timestamp=Time.now
94
+ f=File.open(file_tag, 'w')
95
+ f.write "# Local tag file created by class #{self.class} method #{__method__} at: #{timestamp}\n"
96
+ f.write "# Site, Landing URL, Detected Adware Tag, Tag Version, Tag Description\n"
97
+ tags.each do |key, val|
98
+ f.write "#{key}, #{val[0]}, #{val[1]}, #{val[2]}, #{val[3]}\n"
99
+ end
100
+ f.close
101
+ puts "Tag store cache table is successfully saved: #{file_tag}"
102
+ rescue => ee
103
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
110
104
  end
111
105
  alias_method :save!, :save_to_file!
112
106
 
113
107
  # add tag entries (from the sitetracker list)
114
108
  def refresh (num=@max_parallel,use_cache=true)
115
- #begin
116
- puts "Add entries to the local cache table from site tracker: " if @verbose
117
- results=Hash.new
118
- tags=Wmap::SiteTracker.instance.known_sites.keys
119
- if tags.size > 0
120
- Parallel.map(tags, :in_processes => num) { |target|
121
- check_adware(target,use_cache)
122
- }.each do |process|
123
- if !process
124
- next
125
- else
126
- results.merge!(process)
127
- end
128
- end
129
- @tag_store.merge!(results)
130
- puts "Done loading entries."
131
- tags=nil
132
- return results
133
- else
134
- puts "Error: no entry is loaded. Please check your list and try again."
135
- end
109
+ puts "Add entries to the local cache table from site tracker: " if @verbose
110
+ results=Hash.new
111
+ tags=Wmap::SiteTracker.instance.known_sites.keys
112
+ if tags.size > 0
113
+ Parallel.map(tags, :in_processes => num) { |target|
114
+ check_adware(target,use_cache)
115
+ }.each do |process|
116
+ if !process
117
+ next
118
+ else
119
+ results.merge!(process)
120
+ end
121
+ end
122
+ @tag_store.merge!(results)
123
+ puts "Done loading entries."
136
124
  tags=nil
137
- return results
138
- #rescue => ee
139
- # puts "Exception on method #{__method__}: #{ee}" if @verbose
140
- #end
125
+ return results
126
+ else
127
+ puts "Error: no entry is loaded. Please check your list and try again."
128
+ end
129
+ tags=nil
130
+ return results
131
+ rescue => ee
132
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
141
133
  end
142
134
 
143
135
  # Give a site, locate the landing page, then sift out the adware tag if found
144
136
  def check_adware(site,use_cache=true)
145
- #begin
146
- puts "Check the site for known Adware tags: #{site}" if @verbose
147
- record = Hash.new
148
- if use_cache && @tag_store.key?(site)
149
- puts "Site entry already exist. Skipping: #{site}" if @verbose
150
- else
151
- url = fast_landing(site)
152
- tags = find_tags(url)
153
- return record if tags.size==0
154
- tag_vers=tags.map do |tag|
155
- get_ver(url,tag)
156
- end
157
- tag_descs=tags.map do |tag|
158
- Base64.urlsafe_encode64(get_desc(url,tag))
159
- end
160
- if tags
161
- record[site]=[url, tags.join("|"), tag_vers.join("|"), tag_descs.join("|")]
162
- @tag_store.merge!(record)
163
- puts "Tag entry loaded: #{record}" if @verbose
164
- else
165
- puts "No tag found. Skip site #{site}" if @verbose
166
- end
167
- end
168
- return record
169
- #rescue => ee
170
- # puts "Exception on method #{__method__}: #{ee}: #{site}" if @verbose
171
- #end
137
+ puts "Check the site for known Adware tags: #{site}" if @verbose
138
+ record = Hash.new
139
+ if use_cache && @tag_store.key?(site)
140
+ puts "Site entry already exist. Skipping: #{site}" if @verbose
141
+ else
142
+ url = fast_landing(site)
143
+ tags = find_tags(url)
144
+ return record if tags.size==0
145
+ tag_vers=tags.map do |tag|
146
+ get_ver(url,tag)
147
+ end
148
+ tag_descs=tags.map do |tag|
149
+ Base64.urlsafe_encode64(get_desc(url,tag))
150
+ end
151
+ if tags
152
+ record[site]=[url, tags.join("|"), tag_vers.join("|"), tag_descs.join("|")]
153
+ @tag_store.merge!(record)
154
+ puts "Tag entry loaded: #{record}" if @verbose
155
+ else
156
+ puts "No tag found. Skip site #{site}" if @verbose
157
+ end
158
+ end
159
+ return record
160
+ rescue => ee
161
+ puts "Exception on method #{__method__}: #{ee}: #{site}" if @verbose
172
162
  end
173
163
 
174
164
  # Given a site, determine the landing url
@@ -191,26 +181,26 @@ module Wmap
191
181
  end
192
182
  puts "Landing url found: #{url}" if @verbose
193
183
  return url
184
+ rescue => ee
185
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
194
186
  end
195
187
 
196
188
  # Search the page for known tag signatures. If found return them in an array
197
189
  def find_tags(url)
198
- begin
199
- puts "Search and return tags within the url payload: #{url}" if @verbose
200
- tag_list = []
201
- doc = Nokogiri::HTML(open(url))
202
- doc.text.each_line do |line|
203
- my_line = line.downcase
204
- @tag_signatures.keys.map do |tag|
205
- tag_list.push(tag) if my_line.include?(tag)
206
- end
190
+ puts "Search and return tags within the url payload: #{url}" if @verbose
191
+ tag_list = []
192
+ doc = Nokogiri::HTML(open(url))
193
+ doc.text.each_line do |line|
194
+ my_line = line.downcase
195
+ @tag_signatures.keys.map do |tag|
196
+ tag_list.push(tag) if my_line.include?(tag)
207
197
  end
208
- doc = nil
209
- return tag_list
210
- rescue => ee
211
- puts "Exception on method #{__method__}: #{ee}" if @verbose
212
- return []
213
- end
198
+ end
199
+ doc = nil
200
+ return tag_list
201
+ rescue => ee
202
+ puts "Exception on method #{__method__}: #{ee}" if @verbose
203
+ return []
214
204
  end
215
205
 
216
206
  # Search the url payload for known tag version identifier. If found return a string, else empty string.
@@ -256,6 +246,9 @@ module Wmap
256
246
  end
257
247
  doc = nil
258
248
  return tag_ver
249
+ rescue => ee
250
+ puts "Exception on method #{__method__}: #{ee}: #{url} : #{tag}" if @verbose
251
+ return tag_ver
259
252
  end
260
253
 
261
254
  # Search the url payload for known tag. If found return the base64 encode whole script snippet.
@@ -272,6 +265,9 @@ module Wmap
272
265
  end
273
266
  doc = nil
274
267
  return tag_desc
268
+ rescue => ee
269
+ puts "Exception on method #{__method__}: #{ee}: #{url}: #{tag}" if @verbose
270
+ return tag_desc
275
271
  end
276
272
 
277
273
 
data/version.txt CHANGED
@@ -3,8 +3,8 @@
3
3
  ###############################################################################
4
4
  package = wmap
5
5
  # wmap version 2.0 == web_discovery version 1.5.3
6
- version = 2.5.1
7
- date = 2019-03-17
6
+ version = 2.5.2
7
+ date = 2019-03-18
8
8
 
9
9
  author = Sam (Yang) Li
10
10
  email = yang.li@owasp.org
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam (Yang) Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dnsruby