New to Claude Skills? Learn how to install them →

mukul975 on GitHub

Detecting Fileless Attacks

Free

Identify fileless malware and in-memory threats effectively.

Get this skill

Free · Opens the source repo

What Detecting Fileless Attacks does

Detecting Fileless Attacks on Endpoints is a specialized skill designed for cybersecurity professionals focused on identifying fileless malware and in-memory attacks that evade traditional detection methods. This skill is particularly useful in environments where PowerShell is frequently used, as it provides a comprehensive framework for building detection rules that target attacks executed entirely in RAM. By leveraging telemetry from tools like Sysmon and AMSI, users can effectively capture and analyze indicators of compromise that would otherwise go unnoticed by standard antivirus solutions.

The skill guides users through a structured workflow that begins with enabling necessary telemetry features, such as PowerShell Script Block Logging and Sysmon event logging. These features are crucial for capturing the detailed activity of processes and scripts that may indicate malicious behavior. The skill then provides specific detection techniques for various types of attacks, including PowerShell-based exploitation, reflective DLL injection, and WMI persistence. Each detection method is accompanied by example queries and scripts that can be directly implemented in a security operations environment.

This skill is particularly valuable for incident responders and threat hunters looking to enhance their capabilities in detecting sophisticated attacks that utilize living-off-the-land techniques. By implementing the recommendations and queries provided, users can build a robust detection framework that addresses the unique challenges posed by fileless malware. It empowers security teams to proactively hunt for threats that leverage legitimate tools and processes to compromise systems without leaving traditional file-based artifacts.

However, it is important to note that this skill is not intended for detecting file-based malware or for conducting malware reverse engineering. It is specifically tailored for environments where fileless attacks are a concern, making it a critical addition to any security toolkit focused on modern threat detection.

When to use it

Use this skill when building detection rules for fileless malware, particularly in environments utilizing PowerShell and Sysmon.

When not to use it

Do not use this skill for file-based malware detection or malware reverse engineering tasks.

What you can build with it

Incident Response

Use this skill during incident investigations where traditional AV has failed to detect malicious activity.

Threat Hunting

Employ this skill to proactively hunt for fileless malware in environments heavily utilizing PowerShell.

Enhancing Detection Capabilities

Integrate this skill into your security operations to improve detection of sophisticated in-memory attacks.

How to install Detecting Fileless Attacks

View source

1. Install with the skills CLI

npx skills add mukul975/anthropic-cybersecurity-skills/detecting-fileless-attacks-on-endpoints --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mukul975

Detecting Fileless Attacks on Endpoints

When to Use

Use this skill when:

  • Building detection rules for fileless malware that operates entirely in memory
  • Hunting for PowerShell-based attacks, reflective DLL injection, and WMI abuse
  • Configuring endpoint telemetry (Sysmon, AMSI, PowerShell logging) to capture fileless indicators
  • Investigating incidents where traditional AV found no malicious files

Do not use for detecting file-based malware or for malware reverse engineering.

Prerequisites

  • Sysmon with process creation and WMI event logging enabled
  • PowerShell Script Block Logging and Module Logging enabled
  • AMSI (Antimalware Scan Interface) enabled for script content inspection
  • EDR with behavioral detection capabilities (MDE, CrowdStrike, SentinelOne)

Workflow

Step 1: Enable Required Telemetry

# Enable PowerShell Script Block Logging (GPO or registry)
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" `
  -Name EnableScriptBlockLogging -Value 1 -PropertyType DWORD -Force

# Enable PowerShell Module Logging
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging" `
  -Name EnableModuleLogging -Value 1 -PropertyType DWORD -Force

# Enable PowerShell Transcription
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription" `
  -Name EnableTranscripting -Value 1 -PropertyType DWORD -Force

# Sysmon config for fileless detection (key events):
# Event ID 1: Process creation (captures CommandLine)
# Event ID 7: Image loaded (DLL loading)
# Event ID 8: CreateRemoteThread (injection)
# Event ID 10: Process access (LSASS access)
# Event ID 19/20/21: WMI events

Step 2: Detect PowerShell-Based Attacks

# Indicators of malicious PowerShell:

# Encoded command execution
EventID: 1
CommandLine contains: "powershell" AND ("-enc" OR "-e " OR "-encodedcommand" OR "FromBase64String")

