2007-02-04 01:55:01 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Gtk2
|
|
|
|
|
2007-02-10 22:05:54 +00:00
|
|
|
##
|
|
|
|
# This class describe the modules treeview
|
|
|
|
##
|
|
|
|
class MyModuleTree < MyGlade
|
2007-02-15 22:09:24 +00:00
|
|
|
|
|
|
|
@@completion = []
|
|
|
|
|
2007-02-10 22:05:54 +00:00
|
|
|
CATEGORY, MODULE, ADV, APP = *(0..4).to_a
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
include Msf::Ui::Gtk2::MyControls
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-13 18:02:56 +00:00
|
|
|
def initialize(treeview, viewmodule)
|
2007-02-04 01:55:01 +00:00
|
|
|
super('menu_module')
|
|
|
|
|
2007-02-07 21:02:24 +00:00
|
|
|
@treeview1 = treeview
|
2007-02-07 22:28:55 +00:00
|
|
|
@treeview1.enable_search = true
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-04 19:30:49 +00:00
|
|
|
@model = Gtk::TreeStore.new(String, # Module name
|
|
|
|
Object, # Exploit?
|
|
|
|
TrueClass, # ADV?
|
|
|
|
String # Appartenance
|
|
|
|
)
|
2007-02-13 00:22:05 +00:00
|
|
|
# Register the model for later use
|
|
|
|
$gtk2driver.module_model = @model
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Init buffer module with tags
|
2007-02-07 21:02:24 +00:00
|
|
|
buff = Gtk::TextBuffer.new
|
|
|
|
viewmodule.set_buffer(buff)
|
|
|
|
viewmodule.set_editable(false)
|
|
|
|
viewmodule.set_cursor_visible(false)
|
|
|
|
@buffer = MyModuleView.new(buff)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Renderer Module
|
|
|
|
#renderer1 = Gtk::CellRendererPixbuf.new
|
|
|
|
renderer1 = Gtk::CellRendererText.new
|
|
|
|
|
|
|
|
column1 = Gtk::TreeViewColumn.new("Modules", renderer1, 'text' => CATEGORY)
|
|
|
|
column1.sort_column_id = CATEGORY
|
|
|
|
|
|
|
|
#set model to treeview
|
|
|
|
@treeview1.set_size_request(380, -1)
|
|
|
|
@treeview1.set_model(@model)
|
|
|
|
|
|
|
|
@treeview1.rules_hint = true
|
|
|
|
|
|
|
|
@selection = @treeview1.selection
|
|
|
|
@treeview1.selection.mode = Gtk::SELECTION_BROWSE
|
|
|
|
|
|
|
|
@treeview1.append_column(column1)
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Signals
|
|
|
|
@treeview1.signal_connect('cursor-changed') do |widget, event|
|
|
|
|
widget.selection.selected_each do |model, path, iter|
|
|
|
|
active(iter)
|
|
|
|
end
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview1.signal_connect('button_press_event') do |treeview, event|
|
|
|
|
if event.kind_of? Gdk::EventButton
|
|
|
|
if (event.button == 3)
|
|
|
|
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)
|
2007-03-08 22:44:55 +00:00
|
|
|
treeview.selection.select_path(path)
|
|
|
|
active(iter)
|
|
|
|
@menu_module.popup(nil, nil, event.button, event.time)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2007-02-10 22:05:54 +00:00
|
|
|
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)
|
2007-03-08 22:44:55 +00:00
|
|
|
MsfAssistant::Standard.new(iter.get_value(1))
|
|
|
|
elsif (iter.get_value(APP) == "Payloads")
|
|
|
|
treeview.selection.select_path(path)
|
|
|
|
active(iter)
|
|
|
|
MsfAssistant::Payload.new(iter.get_value(1))
|
|
|
|
else
|
|
|
|
treeview.selection.select_path(path)
|
|
|
|
active(iter)
|
|
|
|
MsfDialog::Error.new($gtk2driver.main, "Not available")
|
|
|
|
end
|
2007-02-10 22:05:54 +00:00
|
|
|
end
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
@one_shot.signal_connect('activate') do |item|
|
2007-02-10 22:05:54 +00:00
|
|
|
if active_module = @selection.selected
|
2007-03-08 22:44:55 +00:00
|
|
|
type = active_module.get_value(APP)
|
|
|
|
if (type == "Standard")
|
|
|
|
MsfAssistant::Standard.new(active_module.get_value(MODULE))
|
|
|
|
elsif (type == "Payloads")
|
|
|
|
MsfAssistant::Payload.new(active_module.get_value(MODULE))
|
|
|
|
else
|
|
|
|
MsfDialog::Error.new($gtk2driver.main, "Not available")
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Add modules in the Gtk::TreeView
|
|
|
|
add_modules()
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-15 22:09:24 +00:00
|
|
|
# Configure the module completion handles for easy reference
|
|
|
|
$gtk2driver.module_completion = @@completion
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
end # def initialize
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add Exploits module in the treeview
|
|
|
|
#
|
2007-02-11 08:57:43 +00:00
|
|
|
def add_modules(filter=/.*/)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Add Parent "Standard (nbr exploits)"
|
|
|
|
iter = @model.append(nil)
|
|
|
|
iter.set_value(CATEGORY, "Standard (#{framework.stats.num_exploits.to_s})")
|
2007-02-10 22:05:54 +00:00
|
|
|
iter.set_value(MODULE, nil)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter.set_value(ADV, true)
|
|
|
|
|
|
|
|
# Add Exploits childs
|
|
|
|
framework.exploits.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
2007-02-15 22:09:24 +00:00
|
|
|
t_module = obj.new.name
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter = @model.append(iter)
|
2007-02-15 22:09:24 +00:00
|
|
|
child_iter.set_value(CATEGORY, t_module)
|
2007-02-10 22:05:54 +00:00
|
|
|
child_iter.set_value(MODULE, obj.new)
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter.set_value(ADV, false)
|
2007-02-04 19:30:49 +00:00
|
|
|
child_iter.set_value(APP, "Standard")
|
2007-02-15 22:09:24 +00:00
|
|
|
@@completion.push(t_module)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Add Parent "Auxiliary (nbr auxiliary)"
|
|
|
|
iter = @model.append(nil)
|
|
|
|
iter.set_value(CATEGORY, "Auxiliary (#{framework.stats.num_auxiliary.to_s})")
|
2007-02-10 22:05:54 +00:00
|
|
|
iter.set_value(MODULE, nil)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter.set_value(ADV, true)
|
|
|
|
|
|
|
|
# Add Auxiliary childs
|
|
|
|
framework.auxiliary.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
2007-02-15 22:09:24 +00:00
|
|
|
t_module = obj.new.name
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter = @model.append(iter)
|
2007-02-15 22:09:24 +00:00
|
|
|
child_iter.set_value(CATEGORY, t_module)
|
2007-02-10 22:05:54 +00:00
|
|
|
child_iter.set_value(MODULE, obj.new)
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter.set_value(ADV, false)
|
2007-02-04 19:30:49 +00:00
|
|
|
child_iter.set_value(APP, "Auxiliary")
|
2007-02-15 22:09:24 +00:00
|
|
|
@@completion.push(t_module)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Add Parent "Payloads (nbr payloads)"
|
|
|
|
iter = @model.append(nil)
|
|
|
|
iter.set_value(CATEGORY, "Payloads (#{framework.stats.num_payloads.to_s})")
|
2007-02-10 22:05:54 +00:00
|
|
|
iter.set_value(MODULE, nil)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter.set_value(ADV, true)
|
2007-02-13 18:02:56 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Add Payloads childs
|
|
|
|
framework.payloads.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
2007-02-15 22:09:24 +00:00
|
|
|
t_module = obj.new.name
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter = @model.append(iter)
|
2007-02-15 22:09:24 +00:00
|
|
|
child_iter.set_value(CATEGORY, t_module)
|
2007-02-10 22:05:54 +00:00
|
|
|
child_iter.set_value(MODULE, obj.new)
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter.set_value(ADV, false)
|
2007-02-04 19:30:49 +00:00
|
|
|
child_iter.set_value(APP, "Payloads")
|
2007-02-15 22:09:24 +00:00
|
|
|
@@completion.push(t_module)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Add Parent "Nops (nbr nops)"
|
|
|
|
iter = @model.append(nil)
|
|
|
|
iter.set_value(CATEGORY, "NOPs (#{framework.stats.num_nops.to_s})")
|
2007-02-10 22:05:54 +00:00
|
|
|
iter.set_value(MODULE, nil)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter.set_value(ADV, true)
|
|
|
|
|
|
|
|
# Add nops childs
|
|
|
|
framework.nops.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
2007-02-15 22:09:24 +00:00
|
|
|
t_module = obj.new.name
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter = @model.append(iter)
|
2007-02-15 22:09:24 +00:00
|
|
|
child_iter.set_value(CATEGORY, t_module)
|
2007-02-10 22:05:54 +00:00
|
|
|
child_iter.set_value(MODULE, obj.new)
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter.set_value(ADV, false)
|
2007-02-04 19:30:49 +00:00
|
|
|
child_iter.set_value(APP, "NOPs")
|
2007-02-15 22:09:24 +00:00
|
|
|
@@completion.push(t_module)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Add Parent "Encoders (nbr encoders)"
|
|
|
|
iter = @model.append(nil)
|
|
|
|
iter.set_value(CATEGORY, "Encoders (#{framework.stats.num_encoders.to_s})")
|
2007-02-10 22:05:54 +00:00
|
|
|
iter.set_value(MODULE, nil)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter.set_value(ADV, true)
|
|
|
|
|
|
|
|
# Add Encoders childs
|
|
|
|
framework.encoders.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
2007-02-15 22:09:24 +00:00
|
|
|
t_module = obj.new.name
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter = @model.append(iter)
|
2007-02-15 22:09:24 +00:00
|
|
|
child_iter.set_value(CATEGORY, t_module)
|
2007-02-10 22:05:54 +00:00
|
|
|
child_iter.set_value(MODULE, obj.new)
|
2007-02-04 01:55:01 +00:00
|
|
|
child_iter.set_value(ADV, false)
|
2007-02-04 19:30:49 +00:00
|
|
|
iter.set_value(APP, "Encoders")
|
2007-02-15 22:09:24 +00:00
|
|
|
@@completion.push(t_module)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end # def add_modules
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display the module information
|
|
|
|
#
|
|
|
|
def active(iter)
|
2007-02-10 22:05:54 +00:00
|
|
|
if not iter[MODULE].nil?
|
|
|
|
@buffer.insert_module(iter.get_value(MODULE))
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-13 08:48:39 +00:00
|
|
|
#
|
|
|
|
# Refresh the module treeview with all msf modules
|
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
def refresh
|
|
|
|
@model.clear()
|
|
|
|
add_modules()
|
|
|
|
end
|
2007-02-13 08:48:39 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# remove all iters in array_iter
|
|
|
|
#
|
|
|
|
def remove(iter_array)
|
2007-02-13 14:07:35 +00:00
|
|
|
|
|
|
|
# first loop to remove unmatched iter
|
2007-02-13 08:48:39 +00:00
|
|
|
iter_array.each do |iter|
|
|
|
|
if (iter[ADV] == false)
|
|
|
|
@model.remove(iter)
|
|
|
|
end
|
|
|
|
end
|
2007-02-13 14:07:35 +00:00
|
|
|
|
|
|
|
# second loop to update parent iter with child iter
|
|
|
|
no_child = []
|
|
|
|
@model.each do |model, path, iter|
|
|
|
|
if (iter[ADV] == true)
|
|
|
|
no_child.push(iter) if not iter.has_child?
|
|
|
|
iter[CATEGORY] = iter[CATEGORY].sub(/[0-9]+/, iter.n_children.to_s)
|
|
|
|
end
|
|
|
|
end
|
2007-02-13 14:38:15 +00:00
|
|
|
|
|
|
|
# remove iter
|
2007-02-13 14:07:35 +00:00
|
|
|
no_child.each do |iter|
|
|
|
|
@model.remove(iter)
|
|
|
|
end
|
2007-02-13 08:48:39 +00:00
|
|
|
end
|
2007-02-13 15:26:38 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# expand the treeview
|
|
|
|
#
|
|
|
|
def expand
|
|
|
|
@treeview1.expand_all
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
end # Class MyExploitsTree
|
|
|
|
|
|
|
|
|
2007-02-26 23:19:59 +00:00
|
|
|
class MyJobTree < MyGlade
|
|
|
|
PIX, TIME, NAME, OBJECT, RHOST, REFNAME = *(0..6).to_a
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
include Msf::Ui::Gtk2::MyControls
|
|
|
|
|
2007-02-13 18:02:56 +00:00
|
|
|
def initialize(treeview)
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview2 = treeview
|
|
|
|
|
2007-02-10 22:05:54 +00:00
|
|
|
@model = Gtk::TreeStore.new(Gdk::Pixbuf, # Pix rhost
|
2007-02-11 00:04:05 +00:00
|
|
|
String, # process TIME
|
2007-02-26 23:19:59 +00:00
|
|
|
String, # exploit shortname
|
|
|
|
Object, # Exploit Object
|
|
|
|
String, # Remote host
|
|
|
|
String # exploit refname
|
2007-02-04 01:55:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Renderer
|
|
|
|
renderer_pix = Gtk::CellRendererPixbuf.new
|
2007-02-11 00:04:05 +00:00
|
|
|
renderer_time = Gtk::CellRendererText.new
|
2007-02-04 01:55:01 +00:00
|
|
|
renderer_name = Gtk::CellRendererText.new
|
|
|
|
|
2007-02-13 18:02:56 +00:00
|
|
|
# Time Gtk::TreeViewColumn
|
2007-02-11 00:04:05 +00:00
|
|
|
column_time = Gtk::TreeViewColumn.new
|
|
|
|
#column_time.set_title("rhost")
|
|
|
|
column_time.pack_start(renderer_pix, false)
|
|
|
|
column_time.set_cell_data_func(renderer_pix) do |column, cell, model, iter|
|
2007-02-04 01:55:01 +00:00
|
|
|
cell.pixbuf = iter[PIX]
|
|
|
|
end
|
2007-02-11 00:04:05 +00:00
|
|
|
column_time.pack_start(renderer_time, true)
|
|
|
|
column_time.set_cell_data_func(renderer_time) do |column, cell, model, iter|
|
|
|
|
cell.text = iter[TIME]
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-11 00:04:05 +00:00
|
|
|
column_time.sort_column_id = TIME
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Name Gtk::TreeViewColumn
|
|
|
|
column_name = Gtk::TreeViewColumn.new
|
2007-02-26 23:19:59 +00:00
|
|
|
column_name.set_title("Module")
|
2007-02-04 01:55:01 +00:00
|
|
|
column_name.pack_start(renderer_name, true)
|
|
|
|
column_name.set_cell_data_func(renderer_name) do |column, cell, model, iter|
|
|
|
|
cell.text = iter[NAME]
|
|
|
|
end
|
|
|
|
|
|
|
|
#set model to treeview
|
|
|
|
@treeview2.set_model(@model)
|
|
|
|
|
|
|
|
@selection = @treeview2.selection
|
|
|
|
@treeview2.selection.mode = Gtk::SELECTION_BROWSE
|
|
|
|
@treeview2.rules_hint = true
|
|
|
|
|
|
|
|
# Add Gtk::TreeViewColumn
|
2007-02-11 00:04:05 +00:00
|
|
|
@treeview2.append_column(column_time)
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview2.append_column(column_name)
|
|
|
|
|
|
|
|
# Add AutoPWN
|
|
|
|
@autopwn_iter = @model.append(nil)
|
|
|
|
@autopwn_iter.set_value(PIX, driver.get_icon("menu_autopwn.png"))
|
2007-02-11 00:04:05 +00:00
|
|
|
@autopwn_iter.set_value(TIME, "AutoPWN")
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Add Parent "One shot"
|
|
|
|
@oneshot_iter = @model.append(nil)
|
|
|
|
@oneshot_iter.set_value(PIX, driver.get_icon("menu_oneshot.png"))
|
2007-02-11 00:04:05 +00:00
|
|
|
@oneshot_iter.set_value(TIME, "One shot")
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-13 18:02:56 +00:00
|
|
|
# Job Gtk::Menu
|
|
|
|
@menu_job = Gtk::Menu.new
|
|
|
|
|
2007-02-27 22:32:05 +00:00
|
|
|
# Stop job
|
2007-02-13 18:02:56 +00:00
|
|
|
kill_job_item_shell = Gtk::ImageMenuItem.new("Kill Job")
|
|
|
|
kill_job_image_shell = Gtk::Image.new
|
|
|
|
kill_job_image_shell.set(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)
|
|
|
|
kill_job_item_shell.set_image(kill_job_image_shell)
|
|
|
|
@menu_job.append(kill_job_item_shell)
|
|
|
|
|
2007-02-27 22:32:05 +00:00
|
|
|
# Refresh
|
|
|
|
refresh_job_item_shell = Gtk::ImageMenuItem.new("Refresh")
|
|
|
|
refresh_job_image_shell = Gtk::Image.new
|
|
|
|
refresh_job_image_shell.set(Gtk::Stock::REFRESH, Gtk::IconSize::MENU)
|
|
|
|
refresh_job_item_shell.set_image(refresh_job_image_shell)
|
|
|
|
@menu_job.append(refresh_job_item_shell)
|
|
|
|
|
|
|
|
@menu_job.show_all
|
2007-02-13 18:02:56 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# TreeView Signals
|
|
|
|
@treeview2.signal_connect('button_press_event') do |treeview, event|
|
|
|
|
if event.kind_of? Gdk::EventButton
|
|
|
|
if (event.button == 3)
|
|
|
|
path, column, x, y = treeview.get_path_at_pos(event.x, event.y)
|
|
|
|
|
|
|
|
begin
|
|
|
|
iter = @treeview2.model.get_iter(path)
|
2007-02-13 18:02:56 +00:00
|
|
|
treeview.selection.select_path(path)
|
|
|
|
@menu_job.popup(nil, nil, event.button, event.time)
|
2007-02-04 01:55:01 +00:00
|
|
|
rescue
|
|
|
|
nil
|
2007-02-27 22:32:05 +00:00
|
|
|
#@menu_job.popup(nil, nil, event.button, event.time)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Menu Signals
|
2007-02-13 18:02:56 +00:00
|
|
|
kill_job_item_shell.signal_connect('activate') do |item|
|
2007-02-04 01:55:01 +00:00
|
|
|
if current = @selection.selected
|
2007-02-27 22:32:05 +00:00
|
|
|
stop_job(current)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
2007-02-27 22:32:05 +00:00
|
|
|
|
|
|
|
refresh_job_item_shell.signal_connect('activate') do |item|
|
|
|
|
refresh_job()
|
|
|
|
end
|
2007-02-13 18:02:56 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
end # def initialize
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add One Shot
|
|
|
|
#
|
2007-02-26 23:19:59 +00:00
|
|
|
def add_oneshot(exploit, rhost)
|
2007-02-11 00:04:05 +00:00
|
|
|
time = Time.now
|
2007-02-04 01:55:01 +00:00
|
|
|
oneshot_childiter = @model.append(@oneshot_iter)
|
|
|
|
#oneshot_childiter.set_value(PIX, nil)
|
2007-02-11 09:22:06 +00:00
|
|
|
oneshot_childiter.set_value(TIME, Time.now.strftime("%H:%m:%S"))
|
2007-02-04 01:55:01 +00:00
|
|
|
oneshot_childiter.set_value(NAME, exploit.shortname)
|
|
|
|
oneshot_childiter.set_value(OBJECT, exploit)
|
2007-02-26 23:19:59 +00:00
|
|
|
oneshot_childiter.set_value(RHOST, rhost)
|
|
|
|
oneshot_childiter.set_value(REFNAME, exploit.refname)
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview2.expand_all()
|
|
|
|
end
|
2007-02-10 22:05:54 +00:00
|
|
|
|
2007-02-27 22:32:05 +00:00
|
|
|
#
|
|
|
|
# Stop job and remove it from the job tree
|
|
|
|
#
|
|
|
|
def stop_job(iter)
|
|
|
|
framework.jobs.each_key do |i|
|
|
|
|
if (framework.jobs[i].name.split(": ")[1] == iter[REFNAME])
|
2007-02-27 22:41:03 +00:00
|
|
|
|
|
|
|
# Stopping job
|
2007-02-27 22:32:05 +00:00
|
|
|
framework.jobs.stop_job(i)
|
2007-02-27 22:41:03 +00:00
|
|
|
|
|
|
|
# Informing the user
|
|
|
|
$gtk2driver.append_log_view("[*] Stopping exploit: #{iter[REFNAME]}")
|
|
|
|
|
|
|
|
# Removing the job from the job tree
|
2007-02-27 22:32:05 +00:00
|
|
|
@model.remove(iter)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Refresh job
|
|
|
|
#
|
|
|
|
def refresh_job
|
|
|
|
puts "TODO: refresh the job tree =>"
|
|
|
|
framework.jobs.keys.sort.each do |k|
|
|
|
|
puts framework.jobs[k].name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
2007-02-26 23:19:59 +00:00
|
|
|
# Remove Target if not a passive exploit
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
2007-02-26 23:19:59 +00:00
|
|
|
def remove_job(rhost, name)
|
|
|
|
found = nil
|
|
|
|
@model.each do |model,path,iter|
|
|
|
|
if (iter[RHOST] == rhost and iter[REFNAME] == name and iter[OBJECT].passive? == false)
|
|
|
|
found = iter
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@model.remove(found) if found
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
2007-02-26 23:19:59 +00:00
|
|
|
end #class MyJobTree
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
class MySessionTree
|
2007-02-28 21:30:10 +00:00
|
|
|
ID_SESSION, PEER, PAYLOAD, O_SESSION, O_BUFFER = *(0..5).to_a
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-11 22:08:24 +00:00
|
|
|
include Msf::Ui::Gtk2::MyControls
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
def initialize(treeview)
|
|
|
|
@treeview = treeview
|
|
|
|
@model = Gtk::ListStore.new(String, # Session ID
|
|
|
|
String, # IP Address
|
|
|
|
String, # Payload Type
|
2007-02-28 21:30:10 +00:00
|
|
|
Object, # Session Object
|
2007-02-28 21:38:38 +00:00
|
|
|
Object # Gtk::TextBuffer
|
2007-02-04 01:55:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Renderer
|
2007-02-11 08:57:43 +00:00
|
|
|
renderer_id = Gtk::CellRendererText.new
|
|
|
|
renderer_peer = Gtk::CellRendererText.new
|
2007-02-04 01:55:01 +00:00
|
|
|
renderer_payload = Gtk::CellRendererText.new
|
|
|
|
|
|
|
|
# ID Session Gtk::TreeViewColumn
|
|
|
|
column_id = Gtk::TreeViewColumn.new
|
|
|
|
column_id.sizing = Gtk::TreeViewColumn::FIXED
|
|
|
|
column_id.fixed_width = 20
|
|
|
|
column_id.set_title("ID")
|
|
|
|
column_id.pack_start(renderer_id, true)
|
|
|
|
column_id.set_cell_data_func(renderer_id) do |column, cell, model, iter|
|
|
|
|
cell.text = iter[ID_SESSION]
|
|
|
|
end
|
|
|
|
column_id.sort_column_id = ID_SESSION
|
|
|
|
|
|
|
|
# Target Gtk::TreeViewColumn
|
2007-02-11 08:57:43 +00:00
|
|
|
column_peer = Gtk::TreeViewColumn.new
|
|
|
|
column_peer.set_title("Target")
|
|
|
|
column_peer.pack_start(renderer_peer, true)
|
|
|
|
column_peer.set_cell_data_func(renderer_peer) do |column, cell, model, iter|
|
2007-02-13 22:51:40 +00:00
|
|
|
cell.text = iter[PEER]
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-13 22:51:40 +00:00
|
|
|
#column_peer.sort_column_id = PEER
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Payload type Gtk::TreeViewColumn
|
|
|
|
column_payload = Gtk::TreeViewColumn.new
|
|
|
|
column_payload.set_title("Payload")
|
|
|
|
column_payload.pack_start(renderer_payload, true)
|
|
|
|
column_payload.set_cell_data_func(renderer_payload) do |column, cell, model, iter|
|
2007-02-13 22:51:40 +00:00
|
|
|
cell.text = iter[PAYLOAD]
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-13 22:51:40 +00:00
|
|
|
#column_payload.sort_column_id = PAYLOAD
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
#set model to treeview
|
|
|
|
@treeview.set_model(@model)
|
|
|
|
|
|
|
|
@selection = @treeview.selection
|
|
|
|
@treeview.selection.mode = Gtk::SELECTION_BROWSE
|
|
|
|
@treeview.rules_hint = true
|
|
|
|
|
|
|
|
# Add Gtk::TreeViewColumn
|
|
|
|
@treeview.append_column(column_id)
|
2007-02-11 08:57:43 +00:00
|
|
|
@treeview.append_column(column_peer)
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview.append_column(column_payload)
|
|
|
|
|
|
|
|
# Session Gtk::Menu
|
|
|
|
@menu_session = Gtk::Menu.new
|
|
|
|
|
2007-02-11 08:57:43 +00:00
|
|
|
session_item_shell = Gtk::ImageMenuItem.new("Interact Session")
|
2007-02-04 01:55:01 +00:00
|
|
|
session_image_shell = Gtk::Image.new
|
|
|
|
session_image_shell.set(Gtk::Stock::EXECUTE, Gtk::IconSize::MENU)
|
|
|
|
session_item_shell.set_image(session_image_shell)
|
|
|
|
@menu_session.append(session_item_shell)
|
|
|
|
|
|
|
|
separator1 = Gtk::SeparatorMenuItem.new
|
|
|
|
@menu_session.append(separator1)
|
|
|
|
|
2007-02-11 22:08:24 +00:00
|
|
|
close_session_item_shell = Gtk::ImageMenuItem.new("Close Session")
|
|
|
|
close_session_image_shell = Gtk::Image.new
|
|
|
|
close_session_image_shell.set(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)
|
|
|
|
close_session_item_shell.set_image(close_session_image_shell)
|
2007-04-22 00:02:51 +00:00
|
|
|
@menu_session.append(close_session_item_shell)
|
|
|
|
|
|
|
|
separator2 = Gtk::SeparatorMenuItem.new
|
|
|
|
@menu_session.append(separator2)
|
|
|
|
|
|
|
|
meterpreter_proc_item_shell = Gtk::ImageMenuItem.new("Process")
|
|
|
|
meterpreter_proc_image_shell = Gtk::Image.new
|
|
|
|
meterpreter_proc_image_shell.set(Gtk::Stock::CLOSE, Gtk::IconSize::MENU)
|
|
|
|
meterpreter_proc_item_shell.set_image(meterpreter_proc_image_shell)
|
|
|
|
@menu_session.append(meterpreter_proc_item_shell)
|
2007-02-11 22:08:24 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
@menu_session.show_all
|
|
|
|
|
|
|
|
# TreeView signals
|
|
|
|
@treeview.signal_connect('button_press_event') do |treeview, event|
|
|
|
|
if event.kind_of? Gdk::EventButton
|
|
|
|
if (event.button == 3)
|
|
|
|
path, column, x, y = treeview.get_path_at_pos(event.x, event.y)
|
|
|
|
|
|
|
|
begin
|
|
|
|
iter = @treeview.model.get_iter(path)
|
|
|
|
treeview.selection.select_path(path)
|
|
|
|
@menu_session.popup(nil, nil, event.button, event.time)
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2007-02-13 19:56:19 +00:00
|
|
|
elsif (event.event_type == Gdk::Event::BUTTON2_PRESS)
|
|
|
|
path, column, x, y = treeview.get_path_at_pos(event.x, event.y)
|
|
|
|
begin
|
|
|
|
iter = @treeview.model.get_iter(path)
|
|
|
|
treeview.selection.select_path(path)
|
2007-02-28 21:38:38 +00:00
|
|
|
open_session(iter)
|
2007-02-13 19:56:19 +00:00
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Items session signals
|
|
|
|
session_item_shell.signal_connect('activate') do |item|
|
|
|
|
if current = @selection.selected
|
2007-02-28 21:38:38 +00:00
|
|
|
open_session(current)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-11 22:08:24 +00:00
|
|
|
close_session_item_shell.signal_connect('activate') do |item|
|
|
|
|
if session_iter = @selection.selected
|
2007-02-12 00:20:06 +00:00
|
|
|
remove_session_iter(session_iter)
|
2007-02-11 22:08:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-04-22 00:02:51 +00:00
|
|
|
meterpreter_proc_item_shell.signal_connect('activate') do |item|
|
|
|
|
if current = @selection.selected
|
|
|
|
print current[O_SESSION].tunnel_peer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
end # def initialize
|
|
|
|
|
2007-02-15 22:09:24 +00:00
|
|
|
#
|
2007-02-13 22:51:40 +00:00
|
|
|
# Add an iter to the session treeview
|
2007-02-15 22:09:24 +00:00
|
|
|
#
|
|
|
|
def add_session(session)
|
2007-02-04 01:55:01 +00:00
|
|
|
iter = @model.append
|
|
|
|
iter[ID_SESSION] = session.sid.to_s
|
2007-02-13 22:51:40 +00:00
|
|
|
iter[PEER] = session.tunnel_peer
|
|
|
|
iter[PAYLOAD] = session.via_payload ? session.via_payload : nil
|
|
|
|
iter[O_SESSION] = session
|
2007-02-28 21:30:10 +00:00
|
|
|
iter[O_BUFFER] = Gtk::TextBuffer.new
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-11 22:08:24 +00:00
|
|
|
|
2007-02-28 21:38:38 +00:00
|
|
|
#
|
|
|
|
# Open the session with the selected iter
|
|
|
|
#
|
|
|
|
def open_session(iter)
|
2007-04-22 00:02:51 +00:00
|
|
|
session = iter[O_SESSION]
|
|
|
|
if (session.type == "meterpreter")
|
|
|
|
Msf::Ui::Gtk2::Console::Meterpreter.new(iter)
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
#Msf::Ui::Gtk2::Console::Basic.new(iter)
|
|
|
|
end
|
2007-02-28 21:38:38 +00:00
|
|
|
end
|
|
|
|
|
2007-02-11 22:08:24 +00:00
|
|
|
#
|
2007-02-12 00:20:06 +00:00
|
|
|
# Kill the session associated with this item
|
2007-02-28 21:38:38 +00:00
|
|
|
# TODO: Bug on the sesson kill
|
2007-02-11 22:08:24 +00:00
|
|
|
#
|
2007-02-11 23:32:01 +00:00
|
|
|
def remove_session_iter(iter)
|
2007-02-12 00:21:52 +00:00
|
|
|
# Just kill the session, let the event handler remove it
|
2007-02-12 00:20:06 +00:00
|
|
|
iter[O_SESSION].kill
|
2007-02-11 23:32:01 +00:00
|
|
|
end
|
|
|
|
|
2007-02-12 00:20:06 +00:00
|
|
|
#
|
2007-02-12 00:21:52 +00:00
|
|
|
# Remove the item from the model
|
|
|
|
# This is called by the framework on_session_close()
|
2007-02-12 00:20:06 +00:00
|
|
|
#
|
|
|
|
def remove_session(session)
|
|
|
|
found = nil
|
|
|
|
@model.each do |model,path,iter|
|
|
|
|
if (iter[ID_SESSION] == session.sid.to_s)
|
|
|
|
found = iter
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@model.remove(found) if found
|
2007-02-11 22:08:24 +00:00
|
|
|
end
|
2007-02-28 21:30:10 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
end # class MySessionTree
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2007-02-11 08:57:43 +00:00
|
|
|
end
|