Class: Watobo::Gui::SitesTree

Inherits:
FXTreeList
  • Object
show all
Includes:
Icons
Defined in:
lib/watobo/gui/sites_tree.rb

Constant Summary

Constants included from Icons

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

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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, interface, project) ⇒ SitesTree

Returns a new instance of SitesTree.



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/watobo/gui/sites_tree.rb', line 179

def initialize(parent, interface, project)
  @project = project
  @interface = interface
  @parent = parent
  @quick_filter = Hash.new
  @show_scope_only = false

  super(parent, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|TREELIST_EXTENDEDSELECT)

  @event_dispatcher_listeners = Hash.new

  @projectIcon = ICON_PROJECT

  @folderIcon = ICON_FOLDER
  @reqIcon = ICON_REQUEST
  @siteIcon= ICON_SITE

  @filtered_domains = Hash.new # domains which already have been filtered

  @tree_filters = {
    :response_status => []
  }
  #    session_leaf = self.appendItem(nil, @session_name, @projectIcon, @projectIcon)

  self.connect(SEL_COMMAND) do |sender, sel, item|
    url_parts = []
    #  p = item
    if self.itemLeaf?(item)
    
        begin
          if item.data
            #if item.data.class.to_s =~ /Qchat/
            #@interface.show_chat(item.data)
            notify(:show_chat, item.data)
          #end
          chat = item.data
          #         url_parts.unshift chat.request.file_ext
          #         p = item.parent
          end
        rescue => bang
        #  puts bang
        #  puts bang.backtrace if $DEBUG
        #puts "!!! Error: could not show selected tree item"
        end
      end
    
    #elsif item.data == :item_type_folder||:item_type_site then
    
    # if !p.nil?
    #   while p.parent
    #    url_parts.unshift p.text.sub(/^\//,'')
    #    p = p.parent
    #  end
    #end
    #   url_parts.unshift p
    #   filter = url_parts.join("/")
    #   puts @quick_filter.keys.join("\n")
    #   puts "===="
    #   puts item
    #   puts "===="
      getApp().beginWaitCursor do
      notify(:show_conversation, @quick_filter[item.object_id]) if @quick_filter[item.object_id]
  #  notify(:apply_site_filter, filter)
    end
  end

  self.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, event|
    exclude_site = nil
    unless event.moved?
      FXMenuPane.new(self) do |menu_pane|

        target = FXMenuCheck.new(menu_pane, "show scope only" )
        target.check = @show_scope_only

        target.connect(SEL_COMMAND) { |tsender, tsel, titem|
          @show_scope_only = tsender.checked?
          reload() if @project
        }

        exclude_submenu = FXMenuPane.new(self) do |sub|
          ["404", "302"].each do |rc|
            target = FXMenuCheck.new(sub, "#{rc} Status" )

            target.check = @tree_filters[:response_status].include? rc

            target.connect(SEL_COMMAND) { |tsender, tsel, titem|
              
              rs = tsender.to_s.slice(/\d+/)
              unless @tree_filters[:response_status].include? rs
                @tree_filters[:response_status].push rs
              else
                @tree_filters[:response_status].delete rs
              end
              reload() if @project
            }
          end
        end
        FXMenuCascade.new(menu_pane, "Hide", nil, exclude_submenu)

        item = sender.getItemAt(event.win_x, event.win_y)

        unless item.nil?

          unless self.itemLeaf?(item)
            FXMenuSeparator.new(menu_pane)
            FXMenuCommand.new(menu_pane, "expand tree" ).connect(SEL_COMMAND) {
              expandFullTree(item)
            }

            FXMenuCommand.new(menu_pane, "collapse tree" ).connect(SEL_COMMAND) {
              self.collapseFullTree(item)
            }

          end

          data = self.getItemData(item)

          if data == :item_type_site then
            FXMenuSeparator.new(menu_pane)

            FXMenuCommand.new(menu_pane, "add site to scope" ).connect(SEL_COMMAND) {

              notify(:add_site_to_scope, item.to_s)
            }

          elsif data.is_a? Watobo::Chat

            FXMenuSeparator.new(menu_pane)
            doManual = FXMenuCommand.new(menu_pane, "Manual Request.." )

            doManual.connect(SEL_COMMAND) {
              if item.data
              @interface.open_manual_request_editor(item.data)
              end

            }
          end
        # submenu = FXMenuPane.new(self) do |domain_menu|

        #   @filtered_domains.each do |domain, filter|
        #     hide_domain = FXMenuCommand.new(domain_menu, "#{domain}" )
        #     hide_domain.connect(SEL_COMMAND) {
        #       @interface.default_settings[:domain_filters].delete(filter)
        #       @filtered_domains.clear
        #       @interface.updateTreeLists
        #     }
        #   end
        # end
        # FXMenuCascade.new(menu_pane, "Unhide Domains", nil, submenu)

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

      end
    end
  end
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



28
29
30
# File 'lib/watobo/gui/sites_tree.rb', line 28

def project
  @project
end

Instance Method Details

#addChat(chat) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/watobo/gui/sites_tree.rb', line 102

def addChat(chat)
  if @show_scope_only == true
     return false unless @project.siteInScope?(chat.request.site)
  end 
  @tree_filters[:response_status].each do |rf|
  #puts "#{chat.response.status} / #{rf}"
    return false if chat.response.status =~ /#{rf}/
  end
  addChatItem(chat)
