Skip to content

Instantly share code, notes, and snippets.

@rootsecdev
Last active March 13, 2024 22:27
Show Gist options
  • Save rootsecdev/994ff3dd7f18bbaff62abd1d979b1925 to your computer and use it in GitHub Desktop.
Save rootsecdev/994ff3dd7f18bbaff62abd1d979b1925 to your computer and use it in GitHub Desktop.
Oauth Audit bypass to graph
Install AZ CLI:
az login --allow-no-subscription
Install MS Graph:
Install-Module Microsoft.Graph -Scope AllUsers
Install MSIdentityTools:
Install-Module MSIdentityTools
Install Import Excel Module:
Install-Module ImportExcel
Login to AZ CLI:
az login --allow-no-subscription
Convert Access token to json:
$graphAccessUserAsAll = az account get-access-token --scope="https://graph.microsoft.com/Directory.AccessAsUser.All" | ConvertFrom-Json
Convert json access token to secure string:
$securePassword = ConvertTo-SecureString -String $graphAccessUserAsAll.accessToken -AsPlainText -Force
Connect to Graph:
Connect-MgGraph -AccessToken $securePassword
Run Report:
Export-MsIdAppConsentGrantReport -ReportOutputType ExcelWorkbook -ExcelWorkbookPath .\AppConsent.xlsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment