Part 6 - Automated YARA Scanning
Learn how to automate YARA scanning with LimaCharlie for real-time malware detection. This guide covers setting up YARA rules, configuring automated scans, and detecting Sliver C2 implants in files an
Last updated
Learn how to automate YARA scanning with LimaCharlie for real-time malware detection. This guide covers setting up YARA rules, configuring automated scans, and detecting Sliver C2 implants in files an
Last updated
YARA helps detect malware by using custom rules to find suspicious patterns in files, processes, and network traffic. It's widely used for threat hunting and incident response.
We will prepare our LimaCharlie instance to detect file system and process activities to trigger YARA scans.
Adding a YARA Signature for the Sliver C2 Payload
Navigate to Automation > YARA Rules in LimaCharlie.
We will configure LimaCharlie to generate alerts when a YARA detection occurs.
Rule 1: YARA Detection
Navigate to Automation > D&R Rules.
Create a new rule:
Detect Block:
Respond Block:
Save the rule as YARA Detection.
Rule 2: YARA Detection in Memory
Create another rule:
Detect Block:
Respond Block:
Save the rule as YARA Detection in Memory.
Since we know a Sliver implant is in the Downloads folder of our Windows VM, we can verify our YARA signature by running a manual scan with the EDR sensor. This ensures everything is working correctly.
In LimaCharlie, go to Sensors List and select your Windows VM sensor.
Open the EDR Sensor Console.
Run the following command, replacing [payload_name]
with your actual payload name from Part 2 - Detecting C2 Activity
Press Enter twice to run the command.
Now we’re ready to automate this process 💪.
Create a new D&R rule: This rule detects and scans any process that runs from the Downloads folder. Since malware is often executed from Downloads, this helps catch potential threats in real time.
Detect Block:
Respond Block:
Save as YARA Scan Downloaded EXE.
Create a new D&R rule:
Detect Block:
Respond Block:
Notice Here :
Previously, we scanned files (using their file path) when they were downloaded.
Now, we scan running processes (using their process ID) instead.
The original YARA rules (from NCSC) failed to detect Sliver when it was running.
This is because those rules were designed to match specific file-based patterns, not live processes.
To fix this, the new rule (sliver-process
) was created, which looks for specific strings inside a running Sliver process.
Using LimaCharlie (LC), the analyst extracted strings from a running Sliver process.
Those strings were then used to refine the new YARA rule.
The screenshots confirm that the new rule detects Sliver in memory.
This rule ensures that even if Sliver bypasses file-based detection, it still gets caught when executed.
Since we already have the Sliver payload in Downloads, instead of re-downloading it, we move it to another folder (Documents) and then move it back to Downloads. This simulates a "newly downloaded" EXE.
Move the Sliver payload between directories:
Verify detections in the Detections tab.
Now this process ensures that any executable file (EXE) launched from the Downloads folder is detected and scanned using YARA.
Open an Admin PowerShell Prompt:
This is required to run the necessary commands with proper privileges.
Kill Any Existing Sliver C2 Processes:
Execute the Sliver payload:
Check the Detections tab for alerts.
This automated YARA scanning setup allows:
Scanning of newly downloaded EXEs.
Scanning of processes launched from the Downloads directory.
Customizable rules for other threat scenarios.
Ready to build your very own SOC Home Lab?
Follow Eric Capuano’s step-by-step guide here: