Skip to content

A highly configurable PowerShell application to provide an automated, repeatable and extendable framework to detect attack activity in EntraID.

Notifications You must be signed in to change notification settings

TheresAFewConors/CloudSweep

Repository files navigation

Made with - PowerShell License - MIT Current Version

CloudSweep Overview

A highly configurable PowerShell application to provide an automated, repeatable and extendable framework to detect attack activity in EntraID.

Contents

Who is this for?

CloudSweep is designed for IR teams during an active intrusion to rapidly collect data needed for an investigation as well as to run after an investigation has concluded to ensure the threat actor does not remain in their network. This can also be used on a regular basis as an early indicator of compromise or as part of existing threat hunting activities.

What does CloudSweep look for?

  • OAuth2 Applications with known malicious Application IDs
  • OAuth2 Applications with suspicious naming conventions (non-alphanumeric names or contain the word "test", etc.).
  • OAuth2 Applications that match existing usernames or service principal IDs, automatically normalizing for common permutations
  • Suspicious user-agents used to authenticate
  • Accounts that may be backdoored via OAuth consent attacks.

Features

Quickly review OAuth applications within EntraID looking for potentially malicious indicators, while also printing out the assigned permissions in human-readable format:

Automatically correlate Users and Service Principal names against registered OAuth Applications within the tenant, automatically normalizing entries for common permutations:

Review signin logs looking for suspicious user-agents on successful sign-ins:

A configurable whitelist is provided to prevent known-good applications within your tenant to appear in further analysis resutls, reducing the need for repeat review:

Identify potentially backdoored accounts through OAuth consent attacks, and saves full signin logs from identified logins to output/signin_logs.json:

Setup

  1. Create a new OAuth2 Application
  2. Copy the Client Secret and App (client) ID.
  3. Copy the Tenant ID.
  4. Put the Client Secret, Client ID and Tenant ID into the ./config/config.json file.
  5. Assign permissions as listed in the Permissions section.
  6. Run the application from an administrative PowerShell window.
  7. The first time you run the tool you will receive multiple "Unknown Application" via the OAuth2 analysis. Copy the application ID into the whitelist.json file to remove these entries from being analyzed in future for known-good applications.

Usage

Each of the individual scripts can be run independently depending on your specific needs. To run all scripts together:

  • Open an Administrative PowerShell Window
  • Run powershell.exe CloudSweep.ps1
  • Profit

ToDo

Help

  • Q. How do I get my tenant ID?
  • A. Search for "Tenant Properties", the Tenant ID is the fifth option on the front page.

Notes

You must assign the following Application permissions (not delegated):

  • Application.Read.All
  • AuditLog.Read.All
  • AuthenticationContext.Read.All
  • Directory.Read.All
  • Policy.Read.All
  • User.Read.All
  • UserAuthenticationMethod.Read.All

You then must grant Admin Consent.

References:

Analysis is based on the following research linked below:

Disclaimer

CloudSweep is only to be used within environments that you either own or have permission to test. This tool will assist with detecting potential threats, however use of this tool does not mean you have detected all potential threats. Regular auditing with a diverse set of tools is recommended. The author accepts no liability for actions taken by its users.

About

A highly configurable PowerShell application to provide an automated, repeatable and extendable framework to detect attack activity in EntraID.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published