Land #17057, Msf::Post::Windows::ExtAPI: Remove load_extapi method

Merge branch 'land-17057' into upstream-master
This commit is contained in:
bwatters 2022-10-07 15:54:52 -05:00
commit ef0ca2edbb
No known key found for this signature in database
GPG Key ID: ECC0F0A52E65F268
9 changed files with 21 additions and 40 deletions

View File

@ -5,8 +5,8 @@ module Msf
module Windows
module Accounts
include Msf::Post::Windows::Error
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::Registry
require 'rex/post/meterpreter/extensions/extapi/command_ids'
GUID = [
['Data1', :DWORD],

View File

@ -1,25 +1,11 @@
# -*- coding: binary -*-
module Msf
class Post
module Windows
module ExtAPI
def load_extapi
if session.extapi
return true
else
begin
return session.core.use("extapi")
rescue Errno::ENOENT
print_error("Unable to load Extended API.")
return false
class Post
module Windows
module ExtAPI
require 'rex/post/meterpreter/extensions/extapi/command_ids'
end
end
end
end # ExtAPI
end # Windows
end # Post
end # Msf
end

View File

@ -11,7 +11,6 @@ module Msf
include Msf::Post::Windows::Error
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::Accounts
require 'rex/post/meterpreter/extensions/extapi/command_ids'
LDAP_SIZELIMIT_EXCEEDED = 0x04
LDAP_OPT_SIZELIMIT = 0x03

View File

@ -8,6 +8,7 @@ class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Exploit::Powershell
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::WMIC
def initialize(info={})
@ -72,7 +73,7 @@ class MetasploitModule < Msf::Exploit::Local
end
def run_host(server)
if load_extapi
if session.extapi
psh_options = { :remove_comspec => true,
:encode_final_payload => true }
else
@ -86,7 +87,7 @@ class MetasploitModule < Msf::Exploit::Local
psh_options)
begin
if load_extapi
if session.extapi
exec_cmd = psh
else
# Get the PSH Payload and split it into bitesize chunks
@ -131,7 +132,7 @@ class MetasploitModule < Msf::Exploit::Local
print_error("[#{server}] failed...)")
end
unless load_extapi
unless session.extapi
print_status("[#{server}] Cleaning up environment variables")
env_vars.each do |env|
cleanup_cmd = "cmd /c REG delete \"HKLM\\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\" /V #{env} /f"

View File

@ -6,7 +6,6 @@
class MetasploitModule < Msf::Post
include Msf::Post::Windows::Priv
include Msf::Post::Windows::Error
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::FileInfo
include Msf::Post::File

View File

@ -148,12 +148,11 @@ class MetasploitModule < Msf::Post
return false
end
unless session_compat?
return false
unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Extapi::COMMAND_ID_EXTAPI_NTDS_PARSE)
fail_with(Failure::BadConfig, 'Session does not support Meterpreter ExtAPI NTDS parser')
end
load_extapi
return true
session_compat?
end
def repair_ntds(path = '')

View File

@ -6,6 +6,7 @@
class MetasploitModule < Msf::Post
include Msf::Auxiliary::Report
include Msf::Post::File
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::Priv
include Msf::Post::Windows::Registry
include Msf::Post::Windows::NetAPI
@ -219,7 +220,7 @@ class MetasploitModule < Msf::Post
end
def adsi_query(domain, adsi_filter, adsi_fields)
return "" unless session.core.use("extapi")
return "" unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Extapi::COMMAND_ID_EXTAPI_ADSI_DOMAIN_QUERY)
query_result = session.extapi.adsi.domain_query(domain, adsi_filter, 255, 255, adsi_fields)

View File

@ -5,7 +5,7 @@
class MetasploitModule < Msf::Post
include Msf::Post::Common
require 'rex/post/meterpreter/extensions/extapi/command_ids'
include Msf::Post::Windows::ExtAPI
def initialize(info = {})
super(

View File

@ -6,6 +6,7 @@
require 'tmpdir'
class MetasploitModule < Msf::Post
include Msf::Post::Windows::ExtAPI
include Msf::Post::Windows::Priv
def initialize(info = {})
@ -54,15 +55,6 @@ class MetasploitModule < Msf::Post
@sockpath ||= "#{Dir.tmpdir}/#{Rex::Text.rand_text_alphanumeric(8)}"
end
def setup
return if session.extapi
vprint_status('Loading extapi extension...')
session.core.use('extapi')
rescue Errno::ENOENT
fail_with(Failure::BadConfig, 'This module is only available in a Windows meterpreter session.')
end
def run
# Check to ensure that UNIX sockets are supported
begin
@ -71,6 +63,10 @@ class MetasploitModule < Msf::Post
fail_with(Failure::BadConfig, 'This module is only supported on a Metasploit installation that supports UNIX sockets.')
end
unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Extapi::COMMAND_ID_EXTAPI_PAGEANT_SEND_QUERY)
fail_with(Failure::BadConfig, 'Session does not support Meterpreter ExtAPI Pageant queries')
end
# Get the socket path from the user supplied options (or leave it blank to get the plugin to choose one)
if datastore['SocketPath']
# Quit if the file exists, so that we don't accidentally overwrite something important on the host system