2012-06-29 00:18:28 -05:00
|
|
|
# -*- 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'
|
2015-09-11 01:56:21 -05:00
|
|
|
require 'msf/core/post/android'
|
2017-01-06 19:51:41 -08:00
|
|
|
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
|
|
|
|
|
|
2017-07-03 00:07:32 -05:00
|
|
|
class Failed < RuntimeError
|
|
|
|
|
end
|
|
|
|
|
|
2013-09-05 13:41:25 -05:00
|
|
|
include Msf::PostMixin
|
|
|
|
|
|
2019-08-15 07:27:28 -05:00
|
|
|
# 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
|
2017-10-11 16:26:25 -05:00
|
|
|
|
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
|
2017-10-11 16:26:25 -05:00
|
|
|
|
2017-10-13 12:14:43 -05:00
|
|
|
# Msf::Module(Msf::PostMixin)#setup
|
2017-10-11 16:26:25 -05:00
|
|
|
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
|
2017-01-17 14:09:27 -06:00
|
|
|
# @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
|
2017-07-03 00:07:32 -05:00
|
|
|
|
|
|
|
|
# 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
|