You can generate Velociraptor VQL with an LLM, and the draft will usually look right. Models know the shape of a VQL artifact: a name, some parameters, a sources list with a SELECT that calls glob() or another artifact. What they get wrong are the names. They call artifacts that don't exist, use function names from other tools, and pass parameters with the wrong spelling. The second problem is quieter: a query that uses only real names can still run sources you didn't ask for and flag the wrong rows.
This guide tests both on a lab. Every Velociraptor result below came from Velociraptor v0.77.4, the current release on the Velociraptor GitHub releases page, installed from the official velociraptor-v0.77.4-linux-amd64 binary after checking its GPG signature against the key ID on the downloads page. We ran it on a disposable Linux lab machine we control, against synthetic cron files. Plugin, function and artifact names were checked against the VQL reference and against the binary itself. The drafts were written for this guide to show mistakes models commonly make in VQL. They are not a captured model transcript, and no model was called in the lab. Velociraptor's output is the evidence.
Authorized work only. Collect from your own lab machines or from endpoints your engagement or incident scope covers. Test a new artifact on one lab machine before it goes anywhere near a hunt, and keep remediation (quarantine, killing processes, deleting files) out of anything a model wrote.
If you know osquery, the job is similar but the language is not: osquery asks SQL questions of fixed tables, covered in osquery queries with an LLM, while VQL chains plugins and whole artifacts on the endpoint. For queries over logs you have already centralized, see KQL hunting queries and Sigma and YARA rules.
Why generate Velociraptor VQL with an LLM
Velociraptor ships hundreds of built-in artifacts, and the Artifact Exchange adds more. The ones you need during an investigation are often narrower than either: this persistence trick on this distro, this file path from this intrusion, joined with a hash so you can pivot. Writing that artifact by hand means looking up plugin names, argument names and the columns another artifact returns. That lookup is the part a model speeds up, and also the part it gets wrong.
The useful shape of the work is: the model drafts, Velociraptor checks, you read the result. There are three checks, and each one catches a different class of mistake.
How to test an LLM Velociraptor artifact
Ask three questions, in order:
- Do the names exist?
velociraptor artifacts verifystatically checks artifact references, plugin and function names, and argument names. The CLI docs describe it as "linting" for CI pipelines, and it exits with errorlevel 1 when an artifact fails. - Does a collection finish cleanly? Run the artifact with
velociraptor artifacts collecton a lab machine and read stderr and the exit code, not just the rows. - Does it return the right rows and nothing else? Plant known-bad and known-benign data, and check which rows come back, which files get uploaded, and whether every row has the fields you asked for.
The first check is cheap and strict. The third is the one that decides whether the artifact is safe to run on a real endpoint.
Step 1: Build a lab with planted cron persistence
The test case is a common Linux triage question: which cron jobs run a file out of /tmp, /var/tmp or /dev/shm, and what is that file? We wrote four cron files under a lab directory and two harmless stand-in scripts (three lines of shell that exit 0) at the paths they reference, with made-up September mtimes like a dropped file might carry:
| Lab file | Entry | Expected result |
|---|---|---|
etc/crontab | Two standard run-parts lines, plus 0 3 * * * root /usr/bin/find /tmp /var/tmp -type f -mtime +7 -delete | Not flagged. The cleanup job mentions /tmp but runs /usr/bin/find |
etc/cron.d/logrotate-lab | */30 * * * * root /usr/sbin/logrotate /etc/logrotate.conf | Not flagged |
etc/cron.d/.sys-update | */10 * * * * root /dev/shm/.cache/kworker-upd >/dev/null 2>&1 | Flagged, with the target's hash |
var/spool/cron/crontabs/www-data | @reboot /tmp/.font-cache/sshd-helper -q | Flagged, with the target's hash and www-data as the user |
The cleanup job is the important row. Plenty of legitimate cron entries mention /tmp as an argument, and a loose filter flags them. The hidden .sys-update file name and the user crontab, which has no user column, are there because real persistence often looks like that.
The artifact reads cron files through the built-in Linux.Sys.Crontab artifact, so we checked its name, parameters and sources against the binary first:
$ velociraptor query "SELECT name, parameters.name AS params, sources.name AS sources FROM artifact_definitions(names='Linux.Sys.Crontab')" --format=jsonl
{"name":"Linux.Sys.Crontab","params":["cronTabGlob","cronTabScripts","Length"],"sources":["CronTabs","CronScripts","Uploaded"]}
Three sources. Keep that in mind for Step 4.
Step 2: The prompt for an AI Velociraptor query
A prompt that gives the model enough to work with:
Write one Velociraptor CLIENT artifact named Custom.Linux.Lab.CronTmpTargets for Velociraptor v0.77. Use the built-in artifact Linux.Sys.Crontab (parameters: cronTabGlob, cronTabScripts, Length; sources: CronTabs, CronScripts, Uploaded; CronTabs columns: Event, User, Minute, Hour, DayOfMonth, Month, DayOfWeek, Command, Path). Take a CronGlob parameter and pass it as cronTabGlob. Read only the CronTabs source. Flag entries whose executed path starts with /tmp/, /var/tmp/ or /dev/shm/, not entries that only mention those directories as arguments. For each flagged entry, return the cron file, the user (for user crontabs, the file name), the command, the target path, and the target's size, mtime and SHA-256. Read-only: no uploads. Use only plugins, functions and arguments documented in the VQL reference. Return YAML only.
The prompt carries the called artifact's real parameters, sources and columns. That context prevents most of the naming errors below. If you don't know them, get them from the artifact_definitions() query in Step 1 and paste the output in.
Step 3: The LLM first draft fails on a wrong artifact name
A typical first draft, from a vaguer prompt ("write a Velociraptor artifact that finds cron jobs running files from /tmp or /dev/shm and hashes them"):
name: Custom.Linux.Lab.CronTmpTargets
description: |
Find cron jobs that execute files from world-writable directories
and hash the target file.
type: CLIENT
parameters:
- name: CronGlob
default: /etc/crontab,/etc/cron.d/**,/var/spool/cron/crontabs/**
sources:
- precondition: SELECT OS FROM info() WHERE OS = 'linux'
query: |
LET cron = SELECT * FROM Artifact.Linux.Sys.Cron(cronTabGlob=CronGlob)
SELECT Path AS CronFile, User, Command,
hash_file(path=commandline_split(command=Command)[0]).SHA256 AS SHA256
FROM cron
WHERE Command =~ "/tmp|/var/tmp|/dev/shm"
It reads well. artifacts verify stops it on the first line of the query:
$ velociraptor artifacts verify defs/draft/cron_tmp_targets.yaml
ERROR: (0,0) artifact_vql_error: Custom.Linux.Lab.CronTmpTargets: query: Unknown artifact reference Linux.Sys.Cron
velociraptor: error: artifacts verify: Failed!
$ echo $?
1
The artifact is Linux.Sys.Crontab. With the name fixed, the next run reports the second invented name:
ERROR: (0,0) artifact_vql_error: Custom.Linux.Lab.CronTmpTargets: query: (4,8) unknown_plugin: Unknown function hash_file()
The function is hash(), and its argument is path. We also tried the two variants models often produce. verify caught both:
# hash(filename=...) instead of hash(path=...)
ERROR: ... query: (4,13) invalid_arg: Invalid arg filename for function hash()
ERROR: ... query: (4,8) required_arg_missing: While calling function hash(), required arg path is not provided
# CronTabGlob= instead of cronTabGlob= in the artifact call
ERROR: ... query: (1,53) unknown_parameter_in_call: Call to Artifact.Linux.Sys.Crontab contains unknown parameter CronTabGlob
Parameter names in an artifact call are case-sensitive. Feed each error back to the model as is. Each one names the exact symbol and its position in the query.
Step 4: It passes verify and still does the wrong thing
With Linux.Sys.Crontab and hash() in place, the draft passes:
$ velociraptor artifacts verify defs/draft3/cron_tmp_targets.yaml
$ echo $?
0
Then we collected it against the lab cron files:
$ velociraptor -D defs/draft3 artifacts collect Custom.Linux.Lab.CronTmpTargets \
--args CronGlob="$LAB/etc/crontab,$LAB/etc/cron.d/**,$LAB/var/spool/cron/crontabs/**" \
--output "$PWD/draft3.zip"
[ERROR] Symbol Command not found. Current Scope is [...], [Mtime, OSPath, Content, _Source]
[ERROR] Symbol Command not found. Current Scope is [...], [OSPath, Upload, _Source]
... (15 of these in total)
velociraptor: error: artifacts collect: Symbol Command not found. ...
$ echo $?
1
The rows that did come back, condensed from the JSON:
CronFile User Command SHA256
lab/etc/crontab root /usr/bin/find /tmp /var/tmp -type f -mtime +7 -delete 91b75e72c495... (this is /usr/bin/find)
lab/etc/cron.d/.sys-update root /dev/shm/.cache/kworker-upd >/dev/null 2>&1 46550828c10e...
lab/var/spool/cron/crontabs/www-data null /tmp/.font-cache/sshd-helper -q 151029dda88c...
And the collection zip held nine uploaded files (lab paths shortened):
uploads/auto/etc/cron.daily/apt-compat
uploads/auto/etc/cron.daily/dpkg
uploads/auto/etc/cron.daily/google-chrome
uploads/auto/etc/cron.daily/logrotate
uploads/auto/etc/cron.daily/sysstat
uploads/auto/.../lab/etc/crontab
uploads/auto/.../lab/etc/cron.d/%2Esys-update
uploads/auto/.../lab/etc/cron.d/logrotate-lab
uploads/auto/.../lab/var/spool/cron/crontabs/www-data
None of this is a syntax error. Four things went wrong:
- The call ran all three sources.
Artifact.Linux.Sys.Crontab()withoutsource=runsCronTabs,CronScriptsandUploaded. The calling artifacts docs say each source's results are consolidated into a single table that "could possibly have columns which differ per row". TheCronScriptsandUploadedrows have noCommandcolumn, so theWHEREclause errored on every one, and the collection exited 1. - It uploaded files the prompt never asked for. The
Uploadedsource callsupload()on every cron file, and becausecronTabScriptskept its default, that included five scripts from the lab machine's real/etc/cron.daily. On a client endpoint, that is data collection you did not plan or scope. - The filter flagged the cleanup job.
Command =~ "/tmp|/var/tmp|/dev/shm"matches any command that mentions those paths. The first token of the cleanup job is/usr/bin/find, so the "suspicious" hash is the systemfindbinary. - The user crontab has no user. Lines in
/var/spool/cron/crontabs/<user>have no user field.Usercomes backnullfor the one row that most needs it.
Step 5: The fixed artifact
name: Custom.Linux.Lab.CronTmpTargets
description: |
Lab triage: cron entries that execute a file from /tmp, /var/tmp or
/dev/shm, with that file's size, mtime and SHA-256.
Read-only. Collect only from lab machines or endpoints in scope.
type: CLIENT
parameters:
- name: CronGlob
default: /etc/crontab,/etc/cron.d/**,/var/spool/cron/crontabs/**
sources:
- precondition: SELECT OS FROM info() WHERE OS = 'linux'
query: |
LET cron = SELECT * FROM Artifact.Linux.Sys.Crontab(
cronTabGlob=CronGlob, source="CronTabs")
LET hits = SELECT Path AS CronFile,
User || Path.Basename AS RunAs,
Command,
parse_string_with_regex(string=Command,
regex="(?:^|\\s)(?P<Target>/(?:tmp|var/tmp|dev/shm)/[^\\s;|&>]+)").Target AS Target
FROM cron
WHERE Target
SELECT CronFile, RunAs, Command, Target,
stat(filename=Target).Size AS TargetSize,
stat(filename=Target).Mtime AS TargetMtime,
hash(path=Target).SHA256 AS SHA256
FROM hits
What changed:
source="CronTabs"limits the call to the one source we want. Built-in artifacts use the same argument, for exampleArtifact.Windows.Forensics.SAM(..., source="Parsed"). NoCronScriptsrows, noUploadedrows, no uploads.- A path match, not a substring match.
parse_string_with_regex()returns a dict of named capture groups. The regex only matches a path that starts at the beginning of the command or after whitespace, and that has at least one character after the directory./tmpas an argument tofinddoesn't match. User || Path.Basename. In VQL,||"returns the first true value encountered", per the VQL fundamentals. System crontabs keep their user column; user crontabs fall back to the file name, which is the user.- Hash the target, not the first token.
stat()andhash()take the extracted path.
It verifies, and the collection finishes with exit code 0 and no errors:
$ velociraptor artifacts verify defs/fixed/cron_tmp_targets.yaml
$ echo $?
0
$ velociraptor -D defs/fixed artifacts collect Custom.Linux.Lab.CronTmpTargets \
--args CronGlob="$LAB/etc/crontab,$LAB/etc/cron.d/**,$LAB/var/spool/cron/crontabs/**" \
--format=json
[
{
"CronFile": "/workspace/seo/velo-lab/lab/etc/cron.d/.sys-update",
"RunAs": "root",
"Command": "/dev/shm/.cache/kworker-upd \u003e/dev/null 2\u003e\u00261",
"Target": "/dev/shm/.cache/kworker-upd",
"TargetSize": 46,
"TargetMtime": "2026-09-08T03:12:44Z",
"SHA256": "46550828c10e856f5528a1ae202b09f60a99179fef18c8a1cb8df0f6ff51b01a",
"_Source": "Custom.Linux.Lab.CronTmpTargets"
},
{
"CronFile": "/workspace/seo/velo-lab/lab/var/spool/cron/crontabs/www-data",
"RunAs": "www-data",
"Command": "/tmp/.font-cache/sshd-helper -q",
"Target": "/tmp/.font-cache/sshd-helper",
"TargetSize": 48,
"TargetMtime": "2026-09-08T03:14:09Z",
"SHA256": "151029dda88c8faf76212b47e5605e92bcfd9748451244b5a97fc5bcbc6962d8",
"_Source": "Custom.Linux.Lab.CronTmpTargets"
}
]
Two rows, both planted. The cleanup job and the logrotate entry are gone, the user crontab has its user, and the hashes match sha256sum on the stand-in files. The same collection with --output produced a zip with results and logs and no uploads/ folder.
A wrong artifact name can fail silently in ad-hoc queries
artifacts verify is strict about artifact names. An ad-hoc velociraptor query is not. A misspelled plugin fails loudly:
$ velociraptor query "SELECT * FROM file_search(globs='/tmp/*')"
[ERROR] Plugin file_search not found. Did you mean filesystems index_search profile profile_goroutines profile_memory read_crypto_file read_file write_crypto_file?
$ echo $?
1
A misspelled artifact does not:
$ velociraptor query "SELECT * FROM Artifact.Linux.Sys.Cron()" --format=jsonl
$ echo $?
0
No rows, no error, exit code 0. With -v, the only trace is an INFO line: Artifact Linux.Sys.Cron not found. An unknown function is reported at runtime (Symbol hash_file not found, exit code 1), and the column comes back null. If you test model-written VQL in a notebook or with velociraptor query, an empty result can mean the artifact name is wrong, not that the endpoint is clean. Wrap the query in an artifact and run artifacts verify before you trust an empty table.
You can also ask the binary directly. The help() plugin lists every VQL function and plugin with its arguments, and artifact_definitions() lists every loaded artifact:
$ velociraptor query "SELECT name, type FROM help() WHERE name =~ 'hash'" --format=jsonl
{"name":"hash","type":"Function"}
{"name":"tlsh_hash","type":"Function"}
$ velociraptor query "SELECT name FROM artifact_definitions() WHERE name =~ '(?i)cron'" --format=jsonl
{"name":"Linux.Sys.Crontab"}
Run those against the same version you will deploy, and paste the output into the prompt. Names change between releases, and your build may include custom or Exchange artifacts the model has never seen.
Common mistakes when you generate Velociraptor VQL with an LLM
- Invented artifact names.
Linux.Sys.Cron,Linux.Persistence.Cronand similar look plausible.artifacts verifycatches them; an ad-hoc query returns nothing. - Function names from other tools.
hash_file(),file_search(),sha256(). Check withhelp(). - Wrong argument names and case.
hash(filename=...)instead ofhash(path=...),glob(glob=...)instead ofglob(globs=...),CronTabGlobinstead ofcronTabGlob. - Calling a multi-source artifact without
source=. You get every source, mixed columns and any uploads those sources perform. - Substring filters on command lines. Match the executed path, not any mention of a directory.
- Ignoring stderr and the exit code. A collection that returns some rows can still have errored on others.
- Testing only the positive case. A query that flags the planted entry proves half the claim. Plant a benign entry that looks similar and check it stays out.
What to send the model
- Send: your Velociraptor version, the
artifact_definitions()output for any artifact you call,help()output for functions you are unsure of, a scrubbed sample of the input (cron lines, paths, registry values), the negative case, and the exact error text fromverifyor the collection. - Scrub: hostnames, usernames, client IDs, internal paths and anything from a real collection, unless your engagement terms allow sharing it. Rebuild the case on a lab machine with placeholder names, get the artifact working there, then run it in scope.
- Don't send collection zips. They contain uploaded files and logs.
- Check retention. On RedRouter, zero data retention is an opt-in setting, off by default. The data handling docs explain what is stored and how to turn it on, and what RedRouter keeps walks through it.
Automating the check
The checking half is two Velociraptor commands, so it scripts easily. This checker runs artifacts verify, collects the artifact into a zip against the lab cron files, and fails on errors, a non-zero exit code, any uploaded file, missing hashes, or the wrong set of flagged cron files. We ran it on the drafts above:
import json, os, subprocess, tempfile, zipfile
VR = "velociraptor"
NAME = "Custom.Linux.Lab.CronTmpTargets"
LAB = "/workspace/seo/velo-lab/lab" # synthetic cron files
CRON_GLOB = f"{LAB}/etc/crontab,{LAB}/etc/cron.d/**,{LAB}/var/spool/cron/crontabs/**"
EXPECTED = {".sys-update", "www-data"} # the two planted cron files
def check(artifact_dir):
v = subprocess.run([VR, "--nobanner", "artifacts", "verify", artifact_dir],
capture_output=True, text=True)
if v.returncode != 0:
errs = [l for l in (v.stdout + v.stderr).splitlines() if l.startswith("ERROR:")]
return False, "artifacts verify failed:\n" + "\n".join(errs)
with tempfile.TemporaryDirectory() as tmp:
out = os.path.join(tmp, "c.zip")
c = subprocess.run([VR, "--nobanner", "-D", artifact_dir, "artifacts", "collect", NAME,
"--args", f"CronGlob={CRON_GLOB}", "--format=json", "--output", out],
capture_output=True, text=True)
uploads, rows = [], []
if os.path.exists(out):
z = zipfile.ZipFile(out)
uploads = [n for n in z.namelist() if n.startswith("uploads/")]
res = f"results/{NAME}.json"
if res in z.namelist():
rows = [json.loads(l) for l in z.read(res).decode().splitlines() if l.strip()]
# drop the "[ERROR] <timestamp>" prefix and the scope dump
errors = sorted({l.split("Z ", 1)[-1].split(". Current Scope")[0].strip()
for l in c.stderr.splitlines() if "[ERROR]" in l})
flagged = {os.path.basename(r["CronFile"]) for r in rows if r.get("CronFile")}
problems = []
if c.returncode != 0 or errors:
problems.append(f"collection exit {c.returncode}, errors: {errors[:2]}")
if uploads:
problems.append(f"{len(uploads)} files uploaded (expected none)")
if flagged != EXPECTED:
problems.append(f"flagged {sorted(flagged) or 'nothing'}; expected {sorted(EXPECTED)}")
if any(not r.get("SHA256") for r in rows):
problems.append("a row has no SHA256")
if problems:
return False, "Verifies, but:\n- " + "\n- ".join(problems)
return True, f"OK: flagged {sorted(flagged)}, hashed {[r['Target'] for r in rows]}, no errors, no uploads"
Pass --output an absolute path. In our run, a relative path resolved against /, and the only sign of failure was an INFO line, collect: open /relprobe-xyz.zip: permission denied, with exit code 0.
Its output:
defs/draft
artifacts verify failed:
ERROR: (0,0) artifact_vql_error: Custom.Linux.Lab.CronTmpTargets: query: Unknown artifact reference Linux.Sys.Cron
defs/draft3
Verifies, but:
- collection exit 1, errors: ['Symbol Command not found']
- 9 files uploaded (expected none)
- flagged ['.sys-update', 'crontab', 'www-data']; expected ['.sys-update', 'www-data']
defs/fixed
OK: flagged ['.sys-update', 'www-data'], hashed ['/dev/shm/.cache/kworker-upd', '/tmp/.font-cache/sshd-helper'], no errors, no uploads
The model half feeds that message back. This sketch uses the OpenAI Python SDK with RedRouter's https://redrouter.org/v1 base URL from the quickstart. We did not run it against the API for this post:
import os
from openai import OpenAI
llm = OpenAI(base_url="https://redrouter.org/v1", api_key=os.environ["REDROUTER_API_KEY"])
messages = [{"role": "user", "content": open("prompt.txt").read()}]
os.makedirs("candidate", exist_ok=True)
for attempt in range(4):
reply = llm.chat.completions.create(model="glm-5.3-flash-red", messages=messages)
yaml_text = reply.choices[0].message.content.strip().removeprefix("```yaml").strip("`").strip()
open("candidate/cron_tmp_targets.yaml", "w").write(yaml_text + "\n")
ok, note = check("candidate")
print(note)
if ok:
break
messages += [{"role": "assistant", "content": yaml_text},
{"role": "user", "content": note + "\nReturn the fixed artifact YAML only."}]
Keep the loop on a lab machine. The checker collects the candidate locally, so a model-written artifact runs with your permissions before you have read it. Read the final YAML yourself before you add it to a server, and test it on one lab client before any hunt.
There are also Model Context Protocol bridges, such as mgreen27/mcp-velociraptor, that let an agent talk to a Velociraptor server directly. This guide doesn't use one. Whatever writes the VQL, the same three checks apply before it touches an endpoint.
Choosing a model for Velociraptor VQL
Use any model that follows a "YAML only" instruction and can take a few rounds of error messages. On RedRouter, GLM 5.3 Flash Red (glm-5.3-flash-red) is $0.25 per 1M input tokens, $0.13 per 1M cached input tokens and $1.00 per 1M output tokens. red-cyber-1 (Beta), the featured model for authorized penetration testing and red-team work, is $0.28 / $0.13 / $1.10 per 1M tokens. The models docs list current rates for every model; plans are on /pricing.
DFIR prompts describe persistence, malware paths and attacker tradecraft in plain terms. RedRouter is built for that kind of authorized security work.
FAQ
Can I generate Velociraptor VQL with an LLM?
Yes, as a first draft. In our lab, a model-style draft failed artifacts verify on an invented artifact name and an invented function. Once those were fixed, it verified but errored at collection time, uploaded nine files and flagged a cleanup job. Limiting the artifact call to one source and matching the executed path fixed all three.
Does velociraptor artifacts verify catch wrong plugin or artifact names?
Yes. In v0.77.4 it reported an unknown artifact reference, an unknown function, an invalid argument, a missing required argument and an unknown parameter in an artifact call, and exited 1. It does not catch logic mistakes such as running the wrong sources or a filter that is too broad.
Why does my LLM Velociraptor artifact return no rows?
Check the artifact name first. An ad-hoc velociraptor query with a misspelled artifact returned no rows and exit code 0; the only trace was an INFO line with -v. Then check stderr for "Symbol not found" errors and confirm parameter names with artifact_definitions().
How do I check that a VQL function or plugin exists?
Ask the binary: SELECT name, type, args.name FROM help() WHERE name =~ 'hash' lists matching functions and plugins with their arguments. The VQL reference has the same information online.
Should an AI Velociraptor query run as a hunt?
Not until a person has read it and it has run cleanly on a lab client. Hunts run on many endpoints at once. Keep model-written VQL read-only, and leave quarantine, process killing and file deletion out of it.
Is it safe to paste Velociraptor results into an LLM?
Not raw collection data unless your engagement terms allow it. Send the schema, error text and lab-style samples instead. On RedRouter, zero data retention is opt-in and off by default; see the data handling docs.
Sources
- Velociraptor documentation: VQL reference,
hash(),glob(),stat(),parse_string_with_regex(),help(), Calling artifacts from VQL, VQL fundamentals, artifacts CLI commands (verify,collect), query CLI command, Linux.Sys.Crontab, Downloads (signing key ID), Artifact Exchange. - Velociraptor: GitHub releases, v0.77.4 release.
- mgreen27/mcp-velociraptor.
- Lab outputs: Velociraptor v0.77.4 (official linux-amd64 binary, GPG signature verified) on a disposable Linux lab machine with synthetic cron files and two stand-in scripts.
- OpenAI Python SDK.
- RedRouter Docs: Quickstart, Models and pricing, Data handling.