Execute Eric Zimmerman’s LECmd and return output for analysis.
Created using @eduardfir SBECmd VQL as a quide.
LECmd is a CLI tool for analyzing lnk data. Learn more - https://github.com/EricZimmerman/LECmd
name: Windows.Applications.LECmd
description: |
Execute Eric Zimmerman's LECmd and return output for analysis.
Created using @eduardfir SBECmd VQL as a quide.
LECmd is a CLI tool for analyzing lnk data. Learn more - https://github.com/EricZimmerman/LECmd
author: Carlos Cajigas @carlos_cajigas
type: CLIENT
tools:
- name: LECmd
url: https://download.mikestammer.com/net6/LECmd.zip
parameters:
- name: sourceFile
default: .
type: regex
description: "RegEx pattern for the name or path of the lnk file. Example 'recent' folder"
- name: localPath
default: .
type: regex
description: "RegEx pattern for the name or path of the target of the lnk file. Example 'cmd.exe'"
- name: arguments
default: .
type: regex
description: "Arguments of the lnk file. Example '/c powershell Invoke-Command'"
- name: dateAfter
description: "search for lnk files with a SourceCreated after this date. YYYY-MM-DD"
- name: dateBefore
description: "search for lnk files with a SourceCreated before this date. YYYY-MM-DD"
precondition: SELECT OS From info() where OS = 'windows'
sources:
- query: |
-- get context on target binary
LET lecmdpackage <= SELECT * FROM Artifact.Generic.Utils.FetchBinary(
ToolName="LECmd", IsExecutable=FALSE)
-- build tempfolder for output
LET tmpdir <= tempdir()
-- decompress utility
LET payload = SELECT *
FROM unzip(filename=lecmdpackage[0].FullPath,
output_directory=tmpdir)
-- execute payload
LET deploy <= SELECT *
FROM execve(argv=[payload.NewPath[0],
"-d",
"c:/",
"--csv",
tmpdir + "lecmd",
"--csvf",
"results.csv"])
-- parse csv
SELECT SourceFile, LocalPath, Arguments, SourceCreated,
SourceModified, WorkingDirectory, RelativePath,
TargetCreated, TargetModified, DriveType, VolumeLabel
FROM parse_csv(filename=tmpdir + "lecmd" + "\\results.csv")
WHERE
(if(condition=dateAfter, then=SourceCreated > dateAfter,
else=TRUE) AND
if(condition=dateBefore, then=SourceCreated < dateBefore,
else=TRUE))
AND SourceFile =~ sourceFile
AND LocalPath =~ localPath
AND Arguments =~ arguments