- the "OneShot" item in module view was changed by an "Execute" item

- "Execute" item now launch the MsfAssistant
- target tree is disabled
- add a double click on the exploit launch MsfAssistant



git-svn-id: file:///home/svn/framework3/trunk@4346 4d416f70-5f16-0410-b530-b9f4589650da
unstable
fab 2007-02-10 22:05:54 +00:00
parent a0c125e118
commit bdd4b0353f
4 changed files with 99 additions and 322 deletions

View File

@ -529,10 +529,10 @@
<widget class="GtkMenu" id="menu_module">
<child>
<widget class="GtkMenuItem" id="one_shot">
<widget class="GtkImageMenuItem" id="one_shot">
<property name="visible">True</property>
<property name="label" translatable="yes">One Shot</property>
<property name="use_underline">True</property>
<property name="label">gtk-execute</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
@ -715,26 +715,14 @@
</child>
</widget>
<widget class="GtkMenu" id="menu_staged">
<widget class="GtkMenu" id="menu_target_tree">
<property name="border_width">5</property>
<child>
<widget class="GtkImageMenuItem" id="staged">
<widget class="GtkImageMenuItem" id="stop">
<property name="visible">True</property>
<property name="label" translatable="yes">Staged</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="stock">gtk-connect</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<property name="label">gtk-stop</property>
<property name="use_stock">True</property>
</widget>
</child>
@ -747,95 +735,8 @@
<child>
<widget class="GtkImageMenuItem" id="delete">
<property name="visible">True</property>
<property name="label" translatable="yes">Delete</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
<widget class="GtkMenu" id="menu_owned">
<child>
<widget class="GtkImageMenuItem" id="owned">
<property name="visible">True</property>
<property name="label" translatable="yes">Exploit</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="séparateur2">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="staged">
<property name="visible">True</property>
<property name="label" translatable="yes">New Staged</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="stock">gtk-connect</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="séparateur1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="delete">
<property name="visible">True</property>
<property name="label" translatable="yes">Delete</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
<property name="label">gtk-clear</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
@ -1007,7 +908,7 @@
<child>
<widget class="GtkTextView" id="textview">
<property name="width_request">300</property>
<property name="width_request">400</property>
<property name="height_request">300</property>
<property name="visible">True</property>
<property name="can_focus">True</property>

View File

@ -68,7 +68,7 @@ class MyApp < MyGlade
@target_tree = MyTargetTree.new(@treeview2, session_tree)
# Module Tree
@module_tree = MyExploitsTree.new(@treeview1, @viewmodule, @target_tree)
@module_tree = MyModuleTree.new(@treeview1, @viewmodule, @target_tree, session_tree)
# Update the StatusBar with all framework modules
refresh()

View File

@ -2,70 +2,6 @@ module Msf
module Ui
module Gtk2
##
# This class perform a little dialog for the target oneshot
#
##
class MyOneShot < MyGlade
include Msf::Ui::Gtk2::MyControls
#
# Init the dialog shot
# Options: entry and warning
#
def initialize(tree_target, exploit, entry = "", warning = "")
super('dialog_oneshot')
@tree_target = tree_target
@oneshot_pix.set_file(File.join(driver.resource_directory, 'pix', 'oneshot.png'))
# Hit Enter key and send an activate signal
@rhost_entry.signal_connect('activate') {@okbutton1.activate}
# If entry supplied, set the Gtk::Entry
if entry
@rhost_entry.set_text(entry)
end
# if warning supplied, set the Gtk::Label with the label
if warning
@warning.set_markup(warning)
end
# Set the default response and sensitive
@dialog_oneshot.default_response = Gtk::Dialog::RESPONSE_OK
@dialog_oneshot.set_response_sensitive(Gtk::Dialog::RESPONSE_OK, true)
# Run the Gtk::Dialog and perform so stuff for the RESPONSE_OK
@dialog_oneshot.run do |response|
case response
when Gtk::Dialog::RESPONSE_OK
parse(@rhost_entry.text, exploit)
else
@dialog_oneshot.destroy
end
end
end # def initialize
#
# Macth if user entry is an IP address, if not, perform a red warning
#
def parse(entry, exploit)
# if entry match, add rhost to the target entry and destroy the MyOneShot class
if entry =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
@tree_target.add_oneshot(entry, exploit.get_value(1))
@dialog_oneshot.destroy
# If not, destroy MyOneShot and perform a new one with the entry and a warning
else
@dialog_oneshot.destroy
warning = "<span foreground=\"red\" style=\"italic\">Please, enter a valid IP address</span>"
MyOneShot.new(@tree_target, exploit, entry, warning)
end
end # def parse
end # class MyOneShot
##
# This class perform an assistant to configure exploits
@ -74,19 +10,15 @@ end # class MyOneShot
# - Add the passive options on the first page (hdm)
##
class MsfAssistant
attr_accessor :input
attr_accessor :output
PIX, TARGET, STAGED, OWNED, NAME, OBJECT, DRIVER, INPUT, OUTPUT = *(0..9).to_a
KEY, DEFAULT, VALUE, DESC = *(0..5).to_a
include Msf::Ui::Gtk2::MyControls
def initialize(staged_iter, session_tree)
def initialize(session_tree, active_module)
@buffer = Gtk::TextBuffer.new
@session_tree = session_tree
@active_module = staged_iter.get_value(OBJECT)
@address = staged_iter.get_value(TARGET)
@active_module = active_module
# initialize exploit driver's exploit instance
@mydriver = Msf::ExploitDriver.new(framework)
@ -360,10 +292,6 @@ class MsfAssistant
iter = model.append
iter[KEY] = key
if (key == "RHOST")
iter[VALUE] = @address
@hash['RHOST'] = @address
end
iter[DEFAULT] = opt.default.to_s
iter[DESC] = opt.desc.to_s
end # def pack
@ -371,10 +299,7 @@ class MsfAssistant
def updatevalue(model, column, path, text)
iter = model.get_iter(path)
iter[column] = text
@hash[iter.get_value(KEY)] = text
# TODO: perform an update iter if RHOST change ...
@hash[iter.get_value(KEY)] = text
end # def updatevalue
def update_page(page)

