Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uupdate to proc_yara to optimise process scanning #47

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions artifacts/definitions/Windows/Detection/Yara/Process.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ sources:
query: |
-- check which Yara to use
LET yara_rules <= YaraUrl || YaraRule

-- find velociraptor process
LET me = SELECT Pid FROM pslist(pid=getpid())

Expand All @@ -112,8 +112,8 @@ sources:
ExePath,
CommandLine,
Pid,
Namespace,
Rule,
Tags,
Meta,
String.Name as YaraString,
String.Offset as HitOffset,
Expand All @@ -124,25 +124,26 @@ sources:
split(string=ProcessName, sep='\\.')[0], Pid,
String.Offset ]
)) as HitContext
FROM yara(
files=format(format="/%d", args=Pid),
accessor='process',
rules=yara_rules,
context=ContextBytes,
number=NumberOfHits)

FROM proc_yara(
pid=int(int=Pid),
rules=yara_rules,
context=ContextBytes,
number=NumberOfHits
)
})

-- upload hits using proc_dump plugin
LET upload_hits = SELECT * FROM foreach(
row=hits,
query={
SELECT
SELECT
ProcessName,
ExePath,
CommandLine,
Pid,
Namespace,
Rule,
Tags,
Meta,
YaraString,
HitOffset,
Expand All @@ -154,12 +155,12 @@ sources:
) as ProcessDump
FROM proc_dump(pid=Pid)
})

-- return rows
SELECT * FROM if(condition=UploadHits,
then=upload_hits,
else=hits)

column_types:
- name: HitContext
type: preview_upload
type: preview_upload