Module: Watobo::Gui::Utils

Included in:
FuzzerGui, InterceptEditor, ResponseViewer, SelectChatDialog, SessionIdSettings, TokenSettings, TranscoderWindow
Defined in:
lib/watobo/gui/utils/gui_utils.rb,
lib/watobo/gui/utils/load_plugins.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_plugins(project = nil) ⇒ Object

Raises:

  • (ArgumentError)


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
# File 'lib/watobo/gui/utils/load_plugins.rb', line 39

def self.load_plugins(project=nil)
  raise ArgumentError, "Need a project" unless project
  # this is the old plugin style
  Dir["#{Watobo.plugin_path}/*"].each do |sub|
    if File.ftype(sub) == "directory"
      pgf = File.join(sub, "gui.rb")
      if File.exist? pgf
        puts "Loading Plugin GUI #{pgf} ..."

        group = File.basename(sub)
        plugin = File.basename(pgf).sub(/\.rb/,'')
        # load "#{@settings[:module_path]}/#{modules}/#{check}"
        group_class = group.slice(0..0).upcase + group.slice(1..-1).downcase
        #
        plugin_class = plugin.slice(0..0).upcase + plugin.slice(1..-1).downcase
        class_name = "Watobo::Plugin::#{group_class}::#{plugin_class}"
        puts
        puts ">> ClassName: #{class_name}"
        puts
        require pgf
        class_constant = Watobo.class_eval(class_name)

        Watobo::Gui.add_plugin class_constant.new(Watobo::Gui.application, project)
      else

        Dir["#{sub}/#{File.basename(sub)}.rb"].each do |plugin_file|
          begin
            puts "* processing plugin file #{plugin_file}" if $DEBUG
            require plugin_file
            group = File.basename(sub)
            plugin = File.basename(plugin_file).sub(/\.rb/,'')
            # load "#{@settings[:module_path]}/#{modules}/#{check}"
            group_class = group.slice(0..0).upcase + group.slice(1..-1).downcase
            #
            plugin_class = plugin.slice(0..0).upcase + plugin.slice(1..-1).downcase
            class_constant = Watobo.class_eval("Watobo::Plugin::#{group_class}::#{plugin_class}")

            Watobo::Gui.add_plugin class_constant.new(Watobo::Gui.application, project)
          rescue => bang
            puts bang if $DEBUG
            puts bang.backtrace if $DEBUG
          #   notify(:logger, LOG_INFO, "problems loading plugin: #{plugin_file}")
          end
        end

        # this the way loading new plugins

        Dir["#{sub}/gui/#{File.basename(sub)}.rb"].each do |plugin_file|
          begin
            puts "* processing plugin file #{plugin_file}" if $DEBUG
            require plugin_file
            group = File.basename(sub)
            plugin = File.basename(plugin_file).sub(/\.rb/,'')
            # load "#{@settings[:module_path]}/#{modules}/#{check}"
            group_class = group.slice(0..0).upcase + group.slice(1..-1).downcase
            #
            plugin_class = plugin.slice(0..0).upcase + plugin.slice(1..-1).downcase
            class_name = "Watobo::Plugin::#{group_class}::Gui::Main"
            #puts class_name
            class_constant = Watobo.class_eval(class_name)

            Watobo::Gui.add_plugin class_constant.new(Watobo::Gui.application, project)
            
          rescue => bang
            puts bang
            puts bang.backtrace if $DEBUG
          #   notify(:logger, LOG_INFO, "problems loading plugin: #{plugin_file}")
          end
        end
        #

        Watobo::Plugin.constants.each do |pc|
          puts ">> PLUGIN >> #{pc.to_s}"
          
          pclass = Watobo::Plugin.class_eval(pc.to_s)
          
          if pclass.respond_to? :create_gui
            puts "ADD NEW PLUGIN #{pc.upcase}"
            # TODO: In later versions - if all plugins are switched to the new style - this will not be necessary here
            gui = pclass.create_gui()
            # puts gui.class
            Watobo::Gui.add_plugin pclass

          # exit
          end
        end
      end
    end
  end

end

Instance Method Details

#addDecoder(menu_pane, text_box) ⇒ Object



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
# File 'lib/watobo/gui/utils/gui_utils.rb', line 79

