Class: Watobo::Gui::FuzzerTree

Inherits:
FXTreeList
  • Object
show all
Includes:
Icons
Defined in:
lib/watobo/gui/fuzzer_gui.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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, project) ⇒ FuzzerTree

Returns a new instance of FuzzerTree.


1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1389

def initialize(owner, project)
   super(owner, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_RIGHT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|TREELIST_EXTENDEDSELECT)
   #  f = Fuzzer.new("FUZZ")
   @fuzzTags = []
   @project = project
   @filters = []

   setup_listeners()

   refresh()


   self.connect(SEL_COMMAND) do |sender, sel, item|
      if self.itemLeaf?(item)
         getApp().beginWaitCursor do
            begin
               if item.data
                  if item.data.is_a? Finding
                     @interface.show_vuln(item.data)
                  end
               end
            rescue => bang
               puts "!!! Error: could not show selected finding"
               puts bang
            end
         end
      elsif item.data == :title then
         @interface.show_vuln(item.first.data) if item.first.data
      end
   end

   self.connect(SEL_DOUBLECLICKED) do |sender, sel, item|
      if self.itemLeaf?(item)
         begin
            if item.data and item.data.is_a? Symbol then
               case item.data
               when :tags
                  addTag()
               when :filter
                  dlg = Watobo::Gui::CreateFilterDlg.new(self, @project)
                  if dlg.execute != 0 then
                     f = dlg.filter
                     notify(:new_filter, f)
                     @filters.push f
                     refresh()
                  end
               end
            elsif item.data.respond_to? :is_tag?
               dlg = Watobo::Gui::CreateGeneratorDlg.new(self)
               if dlg.execute != 0 then
                  # puts "new generator"
                  fuzzer = item.data
                  gen = dlg.getGenerator(fuzzer)
                  fuzzer.addGenerator(gen)
                  refresh()
               end
            elsif item.data.respond_to? :is_generator?
               gen = item.data
               addAction(gen)

            else
               puts "Unknown Object: #{item.data.class}"
            end

         rescue => bang
            puts "!!! Error: could not show selected finding"
            puts bang
         end
      end
   end

   self.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, event|
      unless event.moved?
         item = sender.getItemAt(event.win_x, event.win_y)

         FXMenuPane.new(self) do |menu_pane|
            data = item ? self.getItemData(item) : nil
            if data.is_a? Symbol
               case data
               when :tags

                  m = FXMenuCommand.new(menu_pane, "Add Tag.." )
                  m.connect(SEL_COMMAND) {
                     addTag()
                  }

               when :filter

                  m = FXMenuCommand.new(menu_pane, "Add Filter.." )
                  m.connect(SEL_COMMAND) {
                     dlg = Watobo::Gui::CreateFilterDlg.new(self, @project)
                     if dlg.execute != 0 then
                        f = dlg.filter
                        notify(:new_filter, f)
                        @filters.push f
                        refresh()
                     end
                  }
               end
            elsif data.respond_to? :is_tag?
               m = FXMenuCommand.new(menu_pane, "Add Generator.." )
               m.connect(SEL_COMMAND) {
                  dlg = Watobo::Gui::CreateGeneratorDlg.new(self)
                  if dlg.execute != 0 then
                     # puts "new generator"
                     fuzzer = data
                     gen = dlg.getGenerator(fuzzer)
                     fuzzer.addGenerator(gen)
                     refresh()
                  end
               }
               m = FXMenuCommand.new(menu_pane, "Remove Tag" )
               m.connect(SEL_COMMAND) {
                  # puts "Removing Tag [#{data.name}]"
                  if @fuzzTags.include?(data)
                     # puts "...found tag"
                     @fuzzTags.delete(data)
                  end
                  notify(:remove_tag, data)
                  refresh()
               }
            elsif data.respond_to? :is_generator?
               m = FXMenuCommand.new(menu_pane, "Add Action.." )
               m.connect(SEL_COMMAND) {
                  gen = self.getItemData(item)
                  addAction(gen)
               }
               m = FXMenuCommand.new(menu_pane, "Remove Generator" )
               m.connect(SEL_COMMAND) {
                  tag = self.getItemData(item.parent)
                  tag.deleteGenerator(data)
                  refresh()
               }
            elsif data.respond_to? :is_action?
               m = FXMenuCommand.new(menu_pane, "Remove Action" )
               m.connect(SEL_COMMAND) {
                  gen = self.getItemData(item.parent)
                  gen.removeAction(data)
                  refresh()
               }
            elsif data.respond_to? :is_filter?
               m = FXMenuCommand.new(menu_pane, "Remove Filter" )
               m.connect(SEL_COMMAND) {
                  @filters.delete(data)
                  notify(:remove_filter, data)
                  refresh()
               }
            else
               puts "Unknown Object: #{data.class}"
            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

