/quark:rule-genfrom quark
Generates Quark Engine detection rules from behavior descriptions and decompiled APK code, with validation against real APKs.
Ships in quark. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Use this skill when the user wants to create a Quark rule that detects a specific malicious behavior. The skill guides you through identifying the right API pair, formatting Dalvik descriptors correctly, and validating that the rule actually matches the target APK.
quark --version
If this fails, stop and tell the user: "Quark not found — run pip install quark-engine and try again."
Ask the user to describe the behavior they want to detect in plain English. Example: "Send the device's GPS location via SMS to a remote number."
A decompiled code snippet is required to identify the correct class names, method names, and descriptors. Without it, any generated rule is a guess and the retry loop has no new information.
If the user provides a code snippet: proceed to Step 3.
If no snippet is available: extract relevant method listings from the APK:
# Native Android SDK APIs only, filtered by suspected package — use this first
quark -i native -a "<apk_path>" | grep "<suspected_package>"
# Only if -i native finds nothing: fall back to all methods (very large output)
quark -i all -a "<apk_path>" | grep "<suspected_package>"
Ask the user which package namespace to search for, or search for the most likely Android SDK classes for the described behavior (e.g., SmsManager, LocationManager, TelephonyManager).
From the code snippet, identify exactly two Android API calls that together characterize the behavior:
Quark rules use Dalvik bytecode descriptor syntax. Getting this wrong causes the rule to silently return zero results.
Class names:
L + package path (with / separators) + ;Landroid/telephony/SmsManager;Method descriptors:
(param1param2...)ReturnType;, primitive params are single chars(Ljava/lang/String;Landroid/content/Context;)V(Ljava/lang/String; Landroid/content/Context;)VPrimitive types:
| Java type | Dalvik |
|---|---|
| void | V |
| int | I |
| boolean | Z |
| byte | B |
| long | J |
| byte[] | [B |
Verified example rule (sendLocation_SMS.json):
{
"crime": "Send Location via SMS",
"permission": [
"android.permission.SEND_SMS",
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.ACCESS_FINE_LOCATION"
],
"api": [
{
"class": "Landroid/telephony/TelephonyManager;",
"method": "getCellLocation",
"descriptor": "()Landroid/telephony/CellLocation;"
},
{
"class": "Landroid/telephony/SmsManager;",
"method": "sendTextMessage",
"descriptor": "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V"
}
],
"score": 1,
"label": ["location", "collection"]
}
Score — always set 1 for a newly generated rule. The final score depends on
how the behavior is distributed across real malware samples, so an analyst must
study that distribution and adjust the score later.
Labels — use canonical labels from the existing rules repo:
collection, sms, network, file, command, control, reflection,
telephony, accessibility service, record, wifi, location, screen,
calllog, camera, applications, http, calendar, socket, evasion
Invent a new label only if none of the above apply — document it in your PR.
Write the rule JSON to a temp file:
cat > /tmp/quark_candidate_rule.json << 'EOF'
{
"crime": "...",
"permission": ["..."],
"api": [
{"class": "...", "method": "...", "descriptor": "..."},
{"class": "...", "method": "...", "descriptor": "..."}
],
"score": 1,
"label": ["..."]
}
EOF
bash "${CLAUDE_PLUGIN_ROOT}/skills/rule-gen/scripts/validate_rule.sh" "<apk_path>" /tmp/quark_candidate_rule.json
If behaviors detected (exit 0): proceed to Step 8.
If zero behaviors (exit 1): return to Step 3 with the code snippet still in context. Revise the API pair or descriptor — common causes of zero results:
L prefix or ; suffix)Maximum 3 attempts total. If still zero after 3 tries, tell the user what was tried and ask them to provide a more specific code snippet or a different API pair.
Present the validated rule JSON and suggest a filename:
<crime_in_snake_case>.json
Example: send_location_via_sms.json
Tell the user: "Place this file in your rules directory (~/.quark-engine/quark-rules/rules/ for the default set, or a custom directory passed with -r)."
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ev-flow/quark-engine --plugin quark2 skills in this plugin
Other plugins' skills for the same job