---
title: "9. Enumerating Security controls"
date: 2024-09-04
draft: false
---

Windefender has improved greatly over time. 
- Default, blocks `Powerview`

Built-in powershell cmdlet to check Defender status: `Get-MpComputerStatus` - look at `RealTimeProtectionEnabled`
![](/img/Pasted image 20240903181405.png)

**AppLocker** - https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/what-is-applocker 
- An application whitelist is a list of approved software applications or executables that are allowed to be present and run in a system. 
- Goal is to protect env from malware and unapproved software. 
- Created by Microsoft. 
- Granular control over executables, scripts, windows installer files, dlls, packaged apps, and packed app installers. 
- Common for orgs to block cmd.exe and powershell.exe / write access to certain directories
- This is all bypassable! 
- Orgs focus on blocking the `PowerShell.exe` executable but forget about other PowerShell executable locations: https://www.powershelladmin.com/wiki/PowerShell_Executables_File_System_Locations
	- i.e. `%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe` or the `PowerShell_ISE.exe` version. 

Viewing AppLocker policiy using `Get-AppLockerPolicy` cmdlet
```powershell-session
Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
```

**Powershell constrained language mode**
https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/
Locks down many features needed to use powershell effectively such as: 
- Blocking COM objects
- Only allowing approved .NET types
- XAML based workflows
- Powershell classes
- more... 
To check if you are in a constrained powershell session, or in a full language mode: 
```powershell-session
 $ExecutionContext.SessionState.LanguageMode
```


**LAPS**
Microsoft `Local Admin Password Solution` - used to randomize and rotate local administrator passwords on Windows hosts, preventing lateral movement
- Possible to enumerate what dom users can read laps pw set for machines iwth laps installed, and what machines do not have laps installed
- LAPSToolkit https://github.com/leoloobeek/LAPSToolkit facilitates this w/ several funcs. 
	- Parsing `ExtendedRights` for all computers with `LAPS` enabled, showing groups specifically delegated to read LAPS passwords (often protected groups) 
	- An acct that has joined a computer to a domain receives `All Extended Rights` over that host, and this right gives that account the ability to read passwords. 
- Enumeration may show a user account that can read the LAPS password on a host. This can help us target specific AD users who can read LAPS passwords. 
```powershell-session
Find-LAPSDelegatedGroups
```

We can also use 
```bash
Find-AdmPwdExtendedRights
```
- Checks rights on each computer with LAPS enabled for any groups with read access and users with `all extended rights` 
	- users with `all extended rights` can read LAPS passwords and may be less protected than users in delegated groups, so this is worth checking for. 

Furthermore checking: 
```bash
Get-LAPSComputers
```
- Function used to search for computers that have LAPS enabled when passwords expire and even the randomized passwords in cleartext, if our user has access. 
