AI YARA and Sigma rules
Draft YARA and Sigma rules, then test
Paste a sample’s extracted strings or a short log excerpt into minimax-m3.1-flash-cybersecurity at https://api.pentestllm.ai/v1 and get a draft YARA or Sigma rule back, with a line on why each condition is there. Treat it as a first pass that is ready only after yara and sigma-cli have run it against files and logs whose answer you already know.
from openai import OpenAI client = OpenAI(base_url="https://api.pentestllm.ai/v1", api_key="sk-ptl-live-…") reply = client.chat.completions.create( model="auto/security", messages=[{"role": "user", "content": "Explain this advisory and list what to check on an affected host."}],)print(reply.model) # the build that answeredprint(reply.choices[0].message.content)What the model needs from you
A rule is only as good as the evidence you hand over. For YARA, give the strings you already pulled from the file, the file type, a rough size range and the kind of clean files it must never match. For Sigma, give a few raw events with the field names exactly as your pipeline stores them, the log source (for example Windows process creation from Sysmon) and one sentence on the behaviour you want to catch.
Say where the rule will run. A line like "exercise detection for the Q4 purple team, client lab, signed rules of engagement" gets a tighter answer than a bare request, and keeps the work inside the scope you agreed. The offensive half of that exercise lives on red team; if you do not have a written scope yet, the rules of engagement builder is a quick place to start one.
Prompt template: YARA from strings
Ask for one rule with a meta block, a one-line reason for each string you kept, the strings dropped as too common and why, and two clean file types the rule could still hit by accident. The per-string reasons are what let you spot library names and compiler banners that appear in thousands of clean files.
You write YARA rules for a detection engineering team.Context: purple team exercise under signed scope. The rule scans files on lab hosts. Strings extracted from the target file (one per line):<paste strings> File type: <PE / ELF / Office / script / text>Size range: <e.g. under 2 MB>Must not match: <e.g. our standard developer workstation image> Return: one YARA rule with a meta block; one line per kept string on why it is specific;the strings you dropped as too common; two clean file types this rule could still hit.Worked YARA example: a planted marker
The cleanest way to test a YARA workflow end to end is a canary: a string you plant yourself in a test file, so there is nothing to analyse and no doubt about the right answer. Ask for a rule that matches the marker in ASCII or UTF-16 and ignores case, then prove it both ways. Run the same two checks on every rule the model writes for a real sample: one known-positive file, one folder of known-clean files. If the clean folder prints anything, send the hit back to the model with the file type and ask which string caused it. Pulling the strings out of a sample is analysis work, covered on malware analysis.
echo "build tag ptl-purple-canary-2026" > canary.txtyara --fail-on-warnings -s canary.yar canary.txt # expect one hit with the matched stringyara --fail-on-warnings -r canary.yar ./clean-set/ # expect no output at allWorked Sigma example: a tool fetching a URL
certutil.exe is a Windows certificate utility that can also download files, which makes it a well-known detection idea; SigmaHQ publishes a rule for it. Hand the model your own Sysmon events from a lab host, ask for a draft, and compare its logic with the public rule afterwards. Validate the draft, then turn it into a query for your SIEM. sigma check catches structure and rule-quality issues but does not run the rule against events, so the last test happens in your SIEM: confirm the query fires on the lab event you reproduced, then run it over a week of normal logs and count the noise.
sigma check certutil_url.ymlsigma plugin install splunksigma convert -t splunk -p sysmon certutil_url.ymlWhere drafts usually go wrong
- Strings too common
- Library names and compiler banners appear in thousands of clean files; the per-string reasons make these easy to spot.
- Field names not in your data
- The model writes Sigma taxonomy names; the pipeline you pass with -p maps them to your fields, so check the converted query, not only the YAML.
- Single-value all
- The Sigma spec does not allow all on a single value; sigma check tells you, so fix it rather than suppress it.
- No negative test
- A rule that matched the sample has proved half of what you need; always run the clean-set folder too.
- No file constraints
- A YARA rule that matches a string anywhere scans every log and archive on the host; ask for a file-type check or a filesize limit when the format is known.
- Unversioned drafts
- Keep each draft, its test results and the model id in one commit, so you can tell later which rules a person wrote and which a model proposed.
Call it from a script
Any OpenAI-compatible client works; keys come from the console and per-token rates are on pricing. For Python and TypeScript setup, see the setup guides. Use this for authorized detection-engineering and purple-team work on data you are allowed to handle.
from openai import OpenAIclient = OpenAI(base_url="https://api.pentestllm.ai/v1", api_key="sk-ptl-live-...")reply = client.chat.completions.create( model="minimax-m3.1-flash-cybersecurity", messages=[ {"role": "system", "content": "You write YARA rules for a detection engineering team."}, {"role": "user", "content": "Strings: PTL-PURPLE-CANARY-2026. Text file. One rule, a reason per string."}, ],)print(reply.choices[0].message.content)16 security builds, priced per token
USD per million tokens, live on 2026-11-27; auto/security bills at the build that answers.
Detected refusals and invalid non-streamed JSON qualify for automatic refunds within the daily cap. Verify your receipt.
| Wire formats | |||||
|---|---|---|---|---|---|
| Qwen3.8 27B Cybersecurity | Security | $0.40 | $2.40 | 262K | |
| Uncensored Qwen3.8 27b Cybersecurity | Security | $0.40 | $2.40 | 262K | |
| Gemma 4 26B A4B Cybersecurity | Security | $0.4224 | $1.3376 | 262K | |
| Gemma 4 26B A4B Cybersecurity (Uncensored) | Security | $0.48 | $1.52 | 262K | |
| GLM-5.3 Flash Cybersecurity | Security | $0.4935 | $1.645 | 1049K | |
| GLM-5.3 Flash Cybersecurity (Uncensored) | Security | $0.5093 | $1.6975 | 1049K | |
| Red Team (Flash) | Security | $0.90 | $3.00 | 1000K | |
| Red Team (Pro) | Security | $1.50 | $6.00 | – | |
| OrcaCyber MiniMax M3.1 Flash | Security | $2.00 | $4.00 | 262K | |
| OrcaCyber MiniMax M3.1 Flash (Uncensored) | Security | $2.00 | $4.00 | 262K | |
| OrcaCyber Qwen3.8 Flash Next (Uncensored) | Security | $2.00 | $4.00 | 262K | |
| OrcaCyber Qwen3.8 Flash Next | Security | $2.00 | $4.00 | 262K | |
| Uncensored Qwen3.8 Flash Next Cybersecurity | Security | $2.00 | $4.00 | 262K | |
| Cyber Frontier | Security | $5.25 | $15.75 | 1049K | |
| OrcaCyber Zero 1.5 | Security | $7.50 | $18.75 | 999K | |
| OrcaCyber Zero 1.5 (Uncensored) | Security | $7.50 | $18.75 | 999K |
Questions
Can an AI write YARA rules I can deploy?
It can write a draft that compiles and often matches the sample. Whether it is deployable depends on your tests: one known-positive file, a folder of known-clean files and yara with fail-on-warnings. Deploy only what passes all three.
Does sigma-cli test a rule against my logs?
No. sigma check validates the rule and sigma convert produces a query for a backend such as Splunk. You run that query in your SIEM against a reproduced lab event and against normal traffic.
Which model should I use for detection rules?
Start with minimax-m3.1-flash-cybersecurity, or send auto/security and let the router pick. No public benchmark compares these builds on rule writing yet, so keep your canary and clean-set tests as the judge.
Is this an offensive tool?
No. Drafting YARA and Sigma rules is detection and defence work for authorized purple-team exercises. The page describes testing the rules, not evading them, and asks you to keep the exercise inside a signed scope.