Files
metasploit-gs/lib/msf/core/post.rb
T

90 lines
2.0 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
2010-12-27 17:56:29 +00:00
2012-05-17 16:13:25 -06:00
#
# A Post-exploitation module
#
2013-08-29 13:37:50 -05:00
class Msf::Post < Msf::Module
2013-09-05 13:41:25 -05:00
require 'msf/core/post/common'
require 'msf/core/post_mixin'
require 'msf/core/post/file'
2014-05-21 15:32:29 -05:00
require 'msf/core/post/webrtc'
2013-09-05 13:41:25 -05:00
require 'msf/core/post/linux'
require 'msf/core/post/osx'
require 'msf/core/post/solaris'
require 'msf/core/post/unix'
require 'msf/core/post/windows'
require 'msf/core/post/android'
require 'msf/core/post/hardware'
2013-09-05 13:41:25 -05:00
2017-07-03 00:26:49 -05:00
class Complete < RuntimeError
end
class Failed < RuntimeError
end
2013-09-05 13:41:25 -05:00
include Msf::PostMixin
# file_dropper sets needs_cleanup to true to track exploits that upload files
# some post modules also use file_dropper, so let's define it here
attr_accessor :needs_cleanup
2014-12-04 17:07:59 -06:00
def setup
m = replicant
2014-12-04 17:07:59 -06:00
if m.actions.length > 0 && !m.action
raise Msf::MissingActionError, "Please use: #{m.actions.collect {|e| e.name} * ", "}"
end
# Msf::Module(Msf::PostMixin)#setup
super
2014-12-04 17:07:59 -06:00
end
2013-09-05 13:41:25 -05:00
def type
Msf::MODULE_POST
end
def self.type
Msf::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
2014-05-29 13:20:32 -05:00
2016-04-20 11:02:15 -07:00
# This method returns the ID of the Mdm::Session that the post module
2015-04-13 13:21:41 +05:00
# is currently running against.
2014-05-29 13:20:32 -05:00
#
# @return [NilClass] if there is no database record for the session
# @return [Integer] if there is a database record to get the id for
2014-05-29 13:20:32 -05:00
def session_db_id
if session.db_record
session.db_record.id
else
nil
end
end
# Override Msf::Module#fail_with for Msf::Simple::Post::job_run_proc
def fail_with(reason, msg = nil)
raise Msf::Post::Failed, "#{reason.to_s}: #{msg}"
end
2012-05-17 16:13:25 -06:00
end