View File

@ -2,17 +2,21 @@ module Msf
module Ui
module Gtk2
class MyExploitsTree < MyGlade
CATEGORY, EXPLOIT, ADV, APP = *(0..4).to_a
##
# This class describe the modules treeview
##
class MyModuleTree < MyGlade
CATEGORY, MODULE, ADV, APP = *(0..4).to_a
include Msf::Ui::Gtk2::MyControls
def initialize(treeview, viewmodule, tree_target)
def initialize(treeview, viewmodule, tree_rhost, treesession)
super('menu_module')
@treeview1 = treeview
@treeview1.enable_search = true
@tree_target = tree_target
@tree_rhost = tree_rhost
@session_tree = treesession
@model = Gtk::TreeStore.new(String, # Module name
Object, # Exploit?
@ -75,13 +79,27 @@ class MyExploitsTree < MyGlade
rescue
nil
end
elsif (event.event_type == Gdk::Event::BUTTON2_PRESS)
path, column, x, y = treeview.get_path_at_pos(event.x, event.y)
begin
iter = @treeview1.model.get_iter(path)
if (iter.get_value(ADV) == false)
if (iter.get_value(APP) == "Standard")
treeview.selection.select_path(path)
active(iter)
MsfAssistant.new(@session_tree, iter.get_value(1))
end
end
rescue
nil
end
end
end
end
@one_shot.signal_connect('activate') do |item|
if current = @selection.selected
MyOneShot.new(@tree_target, current)
if active_module = @selection.selected
MsfAssistant.new(@session_tree, active_module.get_value(MODULE))
end
end
@ -101,7 +119,7 @@ class MyExploitsTree < MyGlade
#
iter = @model.append(nil)
iter.set_value(CATEGORY, "Standard (#{framework.stats.num_exploits.to_s})")
iter.set_value(EXPLOIT, nil)
iter.set_value(MODULE, nil)
iter.set_value(ADV, true)
# Add Exploits childs
@ -109,7 +127,7 @@ class MyExploitsTree < MyGlade
next if not mod.match(filter)
child_iter = @model.append(iter)
child_iter.set_value(CATEGORY, obj.new.name)
child_iter.set_value(EXPLOIT, obj.new)
child_iter.set_value(MODULE, obj.new)
child_iter.set_value(ADV, false)
child_iter.set_value(APP, "Standard")
end
@ -119,7 +137,7 @@ class MyExploitsTree < MyGlade
#
iter = @model.append(nil)
iter.set_value(CATEGORY, "Auxiliary (#{framework.stats.num_auxiliary.to_s})")
iter.set_value(EXPLOIT, nil)
iter.set_value(MODULE, nil)
iter.set_value(ADV, true)
# Add Auxiliary childs
@ -127,7 +145,7 @@ class MyExploitsTree < MyGlade
next if not mod.match(filter)
child_iter = @model.append(iter)
child_iter.set_value(CATEGORY, obj.new.name)
child_iter.set_value(EXPLOIT, obj.new)
child_iter.set_value(MODULE, obj.new)
child_iter.set_value(ADV, false)
child_iter.set_value(APP, "Auxiliary")
end
@ -137,7 +155,7 @@ class MyExploitsTree < MyGlade
#
iter = @model.append(nil)
iter.set_value(CATEGORY, "Payloads (#{framework.stats.num_payloads.to_s})")
iter.set_value(EXPLOIT, nil)
iter.set_value(MODULE, nil)
iter.set_value(ADV, true)
# Add Payloads childs
@ -145,7 +163,7 @@ class MyExploitsTree < MyGlade
next if not mod.match(filter)
child_iter = @model.append(iter)
child_iter.set_value(CATEGORY, obj.new.name)
child_iter.set_value(EXPLOIT, obj.new)
child_iter.set_value(MODULE, obj.new)
child_iter.set_value(ADV, false)
child_iter.set_value(APP, "Payloads")
end
@ -155,7 +173,7 @@ class MyExploitsTree < MyGlade
#
iter = @model.append(nil)
iter.set_value(CATEGORY, "NOPs (#{framework.stats.num_nops.to_s})")
iter.set_value(EXPLOIT, nil)
iter.set_value(MODULE, nil)
iter.set_value(ADV, true)
# Add nops childs
@ -163,7 +181,7 @@ class MyExploitsTree < MyGlade
next if not mod.match(filter)
child_iter = @model.append(iter)
child_iter.set_value(CATEGORY, obj.new.name)
child_iter.set_value(EXPLOIT, obj.new)
child_iter.set_value(MODULE, obj.new)
child_iter.set_value(ADV, false)
child_iter.set_value(APP, "NOPs")
end
@ -173,7 +191,7 @@ class MyExploitsTree < MyGlade
#
iter = @model.append(nil)
iter.set_value(CATEGORY, "Encoders (#{framework.stats.num_encoders.to_s})")
iter.set_value(EXPLOIT, nil)
iter.set_value(MODULE, nil)
iter.set_value(ADV, true)
# Add Encoders childs
@ -181,7 +199,7 @@ class MyExploitsTree < MyGlade
next if not mod.match(filter)
child_iter = @model.append(iter)
child_iter.set_value(CATEGORY, obj.new.name)
child_iter.set_value(EXPLOIT, obj.new)
child_iter.set_value(MODULE, obj.new)
child_iter.set_value(ADV, false)
iter.set_value(APP, "Encoders")
end
@ -191,8 +209,8 @@ class MyExploitsTree < MyGlade
# Display the module information
#
def active(iter)
if not iter[EXPLOIT].nil?
@buffer.insert_module(iter.get_value(EXPLOIT))
if not iter[MODULE].nil?
@buffer.insert_module(iter.get_value(MODULE))
end
end
@ -205,66 +223,50 @@ end # Class MyExploitsTree
class MyTargetTree < MyGlade
PIX, TARGET, STAGED, OWNED, NAME, OBJECT, DRIVER , INPUT, OUTPUT= *(0..9).to_a
PIX, RHOST, RUNNING, NAME, OBJECT = *(0..5).to_a
include Msf::Ui::Gtk2::MyControls
def initialize(treeview, session_tree)
super('menu_staged')
super('menu_target_tree')
@treeview2 = treeview
@session_tree = session_tree
@model = Gtk::TreeStore.new(Gdk::Pixbuf, # Pix
@model = Gtk::TreeStore.new(Gdk::Pixbuf, # Pix rhost
String, # RHOST
Gdk::Pixbuf, # Pix Staged
Gdk::Pixbuf, # Pix Owned
Gdk::Pixbuf, # Pix for the running state
String, # exploit refname
Object, # ?
Object, # Msf::ExploitDriver
Object, # INPUT
Object # OUTPUT
Object # Exploit Object
)
# Renderer
renderer_pix = Gtk::CellRendererPixbuf.new
renderer_target = Gtk::CellRendererText.new
renderer_staged_pix = Gtk::CellRendererPixbuf.new
renderer_owned_pix = Gtk::CellRendererPixbuf.new
renderer_rhost = Gtk::CellRendererText.new
renderer_running_pix = Gtk::CellRendererPixbuf.new
renderer_name = Gtk::CellRendererText.new
# Target Gtk::TreeViewColumn
column_target = Gtk::TreeViewColumn.new
column_target.set_title("Target")
column_target.pack_start(renderer_pix, false)
column_target.set_cell_data_func(renderer_pix) do |column, cell, model, iter|
# RHOST Gtk::TreeViewColumn
column_rhost = Gtk::TreeViewColumn.new
column_rhost.set_title("rhost")
column_rhost.pack_start(renderer_pix, false)
column_rhost.set_cell_data_func(renderer_pix) do |column, cell, model, iter|
cell.pixbuf = iter[PIX]
end
column_target.pack_start(renderer_target, true)
column_target.set_cell_data_func(renderer_target) do |column, cell, model, iter|
cell.text = iter[TARGET]
column_rhost.pack_start(renderer_rhost, true)
column_rhost.set_cell_data_func(renderer_rhost) do |column, cell, model, iter|
cell.text = iter[RHOST]
end
column_target.sort_column_id = TARGET
column_rhost.sort_column_id = RHOST
# Staged Gtk::TreeViewColumn
column_staged = Gtk::TreeViewColumn.new
column_staged.sizing = Gtk::TreeViewColumn::FIXED
column_staged.fixed_width = 20
column_staged.set_title("S")
column_staged.pack_start(renderer_staged_pix, false)
column_staged.set_cell_data_func(renderer_staged_pix) do |column, cell, model, iter|
cell.pixbuf = iter[STAGED]
end
# Owned Gtk::TreeViewColumn
column_owned = Gtk::TreeViewColumn.new
column_owned.sizing = Gtk::TreeViewColumn::FIXED
column_owned.fixed_width = 20
#column_owned.set_fixed_width(5)
column_owned.set_title("O")
column_owned.pack_start(renderer_staged_pix, false)
column_owned.set_cell_data_func(renderer_staged_pix) do |column, cell, model, iter|
cell.pixbuf = iter[OWNED]
# Running Gtk::TreeViewColumn
column_running = Gtk::TreeViewColumn.new
column_running.sizing = Gtk::TreeViewColumn::FIXED
column_running.fixed_width = 20
column_running.set_title("S")
column_running.pack_start(renderer_running_pix, false)
column_running.set_cell_data_func(renderer_running_pix) do |column, cell, model, iter|
cell.pixbuf = iter[RUNNING]
end
# Name Gtk::TreeViewColumn
@ -283,49 +285,19 @@ class MyTargetTree < MyGlade
@treeview2.rules_hint = true
# Add Gtk::TreeViewColumn
@treeview2.append_column(column_target)
@treeview2.append_column(column_staged)
@treeview2.append_column(column_owned)
@treeview2.append_column(column_rhost)
@treeview2.append_column(column_running)
@treeview2.append_column(column_name)
# Add AutoPWN
@autopwn_iter = @model.append(nil)
@autopwn_iter.set_value(PIX, driver.get_icon("menu_autopwn.png"))
@autopwn_iter.set_value(TARGET, "AutoPWN")
@autopwn_iter.set_value(RHOST, "AutoPWN")
# Add Parent "One shot"
@oneshot_iter = @model.append(nil)
@oneshot_iter.set_value(PIX, driver.get_icon("menu_oneshot.png"))
@oneshot_iter.set_value(TARGET, "One shot")
# Owned Gtk::Menu
@menu_owned = Gtk::Menu.new
owned_item_exploit = Gtk::ImageMenuItem.new("Exploit")
owned_image_exploit = Gtk::Image.new
owned_image_exploit.set(Gtk::Stock::EXECUTE, Gtk::IconSize::MENU)
owned_item_exploit.set_image(owned_image_exploit)
@menu_owned.append(owned_item_exploit)
separator1 = Gtk::SeparatorMenuItem.new
@menu_owned.append(separator1)
owned_item_new_staged = Gtk::ImageMenuItem.new("New Staged")
owned_image_new_staged = Gtk::Image.new
owned_image_new_staged.set(Gtk::Stock::CONNECT, Gtk::IconSize::MENU)
owned_item_new_staged.set_image(owned_image_new_staged)
@menu_owned.append(owned_item_new_staged)
separator2 = Gtk::SeparatorMenuItem.new
@menu_owned.append(separator2)
owned_item_delete = Gtk::ImageMenuItem.new("Delete")
owned_image_delete = Gtk::Image.new
owned_image_delete.set(Gtk::Stock::CLEAR, Gtk::IconSize::MENU)
owned_item_delete.set_image(owned_image_delete)
@menu_owned.append(owned_item_delete)
@menu_owned.show_all
@oneshot_iter.set_value(RHOST, "One shot")
# TreeView Signals
@treeview2.signal_connect('button_press_event') do |treeview, event|
@ -335,12 +307,13 @@ class MyTargetTree < MyGlade
begin
iter = @treeview2.model.get_iter(path)
if iter.get_value(PIX).nil? && iter.get_value(STAGED).nil?
if iter.get_value(PIX).nil? && iter.get_value(RUNNING).nil?
treeview.selection.select_path(path)
@menu_staged.popup(nil, nil, event.button, event.time)
elsif not iter.get_value(STAGED).nil?
@menu_targetree.popup(nil, nil, event.button, event.time)
elsif not iter.get_value(RUNNING).nil?
treeview.selection.select_path(path)
@menu_owned.popup(nil, nil, event.button, event.time)
nil
# @menu_owned.popup(nil, nil, event.button, event.time)
end
rescue
nil
@ -350,30 +323,15 @@ class MyTargetTree < MyGlade
end
# Menu Signals
@staged.signal_connect('activate') do |item|
@stop.signal_connect('activate') do |item|
if current = @selection.selected
add_staged(current)
puts "TODO: Kill exploit"
end
end
@delete.signal_connect('activate') do |item|
if current = @selection.selected
remove_target(current)
end
end
owned_item_exploit.signal_connect('activate') do |item|
if current = @selection.selected
session = current[DRIVER].run
if (session)
current[OUTPUT].print_status("Session #{session.sid} created, interacting ...")
current[OUTPUT].print_line
end
end
end
owned_item_delete.signal_connect('activate') do |item|
if current = @selection.selected
remove_target(current)
remove_rhost(current)
end
end
end # def initialize
@ -384,30 +342,23 @@ class MyTargetTree < MyGlade
def add_oneshot(target, exploit)
oneshot_childiter = @model.append(@oneshot_iter)
#oneshot_childiter.set_value(PIX, nil)
oneshot_childiter.set_value(TARGET, target)
oneshot_childiter.set_value(RHOST, target)
oneshot_childiter.set_value(NAME, exploit.shortname)
oneshot_childiter.set_value(OBJECT, exploit)
@treeview2.expand_all()
end
#
# Add Staged by launching wizard (MsfAssistant
#
def add_staged(staged_iter)
MsfAssistant.new(staged_iter, @session_tree)
end
#
# Remove Target
#
def remove_target(iter)
def remove_rhost(iter)
@treeview2.model.remove(iter)
end
end #class MyTargetTree
class MySessionTree
ID_SESSION, TARGET, PAYLOAD, O_SESSION, BUFFER, PIPE, INPUT, OUTPUT = *(0..8).to_a
ID_SESSION, RHOST, PAYLOAD, O_SESSION, BUFFER, PIPE, INPUT, OUTPUT = *(0..8).to_a
def initialize(treeview)
@treeview = treeview
@ -423,7 +374,7 @@ class MySessionTree
# Renderer
renderer_id = Gtk::CellRendererText.new
renderer_target = Gtk::CellRendererText.new
renderer_rhost = Gtk::CellRendererText.new
renderer_payload = Gtk::CellRendererText.new
# ID Session Gtk::TreeViewColumn
@ -438,13 +389,13 @@ class MySessionTree
column_id.sort_column_id = ID_SESSION
# Target Gtk::TreeViewColumn
column_target = Gtk::TreeViewColumn.new
column_target.set_title("Target")
column_target.pack_start(renderer_target, true)
column_target.set_cell_data_func(renderer_target) do |column, cell, model, iter|
cell.text = iter[TARGET]
column_rhost = Gtk::TreeViewColumn.new
column_rhost.set_title("Target")
column_rhost.pack_start(renderer_rhost, true)
column_rhost.set_cell_data_func(renderer_rhost) do |column, cell, model, iter|
cell.text = iter[RHOST]
end
column_target.sort_column_id = TARGET
column_rhost.sort_column_id = RHOST
# Payload type Gtk::TreeViewColumn
column_payload = Gtk::TreeViewColumn.new
@ -464,7 +415,7 @@ class MySessionTree
# Add Gtk::TreeViewColumn
@treeview.append_column(column_id)
@treeview.append_column(column_target)
@treeview.append_column(column_rhost)
@treeview.append_column(column_payload)
# Session Gtk::Menu
@ -515,7 +466,7 @@ class MySessionTree
def add_session(session, options, buffer, pipe, input, output)
iter = @model.append
iter[ID_SESSION] = session.sid.to_s
iter[TARGET] = options['RHOST']
iter[RHOST] = options['RHOST']
iter[PAYLOAD] = options['PAYLOAD']
iter[O_SESSION] = session
iter[BUFFER] = buffer