Module: Watobo::Mixin::Parser::Url
- Includes:
- Constants
- Defined in:
- lib/watobo/mixins/httpparser.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
Instance Method Details
#dir ⇒ Object
127
128
129
130
131
132
133
|
# File 'lib/watobo/mixins/httpparser.rb', line 127
def dir
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*)\/.* HTTP/i then
return $1
else
return ""
end
end
|
#doctype ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/watobo/mixins/httpparser.rb', line 166
def doctype
/.*\/.*?\.(\w{2,4})(\?| )/.match(self.first)
return $1 unless $1.nil?
return ''
end
|
#element ⇒ Object
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/watobo/mixins/httpparser.rb', line 155
def element
cl = self.first.gsub(/\?+/, "?")
cl.gsub!(/ HTTP.*/, '')
dummy = cl.split('?').first
if dummy =~ /^[^[:space:]]{1,} ([a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}).*\/(.*)/i then
return $2
else
return ""
end
end
|
#file ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/watobo/mixins/httpparser.rb', line 33
def file
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
tmp = $1
end_of_file_index = tmp.index(/\?/)
if end_of_file_index.nil?
@file = tmp
elsif end_of_file_index == 0
@file = ""
else
@file = tmp[0..end_of_file_index-1]
end
else
@file = ""
end
end
|
#file_ext ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'lib/watobo/mixins/httpparser.rb', line 53
def file_ext
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}[^\?]*\/(.*) HTTP.*/
@file_ext = $1
else
@file_ext = ''
end
end
|
#get_parm_names(&block) ⇒ Object
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/watobo/mixins/httpparser.rb', line 303
def get_parm_names(&block)
parm_names=[]
parmlist=[]
parmlist.concat(get_parms)
parmlist.each do |p|
if p then
p.gsub!(/=.*/, '')
yield p if block_given?
parm_names.push p
end
end
return parm_names
end
|
#get_parm_value(parm_name) ⇒ Object
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/watobo/mixins/httpparser.rb', line 321
def get_parm_value(parm_name)
parm_value = ""
self.get_parms.each do |parm|
if parm =~ /^#{Regexp.quote(parm_name)}=/i then
dummy = parm.split(/=/)
if dummy.length > 1 then
parm_value=dummy[1].strip
end
end
end
return parm_value
end
|
#get_parms ⇒ Object
get_parms returns an array of parm=value
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
|
# File 'lib/watobo/mixins/httpparser.rb', line 275
def get_parms
begin
off = self.first.index('?')
return [] if off.nil?
eop = self.first.index(' HTTP/')
return [] if eop.nil?
parms = self.first[off+1..eop-1].split('&').select { |x| x =~ /=/ }
return parms
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
end
return []
end
|
#host ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
|
# File 'lib/watobo/mixins/httpparser.rb', line 232
def host
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/([\-0-9a-zA-Z.]*)[:0-9]{0,6}/i then
@host = $1
else
@host = ''
end
@host
end
|
#is_chunked? ⇒ Boolean
194
195
196
197
198
199
200
|
# File 'lib/watobo/mixins/httpparser.rb', line 194
def is_chunked?
self.each do |h|
return true if h =~ /^Transfer-Encoding.*chunked/i
break if h.strip.empty?
end
return false
end
|
#is_ssl? ⇒ Boolean
189
190
191
192
|
# File 'lib/watobo/mixins/httpparser.rb', line 189
def is_ssl?
return true if self.first =~ /^[^[:space:]]{1,} https/i
return false
end
|
#method ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/watobo/mixins/httpparser.rb', line 80
def method
if self.first =~ /(^[^[:space:]]{1,}) /i then
return $1
else
return nil
end
end
|
#method_get? ⇒ Boolean
88
89
90
91
92
|
# File 'lib/watobo/mixins/httpparser.rb', line 88
def method_get?
return false if method.nil?
return true if method =~ /^get$/i
return false
end
|
#method_post? ⇒ Boolean
94
95
96
97
98
|
# File 'lib/watobo/mixins/httpparser.rb', line 94
def method_post?
return false if method.nil?
return true if method =~ /^post$/i
return false
end
|
#path ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/watobo/mixins/httpparser.rb', line 110
def path
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/([^\?]*).* HTTP/i then
return $1
else
return ""
end
end
|
#path_ext ⇒ Object
path_ext = “my/path/show.php?p=aaa&debug=true”
119
120
121
122
123
124
125
|
# File 'lib/watobo/mixins/httpparser.rb', line 119
def path_ext
if self.first =~ /^[^[:space:]]{1,} [a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}\/(.*) HTTP\//i then
return $1
else
return ""
end
end
|
#port ⇒ Object
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/watobo/mixins/httpparser.rb', line 257
def port
return nil if self.first.nil?
dummy = self.first
portnum = nil
parts = dummy.split('?')
if parts[0] =~ /^[^[:space:]]{1,} https:\/\//i then
portnum = 443
elsif parts[0] =~ /^[^[:space:]]{1,} http:\/\//i
portnum = 80
end
if parts[0] =~ /^[^[:space:]]{1,} https?:\/\/[\-0-9a-zA-Z.]*:([0-9]{0,6})/i then
portnum = $1
end
return portnum
end
|
#post_parm_value(parm_name) ⇒ Object
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
# File 'lib/watobo/mixins/httpparser.rb', line 335
def post_parm_value(parm_name)
parm_value=""
self.post_parms.each do |parm|
if parm =~ /#{Regexp.quote(parm_name)}/i then
dummy = parm.split(/=/)
if dummy.length > 1 then
parm_value = dummy[1].strip
else
end
end
end
return parm_value
end
|
#proto ⇒ Object
181
182
183
184
185
186
187
|
# File 'lib/watobo/mixins/httpparser.rb', line 181
def proto
proto = "unknown"
if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+):\/\//i
proto = $1
end
proto
end
|
#query ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/watobo/mixins/httpparser.rb', line 135
def query
begin
q = nil
if self.first =~ /^[^[:space:]]{1,} (.*) HTTP.*/ then
uri = $1
end
off = uri.index('?')
return "" if off.nil?
return uri[off+1..-1]
rescue => bang
puts "!!! Could not parse query !!!"
puts bang
puts bang.backtrace if $DEBUG
end
return ''
end
|
#site ⇒ Object
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/watobo/mixins/httpparser.rb', line 213
def site
if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+):\/\/([\-0-9a-zA-Z.]*)([:0-9]{0,6})/i then
host = $2
port_extension = $3
proto = $1
s = host + port_extension
if port_extension == ''
s = host + ":" + DEFAULT_PORT_HTTPS.to_s if proto =~ /^https$/i
s = host + ":" + DEFAULT_PORT_HTTP.to_s if proto =~ /^http$/i
end
@site = s
else
@site = nil
end
@site
end
|
#subDirs ⇒ Object
248
249
250
251
252
253
254
255
|
# File 'lib/watobo/mixins/httpparser.rb', line 248
def subDirs
sub_dirs = self.dir.split(/\//)
dir = ""
sub_dirs.map! do |d|
dir += "/" + d;
end
return sub_dirs
end
|
#url_string ⇒ Object
202
203
204
205
206
207
208
209
|
# File 'lib/watobo/mixins/httpparser.rb', line 202
def url_string
url = ''
if self.first =~ /^[^[:space:]]{1,} ([a-zA-Z]+:\/\/[\-0-9a-zA-Z.]*[:0-9]{0,6}.*) HTTP\//i then
url = $1
end
url
end
|
#urlparms ⇒ Object
returns a string containing all urlparms e.g. “parm1=first&parm2=second”
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/watobo/mixins/httpparser.rb', line 65
def urlparms
begin
off = self.first.index('?')
return nil if off.nil?
eop = self.first.index(' HTTP/')
return nil if eop.nil?
parms = self.first[off+1..eop-1]
return parms
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
end
return nil
end
|