def addDecoder(menu_pane, text_box)
  pos = text_box.selStartPos
  len = text_box.selEndPos - pos
  string2decode = text_box.extractText(pos, len)
  string2decode.extend Watobo::Mixin::Transcoders
  FXMenuSeparator.new(menu_pane)
  FXMenuCaption.new(menu_pane,"- Decoder -")
  FXMenuSeparator.new(menu_pane)
  decodeB64 = FXMenuCommand.new(menu_pane,"Base64: #{string2decode.b64decode}")
  decodeB64.connect(SEL_COMMAND) {
    replace_text(text_box, string2decode.b64decode)
  }
  decodeHex = FXMenuCommand.new(menu_pane,"Hex(A): #{string2decode.hexdecode}")
  decodeHex.connect(SEL_COMMAND) {
    replace_text(text_box, string2decode.hexdecode)
  }
  hex2int = FXMenuCommand.new(menu_pane,"Hex(Int): #{string2decode.hex2int}")
  hex2int.connect(SEL_COMMAND) {
    replace_text(text_box, string2decode.hex2int)
  }
  decodeURL = FXMenuCommand.new(menu_pane,"URL: #{string2decode.url_decode}")
  decodeURL.connect(SEL_COMMAND) {
    replace_text(text_box, string2decode.url_decode)
  }

end

#addEncoder(menu_pane, text_box) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/watobo/gui/utils/gui_utils.rb', line 106

def addEncoder(menu_pane, text_box)
  pos = text_box.selStartPos
  len = text_box.selEndPos - pos
  string2encode = text_box.extractText(pos, len)
  string2encode.extend Watobo::Mixin::Transcoders
  FXMenuSeparator.new(menu_pane)
  FXMenuCaption.new(menu_pane,"- Encoder -")
  FXMenuSeparator.new(menu_pane)
  encodeB64 = FXMenuCommand.new(menu_pane,"Base64: #{string2encode.b64encode}")
  encodeB64.connect(SEL_COMMAND) {
    replace_text(text_box, string2encode.b64encode)
  }
  encodeHex = FXMenuCommand.new(menu_pane,"Hex: #{string2encode.hexencode}")
  encodeHex.connect(SEL_COMMAND) {
    replace_text(text_box, string2encode.hexencode)
  }
  encodeURL = FXMenuCommand.new(menu_pane,"URL: #{string2encode.url_encode}")
  encodeURL.connect(SEL_COMMAND) {
    replace_text(text_box, string2encode.url_encode)
  }

end

#addStringInfo(menu_pane, text_box) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/watobo/gui/utils/gui_utils.rb', line 68

def addStringInfo(menu_pane, text_box)
  pos = text_box.selStartPos
  len = text_box.selEndPos - pos
  string = text_box.extractText(pos, len)
  FXMenuSeparator.new(menu_pane)
  FXMenuCaption.new(menu_pane,"- Info -")
  FXMenuSeparator.new(menu_pane)
  FXMenuCaption.new(menu_pane,"Length: #{string.length}")

end

#cleanupHTTP(text) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/watobo/gui/utils/gui_utils.rb', line 42

def cleanupHTTP(text)

  if text.is_a?(Request) or text.is_a?(Response)
    dummy = []
    text.each do |line|
      chunk = line.gsub(/\r/,'').strip
      dummy.push chunk.gsub("\x00","")
    end
    return dummy.join("\n")
  elsif text.is_a? String
    chunk = text.gsub(/\r/,'').strip
    return chunk.gsub("\x00","")
    #return text.gsub(/\r/,"")

  end
  return nil
end

#removeTags(text) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/watobo/gui/utils/gui_utils.rb', line 27

def removeTags(text)
  if text.class.to_s =~ /Array/i then
    dummy = []
    text.each do |line|
      chunk = line.gsub(/<[^>]*>/,'').strip
      dummy.push chunk.gsub("\x00","") if chunk.length > 0
    end
    return dummy.join("\n")
  elsif text.class.to_s =~ /String/i then
    chunk = text.gsub(/<[^<]*>/,'').strip
    return chunk.gsub("\x00","")
    #return text.gsub(/\r/,"")
  end
end

#replace_text(text_box, string) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/watobo/gui/utils/gui_utils.rb', line 60

def replace_text(text_box, string)
  pos = text_box.selStartPos
  len = text_box.selEndPos - pos
  text_box.removeText(pos,len)
  text_box.insertText(pos, string)
  text_box.setSelection(pos, string.length, true)
end