Module: Watobo::Mixin::Shaper::Web10
- Defined in:
- lib/watobo/mixins/shapers.rb
Constant Summary
Constants included
from Constants
Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED
Instance Method Summary
collapse
-
#add_get_parm(parm, value) ⇒ Object
-
#add_post_parm(parm, value) ⇒ Object
-
#addHeader(header, value) ⇒ Object
(also: #add_header)
-
#appendDir(dir) ⇒ Object
-
#appendQueryParms(parms) ⇒ Object
-
#fix_content_length ⇒ Object
-
#fix_session(pattern, value) ⇒ Object
-
#fixupContentLength ⇒ Object
-
#fixupContentLength_UNUSED ⇒ Object
-
#removeBody ⇒ Object
-
#removeHeader(header) ⇒ Object
(also: #remove_header)
R E M O V E _ H E A D E R.
-
#removeHeader_OLD(header) ⇒ Object
-
#removeURI ⇒ Object
-
#removeUrlParms ⇒ Object
removeUrlParms Function: Remove all parameter within the URL.
-
#replace_get_parm(parm, value) ⇒ Object
-
#replace_header(header, value) ⇒ Object
-
#replace_post_parm(parm, value) ⇒ Object
-
#replaceElement(new_element) ⇒ Object
-
#replaceFileExt(new_file) ⇒ Object
-
#replaceMethod(new_method) ⇒ Object
-
#replaceQuery(new_query) ⇒ Object
-
#replaceURL(new_url) ⇒ Object
-
#restoreURI(uri) ⇒ Object
-
#rewrite_body(pattern, content) ⇒ Object
-
#set_body(content) ⇒ Object
-
#set_content_length(length) ⇒ Object
-
#set_content_type(ctype) ⇒ Object
-
#set_header(header, value) ⇒ Object
-
#set_header_UNUSED(header, value) ⇒ Object
-
#setCookie(cname = "Cookie", value = nil) ⇒ Object
-
#setData(data) ⇒ Object
-
#setDir(dir) ⇒ Object
-
#setHTTPVersion(version) ⇒ Object
-
#setMethod(method) ⇒ Object
(also: #set_method, #method=)
-
#setRawQueryParms(parm_string) ⇒ Object
-
#strip_path ⇒ Object
Instance Method Details
#add_get_parm(parm, value) ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/watobo/mixins/shapers.rb', line 98
def add_get_parm(parm,value)
line = self.shift
new_p = "&"
new_p = "?" if not self.element =~ /\?/
new_p += parm
line.gsub!(/( HTTP\/.*)/, "#{new_p}=#{value}\\1")
self.unshift(line)
end
|
#add_post_parm(parm, value) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/watobo/mixins/shapers.rb', line 90
def add_post_parm(parm,value)
line = self.last
return false if line !~ /=/
line += "&#{parm}=#{value}"
self.pop
self.push line
end
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/watobo/mixins/shapers.rb', line 107
def (, value)
self_copy = []
self_copy.concat(self.)
self_copy.push "#{}: #{value}\r\n"
unless self.body.nil?
self_copy.push "\r\n"
self_copy.push self.body
end
self.replace(self_copy)
end
|
#appendDir(dir) ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/watobo/mixins/shapers.rb', line 82
def appendDir(dir)
dir.strip!
dir.gsub!(/^\//,"")
dir << "/" unless dir =~ /\/$/
self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*\/).*( HTTP\/.*)/, "\\1#{dir}\\2")
end
|
#appendQueryParms(parms) ⇒ Object
335
336
337
338
339
340
341
342
343
344
345
346
|
# File 'lib/watobo/mixins/shapers.rb', line 335
def appendQueryParms(parms)
return if parms.nil?
return if parms == ''
puts self.first
puts self.file_ext
pref = (self.file_ext =~ /\?/) ? '&' : '?'
puts "append query parms"
self.first.gsub!(/(.*) (HTTP\/.*)/, "\\1#{pref}#{parms} \\2")
end
|
#fix_content_length ⇒ Object
261
262
263
264
265
266
267
268
269
|
# File 'lib/watobo/mixins/shapers.rb', line 261
def fix_content_length
return false if self.body.nil?
("Content-Length" , body.length.to_s )
end
|
#fix_session(pattern, value) ⇒ Object
257
258
259
|
# File 'lib/watobo/mixins/shapers.rb', line 257
def fix_session(pattern,value)
end
|
#fixupContentLength ⇒ Object
318
319
320
321
|
# File 'lib/watobo/mixins/shapers.rb', line 318
def fixupContentLength
self.unchunk
self.fix_content_length
end
|
#fixupContentLength_UNUSED ⇒ Object
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
# File 'lib/watobo/mixins/shapers.rb', line 271
def fixupContentLength_UNUSED
te = self.transferEncoding
if te == TE_CHUNKED then
self.("Transfer-Encoding")
self.("Content-Length", "0")
new_r = []
new_r.concat self.
new_r.push "\r\n"
bytes_to_read = 0
body = []
is_new_chunk = false
off = 0
new_body = ''
body_orig = self.body
puts body_orig.class
while body_orig[off..-1] =~ /^([0-9a-fA-F]{1,6})\r\n/
len_raw = "#{$1}"
len = len_raw.hex
chunk_start = off + len_raw.length + 2
chunk_end = chunk_start + len
break if len == 0
new_body.chomp!
new_body += "#{body_orig[chunk_start..chunk_end]}"
off = chunk_end + 2
end
new_r.push new_body
self.replace(new_r)
self.fix_content_length
elsif te == TE_NONE then
self.fix_content_length
end
end
|
#removeBody ⇒ Object
137
138
139
|
# File 'lib/watobo/mixins/shapers.rb', line 137
def removeBody
self.pop if self[-2].strip.empty?
end
|
R E M O V E _ H E A D E R
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/watobo/mixins/shapers.rb', line 187
def ()
begin
eoh_index = self.length
eoh_index -= 1 unless self.body.nil?
self.delete_if {|x| self.index(x) <= eoh_index and x =~ /#{}/i }
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
puts self
puts "====="
end
end
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/watobo/mixins/shapers.rb', line 224
def ()
begin
self_copy = []
eoh = false
self.each do |line|
puts self if line.nil?
if not eoh == true then
if not line =~ /#{}/i
self_copy.push line unless line.nil?
end
else
self_copy.push line unless line.nil?
end
if line and line.strip.empty? then
eoh = true
end
end
self.replace(self_copy)
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
puts self
puts "====="
end
end
|
#removeURI ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/watobo/mixins/shapers.rb', line 124
def removeURI
if self.first =~ /(^[^[:space:]]{1,}) (https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)/ then
uri = $2
self.first.gsub!(/(^[^[:space:]]{1,}) (#{Regexp.quote(uri)})/,"\\1 /")
return uri
else
return nil
end
end
|
#removeUrlParms ⇒ Object
removeUrlParms Function: Remove all parameter within the URL
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/watobo/mixins/shapers.rb', line 206
def removeUrlParms
line = self.shift
new_line = "#{line}"
eop_index = line.rindex(/[^ HTTP]\//)
sop_index = line.index(/(\?|&)/, eop_index)
eou_index = line.index(/ HTTP/)
unless sop_index.nil?
new_line = line[0..sop_index-1]
new_line += line[eou_index..-1]
end
self.unshift new_line
end
|
#replace_get_parm(parm, value) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/watobo/mixins/shapers.rb', line 33
def replace_get_parm(parm,value)
parm_quoted = Regexp.quote(parm)
self.first.gsub!(/([?&]{1})#{parm_quoted}=([^ &]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
end
|
253
254
255
|
# File 'lib/watobo/mixins/shapers.rb', line 253
def (, value)
end
|
#replace_post_parm(parm, value) ⇒ Object
28
29
30
31
|
# File 'lib/watobo/mixins/shapers.rb', line 28
def replace_post_parm(parm,value)
parm_quoted = Regexp.quote(parm)
self.last.gsub!(/([?&]{0,1})#{parm_quoted}=([0-9a-zA-Z\-\._,+<>\%!=]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
end
|
#replaceElement(new_element) ⇒ Object
55
56
57
58
59
|
# File 'lib/watobo/mixins/shapers.rb', line 55
def replaceElement(new_element)
new_element.gsub!(/^\//, "")
self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_element} \\3")
end
|
#replaceFileExt(new_file) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/watobo/mixins/shapers.rb', line 44
def replaceFileExt(new_file)
begin
file = new_file.strip
file.gsub!(/^\//, "")
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1#{file} \\3")
rescue => bang
puts bang
end
end
|
#replaceMethod(new_method) ⇒ Object
40
41
42
|
# File 'lib/watobo/mixins/shapers.rb', line 40
def replaceMethod(new_method)
self.first.gsub!(/^[^[:space:]]{1,}/i, "#{new_method}")
end
|
#replaceQuery(new_query) ⇒ Object
65
66
67
68
|
# File 'lib/watobo/mixins/shapers.rb', line 65
def replaceQuery(new_query)
new_query.gsub!(/^\//, "")
self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_query} \\3")
end
|
#replaceURL(new_url) ⇒ Object
61
62
63
|
# File 'lib/watobo/mixins/shapers.rb', line 61
def replaceURL(new_url)
self.first.gsub!(/(^[^[:space:]]{1,})(.*) (HTTP.*)/i,"\\1 #{new_url} \\3")
end
|
#restoreURI(uri) ⇒ Object
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/watobo/mixins/shapers.rb', line 168
def restoreURI(uri)
if self.first =~ /(^[^[:space:]]{1,}) \/(.*) (HTTP\/.*)/ then
method = $1
rest = $2
http = $3.strip
self.shift
self.unshift "#{method} #{uri}#{rest} #{http}\r\n"
return self.first
else
return nil
end
end
|
#rewrite_body(pattern, content) ⇒ Object
159
160
161
162
163
164
165
166
|
# File 'lib/watobo/mixins/shapers.rb', line 159
def rewrite_body(pattern, content)
if self[-2].strip.empty?
puts "rewrite_body ... #{pattern} - #{content}"
b = self.pop
b.gsub!(/#{pattern}/i, content)
self << b
end
end
|
#set_body(content) ⇒ Object
150
151
152
153
154
155
156
157
|
# File 'lib/watobo/mixins/shapers.rb', line 150
def set_body(content)
if self[-2].strip.empty?
self.pop
else
self << "\r\n"
end
self << content
end
|
#set_content_length(length) ⇒ Object
359
360
361
|
# File 'lib/watobo/mixins/shapers.rb', line 359
def set_content_length(length)
("Content-Length", length)
end
|
#set_content_type(ctype) ⇒ Object
363
364
365
|
# File 'lib/watobo/mixins/shapers.rb', line 363
def set_content_type(ctype)
("Content-Type", ctype)
end
|
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/watobo/mixins/shapers.rb', line 367
def (, value)
begin
= "#{}: #{value}\r\n"
self.each_with_index do |h, i|
if h =~ /^#{Regexp.quote()}:/
h.replace()
return true
end
if h.strip.empty? or i == self.length-1
self.insert(i, )
return true
end
end
rescue => bang
puts bang
end
return false
end
|
141
142
143
144
145
146
147
148
|
# File 'lib/watobo/mixins/shapers.rb', line 141
def (, value)
self.each do |h|
break if h.strip.empty?
if h =~ /^#{}:/
h.replace "#{}: #{value}\r\n"
end
end
end
|
#setCookie(cname = "Cookie", value = nil) ⇒ Object
348
349
350
351
352
353
354
355
356
357
|
# File 'lib/watobo/mixins/shapers.rb', line 348
def setCookie(cname="Cookie", value=nil)
return nil if value.nil?
self.map!{ |l|
break if l.strip.empty?
if l =~ /^#{cname}:/i
l = "#{cname}: #{value}"
end
}
end
|
#setData(data) ⇒ Object
387
388
389
390
391
392
393
394
395
396
|
# File 'lib/watobo/mixins/shapers.rb', line 387
def setData(data)
return if data.nil?
if self.has_body?
self.pop
self.push data
else
self.push("\r\n")
self.push data
end
end
|
#setDir(dir) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/watobo/mixins/shapers.rb', line 74
def setDir(dir)
dir.strip!
dir.gsub!(/^\/+/,"")
dir.gsub!(/\/+$/,"")
dir += "/" unless dir == ''
self.first.gsub!(/(^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/)(.*)( HTTP\/.*)/, "\\1#{dir}\\3")
end
|
#setHTTPVersion(version) ⇒ Object
404
405
406
407
|
# File 'lib/watobo/mixins/shapers.rb', line 404
def setHTTPVersion(version)
self.first.gsub!(/HTTP\/(.*)$/, "HTTP\/#{version}")
end
|
#setMethod(method) ⇒ Object
Also known as:
set_method, method=
398
399
400
|
# File 'lib/watobo/mixins/shapers.rb', line 398
def setMethod(method)
self.first.gsub!(/(^[^[:space:]]{1,}) /, "#{method} ")
end
|
#setRawQueryParms(parm_string) ⇒ Object
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/watobo/mixins/shapers.rb', line 323
def setRawQueryParms(parm_string)
return nil if parm_string.nil?
return nil if parm_string == ''
new_r = ""
path = Regexp.quote(self.path)
if self.first =~ /(.*#{path})/ then
new_r = $1 << "?" << parm_string
end
self.first.gsub!(/(.*) (HTTP\/.*)/, "#{new_r} \\2")
end
|
#strip_path ⇒ Object
70
71
72
|
# File 'lib/watobo/mixins/shapers.rb', line 70
def strip_path()
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1# \\3")
end
|