- add comments
- isolate the view class (the view class) - cleanup the msfgui input driver git-svn-id: file:///home/svn/framework3/trunk@4323 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
f61e726dbe
commit
6612c5c9e5
|
@ -2,8 +2,10 @@ module Msf
|
|||
module Ui
|
||||
module Gtk2
|
||||
|
||||
##
|
||||
# This class help us to retreive all glade widgets and place them in your user instance
|
||||
# like @windows, @widget, ...
|
||||
##
|
||||
class MyGlade
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
|
@ -22,6 +24,9 @@ class MyGlade
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# This is the main class
|
||||
##
|
||||
class MyApp < MyGlade
|
||||
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
@ -40,7 +45,7 @@ class MyApp < MyGlade
|
|||
@window.signal_connect('destroy') { Gtk.main_quit }
|
||||
|
||||
# Default size
|
||||
# @window.set_default_size(1024, 768)
|
||||
# @window.set_default_size(1024, 768)
|
||||
|
||||
# Defaults policies for Gtk::ScrolledWindow
|
||||
@scrolledwindow1.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
||||
|
@ -51,15 +56,15 @@ class MyApp < MyGlade
|
|||
|
||||
# View Module specs
|
||||
@buffer_module = Gtk::TextBuffer.new
|
||||
@viewmodule.set_buffer(@buffer_module)
|
||||
@viewmodule.set_editable(false)
|
||||
@viewmodule.set_cursor_visible(false)
|
||||
# @viewmodule.set_buffer(@buffer_module)
|
||||
# @viewmodule.set_editable(false)
|
||||
# @viewmodule.set_cursor_visible(false)
|
||||
|
||||
# Logs Buffer
|
||||
@buffer = Gtk::TextBuffer.new
|
||||
# @viewlogs.set_buffer(@buffer_logs)
|
||||
# @viewlogs.set_editable(false)
|
||||
# @viewlogs.set_cursor_visible(false)
|
||||
@viewlogs.set_buffer(@buffer_logs)
|
||||
@viewlogs.set_editable(false)
|
||||
@viewlogs.set_cursor_visible(false)
|
||||
|
||||
# Sessions Tree
|
||||
session_tree = MySessionTree.new(@treeview_session)
|
||||
|
@ -82,10 +87,16 @@ class MyApp < MyGlade
|
|||
# end
|
||||
end
|
||||
|
||||
#
|
||||
# Signal to refresh the treeview module
|
||||
#
|
||||
def on_refresh_activate
|
||||
refresh()
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Bye bye
|
||||
#
|
||||
def on_leave_activate
|
||||
Gtk.main_quit
|
||||
end
|
||||
|
@ -94,10 +105,16 @@ class MyApp < MyGlade
|
|||
puts "TODO: Set preferences for the payload choice"
|
||||
end
|
||||
|
||||
#
|
||||
# The About Dialog
|
||||
#
|
||||
def on_about_activate
|
||||
MyAbout.new
|
||||
end
|
||||
|
||||
#
|
||||
# Call the refresh method to reload all module
|
||||
#
|
||||
def refresh
|
||||
@module_tree.refresh
|
||||
context_id = @statusbar.get_context_id("update")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
module MyControls
|
||||
|
||||
#
|
||||
|
@ -29,64 +30,10 @@ module MyControls
|
|||
# Controls
|
||||
#
|
||||
|
||||
class MyModuleView
|
||||
def initialize(buffer)
|
||||
@buffer = buffer
|
||||
@buffer.create_tag("_",
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD
|
||||
)
|
||||
@buffer.create_tag("type",
|
||||
:'foreground' => 'red',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("author",
|
||||
:'foreground' => 'ForestGreen',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("refname",
|
||||
:'foreground' => 'RosyBrown',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("reference",
|
||||
:'foreground' => 'blue',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'underline' => Pango::UNDERLINE_SINGLE,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("description",
|
||||
:'style' => Pango::FontDescription::STYLE_ITALIC,
|
||||
:'wrap_mode' => Gtk::TextTag::WRAP_WORD
|
||||
)
|
||||
end
|
||||
|
||||
def insert_module(obj)
|
||||
@buffer.delete(*@buffer.bounds)
|
||||
start = @buffer.get_iter_at_offset(0)
|
||||
@buffer.insert_with_tags(start, "Type : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.type + "\n", 'type')
|
||||
@buffer.insert_with_tags(start, "Author : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.author_to_s + "\n", 'author')
|
||||
@buffer.insert_with_tags(start, "Path : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.refname + "\n\n", 'refname')
|
||||
@buffer.insert_with_tags(start, "External Reference :\n", "_")
|
||||
extref = ""
|
||||
obj.references.each do |refs|
|
||||
extref << refs.to_s + "\n"
|
||||
end
|
||||
@buffer.insert_with_tags(start, extref + "\n", 'reference')
|
||||
@buffer.insert_with_tags(start, "Description :", '_')
|
||||
desc = ""
|
||||
obj.description.each_line do |line|
|
||||
desc << line.strip + "\n"
|
||||
end
|
||||
@buffer.insert_with_tags(start, desc, 'description')
|
||||
end
|
||||
# TODO: Add control here
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,13 @@ module Msf
|
|||
module Ui
|
||||
module Gtk2
|
||||
|
||||
# require 'msf/ui/gtk2/stream/input'
|
||||
# require 'msf/ui/gtk2/stream/output'
|
||||
# require 'msf/ui/gtk2/stream/console'
|
||||
|
||||
##
|
||||
# This class perform a little dialog for the target oneshot
|
||||
#
|
||||
# TODO:
|
||||
# - Add regexp to control the format address IP
|
||||
# - Add a focus directly on the RESPONSE_OK button
|
||||
##
|
||||
class MyOneShot < MyGlade
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
|
@ -23,7 +26,14 @@ class MyOneShot < MyGlade
|
|||
end
|
||||
end
|
||||
|
||||
class MyMsfAssistant
|
||||
##
|
||||
# This class perform an assistant to configure exploits
|
||||
#
|
||||
# TODO:
|
||||
# - Add the passive options on the first page (hdm)
|
||||
##
|
||||
|
||||
class MsfAssistant
|
||||
PIX, TARGET, STAGED, OWNED, NAME, OBJECT, DRIVER, INPUT, OUTPUT = *(0..9).to_a
|
||||
KEY, DEFAULT, VALUE, DESC = *(0..5).to_a
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ require 'msf/ui/gtk2/frame'
|
|||
require 'msf/ui/gtk2/dialogs'
|
||||
require 'msf/ui/gtk2/logs'
|
||||
require 'msf/ui/gtk2/stream'
|
||||
require 'msf/ui/gtk2/view'
|
||||
|
||||
module Msf
|
||||
module Ui
|
||||
|
|
|
@ -387,10 +387,10 @@ class MyTargetTree < MyGlade
|
|||
end
|
||||
|
||||
#
|
||||
# Add Staged by launching wizard
|
||||
# Add Staged by launching wizard (MsfAssistant
|
||||
#
|
||||
def add_staged(staged_iter)
|
||||
MyMsfAssistant.new(staged_iter, @buffer, @session_tree)
|
||||
MsfAssistant.new(staged_iter, @buffer, @session_tree)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -20,6 +20,7 @@ class Console < MyGlade
|
|||
|
||||
if @console2.run == Gtk::Dialog::RESPONSE_OK
|
||||
puts "ok"
|
||||
@console2.destroy
|
||||
end
|
||||
|
||||
@session.init_ui(@input, @output)
|
||||
|
|
|
@ -3,58 +3,17 @@ module Ui
|
|||
module Gtk2
|
||||
module Stream
|
||||
|
||||
###
|
||||
#
|
||||
# This class implements input against Gtk::TextBuffer in.
|
||||
#
|
||||
###
|
||||
class Input < Rex::Ui::Text::Input
|
||||
|
||||
def initialize(buffer)
|
||||
self.eof = false
|
||||
@buffer = buffer
|
||||
end
|
||||
|
||||
#
|
||||
# Whether or not the input medium supports readline.
|
||||
#
|
||||
def supports_readline
|
||||
true
|
||||
end
|
||||
|
||||
#
|
||||
# Calls the underlying system read.
|
||||
#
|
||||
def sysread(len)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# Gets a line of input
|
||||
#
|
||||
def gets
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# Has the input medium reached end-of-file?
|
||||
#
|
||||
def eof?
|
||||
return eof
|
||||
end
|
||||
|
||||
#
|
||||
# Returns a pollable file descriptor that is associated with this
|
||||
# input medium.
|
||||
#
|
||||
def fd
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# Indicates whether or not this input medium is intrinsicly a
|
||||
# shell provider. This would indicate whether or not it
|
||||
# already expects to have a prompt.
|
||||
#
|
||||
def intrinsic_shell?
|
||||
false
|
||||
end
|
||||
|
||||
#
|
||||
# Reads text from standard input.
|
||||
#
|
||||
|
@ -98,25 +57,6 @@ class Input < Rex::Ui::Text::Input
|
|||
def fd
|
||||
return $stdin
|
||||
end
|
||||
|
||||
def print_error(msg = '')
|
||||
@buffer.insert_at_cursor("[-] #{msg}\n")
|
||||
end
|
||||
|
||||
def print_good(msg = '')
|
||||
@buffer.insert_at_cursor("[+] #{msg}\n")
|
||||
end
|
||||
|
||||
def print_status(msg = '')
|
||||
@buffer.insert_at_cursor("[*] #{msg}\n")
|
||||
end
|
||||
|
||||
def print_line(msg = '')
|
||||
@buffer.insert_at_cursor(msg + "\n")
|
||||
end
|
||||
|
||||
attr_accessor :eof
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
##
|
||||
# This class describe all tags and behaviour for module view rendering
|
||||
# To initialize, a Gtk::TextBuffer must be passed in argument
|
||||
# TODO: Add a pixmap for platform
|
||||
#
|
||||
class MyModuleView
|
||||
def initialize(buffer)
|
||||
@buffer = buffer
|
||||
@buffer.create_tag("_",
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD
|
||||
)
|
||||
@buffer.create_tag("type",
|
||||
:'foreground' => 'red',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("author",
|
||||
:'foreground' => 'ForestGreen',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("refname",
|
||||
:'foreground' => 'RosyBrown',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("reference",
|
||||
:'foreground' => 'blue',
|
||||
:'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
||||
:'underline' => Pango::UNDERLINE_SINGLE,
|
||||
:'left_margin' => 100
|
||||
)
|
||||
@buffer.create_tag("description",
|
||||
:'style' => Pango::FontDescription::STYLE_ITALIC,
|
||||
:'wrap_mode' => Gtk::TextTag::WRAP_WORD
|
||||
)
|
||||
end
|
||||
|
||||
def insert_module(obj)
|
||||
@buffer.delete(*@buffer.bounds)
|
||||
start = @buffer.get_iter_at_offset(0)
|
||||
@buffer.insert_with_tags(start, "Type : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.type + "\n", 'type')
|
||||
@buffer.insert_with_tags(start, "Author : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.author_to_s + "\n", 'author')
|
||||
@buffer.insert_with_tags(start, "Path : ", "_")
|
||||
@buffer.insert_with_tags(start, obj.refname + "\n\n", 'refname')
|
||||
@buffer.insert_with_tags(start, "External Reference :\n", "_")
|
||||
extref = ""
|
||||
obj.references.each do |refs|
|
||||
extref << refs.to_s + "\n"
|
||||
end
|
||||
@buffer.insert_with_tags(start, extref + "\n", 'reference')
|
||||
@buffer.insert_with_tags(start, "Description :", '_')
|
||||
|
||||
# Ugly ... ;-( but crafty
|
||||
desc = ""
|
||||
obj.description.each_line do |line|
|
||||
desc << line.strip + "\n"
|
||||
end
|
||||
@buffer.insert_with_tags(start, desc, 'description')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue