Module: Watobo::Gui::Utils
- Included in:
- FuzzerGui, InterceptEditor, ResponseViewer, SelectChatDialog, SessionIdSettings, SimpleTextView, 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
- #addDecoder(menu_pane, text_box) ⇒ Object
- #addEncoder(menu_pane, text_box) ⇒ Object
- #addStringInfo(menu_pane, text_box) ⇒ Object
- #cleanupHTTP(text) ⇒ Object
- #removeTags(text) ⇒ Object
- #replace_text(text_box, string) ⇒ Object
Class Method Details
.load_plugins(project = nil) ⇒ Object
27 28 29 30 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 |
# File 'lib/watobo/gui/utils/load_plugins.rb', line 27 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 load 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 load 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 load 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
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 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 70 def addDecoder(, text_box) pos = text_box.selStartPos len = text_box.selEndPos - pos string2decode = text_box.extractText(pos, len) string2decode.extend Watobo::Mixin::Transcoders FXMenuSeparator.new() FXMenuCaption.new(,"- Decoder -") FXMenuSeparator.new() decodeB64 = FXMenuCommand.new(,"Base64: #{string2decode.b64decode}") decodeB64.connect(SEL_COMMAND) { replace_text(text_box, string2decode.b64decode) } decodeHex = FXMenuCommand.new(,"Hex(A): #{string2decode.hexdecode}") decodeHex.connect(SEL_COMMAND) { replace_text(text_box, string2decode.hexdecode) } hex2int = FXMenuCommand.new(,"Hex(Int): #{string2decode.hex2int}") hex2int.connect(SEL_COMMAND) { replace_text(text_box, string2decode.hex2int) } decodeURL = FXMenuCommand.new(,"URL: #{string2decode.url_decode}") decodeURL.connect(SEL_COMMAND) { replace_text(text_box, string2decode.url_decode) } end |
#addEncoder(menu_pane, text_box) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 97 def addEncoder(, text_box) pos = text_box.selStartPos len = text_box.selEndPos - pos string2encode = text_box.extractText(pos, len) string2encode.extend Watobo::Mixin::Transcoders FXMenuSeparator.new() FXMenuCaption.new(,"- Encoder -") FXMenuSeparator.new() encodeB64 = FXMenuCommand.new(,"Base64: #{string2encode.b64encode}") encodeB64.connect(SEL_COMMAND) { replace_text(text_box, string2encode.b64encode) } encodeHex = FXMenuCommand.new(,"Hex: #{string2encode.hexencode}") encodeHex.connect(SEL_COMMAND) { replace_text(text_box, string2encode.hexencode) } encodeURL = FXMenuCommand.new(,"URL: #{string2encode.url_encode}") encodeURL.connect(SEL_COMMAND) { replace_text(text_box, string2encode.url_encode) } end |
#addStringInfo(menu_pane, text_box) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 59 def addStringInfo(, text_box) pos = text_box.selStartPos len = text_box.selEndPos - pos string = text_box.extractText(pos, len) FXMenuSeparator.new() FXMenuCaption.new(,"- Info -") FXMenuSeparator.new() FXMenuCaption.new(,"Length: #{string.length}") end |
#cleanupHTTP(text) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 30 def cleanupHTTP(text) if text.is_a?(Request) or text.is_a?(Response) dummy = [] text.each do |line| clean = line.unpack("C*").pack("C*") clean.gsub!(/\r/,'') clean.strip! clean.gsub!("\x00","") dummy << clean 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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 15 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
51 52 53 54 55 56 57 |
# File 'lib/watobo/gui/utils/gui_utils.rb', line 51 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 |