# Download cradle patterns
CommandLine contains: "IEX" AND ("Net.WebClient" OR "DownloadString" OR "Invoke-WebRequest")
CommandLine contains: "Invoke-Expression" AND "New-Object"

# AMSI bypass attempts (Event ID 4104 - Script Block)
ScriptBlock contains: ("Amsi"+"Utils") OR ("amsi"+"InitFailed") OR "SetValue.*amsi"

# Splunk query for suspicious PowerShell:
index=windows source="WinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104
| where match(ScriptBlockText, "(?i)(iex|invoke-expression|downloadstring|net\.webclient|frombase64|bypass|amsi.utils)")
| table _time host ScriptBlockText

Step 3: Detect Process Injection Techniques

# Reflective DLL injection - loads DLL from memory without touching disk
# Detection: Sysmon Event 7 (ImageLoaded) where image path is unusual
EventID: 7
ImageLoaded NOT starts with: "C:\Windows\" AND NOT starts with: "C:\Program Files"

# Process hollowing - creates process in suspended state, replaces memory
# Detection: Process creation followed by immediate memory write
EventID: 1 + 10 correlation
# Process created then accessed with PROCESS_VM_WRITE

# APC injection - queues code to thread's async procedure call queue
# Detection: Sysmon CreateRemoteThread from non-system process
EventID: 8
SourceImage NOT IN (known_legitimate_sources)

# MDE KQL:
DeviceEvents
| where ActionType in ("CreateRemoteThreadApiCall", "NtAllocateVirtualMemoryApiCall")
| where InitiatingProcessFileName !in ("MsMpEng.exe", "svchost.exe")
| project Timestamp, DeviceName, ActionType, InitiatingProcessFileName,
    InitiatingProcessCommandLine, FileName

Step 4: Detect WMI-Based Persistence

# Sysmon Event IDs 19/20/21 for WMI events
EventID: 19  # WmiEventFilter activity detected
EventID: 20  # WmiEventConsumer activity detected
EventID: 21  # WmiEventConsumerToFilter activity detected

# Any WMI event subscription creation is suspicious unless expected
# Common malicious WMI persistence:
Consumer contains: "CommandLineEventConsumer" OR "ActiveScriptEventConsumer"

# Query for WMI subscriptions via osquery or PowerShell:
Get-WMIObject -Namespace root\Subscription -Class __EventFilter
Get-WMIObject -Namespace root\Subscription -Class __EventConsumer
Get-WMIObject -Namespace root\Subscription -Class __FilterToConsumerBinding

Step 5: Detect Registry-Based Execution

# Malware stored in registry values and executed via PowerShell
# Sysmon Event 13 - Registry value set with encoded content
EventID: 13
TargetObject contains: "CurrentVersion\Run"
Details: unusually long value or Base64-encoded content

# Detection query:
index=sysmon EventCode=13
| where match(Details, "[A-Za-z0-9+/=]{100,}")
| table _time host TargetObject Details Image

Key Concepts

TermDefinition
Fileless MalwareMalware that operates entirely in memory without writing executable files to disk
AMSIAntimalware Scan Interface; Windows API allowing security products to inspect script content before execution
Reflective DLL InjectionLoading a DLL from memory rather than disk, avoiding file-based detection
Process HollowingCreating a legitimate process in suspended state and replacing its memory with malicious code
Script Block LoggingPowerShell logging feature that captures deobfuscated script content (Event ID 4104)

Tools & Systems

  • Sysmon: Kernel-level process, DLL, and WMI monitoring
  • AMSI: Windows script content inspection API
  • PowerShell Logging: Script Block, Module, and Transcription logging
  • Microsoft Defender for Endpoint: Behavioral detection for fileless techniques
  • Volatility 3: Memory forensics for post-incident fileless malware analysis

Common Pitfalls

  • Relying on file-based AV: Traditional AV that scans files on disk will miss fileless attacks entirely. Behavioral detection and AMSI are required.
  • Disabled PowerShell logging: Without Script Block Logging, deobfuscated PowerShell commands are invisible to defenders.
  • AMSI bypass not detected: Sophisticated attackers bypass AMSI before executing payloads. Detect AMSI bypass attempts as a high-priority alert.
  • Not monitoring WMI events: WMI persistence is a favored technique of APT groups. Sysmon events 19-21 must be enabled.

Frequently asked questions about Detecting Fileless Attacks

Similar skills