#fuzzTagsObject (readonly)

Returns the value of attribute fuzzTags


1251
1252
1253
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1251

def fuzzTags
  @fuzzTags
end

Instance Method Details

#addAction(generator) ⇒ Object


1332
1333
1334
1335
1336
1337
1338
1339
1340
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1332

def addAction(generator)
   dlg = Watobo::Gui::CreateActionDlg.new(self)
   if dlg.execute != 0 then
      puts "new action"
      new_action = dlg.getAction()
      generator.addAction(new_action) if new_action
      refresh()
   end
end

#addFilterItem(filter) ⇒ Object


1272
1273
1274
1275
1276
1277
1278
1279
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1272

def addFilterItem(filter)

   filter_root = self.findItem("Filters", nil, SEARCH_FORWARD|SEARCH_IGNORECASE)

   filter_item = self.appendItem(filter_root, "Filter: #{filter.filter_type}")
   self.setItemData(filter_item, filter)
   self.appendItem(filter_item, filter.info)
end

#addGeneratorItem(tag_item, generator) ⇒ Object


1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1342

def addGeneratorItem(tag_item, generator)
   begin
      item = self.appendItem(tag_item, generator.genType, ICON_FUZZ_GENERATOR, ICON_FUZZ_GENERATOR)
      self.setItemData(item, generator)
      self.appendItem(item, generator.info)

      generator.actions.each do |a|
         action_item = self.appendItem(item, a.action_type, ICON_FUZZER, ICON_FUZZER)
         self.setItemData(action_item, a)
         self.appendItem(action_item, a.info)
      end
      self.expandTree(item)
   rescue => bang
      puts "!ERROR: could not add GeneratorItem"
      puts bang
   end
end

#addTagObject


1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1282

def addTag()
   dlg = Watobo::Gui::CreateFuzzerDlg.new(self)
   if dlg.execute != 0 then
      tag = dlg.tag
      tag_is_valid = true
      @fuzzTags.each do |f|
         tag_is_valid = false if f.name == tag
      end
      if tag_is_valid and tag != ""
         new_fuzz_tag = FuzzerTag.new(tag)
         @fuzzTags.push new_fuzz_tag
         notify(:new_tag, new_fuzz_tag)
         refresh()
      else
         puts "!!! Could not create empty/used tag !!!"
      end
   end
end

#addTagItem(tag) ⇒ Object


1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1301

def addTagItem(tag)

   tag_root = self.findItem("Tags", nil, SEARCH_FORWARD|SEARCH_IGNORECASE)

   item = self.findItem(tag.name, tag_root, SEARCH_FORWARD|SEARCH_IGNORECASE)

   return nil if item
   tag_item = self.appendItem(tag_root, "Tag: #{tag.name}")
   self.setItemData(tag_item, tag)

   #   item = self.appendItem(fuzz_item, "Generator", ICON_VULN, ICON_VULN)
   #  self.setItemData(item, :generator)

   tag.generators.each do |gen|
      addGeneratorItem(tag_item, gen)
   end


end

#expandSettings(item = nil) ⇒ Object


1369
1370
1371
1372
1373
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1369

def expandSettings(item=nil)
   self.each do |root_item|
      expandSubtree(root_item)
   end
end

#expandSubtree(item = nil) ⇒ Object


1360
1361
1362
1363
1364
1365
1366
1367
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1360

def expandSubtree(item=nil)
   if item
      self.expandTree(item)
      item.each do |child|
         expandSubtree(child)
      end
   end
end

#initTreeObject


1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1321

def initTree()
   fuzz_item = self.appendItem(nil, "Tags", ICON_FUZZ_TAG, ICON_FUZZ_TAG)
   self.setItemData(fuzz_item, :tags)

   item = self.appendItem(nil, "Filters", ICON_FUZZ_FILTER, ICON_FUZZ_FILTER)
   self.setItemData(item, :filter)

   #item = self.appendItem(nil, "Collector", ICON_INFO, ICON_INFO)
   #self.setItemData(item, :collector)
end

#notify(event, *args) ⇒ Object


1263
1264
1265
1266
1267
1268
1269
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1263

def notify(event, *args)
   if @event_dispatcher_listeners[event]
      @event_dispatcher_listeners[event].each do |m|
         m.call(*args) if m.respond_to? :call
      end
   end
end

#refreshObject


1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1375

def refresh()
   self.clearItems()
   initTree()
   @fuzzTags.each do |f|
      addTagItem(f)
   end

   @filters.each do |f|
      addFilterItem(f)
   end

   expandSettings()
end

#setup_listenersObject


1254
1255
1256
1257
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1254

def setup_listeners
   @event_dispatcher_listeners = {}

end

#subscribe(event, &callback) ⇒ Object


1259
1260
1261
# File 'lib/watobo/gui/fuzzer_gui.rb', line 1259

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