From 797badb271f0f53d6a1e2e956293c3ccd746c0b7 Mon Sep 17 00:00:00 2001 From: fab <> Date: Mon, 26 Feb 2007 23:19:59 +0000 Subject: [PATCH] add remove job after framework_event_manager opened a session only if exploit.passive? return fase rename MyTargetTree by MyJobTree and all the attr_accessor reference git-svn-id: file:///home/svn/framework3/trunk@4479 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/ui/gtk2/app.rb | 4 +-- lib/msf/ui/gtk2/dialogs.rb | 4 +-- lib/msf/ui/gtk2/driver.rb | 2 +- lib/msf/ui/gtk2/frame.rb | 32 +++++++++++++++------- lib/msf/ui/gtk2/framework_event_manager.rb | 4 +++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lib/msf/ui/gtk2/app.rb b/lib/msf/ui/gtk2/app.rb index 631bf856ca..eda8264717 100644 --- a/lib/msf/ui/gtk2/app.rb +++ b/lib/msf/ui/gtk2/app.rb @@ -64,14 +64,14 @@ class MyApp < MyGlade @session_tree = MySessionTree.new(@treeview_session) # Target Tree - @target_tree = MyTargetTree.new(@treeview2) + @job_tree = MyJobTree.new(@treeview2) # Module Tree @module_tree = MyModuleTree.new(@treeview1, @viewmodule) # Configure the window handles for easy reference $gtk2driver.session_tree = @session_tree - $gtk2driver.target_tree = @target_tree + $gtk2driver.job_tree = @job_tree $gtk2driver.module_tree = @module_tree $gtk2driver.log_text = @viewlogs diff --git a/lib/msf/ui/gtk2/dialogs.rb b/lib/msf/ui/gtk2/dialogs.rb index bb879d4489..96db5b92b8 100644 --- a/lib/msf/ui/gtk2/dialogs.rb +++ b/lib/msf/ui/gtk2/dialogs.rb @@ -17,7 +17,7 @@ class MsfAssistant def initialize(active_module) @session_tree = $gtk2driver.session_tree - @target_tree = $gtk2driver.target_tree + @job_tree = $gtk2driver.job_tree @active_module = active_module # initialize exploit driver's exploit instance @@ -338,7 +338,7 @@ class MsfAssistant begin @mydriver.run - @target_tree.add_oneshot(@active_module) + @job_tree.add_oneshot(@active_module, @hash["RHOST"]) rescue ::Exception => e @pipe.print_error("Exploit failed: #{e}") end diff --git a/lib/msf/ui/gtk2/driver.rb b/lib/msf/ui/gtk2/driver.rb index 4b3a208342..8bdd7106d4 100644 --- a/lib/msf/ui/gtk2/driver.rb +++ b/lib/msf/ui/gtk2/driver.rb @@ -25,7 +25,7 @@ module Gtk2 ### class Driver < Msf::Ui::Driver - attr_accessor :session_tree, :module_tree, :target_tree, :log_text, :module_model + attr_accessor :session_tree, :module_tree, :job_tree, :log_text, :module_model attr_accessor :module_completion include Msf::Ui::Gtk2::FrameworkEventManager diff --git a/lib/msf/ui/gtk2/frame.rb b/lib/msf/ui/gtk2/frame.rb index bc17e68e35..851911e71a 100644 --- a/lib/msf/ui/gtk2/frame.rb +++ b/lib/msf/ui/gtk2/frame.rb @@ -264,8 +264,8 @@ class MyModuleTree < MyGlade end # Class MyExploitsTree -class MyTargetTree < MyGlade - PIX, TIME, NAME, OBJECT = *(0..4).to_a +class MyJobTree < MyGlade + PIX, TIME, NAME, OBJECT, RHOST, REFNAME = *(0..6).to_a include Msf::Ui::Gtk2::MyControls @@ -274,8 +274,10 @@ class MyTargetTree < MyGlade @model = Gtk::TreeStore.new(Gdk::Pixbuf, # Pix rhost String, # process TIME - String, # exploit refname - Object # Exploit Object + String, # exploit shortname + Object, # Exploit Object + String, # Remote host + String # exploit refname ) # Renderer @@ -298,7 +300,7 @@ class MyTargetTree < MyGlade # Name Gtk::TreeViewColumn column_name = Gtk::TreeViewColumn.new - column_name.set_title("Payload") + column_name.set_title("Module") column_name.pack_start(renderer_name, true) column_name.set_cell_data_func(renderer_name) do |column, cell, model, iter| cell.text = iter[NAME] @@ -365,24 +367,34 @@ class MyTargetTree < MyGlade # # Add One Shot # - def add_oneshot(exploit) + def add_oneshot(exploit, rhost) time = Time.now oneshot_childiter = @model.append(@oneshot_iter) #oneshot_childiter.set_value(PIX, nil) oneshot_childiter.set_value(TIME, Time.now.strftime("%H:%m:%S")) oneshot_childiter.set_value(NAME, exploit.shortname) oneshot_childiter.set_value(OBJECT, exploit) + oneshot_childiter.set_value(RHOST, rhost) + oneshot_childiter.set_value(REFNAME, exploit.refname) @treeview2.expand_all() end # - # Remove Target + # Remove Target if not a passive exploit # - def remove_target(iter) - @treeview2.model.remove(iter) + 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 end -end #class MyTargetTree +end #class MyJobTree class MySessionTree ID_SESSION, PEER, PAYLOAD, O_SESSION = *(0..4).to_a diff --git a/lib/msf/ui/gtk2/framework_event_manager.rb b/lib/msf/ui/gtk2/framework_event_manager.rb index 482f9ab3d9..c2a0334a70 100644 --- a/lib/msf/ui/gtk2/framework_event_manager.rb +++ b/lib/msf/ui/gtk2/framework_event_manager.rb @@ -33,6 +33,10 @@ module FrameworkEventManager $gtk2driver.append_log_view("[*] Session #{session.sid} created for #{session.tunnel_peer}\n") Msf::Ui::Gtk2::Stream::Session.new($gtk2driver.session_tree, session) + # remove job if not a passive exploit + rhost = session.tunnel_peer.split(':')[0] + $gtk2driver.job_tree.remove_job(rhost, session.via_exploit) + if (Msf::Logging.session_logging_enabled? == true) Msf::Logging.start_session_log(session) end