Module: Watobo::Mixin::Shaper::Web10
- Includes:
- Constants
- 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::AUTH_TYPE_UNKNOWN, 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
(also: #setHeader)
-
#set_header_UNUSED(header, value) ⇒ 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
82
83
84
85
86
87
88
89
|
# File 'lib/watobo/mixins/shapers.rb', line 82
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
74
75
76
77
78
79
80
|
# File 'lib/watobo/mixins/shapers.rb', line 74
def add_post_parm(parm,value)
line = self.last
return false if line !~ /=/
line += "&#{parm}=#{value}"
self.pop
self.push line
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/watobo/mixins/shapers.rb', line 91
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
66
67
68
69
70
71
72
|
# File 'lib/watobo/mixins/shapers.rb', line 66
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
320
321
322
323
324
325
326
327
328
329
330
331
|
# File 'lib/watobo/mixins/shapers.rb', line 320
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
246
247
248
249
250
251
252
253
254
|
# File 'lib/watobo/mixins/shapers.rb', line 246
def fix_content_length
return false if self.body.nil?
blen = self.body.force_encoding("ASCII-8BIT").length
("Content-Length" , blen)
end
|
#fix_session(pattern, value) ⇒ Object
242
243
244
|
# File 'lib/watobo/mixins/shapers.rb', line 242
def fix_session(pattern,value)
end
|
#fixupContentLength ⇒ Object
303
304
305
306
|
# File 'lib/watobo/mixins/shapers.rb', line 303
def fixupContentLength
self.unchunk
self.fix_content_length
end
|
#fixupContentLength_UNUSED ⇒ Object
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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
|
# File 'lib/watobo/mixins/shapers.rb', line 256
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
121
122
123
|
# File 'lib/watobo/mixins/shapers.rb', line 121
def removeBody
self.pop if self[-2].strip.empty?
end
|
R E M O V E _ H E A D E R
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/watobo/mixins/shapers.rb', line 171
def ()
begin
while i = .index{|h| h =~ /#{}/i }
self.delete_at i
end
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
puts self
puts "====="
end
end
|
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/watobo/mixins/shapers.rb', line 209
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
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/watobo/mixins/shapers.rb', line 108
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/watobo/mixins/shapers.rb', line 191
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
21
22
23
24
|
# File 'lib/watobo/mixins/shapers.rb', line 21
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
|
238
239
240
|
# File 'lib/watobo/mixins/shapers.rb', line 238
def (, value)
end
|
#replace_post_parm(parm, value) ⇒ Object
16
17
18
19
|
# File 'lib/watobo/mixins/shapers.rb', line 16
def replace_post_parm(parm,value)
parm_quoted = Regexp.quote(parm)
self.last.gsub!(/([?&]{1}|^)#{parm_quoted}=([^&]*)(&{0,1})/i, "\\1#{parm}=#{value}\\3")
end
|
#replaceElement(new_element) ⇒ Object
40
41
42
43
|
# File 'lib/watobo/mixins/shapers.rb', line 40
def replaceElement(new_element)
new_element.gsub!(/^\//, "")
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1#{new_element} \\3")
end
|
#replaceFileExt(new_file) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/watobo/mixins/shapers.rb', line 30
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
26
27
28
|
# File 'lib/watobo/mixins/shapers.rb', line 26
def replaceMethod(new_method)
self.first.gsub!(/^[^[:space:]]{1,}/i, "#{new_method}")
end
|
#replaceQuery(new_query) ⇒ Object
49
50
51
52
|
# File 'lib/watobo/mixins/shapers.rb', line 49
def replaceQuery(new_query)
new_query.gsub!(/^\//, "")
self.first.gsub!(/(.*\/)(.*) (HTTP.*)/i,"\\1#{new_query} \\3")
end
|
#replaceURL(new_url) ⇒ Object
45
46
47
|
# File 'lib/watobo/mixins/shapers.rb', line 45
def replaceURL(new_url)
self.first.gsub!(/(^[^[:space:]]{1,})(.*) (HTTP.*)/i,"\\1 #{new_url} \\3")
end
|
#restoreURI(uri) ⇒ Object
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/watobo/mixins/shapers.rb', line 152
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
143
144
145
146
147
148
149
150
|
# File 'lib/watobo/mixins/shapers.rb', line 143
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
134
135
136
137
138
139
140
141
|
# File 'lib/watobo/mixins/shapers.rb', line 134
def set_body(content)
if self[-2].strip.empty?
self.pop
else
self << "\r\n"
end
self << content
end
|
#set_content_length(length) ⇒ Object
333
334
335
|
# File 'lib/watobo/mixins/shapers.rb', line 333
def set_content_length(length)
("Content-Length", length)
end
|
#set_content_type(ctype) ⇒ Object
337
338
339
|
# File 'lib/watobo/mixins/shapers.rb', line 337
def set_content_type(ctype)
("Content-Type", ctype)
end
|
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'lib/watobo/mixins/shapers.rb', line 341
def (, value)
begin
= "#{}: #{value}\r\n"
self.each_with_index do |h, i|
if h =~ /^#{Regexp.quote()}:/i
self[i] =
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
|
125
126
127
128
129
130
131
132
|
# File 'lib/watobo/mixins/shapers.rb', line 125
def (, value)
self.each do |h|
break if h.strip.empty?
if h =~ /^#{}:/
h.replace "#{}: #{value}\r\n"
end
end
end
|
#setData(data) ⇒ Object
363
364
365
366
367
368
369
370
371
372
|
# File 'lib/watobo/mixins/shapers.rb', line 363
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
58
59
60
61
62
63
64
|
# File 'lib/watobo/mixins/shapers.rb', line 58
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
382
383
384
385
|
# File 'lib/watobo/mixins/shapers.rb', line 382
def setHTTPVersion(version)
self.first.gsub!(/HTTP\/(.*)$/, "HTTP\/#{version}")
end
|
#setMethod(method) ⇒ Object
Also known as:
set_method, method=
374
375
376
377
|
# File 'lib/watobo/mixins/shapers.rb', line 374
def setMethod(method)
m = method.is_a?(Symbol) ? method.to_s.upcase : method
self.first.gsub!(/(^[^[:space:]]{1,}) /, "#{m} ")
end
|
#setRawQueryParms(parm_string) ⇒ Object
308
309
310
311
312
313
314
315
316
317
318
|
# File 'lib/watobo/mixins/shapers.rb', line 308
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
54
55
56
|
# File 'lib/watobo/mixins/shapers.rb', line 54
def strip_path()
self.first.gsub!(/([^\?]*\/)(.*) (HTTP.*)/i,"\\1# \\3")
end
|