Make the Exploit::Local class useful

This commit is the main infrastructure needed to run exploits in a local
context, gluing the Exploit and Post module classes together.
unstable
James Lee 2012-05-17 16:13:25 -06:00
parent 3902ed431e
commit 5717f52246
2 changed files with 46 additions and 26 deletions

View File

@ -1,5 +1,6 @@
require 'msf/core' require 'msf/core'
require 'msf/core/module' require 'msf/core/module'
require 'msf/core/post'
module Msf module Msf
@ -137,6 +138,7 @@ class Exploit < Msf::Module
# #
### ###
class Local < Exploit class Local < Exploit
include PostMixin
# #
# Returns the fact that this exploit is a local exploit. # Returns the fact that this exploit is a local exploit.

View File

@ -2,19 +2,16 @@ require 'msf/core'
require 'msf/core/module' require 'msf/core/module'
module Msf module Msf
class Post < Msf::Module
#
# A mixin used for providing Modules with post-exploitation options and helper methods
#
module PostMixin
include Msf::Auxiliary::Report include Msf::Auxiliary::Report
include Msf::Module::HasActions include Msf::Module::HasActions
def self.type
MODULE_POST
end
def type
MODULE_POST
end
def initialize(info={}) def initialize(info={})
super super
@ -31,13 +28,16 @@ class Post < Msf::Module
# if one doesn't exist. Initializes user input and output on the session. # if one doesn't exist. Initializes user input and output on the session.
# #
def setup def setup
@sysinfo = nil
if not session if not session
raise Msf::OptionValidateError.new(["SESSION"]) raise Msf::OptionValidateError.new(["SESSION"])
end end
super
check_for_session_readiness() if session.type == "meterpreter" check_for_session_readiness() if session.type == "meterpreter"
@session.init_ui(self.user_input, self.user_output) @session.init_ui(self.user_input, self.user_output)
@sysinfo = nil
end end
# Meterpreter sometimes needs a little bit of extra time to # Meterpreter sometimes needs a little bit of extra time to
@ -114,23 +114,6 @@ class Post < Msf::Module
sessions sessions
end end
#
# Create an anonymous module not tied to a file. Only useful for IRB.
#
def self.create(session)
mod = new
mod.instance_variable_set(:@session, session)
# Have to override inspect because for whatever reason, +type+ is coming
# from the wrong scope and i can't figure out how to fix it.
mod.instance_eval do
def inspect
"#<Msf::Post anonymous>"
end
end
mod.class.refname = "anonymous"
mod
end
# #
# Return false if the given session is not compatible with this module # Return false if the given session is not compatible with this module
@ -219,5 +202,40 @@ protected
end end
end end
end end
#
# A Post-exploitation module
#
#
class Post < Msf::Module
include PostMixin
def type
MODULE_POST
end
def self.type
MODULE_POST
end
#
# Create an anonymous module not tied to a file. Only useful for IRB.
#
def self.create(session)
mod = new
mod.instance_variable_set(:@session, session)
# Have to override inspect because for whatever reason, +type+ is coming
# from the wrong scope and i can't figure out how to fix it.
mod.instance_eval do
def inspect
"#<Msf::Post anonymous>"
end
end
mod.class.refname = "anonymous"
mod
end
end
end end