- Perform a match IP address for MyOneShot (Gtk::Dialog) and a Gtk::Label warning
git-svn-id: file:///home/svn/framework3/trunk@4333 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
c8dc150cc9
commit
4a875fa468
|
@ -626,7 +626,7 @@
|
|||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
|
@ -672,9 +672,34 @@
|
|||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="warning">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">5</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
|
|
|
@ -5,30 +5,67 @@ module Gtk2
|
|||
##
|
||||
# This class perform a little dialog for the target oneshot
|
||||
#
|
||||
# TODO:
|
||||
# - Add regexp to control the format address IP
|
||||
##
|
||||
class MyOneShot < MyGlade
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
def initialize(tree_target, exploit)
|
||||
#
|
||||
# Init the dialog shot
|
||||
# Options: entry and warning
|
||||
#
|
||||
def initialize(tree_target, exploit, entry = "", warning = "")
|
||||
super('dialog_oneshot')
|
||||
@tree_target = tree_target
|
||||
#puts exploit.get_value(1).fullname
|
||||
@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}
|
||||
|
||||
@dialog_oneshot.default_response = Gtk::Dialog::RESPONSE_OK
|
||||
@dialog_oneshot.set_response_sensitive(Gtk::Dialog::RESPONSE_OK, true)
|
||||
if @dialog_oneshot.run == Gtk::Dialog::RESPONSE_OK
|
||||
@tree_target.add_oneshot(@rhost_entry.text, exploit.get_value(1))
|
||||
# If entry supplied, set the Gtk::Entry
|
||||
if entry
|
||||
@rhost_entry.set_text(entry)
|
||||
end
|
||||
|
||||
@dialog_oneshot.destroy
|
||||
end
|
||||
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
|
||||
|
@ -36,7 +73,6 @@ end
|
|||
# TODO:
|
||||
# - Add the passive options on the first page (hdm)
|
||||
##
|
||||
|
||||
class MsfAssistant
|
||||
attr_accessor :input
|
||||
attr_accessor :output
|
||||
|
|
Loading…
Reference in New Issue