Class: Watobo::Gui::FuzzRequestEditor

Inherits:
RequestEditor
  • Object
show all
Defined in:
lib/watobo/gui/fuzzer_gui.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, opts) ⇒ FuzzRequestEditor

Returns a new instance of FuzzRequestEditor.



323
324
325
326
327
328
# File 'lib/watobo/gui/fuzzer_gui.rb', line 323

def initialize(owner, opts)
   super(owner, opts)

   @tags = []

end

Instance Method Details

#addTag(tag) ⇒ Object



311
312
313
# File 'lib/watobo/gui/fuzzer_gui.rb', line 311

def addTag(tag)
   @tags.push tag
end

#highlight(pattern) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
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
# File 'lib/watobo/gui/fuzzer_gui.rb', line 237

def highlight(pattern)
   sindex = nil
   eindex = nil

   dummy = @textbox.to_s
   @textbox.setText(dummy)

   pos = 0
   @pattern_matches.clear

   loop do

      sindex, eindex = @textbox.findText(pattern, pos, SEARCH_EXACT|SEARCH_IGNORECASE|SEARCH_FORWARD)
      #   puts sindex
      sindex, eindex = @textbox.findText(pattern, pos, :flags => SEARCH_REGEX|SEARCH_IGNORECASE|SEARCH_FORWARD) if not sindex
      #  puts sindex
      sindex, eindex = @textbox.findText(Regexp.quote(pattern), pos, :flags => SEARCH_REGEX|SEARCH_IGNORECASE|SEARCH_FORWARD) if not sindex

      break if not sindex or sindex.length == 0


      pos = eindex.last+1

      sindex.length.times do |i|
         start = sindex[i]
         len = eindex[i] - sindex[i]
         @pattern_matches.push [ start, len] if start >= 0

      end

      break if sindex.last < 0
      #   puts sindex

   end

   # puts "* found pattern #{pattern} #{@pattern_matches.length} times"

   @pattern_matches.each do |start, len|
      begin
         style = @style
         match = @textbox.to_s.slice(start, len)
         # puts "#{match}/#{start}/#{len}"
         match.gsub!(/%%/, '')
         style = @tags.include?(match) ? 1 : 2

         @textbox.changeStyle(start, len, style)
      rescue => bang
         puts "outch"
         puts bang
      end
   end
   return @pattern_matches
end

#highlightTagsObject



319
320
321
# File 'lib/watobo/gui/fuzzer_gui.rb', line 319

def highlightTags()
   highlight("(%%[^%]*%%)")
end

#parseRequest(fuzzels) ⇒ Object



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/watobo/gui/fuzzer_gui.rb', line 293

def parseRequest(fuzzels)
   begin
      new_request = nil
      if fuzzels then
         new_request = @textbox.to_s
         fuzzels.each do |marker, value|
            new_request.gsub!(/%%#{marker}%%/, value.to_s)
         end
      end

      return Watobo::Utils.text2request(new_request)
   rescue => bang
      puts bang
      puts bang.backtrace if $DEBUG
   end
   return nil
end

#removeTag(tag) ⇒ Object



315
316
317
# File 'lib/watobo/gui/fuzzer_gui.rb', line 315

def removeTag(tag)
   @tags.delete(tag)
end