end

#addChatItem(chat) ⇒ Object

end



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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/watobo/gui/sites_tree.rb', line 114

def addChatItem(chat)

  site = self.findItem(chat.request.site, nil, SEARCH_FORWARD|SEARCH_IGNORECASE)

  if not site then
    # found new site
    site = self.appendItem(nil, chat.request.site, @siteIcon, @siteIcon)
    #site = @findings_tree.moveItem(project.first,project,site)
    self.setItemData(site, :item_type_site)

  end

  @quick_filter[site.object_id] ||= []
  @quick_filter[site.object_id].push chat

  folder_parent = site
  #puts "ADD_REQUEST: #{chat.request.first}"
  dir = chat.request.dir

  if dir != "" then
    #puts "Check Folder: #{chat.request.path} - #{chat.request.site}" if path =~ /jump/
    folders = dir.split('/')
    folders.each do |folder_name|
    #   puts "search for folder #{folder_name}"
      folder_item = nil
      folder_parent.each do |c|
        folder_item = c if c.to_s == folder_name
      end
      #folder_item = self.findItem(folder_name, folder_parent, SEARCH_FORWARD|SEARCH_WRAP)
      if folder_item.nil? then
        #folder_item = self.appendItem(folder_parent, folder_name, @folderIcon, @folderIcon)
        folder_item = self.insertItem(folder_parent.first, folder_parent, folder_name, @folderIcon, @folderIcon)
        self.setItemData(folder_item, :item_type_folder)

      #     puts "added folder #{folder_name} to #{folder_parent} for site #{chat.request.site}"
      end
      @quick_filter[folder_item.object_id] ||= []
      @quick_filter[folder_item.object_id].push chat
      folder_parent = folder_item
    end
  end
  ml = 25
  fext = chat.request.file_ext
  element = "/" + fext.slice(0, ml)
  element += "..." if fext.length > ml

  item = nil
  folder_parent.each do |c|
    item = c if c.to_s == element
  end

  if item.nil?
  # puts item.text.methods.sort

  # puts "added file #{element} to #{folder_parent} for site #{chat.request.site}" if chat.request.url =~ /series60/i
  new_item = self.appendItem(folder_parent, element, @reqIcon, @reqIcon)
  #   self.textColor = FXColor::Red
  self.setItemData(new_item, chat)
  @quick_filter[new_item.object_id] ||= []
  #puts new_item.class
  @quick_filter[new_item.object_id].push chat
  end

end

#collapseFullTree(item) ⇒ Object



84
85
86
87
88
89
# File 'lib/watobo/gui/sites_tree.rb', line 84

def collapseFullTree(item)
  self.collapseTree(item)
  item.each do |c|
    collapseFullTree(c) if !self.itemLeaf?(c)
  end
end

#expandFullTree(item) ⇒ Object



56
57
58
59
60
61
# File 'lib/watobo/gui/sites_tree.rb', line 56

def expandFullTree(item)
  self.expandTree(item)
  item.each do |c|
    expandFullTree(c) if !self.itemLeaf?(c)
  end
end

#hidden?(chat) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
95
# File 'lib/watobo/gui/sites_tree.rb', line 91

def hidden?(chat)

  #TODO: Filter
  false
end

#hideDomain(domain_filter) ⇒ Object



97
98
99
100
# File 'lib/watobo/gui/sites_tree.rb', line 97

def hideDomain(domain_filter)
  # @interface.default_settings[:domain_filters].push domain_filter
  # @interface.updateTreeLists()
end

#refresh_treeObject



46
47
48
49
50
51
52
53
54
# File 'lib/watobo/gui/sites_tree.rb', line 46

def refresh_tree()
  self.clearItems

  Watobo::Chats.each do |chat|
    addChat(chat)
  end

# @interface.updateRequestTable(@project)
end

#reloadObject



36
37
38
39
40
41
42
43
44
# File 'lib/watobo/gui/sites_tree.rb', line 36

def reload()
  self.clearItems

  Watobo::Chats.each do |chat|
    addChat(chat)
  end

# @interface.updateRequestTable(@project)
end

#subscribe(event, &callback) ⇒ Object



32
33
34
# File 'lib/watobo/gui/sites_tree.rb', line 32

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

#useRegularIconsObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/watobo/gui/sites_tree.rb', line 73

def useRegularIcons()
  regular_font = FXFont.new(getApp(), "helvetica", GUI_REGULAR_FONT_SIZE)
  regular_font.create
  # Findings Tree Icons
  @folderIcon = ICON_FOLDER
  @reqIcon = ICON_REQUEST
  @siteIcon= ICON_SITE
  self.font = regular_font
  reload()
end

#useSmallIconsObject



63
64
65
66
67
68
69
70
71
# File 'lib/watobo/gui/sites_tree.rb', line 63

def useSmallIcons()
  small_font = FXFont.new(getApp(), "helvetica", GUI_SMALL_FONT_SIZE)
  small_font.create
  @folderIcon = ICON_FOLDER_SMALL
  @reqIcon = ICON_REQUEST_SMALL
  @siteIcon= ICON_SITE_SMALL
  self.font = small_font
  reload()
end