Atlantiraptor Docs

Windows.Detection.Yara.Device

Type: Client · Author: Matt Green - @mgreen27

Scans physical disk sectors with YARA rules at configurable offsets and uploads hit context.

There are 2 kinds of YARA rules that can be deployed:

  1. Url link to a YARA rule.
  2. or a Standard YARA rule attached as a parameter.

Only one method of YARA will be applied and search order is as above. The default is targeting the Master Boot Record (MBR).

Note: by default the YARA scan will stop after one hit. Multi-string rules will also only show one string in returned rows.

Due to scanning raw devices and size being potentially very large I have included an example on how to upload the MBR as the default YARA rule.

Parameters

Name Type Default Description
DevicePath string \\.\PHYSICALDRIVE0 Raw Device for main disk to target.
StartOffest int 0
ScanLength int 512
YaraUrl upload If configured will attempt to download Yara rules from Url
YaraRule yara (see the artifact source)
NumberOfHits int 1 THis artifact will stop by default at one hit. This setting allows additional hits
ContextBytes int64 0 Include this amount of bytes around hit as context.

Source

Defined in artifacts/definitions/Windows/Detection/Yara/Device.yaml.

name: Windows.Detection.Yara.Device
author: Matt Green - @mgreen27
description: |
  Scans physical disk sectors with YARA rules at configurable offsets
  and uploads hit context.

  There are 2 kinds of YARA rules that can be deployed:

  1. Url link to a YARA rule.
  2. or a Standard YARA rule attached as a parameter.

  Only one method of YARA will be applied and search order is as
  above. The default is targeting the Master Boot Record (MBR).

  Note: by default the YARA scan will stop after one hit. Multi-string
  rules will also only show one string in returned rows.

  Due to scanning raw devices and size being potentially very large I
  have included an example on how to upload the MBR as the default
  YARA rule.

parameters:
  - name: DevicePath
    default: \\.\PHYSICALDRIVE0
    description: Raw Device for main disk to target.
  - name: StartOffest
    type: int
    default: 0
  - name: ScanLength
    type: int
    default: 512
  - name: YaraUrl
    description: If configured will attempt to download Yara rules from Url
    type: upload
  - name: YaraRule
    type: yara
    default: |
        rule MBR {
            meta:
                author = "Matt Green - @mgreen27"
                description = "Checks MBR header at offset 510 and collects MBR in HitContext"
            strings:
                $mbr = /^.{512}$/ //first entry covering bytes we want to upload.
                $mbrheader = { 55 AA }
            condition:
                $mbr and $mbrheader at 510
        }
  - name: NumberOfHits
    description: THis artifact will stop by default at one hit. This setting allows additional hits
    default: 1
    type: int
  - name: ContextBytes
    description: Include this amount of bytes around hit as context.
    default: 0
    type: int64

sources:
  - query: |
      -- check which Yara to use
      LET yara_rules <= YaraUrl || YaraRule

      -- target yara with raw_file pachspec
      SELECT
        DevicePath,
        StartOffest,
        ScanLength,
        Namespace,
        Rule,
        Meta,
        Tags,
        String.Name as YaraString,
        String.Offset AS HitOffset,
        upload(
            accessor='data',
            file=String.Data,
            name=format(format='%s_%s',
                    args=[basename(path=DevicePath),str(str=String.Offset)])
                ) AS HitContext
      FROM yara(files=pathspec(
                    DelegateAccessor="raw_file",
                    DelegatePath=DevicePath,
                    Path=StartOffest),
                accessor='offset',
                start=0,
                end=ScanLength,
                rules=yara_rules,
                context=ContextBytes,
                number=NumberOfHits )

column_types:
  - name: HitContext
    type: upload_preview

Edit this page on GitHub

© 2026 Atlant Security EOOD. Atlantiraptor is free software under the GNU Affero General Public License v3. It is based on Velociraptor by Velocidex, and keeps its copyright notices. Velociraptor is a trademark of its owner; Atlantiraptor is not affiliated with or endorsed by it.