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 +4 -4
- data/lib/wmap/url_crawler/adware_tag.rb +125 -129
- data/version.txt +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6489f1302aecc4bc426c93c2e4f0a717e7f908186eee6ded623b3b0dbb10c0f
|
4
|
+
data.tar.gz: dc7875e566e929991dc9adce78db8dd5a47bc2643f745cea2c7b5a69f85ad8fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
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.
|
7
|
-
date = 2019-03-
|
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.
|
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-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dnsruby
|