Detection rules › YARA-L

Purple Knight Tool Execution Detected

Type
alert
Time window
10m
Match by
hostname
Source
github.com/chronicle/detection-rules

This detection rule identifies the execution of the Purple Knight tool, a free Active Directory security assessment utility developed by Semperis. Purple Knight is designed to scan for AD vulnerabilities, misconfigurations, and common attack paths. While it is a legitimate tool used by defenders, its execution in production environments may also indicate red team activity or unauthorized reconnaissance by adversaries attempting to map domain weaknesses.

MITRE ATT&CK coverage

TacticTechniques
DiscoveryT1087 Account Discovery

References

Event coverage

Rule body yaral

/*
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

rule hacktool_purpleknight_execution {

    meta:
      author = "Georg Lauenstein - suresecure GmbH"
      description = "This detection rule identifies the execution of the Purple Knight tool, a free Active Directory security assessment utility developed by Semperis. Purple Knight is designed to scan for AD vulnerabilities, misconfigurations, and common attack paths. While it is a legitimate tool used by defenders, its execution in production environments may also indicate red team activity or unauthorized reconnaissance by adversaries attempting to map domain weaknesses."
      rule_id = "mr_69e428bb-c946-4e3f-abb8-0e28316f2389"
      rule_name = "Purple Knight Tool Execution Detected"
      tactic = "TA0007"
      technique = "T1087"
      references = "https://www.purple-knight.com/"
      type = "alert"
      platform = "Windows, EDR"
      data_source = "Microsoft Sysmon, Windows Event Logs"
      severity = "Medium"  // Adjust based on your risk assessment
      priority = "Medium"  // Adjust based on your incident response process

    events:
      $purple_knight.metadata.event_type = "PROCESS_LAUNCH"
      (
        $purple_knight.target.process.file.full_path = /\\PurpleKnight\.exe$/ nocase or
        $purple_knight.principal.process.file.full_path = /\\PurpleKnight\.exe$/ nocase or
        $purple_knight.principal.process.command_line = /PurpleKnight/ nocase
      )

    // Capture the hostname where the event occurred
    $purple_knight.principal.hostname = $hostname

    match:
      $hostname over 10m

    outcome:
      $risk_score = max(65)
      $event_count = count_distinct($purple_knight.metadata.id)
      $principal_process_pid = array_distinct($purple_knight.principal.process.pid)
      $principal_process_command_line = array_distinct($purple_knight.principal.process.command_line)
      $principal_process_file_sha256 = array_distinct($purple_knight.principal.process.file.sha256)
      $principal_process_file_full_path = array_distinct($purple_knight.principal.process.file.full_path)
      $principal_process_product_specific_process_id = array_distinct($purple_knight.principal.process.product_specific_process_id)
      $principal_process_parent_process_product_specific_process_id = array_distinct($purple_knight.principal.process.parent_process.product_specific_process_id)
      $target_process_pid = array_distinct($purple_knight.target.process.pid)
      $target_process_command_line = array_distinct($purple_knight.target.process.command_line)
      $target_process_file_sha256 = array_distinct($purple_knight.target.process.file.sha256)
      $target_process_file_full_path = array_distinct($purple_knight.target.process.file.full_path)
      $target_process_product_specific_process_id = array_distinct($purple_knight.target.process.product_specific_process_id)
      $principal_user_userid = array_distinct($purple_knight.principal.user.userid)

    condition:
      $purple_knight
}

Stages and Predicates

Stage 0: match + condition

match:
    $hostname over 10m
condition:
    $purple_knight

Fires when at least one $purple_knight event in the 10m window.

Stage 1: events: $purple_knight · PROCESS_LAUNCH

$purple_knight.metadata.event_type = "PROCESS_LAUNCH"
  (
    $purple_knight.target.process.file.full_path = /\\PurpleKnight\.exe$/ nocase or
    $purple_knight.principal.process.file.full_path = /\\PurpleKnight\.exe$/ nocase or
    $purple_knight.principal.process.command_line = /PurpleKnight/ nocase
  )

// Capture the hostname where the event occurred
$purple_knight.principal.hostname = $hostname

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
principal.process.command_lineregex_match
  • PurpleKnight transforms: nocase
principal.process.file.full_pathregex_match
  • \PurpleKnight.exe$ transforms: nocase
target.process.file.full_pathregex_match
  • \PurpleKnight.exe$ transforms: nocase

Output fields

Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.

FieldSource
risk_scoremax(65)
event_countcount_distinct($purple_knight.metadata.id)
principal_process_pidarray_distinct($purple_knight.principal.process.pid)
principal_process_command_linearray_distinct($purple_knight.principal.process.command_line)
principal_process_file_sha256array_distinct($purple_knight.principal.process.file.sha256)
principal_process_file_full_patharray_distinct($purple_knight.principal.process.file.full_path)
principal_process_product_specific_process_idarray_distinct($purple_knight.principal.process.product_specific_process_id)
principal_process_parent_process_product_specific_process_idarray_distinct($purple_knight.principal.process.parent_process.product_specific_process_id)
target_process_pidarray_distinct($purple_knight.target.process.pid)
target_process_command_linearray_distinct($purple_knight.target.process.command_line)
target_process_file_sha256array_distinct($purple_knight.target.process.file.sha256)
target_process_file_full_patharray_distinct($purple_knight.target.process.file.full_path)
target_process_product_specific_process_idarray_distinct($purple_knight.target.process.product_specific_process_id)
principal_user_useridarray_distinct($purple_knight.principal.user.userid)