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
|
|
|
|
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-11 00:04:05 +00:00
|
|
|
def initialize(treeview, viewmodule, treetarget, treesession)
|
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-11 00:04:05 +00:00
|
|
|
@target_tree = treetarget
|
2007-02-10 22:05:54 +00:00
|
|
|
@session_tree = treesession
|
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-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-02-04 19:30:49 +00:00
|
|
|
if (iter.get_value(APP) == "Standard")
|
|
|
|
treeview.selection.select_path(path)
|
|
|
|
active(iter)
|
|
|
|
@menu_module.popup(nil, nil, event.button, event.time)
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: Add specific menus for :
|
|
|
|
# - payload
|
|
|
|
# - auxiliary
|
|
|
|
# - nops
|
|
|
|
# - encoders
|
|
|
|
|
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)
|
|
|
|
MsfAssistant.new(@session_tree, iter.get_value(1))
|
|
|
|
end
|
|
|
|
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-02-11 00:04:05 +00:00
|
|
|
MsfAssistant.new(@session_tree, @target_tree, active_module.get_value(MODULE))
|
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-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
|
|
|
@m_tree_modules_items = {}
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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)
|
|
|
|
child_iter = @model.append(iter)
|
|
|
|
child_iter.set_value(CATEGORY, obj.new.name)
|
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-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)
|
|
|
|
child_iter = @model.append(iter)
|
|
|
|
child_iter.set_value(CATEGORY, obj.new.name)
|
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-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)
|
|
|
|
|
|
|
|
# Add Payloads childs
|
|
|
|
framework.payloads.each_module do |mod, obj|
|
|
|
|
next if not mod.match(filter)
|
|
|
|
child_iter = @model.append(iter)
|
|
|
|
child_iter.set_value(CATEGORY, obj.new.name)
|
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-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)
|
|
|
|
child_iter = @model.append(iter)
|
|
|
|
child_iter.set_value(CATEGORY, obj.new.name)
|
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-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)
|
|
|
|
child_iter = @model.append(iter)
|
|
|
|
child_iter.set_value(CATEGORY, obj.new.name)
|
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-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
|
|
|
|
|
|
|
def refresh
|
|
|
|
@model.clear()
|
|
|
|
add_modules()
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
end # Class MyExploitsTree
|
|
|
|
|
|
|
|
|
|
|
|
class MyTargetTree < MyGlade
|
2007-02-11 00:04:05 +00:00
|
|
|
PIX, TIME, PID, NAME, OBJECT = *(0..5).to_a
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
include Msf::Ui::Gtk2::MyControls
|
|
|
|
|
2007-02-04 23:33:27 +00:00
|
|
|
def initialize(treeview, session_tree)
|
2007-02-10 22:05:54 +00:00
|
|
|
super('menu_target_tree')
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
@treeview2 = treeview
|
|
|
|
@session_tree = session_tree
|
|
|
|
|
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
|
|
|
|
String, # process PID
|
2007-02-04 01:55:01 +00:00
|
|
|
String, # exploit refname
|
2007-02-10 22:05:54 +00:00
|
|
|
Object # Exploit Object
|
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
|
|
|
|
renderer_pid = Gtk::CellRendererText.new
|
2007-02-04 01:55:01 +00:00
|
|
|
renderer_name = Gtk::CellRendererText.new
|
|
|
|
|
2007-02-10 22:05:54 +00:00
|
|
|
# RHOST 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
|
|
|
|
2007-02-11 00:04:05 +00:00
|
|
|
# PID Gtk::TreeViewColumn
|
|
|
|
column_pid = Gtk::TreeViewColumn.new
|
|
|
|
column_pid.sizing = Gtk::TreeViewColumn::FIXED
|
|
|
|
column_pid.fixed_width = 25
|
|
|
|
column_pid.set_title("PID")
|
|
|
|
column_pid.pack_start(renderer_pid, false)
|
|
|
|
column_pid.set_cell_data_func(renderer_pid) do |column, cell, model, iter|
|
|
|
|
cell.text = iter[PID]
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Name Gtk::TreeViewColumn
|
|
|
|
column_name = Gtk::TreeViewColumn.new
|
|
|
|
column_name.set_title("Name")
|
|
|
|
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)
|
|
|
|
@treeview2.append_column(column_pid)
|
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
|
|
|
|
|
|
|
# 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-11 00:04:05 +00:00
|
|
|
if iter.get_value(PIX).nil? && iter.get_value(PID).nil?
|
2007-02-04 01:55:01 +00:00
|
|
|
treeview.selection.select_path(path)
|
2007-02-10 22:05:54 +00:00
|
|
|
@menu_targetree.popup(nil, nil, event.button, event.time)
|
2007-02-11 00:04:05 +00:00
|
|
|
elsif not iter.get_value(PID).nil?
|
2007-02-04 01:55:01 +00:00
|
|
|
treeview.selection.select_path(path)
|
2007-02-10 22:05:54 +00:00
|
|
|
nil
|
|
|
|
# @menu_owned.popup(nil, nil, event.button, event.time)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Menu Signals
|
2007-02-10 22:05:54 +00:00
|
|
|
@stop.signal_connect('activate') do |item|
|
2007-02-04 01:55:01 +00:00
|
|
|
if current = @selection.selected
|
2007-02-10 22:05:54 +00:00
|
|
|
puts "TODO: Kill exploit"
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@delete.signal_connect('activate') do |item|
|
|
|
|
if current = @selection.selected
|
2007-02-11 00:04:05 +00:00
|
|
|
remove_time(current)
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end # def initialize
|
|
|
|
|
|
|
|
#
|
|
|
|
# Add One Shot
|
|
|
|
#
|
2007-02-11 00:04:05 +00:00
|
|
|
def add_oneshot(exploit)
|
|
|
|
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-11 00:04:05 +00:00
|
|
|
oneshot_childiter.set_value(PID, Process::pid.to_s)
|
2007-02-04 01:55:01 +00:00
|
|
|
oneshot_childiter.set_value(NAME, exploit.shortname)
|
|
|
|
oneshot_childiter.set_value(OBJECT, exploit)
|
|
|
|
@treeview2.expand_all()
|
|
|
|
end
|
2007-02-10 22:05:54 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
|
|
|
# Remove Target
|
|
|
|
#
|
2007-02-11 00:04:05 +00:00
|
|
|
def remove_time(iter)
|
2007-02-04 01:55:01 +00:00
|
|
|
@treeview2.model.remove(iter)
|
|
|
|
end
|
|
|
|
|
|
|
|
end #class MyTargetTree
|
|
|
|
|
|
|
|
class MySessionTree
|
2007-02-11 08:57:43 +00:00
|
|
|
ID_SESSION, PEER, PAYLOAD, O_SESSION, BUFFER, PIPE, INPUT, OUTPUT = *(0..8).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
|
|
|
|
Object, # Session Object
|
|
|
|
Object, # Gtk::TextBuffer Object
|
2007-02-05 22:36:43 +00:00
|
|
|
Object, # Bidirectional_pipe
|
2007-02-04 01:55:01 +00:00
|
|
|
Object, # Input Object
|
|
|
|
Object # Output Object
|
|
|
|
)
|
|
|
|
|
|
|
|
# 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|
|
|
|
|
cell.text = iter[O_SESSION].tunnel_peer
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-11 08:57:43 +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-11 08:57:43 +00:00
|
|
|
cell.text = iter[O_SESSION].via_payload ? iter[O_SESSION].via_payload : nil
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
column_payload.sort_column_id = PAYLOAD
|
|
|
|
|
|
|
|
#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)
|
|
|
|
@menu_session.append(close_session_item_shell)
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Items session signals
|
|
|
|
session_item_shell.signal_connect('activate') do |item|
|
|
|
|
if current = @selection.selected
|
2007-02-11 08:57:43 +00:00
|
|
|
Msf::Ui::Gtk2::Stream::Console.new(current[O_SESSION])
|
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-11 23:32:01 +00:00
|
|
|
remove_session(session_iter)
|
2007-02-11 22:08:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
end # def initialize
|
|
|
|
|
2007-02-11 08:57:43 +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-11 08:57:43 +00:00
|
|
|
iter[O_SESSION] = session
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-11 22:08:24 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Remove the session when receive the on_session_close from framework_event_manager
|
|
|
|
#
|
2007-02-11 23:32:01 +00:00
|
|
|
def remove_session_iter(iter)
|
|
|
|
session.interacting = false if session.interactive?
|
|
|
|
framework.events.on_session_close(iter[O_SESSION])
|
|
|
|
remove_session(iter)
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_session(iter)
|
|
|
|
@model.remove(iter)
|
2007-02-11 22:08:24 +00:00
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
end # class MySessionTree
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2007-02-11 08:57:43 +00:00
|
|
|
end
|