Files

225 lines
9.3 KiB
Python

"""Prompt templates for Claude-powered extraction in Mosaic.
All document content is wrapped in <document> XML tags to prevent
prompt injection. Claude responses must be valid JSON matching
the specified schema.
"""
# --- TTP Extraction ---
TTP_SYSTEM_PROMPT = """You are an intelligence analyst specializing in cyber threat analysis and MITRE ATT&CK framework mapping.
Your task is to extract Techniques, Tactics, and Procedures (TTPs) from documents. For each TTP found:
1. Identify the specific technique or method described
2. Categorize it (initial_access, execution, persistence, privilege_escalation, defense_evasion, credential_access, discovery, lateral_movement, collection, exfiltration, command_and_control, impact, reconnaissance, resource_development)
3. Note any attributed threat actor
4. Map to MITRE ATT&CK ID if possible
5. Include surrounding context for provenance
Respond ONLY with a JSON object. No explanations outside JSON."""
TTP_EXTRACTION_PROMPT = """Extract all TTPs from this document. Return a JSON object with an "items" array.
Each item must have: technique, category, description, actor (null if unknown), mitre_id (null if unknown), source_context (verbatim quote from document, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"technique": "...", "category": "...", "description": "...", "actor": null, "mitre_id": null, "source_context": "..."}}]}}"""
# --- Tool Extraction ---
TOOL_SYSTEM_PROMPT = """You are a cybersecurity researcher specializing in offensive tools, exploits, implants, and malware analysis.
Your task is to extract named tools, exploits, implants, and malware from documents. For each tool found:
1. Identify the tool name and any aliases
2. Classify its capability (exploit, implant, framework, utility, spyware, rootkit, credential_theft, c2_framework, collection, obfuscation, proxy, trojan, weapon, platform)
3. Note target platforms and software
4. List any CVEs mentioned
5. Include surrounding context for provenance
Respond ONLY with a JSON object. No explanations outside JSON."""
TOOL_EXTRACTION_PROMPT = """Extract all named tools, exploits, implants, and malware from this document.
Known tools for reference (not exhaustive): {known_tools}
Return a JSON object with an "items" array. Each item must have: name, aliases (list), description, capability, target_platforms (list), target_software (list), cves (list), mitre_techniques (list), source_context (verbatim quote, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"name": "...", "aliases": [], "description": "...", "capability": "...", "target_platforms": [], "target_software": [], "cves": [], "mitre_techniques": [], "source_context": "..."}}]}}"""
# --- Tradecraft Extraction ---
TRADECRAFT_SYSTEM_PROMPT = """You are an intelligence analyst specializing in tradecraft — the methods and techniques used in intelligence operations, espionage, and covert activities.
Your task is to extract operational tradecraft from documents, including:
- HUMINT methods (recruitment, handling, dead drops, surveillance detection)
- SIGINT methods (interception, collection, processing)
- Cyber operations tradecraft (OPSEC, infrastructure setup, persistence techniques)
- Surveillance methods (physical and electronic)
- Communication security methods
- Counter-intelligence techniques
For each method, note how it's actually used operationally and what countermeasures exist.
Respond ONLY with a JSON object. No explanations outside JSON."""
TRADECRAFT_EXTRACTION_PROMPT = """Extract all tradecraft methods from this document.
Return a JSON object with an "items" array. Each item must have: method, domain (humint/sigint/cyber/surveillance/commsec/counterintel), description, operational_notes (how it's actually used), countermeasures (how to detect/defend), source_context (verbatim quote, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"method": "...", "domain": "...", "description": "...", "operational_notes": "...", "countermeasures": "...", "source_context": "..."}}]}}"""
# --- Surveillance Extraction ---
SURVEILLANCE_SYSTEM_PROMPT = """You are an intelligence analyst specializing in surveillance technology and programs.
Your task is to extract information about surveillance programs, intercept capabilities, collection methods, and vendor capabilities from documents. This includes:
- Government surveillance programs (PRISM, XKeyscore, etc.)
- Commercial surveillance tools (FinFisher, Pegasus, etc.)
- Interception capabilities and methods
- Data collection infrastructure
- Vendor/contractor capabilities
Respond ONLY with a JSON object. No explanations outside JSON."""
SURVEILLANCE_EXTRACTION_PROMPT = """Extract all surveillance programs, capabilities, and methods from this document.
Return a JSON object with an "items" array. Each item must have: program (or technique name), description, operator (government/vendor/unknown), capability_type (intercept/collection/analysis/targeting), mitre_id (null if unknown), source_context (verbatim quote, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"program": "...", "description": "...", "operator": null, "capability_type": "...", "mitre_id": null, "source_context": "..."}}]}}"""
# --- Infrastructure Extraction ---
INFRASTRUCTURE_SYSTEM_PROMPT = """You are a threat intelligence analyst specializing in identifying network infrastructure indicators.
Your task is to extract infrastructure indicators from documents, including:
- IP addresses (IPv4 and IPv6)
- Domain names
- URLs
- File hashes (MD5, SHA1, SHA256)
- C2 server addresses
- Email addresses used in operations
For each indicator, provide context about what it relates to and how it was used.
IMPORTANT: Only extract indicators that appear in the actual document text. Do not fabricate or guess indicators.
Respond ONLY with a JSON object. No explanations outside JSON."""
INFRASTRUCTURE_EXTRACTION_PROMPT = """Extract all network infrastructure indicators from this document.
Return a JSON object with an "items" array. Each item must have: indicator (the actual IP/domain/URL/hash), indicator_type (ipv4/ipv6/domain/url/hash/email), context (what this indicator relates to), source_context (verbatim surrounding text, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"indicator": "...", "indicator_type": "...", "context": "...", "source_context": "..."}}]}}"""
# --- Entity Extraction ---
ENTITY_SYSTEM_PROMPT = """You are an intelligence analyst specializing in entity identification and relationship mapping.
Your task is to extract named entities from documents, including:
- People (officials, operators, researchers, targets)
- Organizations (agencies, companies, units, departments)
- Programs (codenames, project names, operation names)
- Codenames (tool names, operation names, program designators)
- Military/intelligence units
For each entity, identify relationships to other entities mentioned in the same document.
Respond ONLY with a JSON object. No explanations outside JSON."""
ENTITY_EXTRACTION_PROMPT = """Extract all named entities and their relationships from this document.
Return a JSON object with an "items" array. Each item must have: name, type (person/org/program/codename/unit), description, relationships (list of {{"entity": "name", "relationship_type": "type"}}), source_context (verbatim quote, max 200 chars).
<document>
{document}
</document>
Return JSON:
{{"items": [{{"name": "...", "type": "...", "description": "...", "relationships": [{{"entity": "...", "relationship_type": "..."}}], "source_context": "..."}}]}}"""
# --- Interactive Query Prompts ---
QUERY_SYSTEM_PROMPT = """You are an intelligence analyst with access to a corpus of documents. Answer questions based on the provided document excerpts. Always cite your sources by referencing the document title or ID.
If the provided context doesn't contain enough information to answer confidently, say so explicitly rather than speculating."""
QUERY_PROMPT = """Based on the following document excerpts, answer the user's question.
{context}
Question: {question}
Provide a detailed answer with citations to specific documents."""
EMULATE_PROMPT = """Based on the extracted intelligence data below, create a detailed TTP playbook for emulating the threat actor: {actor}
Include:
1. Initial access methods they've used
2. Persistence mechanisms
3. Lateral movement techniques
4. Data collection methods
5. Exfiltration techniques
6. C2 infrastructure patterns
7. OPSEC practices
8. Recommended tools for emulation
{context}
Generate the playbook:"""
COMPARE_PROMPT = """Compare these two tools/capabilities based on the extracted intelligence:
Tool A: {tool_a}
Tool B: {tool_b}
{context}
Compare across: capability, target platforms, sophistication, attribution, detection methods."""
BRIEF_PROMPT = """Generate an intelligence briefing on the topic: {topic}
Based on the following extracted intelligence:
{context}
Structure the briefing with:
1. Executive Summary
2. Key Findings
3. Technical Details
4. Threat Assessment
5. Recommended Actions"""
SCENARIO_PROMPT = """Generate an adversary simulation scenario targeting: {target}
Based on the following threat intelligence:
{context}
Include:
1. Threat actor profile (based on extracted TTPs)
2. Attack chain (step by step)
3. Tools and infrastructure needed
4. Detection opportunities for blue team
5. Recommended mitigations"""