Skip to content

Microsoft Intune Executor

Category: Endpoint Security Script: ms_intune.py Integration: REST API (Microsoft Graph, OAuth2) Faraday Plugin: Raw JSON Website: https://www.microsoft.com/en-us/security/business/microsoft-intune

Description

Imports the managed devices of a Microsoft Intune tenant into Faraday. Each device becomes a host, and each non-compliant device gets a vulnerability that describes its compliance problem.

Prerequisites

  • A Microsoft Entra ID (Azure AD) app registration with a client secret
  • The application permissions DeviceManagementManagedDevices.Read.All and DeviceManagementConfiguration.Read.All, with admin consent granted
  • Network access to login.microsoftonline.com and graph.microsoft.com

Configuration

Environment Variables (Setup)

Variable Required Description
AZURE_TENANT_ID Yes Directory (tenant) ID of the Entra ID tenant
AZURE_CLIENT_ID Yes Application (client) ID of the app registration
AZURE_CLIENT_SECRET Yes Client secret of the app registration

These variables are also accepted as execution arguments, so a single run can override them.

Execution Arguments

Parameter Type Mandatory Description
INTUNE_COMPLIANCE_STATE_FILTER string No Only import devices in this compliance state: compliant, nonCompliant or unknown (default: all)
INTUNE_PLATFORM string No Only import devices of this platform: windows, macos, ios or android (default: all)
INTUNE_MIN_SEVERITY string No Minimum severity to import: info, low, medium, high or critical (default: info)

YAML Configuration Example

executors:
  ms_intune:
    repo_executor: ms_intune.py
    max_size: 65536
    varenvs:
      AZURE_TENANT_ID: "<azure_tenant_id>"
      AZURE_CLIENT_ID: "<azure_client_id>"
      AZURE_CLIENT_SECRET: "<azure_client_secret>"
    params:
      INTUNE_COMPLIANCE_STATE_FILTER:
        mandatory: false
        type: string
        base: string
      INTUNE_PLATFORM:
        mandatory: false
        type: string
        base: string
      INTUNE_MIN_SEVERITY:
        mandatory: false
        type: string
        base: string

How It Works

  1. Requests a token from login.microsoftonline.com/{AZURE_TENANT_ID}/oauth2/v2.0/token (client credentials, scope https://graph.microsoft.com/.default)
  2. Reads deviceManagement/managedDevices from Microsoft Graph v1.0, following the next-page links. INTUNE_COMPLIANCE_STATE_FILTER and INTUNE_PLATFORM are sent to Graph as an OData $filter.
  3. Reads the compliance policies and the device configurations (with their assignments) and adds them as references
  4. Creates one host per device, and one vulnerability for every device that is not compliant:
    • Severity: nonCompliant and error are high, conflict is medium, inGracePeriod is low, unknown and configManager are info
    • Status: open for non-compliant states
  5. Drops vulnerabilities below INTUNE_MIN_SEVERITY

Notes

  • Compliant devices are still imported as hosts, without vulnerabilities.
  • The host IP is the device's IPv4 address when Intune reports one, otherwise 0.0.0.0. The description holds the device ID, user, operating system, model, serial number, compliance state and last sync time.
  • The setup variables can also be passed as execution arguments.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor. Use INTUNE_MIN_SEVERITY to filter by severity.