ms_graph_enumerate_applications
Description
Identify the use GraphRunner's Invoke-DumpApps function to collect applications and external apps as well as users that consented to permissions in their apps.
Query · yara_l
events:
$app_api.metadata.event_type = "NETWORK_HTTP"
$app_api.metadata.product_event_type = "Microsoft Graph Activity"
$app_api.target.url = "https://graph.microsoft.com/v1.0/applications" nocase
$app_api.network.http.method = "GET"
$app_api.network.http.response_code = 200
//Can be tuned for specific User Agent strings being used - by default GraphRunner does not forge the UA for this action
//$app_api.network.http.user_agent = /PowerShell/ nocase
$app_api.principal.ip = $ip
$app_api.network.session_id = $session
$app_api.metadata.event_timestamp.seconds < $role_api.metadata.event_timestamp.seconds
$role_api.metadata.event_type = "NETWORK_HTTP"
$role_api.metadata.product_event_type = "Microsoft Graph Activity"
re.regex($role_api.target.url, `^https:\/\/graph.microsoft.com\/v1.0\/servicePrincipals\(appId='.*'\)/appRoleAssignedTo$`) nocase
$role_api.network.http.method = "GET"
$role_api.network.http.response_code = 200
//Can be tuned for specific User Agent strings being used - by default GraphRunner does not forge the UA for this action
//$role_api.network.http.user_agent = /PowerShell/ nocase
$role_api.principal.ip = $ip
$role_api.network.session_id = $session
re.capture($role_api.target.url, `^https:\/\/graph.microsoft.com\/v1.0\/servicePrincipals\(appId='(.*)'\)/appRoleAssignedTo$`) = $app_guid
match:
$ip, $session over 5m
outcome:
$risk_score = 35
$event_count = count_distinct($app_api.metadata.id) + count_distinct($role_api.metadata.id)
$requesting_user_guid = array_distinct($app_api.principal.user.userid)
$requesting_ip = array_distinct($app_api.principal.ip)
$user_agent = array_distinct($app_api.network.http.user_agent)
$location = array_distinct($app_api.principal.location.name)
$target_application_id_guid = array_distinct($app_api.target.resource.product_object_id)
$session_id = array_distinct($app_api.network.session_id)
$application_count = count_distinct($app_guid)
$application_list = array_distinct($app_guid) //limited to 25 applications
condition:
$app_api and $role_api