More UI updates

git-svn-id: file:///home/svn/framework3/trunk@5293 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2008-01-20 22:40:11 +00:00
parent c07105c70a
commit 289d280291
13 changed files with 235 additions and 24 deletions

View File

@ -689,6 +689,14 @@
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="view_code">
<property name="visible">True</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -44,9 +44,9 @@ module Interactive
#
def tunnel_peer
begin
rstream.peerinfo
@peer_info = rstream.peerinfo
rescue
framework.sessions.deregister(self)
@peer_info
end
end

View File

@ -26,7 +26,7 @@ module Msf
["Select your options", "option", true, true, true, false],
],
['Review',
["Check your review", "end", true, true, true, true],
["Confirm settings", "end", true, true, true, true],
],
].collect do |item, state|
WIZARD2[item] = WizardStruct2.new(

View File

@ -34,7 +34,7 @@ module Msf
["Select your options", "option", true, true, true, false],
],
['Review',
["Check your review", "end", true, true, true, true],
["Confirm settings", "end", true, true, true, true],
],
].collect do |item, state|
WIZARD[item] = WizardStruct.new(
@ -329,13 +329,28 @@ module Msf
@options_evasion.remove(widget)
end
# Pack
self.main.pack_start(@options_required, false, false, 10)
# TODO: Display temporaly desactived
# Pack
#self.main.pack_start(@options_required, false, false, 10)
#self.main.pack_start(@frame_advanced, false, false, 10)
#self.main.pack_start(@frame_evasion, false, false, 10)
scrl = Gtk::ScrolledWindow.new
scrl.shadow_type = Gtk::SHADOW_NONE
scrl.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
vscr = Gtk::VBox.new
vscr.pack_start(@options_required, false, false, 10)
vscr.pack_start(@frame_advanced, false, false, 10)
vscr.pack_start(@frame_evasion, false, false, 10)
scrl.add_with_viewport(vscr)
self.main.pack_start(scrl, false, false, 20)
# Payload options
@mydriver.payload = framework.payloads.create(@hash["PAYLOAD"])

View File

@ -18,8 +18,9 @@ module Msf
def initialize(title)
super()
self.resizable = false
self.set_default_size(600, 400)
self.set_window_position(Gtk::Window::POS_CENTER)
self.title = title
self.set_border_width(1)
# First page
@page = "intro"
@ -42,8 +43,8 @@ module Msf
@vbox_left.pack_start(create_save(), false, false, 5)
# Main frame
@main = Gtk::VBox.new(false, 5)
@hbox.pack_start(@main, true, true, 5)
@main = Gtk::VBox.new(false, 10)
@hbox.pack_start(@main, true, true, 10)
# Separator
separator = Gtk::HSeparator.new

View File

@ -0,0 +1,38 @@
module Msf
module Ui
module Gtk2
class MsfDialog
##
# Display an error Gtk style
# parent: the Gtk parent widget
# title: the error title
# message: the error
##
class Confirm < Msf::Ui::Gtk2::SkeletonAlert
def initialize(parent, title, message=nil)
super(parent, title, Gtk::Stock::DIALOG_WARNING,
[
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
[Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK]
],
message
)
self.default_response = Gtk::Dialog::RESPONSE_CANCEL
signal_connect("response") do |dialog,res_id|
if(res_id == Gtk::Dialog::RESPONSE_OK)
yield()
end
end
show_all and run
destroy
end
end
end
end
end
end

View File

@ -8,3 +8,4 @@ require 'msf/ui/gtk2/dialog/payload'
require 'msf/ui/gtk2/dialog/error'
require 'msf/ui/gtk2/dialog/warning'
require 'msf/ui/gtk2/dialog/information'
require 'msf/ui/gtk2/dialog/confirm'

View File

@ -139,6 +139,18 @@ module Gtk2
end
end
@view_code.signal_connect('activate') do |item|
if active_module = @selection.selected
type = active_module.get_value(TYPE)
if (type == EXP or type == AUX)
MsfWindow::CodeView.new(active_module.get_value(MOD))
elsif (type == DIR)
# Ignore
else
MsfDialog::Error.new($gtk2driver.main, "Not available")
end
end
end
# Add modules in the Gtk::TreeView
add_modules()
@ -178,6 +190,32 @@ module Gtk2
end
end
#
# Prune empty module directories from the hash
#
def prune_hash(key, hash)
cnt = 0
hash.keys.each do |k|
if(hash[k].class != ::Hash)
cnt += 1
next
end
num = prune_hash(k, hash[k])
if (num == 0)
hash.delete(k)
end
cnt += num
end
# $stdout.puts "#{key} == #{cnt}"
cnt
end
#
# Add Exploits module in the treeview
#
@ -194,9 +232,19 @@ module Gtk2
ref = ref[part]
end
ref[name] = obj.new
ins = obj.new
if (
mod =~ filter or
ins.name =~ filter or
ins.description.gsub(/\s+/, " ") =~ filter or
ins.author_to_s =~ filter or
ins.references.map {|x| x.to_s}.join(" ") =~ filter
)
ref[name] = obj.new
end
end
prune_hash("exploits", mod_exploits)
mod_auxiliary = {}
framework.auxiliary.each_module do |mod, obj|
@ -208,9 +256,21 @@ module Gtk2
ref = ref[part]
end
ref[name] = obj.new
ins = obj.new
if (
mod =~ filter or
ins.name =~ filter or
ins.description.gsub(/\s+/, " ") =~ filter or
ins.author_to_s =~ filter or
ins.references.map {|x| x.to_s}.join(" ") =~ filter
)
ref[name] = obj.new
end
end
prune_hash("auxiliary", mod_auxiliary)
add_modules_to_store(
@model, nil, "Exploits", mod_exploits,
{
@ -233,7 +293,6 @@ module Gtk2
}
)
#
# TODO: To implement later ...
#
@ -307,9 +366,9 @@ module Gtk2
#
# Refresh the module treeview with all msf modules
#
def refresh
def refresh(filter=/.*/)
@model.clear()
add_modules()
add_modules(filter)
end
#

View File

@ -58,6 +58,10 @@ module Msf
found = []
filter = Regexp.new(text, Regexp::IGNORECASE)
$gtk2driver.module_tree.refresh(filter)
$gtk2driver.module_tree.expand
return
i_type = Msf::Ui::Gtk2::MyModuleTree::TYPE
i_type_dir = Msf::Ui::Gtk2::MyModuleTree::DIR
i_desc = Msf::Ui::Gtk2::MyModuleTree::DESC

View File

@ -1,5 +1,4 @@
require 'msf/ui/gtk2/window/logs'
require 'msf/ui/gtk2/window/auxiliary'
require 'msf/ui/gtk2/window/consoles'
require 'msf/ui/gtk2/window/codeview'

View File

@ -0,0 +1,55 @@
module Msf
module Ui
module Gtk2
class MsfWindow
#
# This class performs a Gtk::Window to display logs from framework
#
class CodeView < Msf::Ui::Gtk2::SkeletonBasic
include Msf::Ui::Gtk2::MyControls
def initialize(m)
# call the parent
super("Source Code of #{m.type.capitalize} #{m.refname}")
# Define the size and border
set_default_size(600, 480)
set_border_width(10)
# Main hbox
vbox = Gtk::VBox.new(false, 0)
add(vbox)
textview = Gtk::TextView.new
textview.set_editable(false)
sw = Gtk::ScrolledWindow.new()
sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
vbox.pack_start(sw, true, true, 0)
sw.add(textview)
buff = textview.buffer
fixr = buff.create_tag("fixr",
{
"font" => "Courier"
}
)
buff.insert(buff.end_iter, File.read(m.file_path), "fixr")
show_all
end
end
end
end
end
end

View File

@ -13,6 +13,7 @@ class MsfWindow
attr_accessor :input, :prompt
attr_accessor :pipe, :console
attr_accessor :console_thread, :reader_thread
attr_accessor :console_window
class MyPipe < Rex::IO::BidirectionalPipe
def prompting?
@ -126,10 +127,14 @@ class MsfWindow
self.output.buffer.text = ""
self.history = []
self.hindex = 0
when 'irb'
skip = true
end
self.history.push(line)
self.hindex = self.history.length - 1
self.output.append_output(self.output.prompt.text) if not self.output.console.busy
self.output.append_output(line + "\n")
self.output.pipe.write_input(line+"\n") if not skip
obj.text = ''
@ -138,6 +143,27 @@ class MsfWindow
self.signal_connect('key-press-event') do |obj, key|
case key.keyval
when "c"[0]
if (key.state.name == "GDK_CONTROL_MASK")
if(self.output.console.active_session)
MsfDialog::Confirm.new(self.output.console_window, "Close Session", "Close this session?") {
self.output.append_output("\n[*] Closing session...\n")
self.output.console.active_session.kill()
}
end
true
end
when "z"[0]
if (key.state.name == "GDK_CONTROL_MASK")
if(self.output.console.active_session)
MsfDialog::Confirm.new(self.output.console_window, "Suspend Session", "Suspend this session?") {
self.output.append_output("\n[*] Suspending session...\n")
self.output.console.active_session.detach()
}
end
true
end
when Gdk::Keyval::GDK_Up
if history.length > 0
self.text = history[hindex]
@ -247,6 +273,8 @@ class MsfWindow
scrl = Gtk::ScrolledWindow.new
text = ConsoleOutput.new
text.console_window = self
text.editable = false
text.accepts_tab = false
scrl.add(text)
@ -267,7 +295,6 @@ class MsfWindow
input = MyInput.new(text)
input.set_size_request(-1, 25)
input.has_frame = false
input.focus = true
text.prompt = prompt
@ -285,6 +312,7 @@ class MsfWindow
tab.set_page(tab.page_num(vbox))
input.can_focus = true
input.has_focus = true
input.focus = true
label_btn.signal_connect("clicked") do |obj|
idx = tab.page_num(vbox)
@ -316,6 +344,9 @@ class MsfWindow
hbox = Gtk::HBox.new
btn = Gtk::Button.new("New Console")
btn.set_image(Gtk::Image.new(Gtk::Stock::NEW, Gtk::IconSize::MENU))
btn.relief = Gtk::RELIEF_NONE
hbox.add(btn)
vbox.pack_start(hbox, false, false, 0)