Class: Watobo::Plugin::Catalog::Catalog

Inherits:
Template::Plugin show all
Defined in:
plugins/catalog/catalog.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::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

Constants included from Gui::Icons

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

Constants included from Gui

Gui::DIFF_TYPE_NEW, Gui::DIFF_TYPE_ORIG, Gui::SEL_TYPE_GREP, Gui::SEL_TYPE_HIGHLIGHT, Gui::TABLE_COL_COMMENT, Gui::TABLE_COL_COOKIE, Gui::TABLE_COL_HOST, Gui::TABLE_COL_METHOD, Gui::TABLE_COL_PARMS, Gui::TABLE_COL_PATH, Gui::TABLE_COL_SSL, Gui::TABLE_COL_STATUS

Constants included from Diff::LCS

Diff::LCS::BalancedCallbacks, Diff::LCS::PATCH_MAP, Diff::LCS::SequenceCallbacks, Diff::LCS::VERSION

Instance Attribute Summary

Attributes inherited from Template::Plugin

#icon, #plugin_name

Instance Method Summary collapse

Methods inherited from Template::Plugin

#clearEvents, #load_icon, #notify, #subscribe

Methods included from Diff::LCS

LCS, __diff_direction, __inverse_vector, __lcs, __normalize_patchset, __position_hash, __replace_next_larger, #diff, diff, #lcs, patch, #patch, #patch!, patch!, #sdiff, sdiff, #traverse_balanced, traverse_balanced, #traverse_sequences, traverse_sequences, #unpatch, unpatch!, #unpatch!

Constructor Details

#initialize(owner, project) ⇒ Catalog

Returns a new instance of Catalog.


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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'plugins/catalog/catalog.rb', line 286

def initialize(owner, project)
  
  super(owner, "Catalog Scanner", project, :opts => DECOR_ALL, :width=>800, :height=>600)
  menu_bar = FXMenuBar.new(self, :opts => LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_GROOVE)
  menu_pane = FXMenuPane.new(self)
  
  text = "Catalog-Scanner will test the web application for known directories and/or files.\nYou need two files (db_tests and db_variables) in the DB folder. "
  text << "These files must have the same format as nikto DB files (http://cirt.net/nikto2).\nSo, if you have your own DB files, you"
  text << " can use them with this plugin."
    
load_icon(__FILE__)
       
