Class: Watobo::Gui::InterceptEditor

Inherits:
FXVerticalFrame
  • Object
show all
Includes:
Utils
Defined in:
lib/watobo/gui/interceptor_gui.rb

Constant Summary

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

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

Methods included from Utils

#addDecoder, #addEncoder, #addStringInfo, #cleanupHTTP, load_plugins, #removeTags, #replace_text

Constructor Details

#initialize(owner, opts) ⇒ InterceptEditor

Returns a new instance of InterceptEditor.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/watobo/gui/interceptor_gui.rb', line 31

def initialize(owner, opts)

  super(owner, opts)

  @lock = Mutex.new
  @text = nil

  @event_dispatcher_listeners = Hash.new

  text_view_header = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_SIDE_BOTTOM|LAYOUT_FIX_HEIGHT, :height => 24, :padding => 0)

  #@auto_apply_cbtn.connect(SEL_COMMAND, method(:onInterceptChanged))

  @pmatch_btn = FXButton.new(text_view_header, "<", nil, nil, 0, FRAME_RAISED|LAYOUT_FILL_Y)
  @pmatch_btn.disable

  @pmatch_btn.connect(SEL_COMMAND) {
    if @textbox.numMatches > 0
      @match_pos_label.textColor = 'black'
      pos = @textbox.showPrevMatch() + 1
      @match_pos_label.text = "#{pos}/#{@textbox.numMatches}"
    else
      @match_pos_label.textColor = 'grey'
    end
  }

  @match_pos_label = FXLabel.new(text_view_header, "0/0", :opts => LAYOUT_FILL_Y)
  @match_pos_label.textColor = 'grey'

  @nmatch_btn = FXButton.new(text_view_header, ">", nil, nil, 0, FRAME_RAISED|LAYOUT_FILL_Y)
  @nmatch_btn.disable

  @nmatch_btn.connect(SEL_COMMAND) {

    @textbox.showNextMatch()
    if @textbox.numMatches > 0
      @match_pos_label.textColor = 'black'
      pos = @textbox.showNextMatch() + 1
      @match_pos_label.text = "#{pos}/#{@textbox.numMatches}"
    else
      @match_pos_label.textColor = 'grey'
    end
  }

  @filter_dt = FXDataTarget.new('')
  # @filter_text = FXTextField.new(text_view_header, 10,
  # :target => @filter_dt, :selector => FXDataTarget::ID_VALUE,
  # :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y)

  @filter_text = FXComboBox.new(text_view_header, 20, @filter_dt, 0, FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
  @filter_text.connect(SEL_COMMAND){
    applyFilter()
    addFilterHistory()
  }

  @filter_text.connect(SEL_CHANGED) {
    applyFilter()
  }
  inputFieldHotkeyHandler(@filter_text)

  @auto_select_cbtn = FXCheckButton.new(text_view_header, "auto-select", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP|LAYOUT_RIGHT|LAYOUT_FILL_Y)
  #@mode_btn = FXButton.new(text_view_header, "Highlight", :opts=> MENUBUTTON_DOWN|FRAME_RAISED|FRAME_THICK|ICON_AFTER_TEXT|LAYOUT_RIGHT|LAYOUT_FILL_Y)

  reset_button = FXButton.new(text_view_header, "&Reset", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_Y)
  reset_button.connect(SEL_COMMAND){ resetTextbox() }

  #-----------------------
  text_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding=>0)

  @textbox_dt = FXDataTarget.new('')

  @textbox = Watobo::Gui::TextView2.new(text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  #  @textbox = Watobo::Gui::TextView2.new(text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  # @textbox = FXText.new(text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  # @textbox = FXText.new(text_frame, :target => @textbox_dt, :selector => FXDataTarget::ID_VALUE, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @textbox.textStyle -= TEXT_WORDWRAP
  @textbox.extend Watobo::Mixins::RequestParser

  @textbox.editable = true

  @markers = []

  @record_input = false # EXPERIMENTAL !!!

  @last_cursor_pos = 0
  @start_selection_pos = 0

  @input_start = 0
  @input_len = 0

  @textbox.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, event|
    unless event.moved?
      FXMenuPane.new(self) do |menu_pane|
        addStringInfo(menu_pane, sender)
        addDecoder(menu_pane, sender)
        addEncoder(menu_pane, sender)
        FXMenuSeparator.new(menu_pane)
        target = FXMenuCheck.new(menu_pane, "word wrap" )
        target.check = ( @textbox.textStyle & TEXT_WORDWRAP > 0 ) ? true : false
        target.connect(SEL_COMMAND) { |tsender, tsel, titem|
          if tsender.checked?
            @textbox.textStyle |= TEXT_WORDWRAP
          else
          @textbox.textStyle ^= TEXT_WORDWRAP
          end
        }

        menu_pane.create
        menu_pane.popup(nil, event.root_x, event.root_y)
        app.runModalWhileShown(menu_pane)
      end

    end
  end

  # KEY_Return
  # KEY_Control_L
  # KEY_Control_R
  # KEY_s
  @ctrl_pressed = false

  @textbox.connect(SEL_KEYPRESS, method(:initEditKeys))

  @textbox.connect(SEL_KEYRELEASE) do |sender, sel, event|
    @ctrl_pressed = false if event.code == KEY_Control_L or event.code == KEY_Control_R
    false
  end

end

Instance Method Details

#clearObject



173
174
175
# File 'lib/watobo/gui/interceptor_gui.rb', line 173

def clear
  @textbox.setText('')
end

#clearEvents(event) ⇒ Object



165
166
167
# File 'lib/watobo/gui/interceptor_gui.rb', line 165

def clearEvents(event)
  @event_dispatcher_listener[event].clear
end

#empty?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/watobo/gui/interceptor_gui.rb', line 169

def empty?
  @textbox.to_s.empty?
end

#parseRequest(prefs = {}) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/watobo/gui/interceptor_gui.rb', line 197

def parseRequest(prefs={})
  begin
    return @textbox.to_request(prefs)
  rescue SyntaxError, LocalJumpError, NameError
    notify(:error, "#{$!}")
  rescue => bang
    puts bang
    puts bang.backtrace if $DEBUG
    notify(:error, "Could not parse request: #{$!}")
  end

  return nil
end

#setText(text = nil) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/watobo/gui/interceptor_gui.rb', line 177

def setText(text=nil)
  return false if text.nil?
  if text.is_a? Array
  new_text = text.join
  else
    new_text = "#{text}"
  end

  @lock.synchronize do
    @text  = new_text.strip.gsub(/\r/,'')

    unless @text.empty?
    @textbox.setText @text
    end
  end
#  @textbox.handle(self, FXSEL(SEL_UPDATE, 0), nil)
#@textbox.update

end

#subscribe(event, &callback) ⇒ Object



161
162
163
# File 'lib/watobo/gui/interceptor_gui.rb', line 161

def subscribe(event, &callback)
  (@event_dispatcher_listeners[event] ||= []) << callback
end

#to_response(prefs = {}) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/watobo/gui/interceptor_gui.rb', line 211

def to_response(prefs={})
  begin
    return @textbox.to_response(prefs)
  rescue SyntaxError, LocalJumpError, NameError
  #  puts bang
  #  puts bang.backtrace if $DEBUG
    notify(:error, "#{$!}")
  rescue => bang
  puts bang
  notify(:error, "Could not parse request: #{$!}")
  end

  return nil
end