Defense Evasion
Check Defenses
# Defender Status
(Get-MpComputerStatus).RealTimeProtectionEnabled
# Language Mode
$ExecutionContext.SessionState.LanguageMode
# AppLocker
## From Registry
Get-ChildItem 'HKLM:Software\Policies\Microsoft\Windows\SrpV2'
Get-ChildItem 'HKLM:Software\Policies\Microsoft\Windows\SrpV2\Exe'
# From Get-AppLockerPolicy cmdlet
$policy = Get-AppLockerPolicy -Effective
$policy.RuleCollections
# From GPO
beacon> ldapsearch (objectClass=groupPolicyContainer) --attributes displayName,gPCFileSysPath
beacon> ls $gPCFileSysPath
beacon> download $gPCFileSysPath
PS> Parse-PolFile -Path $file.polEvasion
Check Binary
Obfuscate Binary
Cobalt Strike Profile
SSH into team server and edit the profile:
Add the following chunk:
Restart the server
amsi_disableDOES NOT apply to thepowershellcommand - usepowerpick or psinjectinstead.
psexec spawnto
Some notable examples include
System.Management.Automation.dll, which is required bypowerpickandpsinject.cryptdll.dll, samlib.dll, and vaultcli.dllare required bymimikatz.So, PPID spoofing can help in avoiding detection:
Cobalth Strike Artifacts & Resources
Launch Visual Studio Code. Go to File > Open Folder and select
C:\Tools\cobaltstrike\arsenal-kit\kits\artifact.Navigate to src-common and open
patch.c. Scroll to line~45and modify the for loop. This is for the svc exe payloads.
Scroll to line
~116and modify the other for loop. This is for the normal exe payloads.
Save the changes (File > Save) and close the folder (File > Close Folder). On the Windows taskbar, right-click on the Terminal icon launch Ubuntu. Change the working directory.
Open the Cobalt Strike client and load artifact.cna from C:\Tools\cobaltstrike\custom-artifacts\mailslot.
Go to File > Open Folder and select
C:\Tools\cobaltstrike\custom-resources. Selecttemplate.x64.ps1. Rename thefunc_get_proc_addressfunction online 3toget_proc_address. Rename thefunc_get_delegate_typefunction online 10toget_delegate_type.Scroll to line
32and replace it with:
Select
compress.ps1and UseInvoke-Obfuscationto create a unique obfuscated version.Open the Cobalt Strike client and load resources.cna from C:\Tools\cobaltstrike\custom-resources.
AppLocker Bypass
Path Wildcards
Writable Directories (%WINDIR%*)
LOLBAS (MSBuild)
PowerShell CLM
This can be abused by creating a custom COM object that will load an arbitrary DLL into the PowerShell process. This is a similar process to when we added registry entries for COM hijacking.
Now run the command to use it:
AppLocker can enforce DLL rules, but these are rarely enabled due to the performance concerns. When disabled, you can load arbitrary DLLs using rundll32. This requires that the DLL have at least one exported function that you call.
Last updated