Code Monkey home page Code Monkey logo

monitoracechanges's Introduction

MonitorACEChanges

Note: please test this in a test environment before applying this in production. This should be considered as Proof of Concept code. Tested on Windows Server 2019 with an 2016 forest functional level.

Due the lack of public examples on how to monitor for ACE changes in AD I created these 2 PoC's. There are probally better was to monitor this that either work or scale better, (for example using a SIEM), but this is mainly to show that if you know where to look you can collect enough data to monitor for ACE changes in Active Directory.

Example 1: Get current SDDLs

GetKnownGoods.ps1 will collect SDDL's of all the current AD Objects. This example then exports these values to a XML file.
This process could be implemented to run on a schedule to collect this data over time. Another process could be implemented that compares these results to detect malicious activity.

Example 2: Use EventID 5136 and known 'good' SDDL values to detect changes in ACE's.

After configuring Audit Directory Services Changes and a SACL whenever a change to a ACE of a AD Object is made a Event with EventID 5136 is logged. MonitorEvents.ps1 uses the data collected by previous example GetKnownGoods.ps1 as known good values. It then compares these values against triggered events to determine what changed from the previously known 'good' state.

With known good states
MonitorEvents.ps1

Without known good states MonitorEvents.ps1

Prerequisites for Example 2.

  1. Create a GPO and follow this guide to apply the 'Baseline Recommendation' at minimum.
    https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/audit-policy-recommendations

  2. Create a second GPO to enforce Advanced Auditing.
    https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/Monitoring-Active-Directory-for-Signs-of-Compromise#enforcing-traditional-auditing-or-advanced-auditing

  3. Apply a SACL on the root of AD that monitors changes made to properties and permissions.
    SACL

  4. Apply GPO's to the Domain Controllers OU and reboot them.
    gpos

  5. Run GetKnownGoods.ps1. Make sure to update the paths for Export-CliXML and Import-CliXML.

License

MIT

Authors

Justin Perdok (@justin-p), Orange Cyberdefense

Contributing

Feel free to open issues, contribute and submit your Pull Requests. You can also ping me on Twitter (@JustinPerdok)

monitoracechanges's People

Contributors

justin-p avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.