Class: Watobo::Gui::InterceptorUI

Inherits:
FXTopWindow
  • Object
show all
Includes:
Responder, Icons
Defined in:
lib/watobo/gui/interceptor_gui.rb

Constant Summary

Constants included from Icons

Watobo::Gui::Icons::ICON_ADD_PROJECT, Watobo::Gui::Icons::ICON_BROWSER_MEDIUM, Watobo::Gui::Icons::ICON_BROWSER_SMALL, Watobo::Gui::Icons::ICON_BTN_DOWN, Watobo::Gui::Icons::ICON_BTN_UP, Watobo::Gui::Icons::ICON_CB_CHECKED, Watobo::Gui::Icons::ICON_CB_CHECKED_ORANGE, Watobo::Gui::Icons::ICON_CB_UNCHECKED, Watobo::Gui::Icons::ICON_CONVERSATION, Watobo::Gui::Icons::ICON_DASHBOARD, Watobo::Gui::Icons::ICON_DIFFER, Watobo::Gui::Icons::ICON_FOLDER, Watobo::Gui::Icons::ICON_FOLDER_SMALL, Watobo::Gui::Icons::ICON_FUZZER, Watobo::Gui::Icons::ICON_FUZZER_MEDIUM, Watobo::Gui::Icons::ICON_FUZZER_SMALL, Watobo::Gui::Icons::ICON_FUZZ_FILTER, Watobo::Gui::Icons::ICON_FUZZ_GENERATOR, Watobo::Gui::Icons::ICON_FUZZ_TAG, Watobo::Gui::Icons::ICON_HINTS, Watobo::Gui::Icons::ICON_HINTS_INFO, Watobo::Gui::Icons::ICON_HINTS_INFO_SMALL, Watobo::Gui::Icons::ICON_HINTS_SMALL, Watobo::Gui::Icons::ICON_INFO, Watobo::Gui::Icons::ICON_INFO_INFO, Watobo::Gui::Icons::ICON_INFO_INFO_SMALL, Watobo::Gui::Icons::ICON_INFO_SMALL, Watobo::Gui::Icons::ICON_INFO_USER, Watobo::Gui::Icons::ICON_INFO_USER_SMALL, Watobo::Gui::Icons::ICON_INTERCEPTOR, Watobo::Gui::Icons::ICON_LOGIN_WIZZARD, Watobo::Gui::Icons::ICON_MANUAL_REQUEST, Watobo::Gui::Icons::ICON_MANUAL_REQUEST_MEDIUM, Watobo::Gui::Icons::ICON_MANUAL_REQUEST_SMALL, Watobo::Gui::Icons::ICON_PAUSE, Watobo::Gui::Icons::ICON_PLUGIN, Watobo::Gui::Icons::ICON_PROJECT, Watobo::Gui::Icons::ICON_PROJECT_SMALL, Watobo::Gui::Icons::ICON_REPORT, Watobo::Gui::Icons::ICON_REQUEST, Watobo::Gui::Icons::ICON_REQUEST_SMALL, Watobo::Gui::Icons::ICON_SEND_REQUEST, Watobo::Gui::Icons::ICON_SITE, Watobo::Gui::Icons::ICON_SITE_SMALL, Watobo::Gui::Icons::ICON_START, Watobo::Gui::Icons::ICON_STOP, Watobo::Gui::Icons::ICON_TOKEN, Watobo::Gui::Icons::ICON_TRANSCODER, Watobo::Gui::Icons::ICON_VULN, Watobo::Gui::Icons::ICON_VULN_BP, Watobo::Gui::Icons::ICON_VULN_BP_SMALL, Watobo::Gui::Icons::ICON_VULN_CRITICAL, Watobo::Gui::Icons::ICON_VULN_CRITICAL_SMALL, Watobo::Gui::Icons::ICON_VULN_HIGH, Watobo::Gui::Icons::ICON_VULN_HIGH_SMALL, Watobo::Gui::Icons::ICON_VULN_LOW, Watobo::Gui::Icons::ICON_VULN_LOW_SMALL, Watobo::Gui::Icons::ICON_VULN_MEDIUM, Watobo::Gui::Icons::ICON_VULN_MEDIUM_SMALL, Watobo::Gui::Icons::ICON_VULN_SMALL, Watobo::Gui::Icons::ICON_WATOBO, Watobo::Gui::Icons::SIBERAS_ICON, Watobo::Gui::Icons::TBL_ICON_LOCK, Watobo::Gui::Icons::WATOBO_LOGO

