Skip to content

Commit 78b5bba

Browse files
authored
Merge branch 'main' into patch-1
2 parents ba233a8 + 3cbf3f3 commit 78b5bba

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

defender-endpoint/defender-endpoint-demonstration-controlled-folder-access.md

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.collection:
1414
- demo
1515
ms.topic: article
1616
ms.subservice: asr
17-
ms.date: 02/16/2024
17+
ms.date: 10/11/2024
1818
---
1919

2020
# Controlled folder access (CFA) demonstrations (block ransomware)
@@ -44,10 +44,10 @@ Set-MpPreference -ControlledFolderAccessProtectedFolders C:\demo\
4444
## Rule states
4545

4646
|State | Mode| Numeric value |
47-
|:---|:---|:---|
48-
| Disabled | = Off | 0 |
49-
| Enabled | = Block mode | 1 |
50-
| Audit | = Audit mode | 2 |
47+
|---|---|---|
48+
| Disabled | Off | 0 |
49+
| Enabled | Block mode | 1 |
50+
| Audit | Audit mode | 2 |
5151

5252
## Verify configuration
5353

@@ -63,65 +63,86 @@ Get-MpPreference
6363

6464
### Setup
6565

66-
Download and run this [setup script](https://demo.wd.microsoft.com/Content/CFA_SetupScript.zip). Before running the script set execution policy to Unrestricted using this PowerShell command:
66+
Download and run this [setup script](https://demo.wd.microsoft.com/Content/CFA_SetupScript.zip). Before running the script, set execution policy to `Unrestricted` by using this PowerShell command:
6767

6868
```powershell
6969
Set-ExecutionPolicy Unrestricted
7070
```
7171

72-
You can perform these manual steps instead:
72+
Or, you can perform these manual steps instead:
7373

74-
1. Create a folder under c: named demo, "c:\demo".
74+
1. Create a folder under `c:` named `demo`, as in `c:\demo`.
7575

76-
2. Save this [clean file](https://demo.wd.microsoft.com/Content/testfile_safe.txt) into c:\demo (we need something to encrypt).
76+
2. Save this [clean file](https://demo.wd.microsoft.com/Content/testfile_safe.txt) into `c:\demo` (we need something to encrypt).
7777

78-
3. Execute PowerShell commands listed earlier in this article.
78+
3. Run the PowerShell commands listed earlier in this article.
79+
80+
Next, check that status of the *Aggressive Ransomware Prevention* ASR rule and disable it for the duration of this test if it's enabled:
7981

80-
### Scenario 1: CFA blocks ransomware test file
8182

82-
1. Turn on CFA using PowerShell command:
83-
8483
```powershell
85-
Set-MpPreference -EnableControlledFolderAccess Enabled
84+
$idx = $(Get-MpPreference).AttackSurfaceReductionRules_Ids.IndexOf("C1DB55AB-C21A-4637-BB3F-A12568109D35")
85+
if ($idx -ge 0) {Write-Host "Rule Status: " $(Get-MpPreference).AttackSurfaceReductionRules_Actions[$idx]} else {Write-Host "Rule does not exist on this machine"}
8686
```
8787

88-
2. Add the demo folder to protected folders list using PowerShell command:
88+
If the rule exists and the status is `1 (Enabled)` or `6 (Warn)`, it must be disabled to run this test:
8989

9090
```powershell
91-
Set-MpPreference -ControlledFolderAccessProtectedFolders C:\demo\
91+
Add-MpPreference -AttackSurfaceReductionRules_Ids C1DB55AB-C21A-4637-BB3F-A12568109D35 -AttackSurfaceReductionRules_Actions Disabled
9292
```
9393

94-
3. Download the ransomware [test file](https://demo.wd.microsoft.com/Content/ransomware_testfile_unsigned.exe)
95-
4. Execute the ransomware test file *this isn't ransomware, it simple tries to encrypt c:\demo
94+
### Scenario 1: CFA blocks ransomware test file
95+
96+
1. Turn on CFA using PowerShell command:
97+
98+
```powershell
99+
Set-MpPreference -EnableControlledFolderAccess Enabled
100+
```
101+
102+
2. Add the demo folder to protected folders list using PowerShell command:
103+
104+
```powershell
105+
Set-MpPreference -ControlledFolderAccessProtectedFolders C:\demo\
106+
```
107+
108+
3. Download the ransomware [test file](https://demo.wd.microsoft.com/Content/ransomware_testfile_unsigned.exe).
109+
110+
4. Execute the ransomware test file. Note that it isn't ransomware; it simply tries to encrypt `c:\demo`.
96111

97112
#### Scenario 1 expected results
98113

99-
5 seconds after executing the ransomware test file you should see a notification CFA blocked the encryption attempt.
114+
About five seconds after executing the ransomware test file, you should see a notification that CFA blocked the encryption attempt.
100115

101116
### Scenario 2: What would happen without CFA
102117

103118
1. Turn off CFA using this PowerShell command:
104119

105-
```powershell
106-
Set-MpPreference -EnableControlledFolderAccess Disabled
107-
```
120+
```powershell
121+
Set-MpPreference -EnableControlledFolderAccess Disabled
122+
```
108123

109-
2. Execute the ransomware [test file](https://demo.wd.microsoft.com/Content/ransomware_testfile_unsigned.exe)
124+
2. Execute the ransomware [test file](https://demo.wd.microsoft.com/Content/ransomware_testfile_unsigned.exe).
110125

111126
#### Scenario 2 expected results
112127

113-
- The files in c:\demo are encrypted and you should get a warning message
128+
- The files in `c:\demo` are encrypted and you should get a warning message
114129
- Execute the ransomware test file again to decrypt the files
115130

116131
## Clean-up
117132

118-
Download and run this [cleanup script](https://demo.wd.microsoft.com/Content/ASR_CFA_CleanupScript.zip). You can perform these manual steps instead:
133+
1. Download and run this [cleanup script](https://demo.wd.microsoft.com/Content/ASR_CFA_CleanupScript.zip). You can perform these manual steps instead:
119134

120-
```powershell
121-
Set-MpPreference -EnableControlledFolderAccess Disabled
122-
```
135+
```powershell
136+
Set-MpPreference -EnableControlledFolderAccess Disabled
137+
```
138+
139+
2. Clean up `c:\demo` encryption by using the [encrypt/decrypt file](https://demo.wd.microsoft.com/Content/ransomware_cleanup_encrypt_decrypt.exe)
140+
141+
3. If the *Aggressive Ransomware Prevention* ASR rule was enabled and you disabled it at the beginning of this test, enable it again:
123142

124-
Clean up c:\demo encryption by using the [encrypt/decrypt file](https://demo.wd.microsoft.com/Content/ransomware_cleanup_encrypt_decrypt.exe)
143+
```powershell
144+
Add-MpPreference -AttackSurfaceReductionRules_Ids C1DB55AB-C21A-4637-BB3F-A12568109D35 -AttackSurfaceReductionRules_Actions Enabled
145+
```
125146

126147
## See also
127148

0 commit comments

Comments
 (0)