Nuke it from orbit, it’s the only way to be sure!
Ok, in an ideal world you can re-deploy your entire environment from scratch, but back in the most people’s real world’s that’s not that simple. So, what do we do if we can’t nuke from orbit in a post compromise situation? Well, we need to clean up! This isn’t an exhaustive list, not a total guide. it’s a quick list to make you think about some key common areas and actions that might need to be taken! after all if someone got r00t, who knows what they did! (trust me, most orgs monitoring is a bit naff!)
Potential Actions
- Reset all user account passwords twice (thanks @tazwake)
- Reset all administrator passwords
- Reset all service accounts passwords
- Reset (twice – but bear in mind the issues with replication so there’s specific guidance on this) the KRBTGT password
- Reset all computer account passwords
- Check the value of the computer account password change value
- By default, it is 30 days, threat actors can change this to give themselves access using machine hashes for a longer duration. https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/domain-member-maximum-machine-account-password-age
- Reset all LAPS Passwords
- Reset permissions on AdminSDHolders object
- Revoke and re-issue all certificates from ADCS
- Check for malicious scheduled tasks (thanks @SchizoDuckie)
- Check for malicious WMI event filters
- Check for malicious autoruns or other registry-based persistence mechanisms
- Check for utilman style backdoors
- Check for malicious printers/printer drivers (thanks @SchizoDuckie)
- Review Active Directory Delegated access permissions (thank https://twitter.com/@indachtig)
- Rotate ADFS token signing and token decryption certificates (thanks @4n6Bexaminer)
- Check Service Control Manager (SCM) security descriptors (https://docs.microsoft.com/en-us/windows/win32/services/service-security-and-access-rights) (thanks @EricaZeli)
- Check for object changes around initial access/event timescales (thanks @IISResetMe)
- Validate group memberships against known baselines (replication metadata, backup, AD reporting tools/reports etc.) (thanks @IISResetMe)
- Harden Active Directory (look at pingcastle and MITRE) (thanks @MarkSewe)
- Review logon scripts in GPOS and SYSVOL (thanks @CisoDiagonal and A-HAX!)
- Rotate Group Managed Service Accounts (GMSA) (thanks @infosecspy)
- Rotate LAPS credentials
- Review Azure AD/AD Connect (thanks @infosecspy)
- Harden Endpoints
- Update AV
- Deploy EDR
- Deploy SYSMON
- DNS Zone Integrity (Public and Private) (thanks to @jermuv)
- Rote domain trust keys (thanks @DebugPrivilege)
- Review potential RBCD Bakdoors (thanks @DebugPrivilege)
- Review msDsConsistencyGuid attribute of compromised accounts (thanks @DebugPrivilege)
- Check Exchange (easy right?)
- Review accounts for “Key Trust Account Mapping” takeover and reset if required (thanks @nodauf)
- https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab
- Review Active Directory Domains and Trusts (thanks @dragon199421)
- Deploy new Domain Controllers (keep existing forest/domain metadata)
- Clear VSS/Backups/Snapshots that are likely to be classed as unsafe (thanks to @Digit4lbytes)
There’s also a great blog by Huy here with practical steps to take with LockBit 2.0 as an example:
Human Considerations
This activity is clearly one of last resort where backups might not be available of availability trumps, integrity and confidentiality to the point restoring simply isn’t feasible). A great point made by https://twitter.com/@_4_d_4_m_ was to ensure your people are ok (they have enough rest, food, water, exercise etc.). Incidents are stressful as hell so make sure you and your people are ok!
Useful Tools
- PingCastle – https://www.pingcastle.com/
- Bloodhound – https://github.com/BloodHoundAD/BloodHound
- Adalanche – https://github.com/lkarlslund/adalanche
- ADACLScanner – https://github.com/canix1/ADACLScanner
- SysInternals – https://docs.microsoft.com/en-us/sysinternals/
Summary
If someone has gained a significant level of access into core identity systems like Active Directory Services you are possible going to have one hell of a time making sure they are out, Ideally as I said at the start you would nuke it all, but that isn’t always possible, but hopefully you are really starting to think… we really need to be able to rebuild/restore. Either way your best defence is a good defence, identify and prevent are your friends! Stay safe! If you have suggestions for this list, please get in contact! It was built by the community for the community!