Constants included from Interceptor

Interceptor::INTERCEPT_BOTH, Interceptor::INTERCEPT_DEFAULT_PORT, Interceptor::INTERCEPT_NONE, Interceptor::INTERCEPT_REQUEST, Interceptor::INTERCEPT_RESPONSE, Interceptor::MODE_REGULAR, Interceptor::MODE_TRANSPARENT, Interceptor::REWRITE_BOTH, Interceptor::REWRITE_NONE, Interceptor::REWRITE_REQUEST, Interceptor::REWRITE_RESPONSE

Instance Method Summary collapse

Constructor Details

#initialize(owner, opts) ⇒ InterceptorUI

Returns a new instance of InterceptorUI.


487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/watobo/gui/interceptor_gui.rb', line 487

def initialize(owner, opts)
  # Invoke base class initialize function first

  super( owner, 'Interceptor', nil, nil, DECOR_ALL|DECOR_TITLE|DECOR_BORDER|DECOR_RESIZE, 0, 0, 600, 400, 0, 0, 0, 0, 0, 0)
  self.connect(SEL_CLOSE, method(:onClose))
  self.icon = ICON_INTERCEPTOR
  #@interceptor = interceptor

  @request_list = []
  @response_list = []

  @request_queue = []
  @response_queue = []

  @request_lock = Mutex.new
  @response_lock = Mutex.new

  # initial frame setup
  mr_splitter = FXSplitter.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_VERTICAL|SPLITTER_REVERSED|SPLITTER_TRACKING)

  top_frame = FXVerticalFrame.new(mr_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y||LAYOUT_FIX_HEIGHT|LAYOUT_BOTTOM,:height => 500)
  top_splitter = FXSplitter.new(top_frame, LAYOUT_FILL_X|SPLITTER_HORIZONTAL|LAYOUT_FILL_Y|SPLITTER_TRACKING)

  #log_frame = FXVerticalFrame.new(mr_splitter, :opts => LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM,:height => 100)

  filter_frame = FXVerticalFrame.new(top_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y||LAYOUT_FIX_HEIGHT|LAYOUT_BOTTOM)
   gbframe = FXGroupBox.new(filter_frame, "Intercept", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(gbframe, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
#  FXLabel.new(filter_frame, "Intercept:" )
  @intercept_request = FXCheckButton.new(frame, "Requests", nil, 0,
  ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @intercept_request.connect(SEL_COMMAND, method(:onInterceptChanged))

  @intercept_response = FXCheckButton.new(frame, "Response", nil, 0,
  ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @intercept_response.connect(SEL_COMMAND, method(:onInterceptChanged))
  @filter_options_btn = FXButton.new(frame, "Options", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
  @filter_options_btn.connect(SEL_COMMAND, method(:onBtnFilterOptions))
  
  gbframe = FXGroupBox.new(filter_frame, "Rewrite", LAYOUT_SIDE_RIGHT|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(gbframe, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
  #FXLabel.new(filter_frame, "Rewrite:" )
  @rewrite_request = FXCheckButton.new(frame, "Requests", nil, 0,
  ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @rewrite_request.connect(SEL_COMMAND, method(:onInterceptChanged))

  @rewrite_response = FXCheckButton.new(frame, "Response", nil, 0,
  ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
  @rewrite_response.connect(SEL_COMMAND, method(:onInterceptChanged))

 @rewrite_options_btn = FXButton.new(frame, "Options", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
  @rewrite_options_btn.connect(SEL_COMMAND){ open_rewrite_options_dialog }
 
  #@intercept_request.checkState = false
  #@intercept_response.checkState = false
  if Watobo::Interceptor.active?

    @intercept_request.checkState = Watobo::Interceptor.intercept_requests?
    @intercept_response.checkState = Watobo::Interceptor.intercept_requests?
  end

  view_frame = FXVerticalFrame.new(top_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y||LAYOUT_FIX_HEIGHT|LAYOUT_BOTTOM)

  @tabBook = FXTabBook.new(view_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)

  button_frame = FXHorizontalFrame.new(view_frame, LAYOUT_FILL_X)
  @tabBook.connect(SEL_COMMAND) { |sender, sel, item|
    case item
    when 0
      enable_buttons if @request_list.length > 0
    when 1
      enable_buttons if @response_list.length > 0
    end

  }
  @request_tab = FXTabItem.new(@tabBook, "Request (0)", nil)
  request_frame_outer = FXVerticalFrame.new(@tabBook, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
  # request_frame = FXVerticalFrame.new(request_frame_outer, LAYOUT_FILL_X|LAYOUT_FILL_Y)

  @requestbox = Watobo::Gui::InterceptEditor.new(request_frame_outer, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  

  @response_tab = FXTabItem.new(@tabBook, "Response (0)", nil)
  response_frame_outer = FXVerticalFrame.new(@tabBook, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
  #response_frame = FXVerticalFrame.new(response_frame_outer, LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding=>0)
  # @responsebox = Watobo::Gui::RequestEditor.new(response_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y )
  @responsebox = Watobo::Gui::InterceptEditor.new(response_frame_outer, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  # @responsebox.editable = true

  @accept_button = FXButton.new(button_frame, "Accept", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
  @accept_button.connect(SEL_COMMAND, method(:onAcceptChanges))

  @discard_button = FXButton.new(button_frame, "Discard", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
  @discard_button.connect(SEL_COMMAND, method(:onDiscard))

  @drop_button = FXButton.new(button_frame, "Drop", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
  @drop_button.connect(SEL_COMMAND, method(:onDrop))

  #  log_text_frame = FXVerticalFrame.new(log_frame, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding=>0)
  #  @log_viewer = FXText.new(log_text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)

  disable_buttons()

  # start an update timer
  @update_timer = FXApp.instance.addTimeout( 50, :repeat => true) {
    @request_lock.synchronize do
      unless @request_queue.empty?
        @request_list.concat @request_queue
        @request_queue.clear
        @request_tab.text = "Request (#{@request_list.length})"
      end

      if @request_list.length > 0 and @requestbox.empty?
        @requestbox.setText @request_list.first[:request]
      end

    end
    @response_lock.synchronize do
      unless @response_queue.empty?
        @response_list.concat @response_queue
        @response_queue.clear
        @response_tab.text = "Response (#{@response_list.length})"
      end

      if @response_list.length > 0 and @responsebox.empty?
        @responsebox.setText @response_list.first[:response]
      end

    end
    update_buttons
  }

end

Instance Method Details

#addRequest(request, thread) ⇒ Object


450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/watobo/gui/interceptor_gui.rb', line 450

def addRequest(request, thread)
  puts "* [Interceptor] addRequest"

  new_request = {
    :request => request,
    :thread => thread
  }

  @request_lock.synchronize do
  #   enable_buttons()
    @request_queue << new_request

  end

# enable_buttons()

end

#addResponse(response, thread) ⇒ Object


468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/watobo/gui/interceptor_gui.rb', line 468

def addResponse(response, thread)
  response.extend Watobo::Mixin::Parser::Web10
  response.extend Watobo::Mixin::Shaper::Web10

  response.fixupContentLength()

  #  puts response

  new_response = {
    :response => response,
    :thread => thread
  }

  @response_lock.synchronize do
    @response_queue.push new_response

  end
end

#executeObject


434
435
436
437
438
# File 'lib/watobo/gui/interceptor_gui.rb', line 434

def execute
  create
  show(PLACEMENT_SCREEN)
# getApp().runModalFor(self)
end

#modifyRequest(request, thread) ⇒ Object

this method is obsolet! Use addRequest() instead


441
442
443
# File 'lib/watobo/gui/interceptor_gui.rb', line 441

def modifyRequest(request, thread)
  addRequest(request, thread)
end

#modifyResponse(request, thread) ⇒ Object

this method is obsolet! Use addResponse() instead


446
447
448
# File 'lib/watobo/gui/interceptor_gui.rb', line 446

def modifyResponse(request, thread)
  addResponse(request, thread)
end

#releaseAllObject


621
622
623
624
625
626
627
628
629
630
631
632
633
634
# File 'lib/watobo/gui/interceptor_gui.rb', line 621

def releaseAll()
  #  puts "* closing interceptor"
  #  puts "* disable all interceptions"
  #@project.intercept_request = false
  #@project.intercept_response = false
  #  puts "* release all interceptions ..."
  @request_list.each do |ir|
    ir[:thread].run
  end
  @response_list.each do |ir|
    ir[:thread].run
  end

end