• Home
  • Learn
  • DetectionHub
  • Ranking
  • About
  • Blog
  • Login
Medium·Updated on 2025-03-15

LOLBas-Forfiles Tool Abuse for Arbitrary Command Execution

1,234
Submissions
67.5%
Pass Rate
10 minutes
Estimated Time
Sysmon LOLBAS

Description

The LOLBas (Living Off The Land Binaries, Scripts and Libraries) project documents numerous Windows native tools that can be maliciously exploited. These legitimate system components are frequently abused in red team operations and APT attacks to bypass security detection and execute malicious operations.

forfiles.exe is a built-in Windows file search and batch processing tool designed to find files based on specified criteria and execute designated operations on each matching file.

Attackers can exploit this tool’s command execution capabilities by cleverly crafting parameter combinations to achieve arbitrary code execution, using it as a proxy tool for command execution.

In real attack scenarios, abnormal invocation of such legitimate tools often provides strong stealth capabilities, effectively bypassing simple detection mechanisms based on process names. Timely identification of abnormal usage patterns of these legitimate tools is crucial for detecting advanced threat behaviors.

Challenge Objective

Write detection rules to identify suspicious behavior involving the use of forfiles tool for command execution.

When writing detection queries, ensure the IpAddress field is included in the output for further validation.

Data Sample

Data source: Sysmon; sample data:

{  "Channel": "Microsoft-Windows-Sysmon/Operational",  "CommandLine": "forfiles  /p c:\\windows\\system32 /m notepad.exe /c \"cmd /c c:\\windows\\system32\\calc.exe\"",  "Company": "Microsoft Corporation",  "Computer": "DESKTOP-xxxx",  "CurrentDirectory": "C:\\Users\\admin\\",  "Description": "ForFiles - Executes a command on selected files",  "EventId": 1,  "FileVersion": "10.0.19041.1 (WinBuild.160101.0800)",  "Hashes": "MD5=9BB67AEA5E26CB136F23F29CC48D6B9E,SHA256=9B4886F187489A190BB2C412772C1998539F086C63A4CFD72FF3B107CBC21907,IMPHASH=BB3BC1A3FEF88F916302D61DDC886F80",  "Image": "C:\\Windows\\System32\\forfiles.exe",  "IntegrityLevel": "Medium",  "LogonGuid": "{769c9af7-407c-6867-bd8c-1a0700000000}",  "LogonId": "0x71a8cbd",  "OriginalFileName": "forfiles.exe",  "ParentCommandLine": "\"C:\\WINDOWS\\system32\\cmd.exe\" ",  "ParentImage": "C:\\Windows\\System32\\cmd.exe",  "ParentProcessGuid": "{769c9af7-409e-6867-4509-000000000900}",  "ParentProcessId": "9152",  "ParentUser": "DESKTOP-xxxx\\admin",  "ProcessGuid": "{769c9af7-4121-6867-9109-000000000900}",  "ProcessId": "5184",  "Product": "Microsoft? Windows? Operating System",  "RuleName": "-",  "SystemTime": "2025-07-04T02:49:05.4247384Z",  "TerminalSessionId": "2",  "User": "DESKTOP-xxxx\\admin",  "UtcTime": "2025-07-04 02:49:05.421",}

References

loading...

Fields

No fields found

0 fields selected

Preview Results