FXMenuTitle.new(menu_bar, "Help" , :popupMenu => menu_pane)
menu = FXMenuCommand.new(menu_pane, "About" )
menu.connect(SEL_COMMAND) { 
  dlg = Watobo::Plugin::Catalog::About.new(self, text)
  dlg.execute
  }

  @event_dispatcher_listeners = Hash.new
  @scanner = nil
  @plugin_name = "Catalog-Scan"
 
  @site = nil
  @dir = nil

  begin
    hs_green = FXHiliteStyle.new
    hs_green.normalForeColor = FXRGBA(255,255,255,255) #FXColor::Red
    hs_green.normalBackColor = FXRGBA(0,255,0,1)   # FXColor::White
    hs_green.style = FXText::STYLE_BOLD

    hs_red = FXHiliteStyle.new
    hs_red.normalForeColor = FXRGBA(255,255,255,255) # FXColor::Red
    hs_red.normalBackColor = FXRGBA(255,0,0,1)   # FXColor::White
    hs_red.style = FXText::STYLE_BOLD

    path = Dir.getwd

    mr_splitter = FXSplitter.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y|SPLITTER_VERTICAL|SPLITTER_REVERSED|SPLITTER_TRACKING)
    # top = FXHorizontalFrame.new(mr_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_SIDE_BOTTOM)
    top_frame = FXVerticalFrame.new(mr_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_FIX_HEIGHT|LAYOUT_BOTTOM, :height => 500)
  #   info_frame = FXGroupBox.new(top_frame, "Info", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
 #   info = FXText.new(info_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP)
 #   info.setText text
 #   info.backColor = info.parent.backColor
 #   info.disable
    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)

    @settings_frame = FXVerticalFrame.new(top_splitter, :opts => LAYOUT_FILL_Y, :padding => 0)
    #request_frame = FXVerticalFrame.new(top_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
      request_frame = FXGroupBox.new(top_splitter, "Request Template", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
      FXLabel.new(request_frame, "Select a request template from drop-down list or enter manually.")
    @requestCombo = FXComboBox.new(request_frame, 5, nil, 0,
    COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

    @requestCombo.numVisible = 0
    @requestCombo.numColumns = 50
    @requestCombo.editable = false
    @requestCombo.connect(SEL_COMMAND, method(:onSelectRequest))

    @request_editor = RequestEditor.new(request_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding=>0)

    ts_frame = FXGroupBox.new(@settings_frame, "Scan Settings", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)

   # @scope_only_cb = FXCheckButton.new(@settings_frame, "target scope only", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
   # @scope_only_cb.setCheck(false)
   # @scope_only_cb.connect(SEL_COMMAND) { updateView() }

    @sites_combo = FXComboBox.new(ts_frame, 5, nil, 0,
    COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

    @sites_combo.numVisible = @sites_combo.numItems >= 20 ? 20 : @sites_combo.numItems
    @sites_combo.numColumns = 35
    @sites_combo.editable = false
    @sites_combo.connect(SEL_COMMAND, method(:onSiteSelect))

    FXLabel.new(ts_frame, "Root Directory:")
    @dir_combo = FXComboBox.new(ts_frame, 5, nil, 0,
    COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
    @dir_combo.numVisible = 20
    @dir_combo.numColumns = 35
    @dir_combo.editable = false
    @dir_combo.connect(SEL_COMMAND, method(:onDirSelect))

    @test_all_dirs = FXCheckButton.new(ts_frame, "test all sub-directories", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
    @test_all_dirs.setCheck(false)

    # @use_ssl = FXCheckButton.new(@settings_frame, "use SSL", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)

    #   @run_passive_checks = FXCheckButton.new(@settings_frame, "run passive checks", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
    #   @run_passive_checks.setCheck(false)

    frame = FXGroupBox.new(@settings_frame, "Logging", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
    @logScanChats = FXCheckButton.new(frame, "enable", nil, 0, JUSTIFY_LEFT|JUSTIFY_TOP|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP)
    @logScanChats.checkState = false

    @logScanChats.connect(SEL_COMMAND) do |sender, sel, item|
      if @logScanChats.checked? then
        @scanlog_dir_text.enabled = true
        @scanlog_dir_text.backColor = FXColor::White
      else
        @scanlog_dir_text.enabled = false
        @scanlog_dir_text.backColor = @scanlog_dir_text.parent.backColor 
      end
    end

    @scanlog_dir_dt = FXDataTarget.new('')
   # @scanlog_dir_dt.value = @project.scanLogDirectory() if File.exist?(@project.scanLogDirectory())
    @scanlog_dir_label = FXLabel.new(frame, "Scan Name:" )
    scanlog_frame = FXHorizontalFrame.new(frame,:opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP)
    @scanlog_dir_text = FXTextField.new(scanlog_frame, 20,
    :target => @scanlog_dir_dt, :selector => FXDataTarget::ID_VALUE,
    :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_FILL_X)
    @scanlog_dir_text.handle(self, FXSEL(SEL_UPDATE, 0), nil)
    unless @logScanChats.checked?
      @scanlog_dir_text.enabled = false
      @scanlog_dir_text.backColor = @scanlog_dir_text.parent.backColor
    end 
 
  @db_files = %w( db_tests db_variables )
  
  @path = File.expand_path(File.dirname(__FILE__))
  
  
  @known_db_paths = [                             
                  #   File.expand_path(File.dirname(__FILE__)), 
                    # "/pentest/web/nikto/plugins" # BackTrack
                    @path
                     ]
  config = load_config
  unless config.nil?
    if config.has_key? :path_history
      begin
      config[:path_history].each do |p|
        @known_db_paths << p unless @known_db_paths.include? p
      end
      rescue => bang
        puts "!Broken Path History"                
      end
    end
      @path = config[:db_path] if config.has_key? :db_path              
    
  end                   
 
   frame = FXGroupBox.new(@settings_frame, "DB Path", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X, 0, 0, 0, 0)
    #FXLabel.new(frame, "Path:" )
    db_frame = FXHorizontalFrame.new(frame,:opts => LAYOUT_FILL_X|LAYOUT_SIDE_TOP)
     @db_path_combo = FXComboBox.new(db_frame, 5, nil, 0,
    COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
    
    @db_path_combo.numVisible = 3
    @db_path_combo.numColumns = 8
    
    @db_path_combo.editable = false
    @db_path_combo.connect(SEL_COMMAND){
      path = @db_path_combo.getItemData(@db_path_combo.currentItem)
      set_db_path path
    }
   # @db_path_txt = FXTextField.new(db_frame, 20, nil, 0, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_FILL_X)
   # @db_path_txt.text = @path
   # @db_path_txt.handle(self, FXSEL(SEL_UPDATE, 0), nil)
    @db_path_btn = FXButton.new(db_frame, "add")
    @db_path_btn.connect(SEL_COMMAND){ 
      select_db_path
      # @db_path_txt.text = @path              
       }
    #@check_buttons = Hash.new
    
     
     path_index = 0
     @known_db_paths.each_with_index do |dbp,i|              
       if File.exist? dbp               
           item = @db_path_combo.appendItem(dbp)
           @db_path_combo.setItemData(item, dbp)
           path_index = i if dbp == @path
       end
     end
     
     @db_path_combo.currentItem = path_index if @db_path_combo.numItems > 0
     
    @pbar = FXProgressBar.new(@settings_frame, nil, 0, LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK|PROGRESSBAR_HORIZONTAL)
    
    reset_pbar
   
    @speed = FXLabel.new(@settings_frame, "Requests per second: 0")

    @start_button = FXButton.new(@settings_frame, "start")
    @start_button.connect(SEL_COMMAND, method(:start))
    @start_button.disable

#    gbox = FXGroupBox.new(@settings_frame, "Info", LAYOUT_SIDE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 150)
#    gbframe = FXVerticalFrame.new(gbox, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
#    fxtext = FXText.new(gbframe, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP)
#    fxtext.backColor = fxtext.parent.backColor
#    fxtext.disable
#    text = "Catalog-Scanner will test the web application for known directories and/or files. There must be two files in the appropriate plugin folder:\n"
#    text << "- db_tests\n- db_variables\n\nThe format of these files is very similar to the format nikto (http://cirt.net/nikto2) is using. So if you have your own nikto.db-files, you"
#    text << " can use them with this plugin."
#    text << "\n\nCatalog Directory:\n#{File.dirname(__FILE__)}"
#    fxtext.setText(text)

    @check = nil

    log_frame_header = FXHorizontalFrame.new(log_frame, :opts => LAYOUT_FILL_X)
    FXLabel.new(log_frame_header, "Logs:" )

    #log_text_frame = FXHorizontalFrame.new(bottom_frame, :opts => LAYOUT_FILL_X|FRAME_SUNKEN|LAYOUT_BOTTOM)
    log_text_frame = FXVerticalFrame.new(log_frame, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding=>0)
    @log_viewer = LogViewer.new(log_text_frame, nil, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
       
    updateView()
    start_update_timer()
    
  rescue => bang
    puts bang
    puts bang.backtrace if $DEBUG
  end
end

Instance Method Details

#createObject


507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'plugins/catalog/catalog.rb', line 507

def create
  super                  # Create the windows
  @log_viewer.purge_logs
  @request_editor.setText('')
  @requestCombo.clearItems()

  @start_button.text = "Start"

  show(PLACEMENT_SCREEN) # Make the main window appear
  disableOptions()
  @start_button.disable
  
  updateView()
end

#updateViewObject


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
# File 'plugins/catalog/catalog.rb', line 245

def updateView()
  @sites_combo.clearItems()
  @dir_combo.clearItems()
  @dir_combo.disable

  
    @sites_combo.appendItem("no site selected", nil)
    scope_only = Watobo::Scope.exist?
    sites = Watobo::Chats.sites(:in_scope => Watobo::Scope.exist? )
    if sites.empty?
      scope_only = false
      @log_viewer.log(LOG_INFO, "Defined scope does not match one site. Using all sites.")
    end
    Watobo::Chats.sites(:in_scope => scope_only ).each do |site|
      site_string = site
      if site.length > 60
        site_string = site.slice(0..55)
        site_string << "...:"
        site_string << site.gsub(/.*:/,'')
      end
      @sites_combo.appendItem(site_string, site)
    end
    @sites_combo.numVisible = @sites_combo.numItems >= 20 ? 20 : @sites_combo.numItems
    @sites_combo.setCurrentItem(0) if @sites_combo.numItems > 0
    ci = @sites_combo.currentItem
    site = ( ci >= 0 ) ? @sites_combo.getItemData(ci) : nil
    puts site
    puts site.class

    unless site.nil?
      @dir_combo.enable
      Watobo::Chats.dirs(site) do |dir|
        puts dir
        @dir_combo.appendItem(dir.slice(0..35), dir)
      end
      @dir_combo.setCurrentItem(0, true) if @dir_combo.numItems > 0

    end
  
end