From 1351af830066f1071e78f01f7f65269c53087250 Mon Sep 17 00:00:00 2001 From: James Lee Date: Mon, 27 Dec 2010 17:56:29 +0000 Subject: [PATCH] missed file. =( git-svn-id: file:///home/svn/framework3/trunk@11422 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/post.rb | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lib/msf/core/post.rb diff --git a/lib/msf/core/post.rb b/lib/msf/core/post.rb new file mode 100644 index 0000000000..1fd779d21c --- /dev/null +++ b/lib/msf/core/post.rb @@ -0,0 +1,90 @@ +require 'msf/core' +require 'msf/core/module' + +module Msf +class Post < Msf::Module + + include Msf::Auxiliary::Report + + def self.type + MODULE_POST + end + def type + MODULE_POST + end + + def initialize(info={}) + super + + register_options( [ + OptInt.new('SESSION', [ true, "The session to run this module on." ]) + ] , Msf::Post) + end + + def setup + @sysinfo = nil + @session = framework.sessions[datastore["SESSION"].to_i] + @session ||= framework.sessions[datastore["SESSION"].to_s] + if not @session + raise Msf::OptionValidateError.new(["SESSION"]) + end + @session.init_ui(self.user_input, self.user_output) + end + + # + # Default cleanup handler does nothing + # + def cleanup + end + + def session + @session + end + + def client + @session + end + + def platform + session.platform + end + + # + # Cached sysinfo, returns nil for non-meterpreter sessions + # + def sysinfo + begin + @sysinfo ||= session.sys.config.sysinfo + rescue NoMethodError + @sysinfo = nil + end + @sysinfo + end + + # + # Can be overridden by individual modules to add new commands + # + def post_commands + {} + end + + # + # Default stance is passive + # + def passive + false + end + + def compatible_sessions + sessions = [] + framework.sessions.each do |sid, s| + next unless self.module_info["SessionTypes"].include?(s.type) + sessions << sid + end + sessions + end + + +end +end +