[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EFE33M9D0TW6SW4D5N5W8B":3,"skill-same:01M7EFE33M9D0TW6SW4D5N5W8B":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":6,"ownerHtmlUrl":58,"ownerBlogUrl":6,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M7EFE33M9D0TW6SW4D5N5W8B","building-attack-pattern-library-from-cti-reports",null,"Parse cyber threat intelligence reports (Mandiant, CrowdStrike, Talos, Microsoft) with stix2, mitreattack-python, and spaCy to extract adversary behaviors, map them to MITRE ATT&CK technique IDs, and build a searchable STIX 2.1 attack-pattern library with detection templates. Use when cataloging attack patterns from CTI reports for threat-informed detection engineering, or generating Sigma\u002FYARA templates from documented behaviors.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fbuilding-attack-pattern-library-from-cti-reports\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: building-attack-pattern-library-from-cti-reports\ndescription: Parse cyber threat intelligence reports (Mandiant, CrowdStrike, Talos, Microsoft) with stix2, mitreattack-python, and spaCy to extract adversary behaviors, map them to MITRE ATT&CK technique IDs, and build a searchable STIX 2.1 attack-pattern library with detection templates. Use when cataloging attack patterns from CTI reports for threat-informed detection engineering, or generating Sigma\u002FYARA templates from documented behaviors.\ndomain: cybersecurity\nsubdomain: threat-intelligence\ntags:\n- attack-pattern\n- cti-reports\n- mitre-attack\n- stix\n- detection-engineering\n- threat-intelligence\n- nlp\n- extraction\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nd3fend_techniques:\n- File Metadata Consistency Validation\n- Application Protocol Command Analysis\n- Identifier Analysis\n- Content Format Conversion\n- Message Analysis\nnist_csf:\n- ID.RA-01\n- ID.RA-05\n- DE.CM-01\n- DE.AE-02\nmitre_attack:\n- T1566.001\n- T1059.001\n- T1003.001\n- T1558.003\n- T1550.002\n---\n# Building Attack Pattern Library from CTI Reports\n\n## Overview\n\nCyber threat intelligence (CTI) reports from vendors like Mandiant, CrowdStrike, Talos, and Microsoft contain detailed descriptions of adversary behaviors that can be extracted, normalized, and cataloged into a structured attack pattern library. This skill covers parsing CTI reports to extract adversary techniques, mapping behaviors to MITRE ATT&CK technique IDs, creating STIX 2.1 Attack Pattern objects, building a searchable library indexed by tactic, technique, and threat actor, and generating detection rule templates from documented patterns.\n\n\n## When to Use\n\n- When deploying or configuring building attack pattern library from cti reports capabilities in your environment\n- When establishing security controls aligned to compliance requirements\n- When building or improving security architecture for this domain\n- When conducting security assessments that require this implementation\n\n## Prerequisites\n\n- Python 3.9+ with `stix2`, `mitreattack-python`, `spacy`, `requests` libraries\n- Collection of CTI reports (PDF, HTML, or text format)\n- MITRE ATT&CK STIX data (local or via TAXII)\n- Understanding of ATT&CK technique structure and naming conventions\n- Familiarity with detection engineering concepts (Sigma, YARA)\n\n## Key Concepts\n\n### Attack Pattern Extraction\n\nCTI reports describe adversary behaviors in natural language. Extraction involves identifying action verbs and technical terms that map to ATT&CK techniques, recognizing tool names and malware families, identifying infrastructure indicators, and mapping sequences of behaviors to attack chains (kill chain phases).\n\n### STIX 2.1 Attack Pattern Objects\n\nSTIX defines Attack Pattern as a Structured Domain Object (SDO) that describes ways threat actors attempt to compromise targets. Each pattern links to ATT&CK via external references, includes kill chain phases (tactics), and can be related to Intrusion Sets, Malware, and Tool objects.\n\n### Detection Rule Generation\n\nExtracted attack patterns inform detection engineering by providing: specific procedure examples for Sigma rule creation, behavioral sequences for correlation rules, IOC patterns for YARA and Snort rules, and data source requirements for telemetry gaps.\n\n## Workflow\n\n### Step 1: Parse CTI Reports and Extract Behaviors\n\n```python\nimport re\nimport json\nfrom collections import defaultdict\n\nclass CTIReportParser:\n    \"\"\"Parse CTI reports to extract adversary behaviors.\"\"\"\n\n    BEHAVIOR_INDICATORS = [\n        \"used\", \"executed\", \"deployed\", \"leveraged\", \"exploited\",\n        \"established\", \"created\", \"modified\", \"downloaded\", \"uploaded\",\n        \"exfiltrated\", \"injected\", \"enumerated\", \"spawned\", \"dropped\",\n        \"persisted\", \"escalated\", \"moved laterally\", \"collected\",\n        \"encrypted\", \"compressed\", \"encoded\", \"obfuscated\",\n    ]\n\n    TOOL_PATTERNS = [\n        r'\\b(Cobalt Strike|Mimikatz|PsExec|BloodHound|Rubeus|Impacket)\\b',\n        r'\\b(PowerShell|cmd\\.exe|WMI|WMIC|certutil|bitsadmin)\\b',\n        r'\\b(Metasploit|Empire|Covenant|Sliver|Brute Ratel)\\b',\n        r'\\b(Lazagne|SharpHound|ADFind|Sharphound|Invoke-Obfuscation)\\b',\n    ]\n\n    TECHNIQUE_KEYWORDS = {\n        \"spearphishing\": \"T1566\",\n        \"phishing attachment\": \"T1566.001\",\n        \"phishing link\": \"T1566.002\",\n        \"powershell\": \"T1059.001\",\n        \"command line\": \"T1059.003\",\n        \"scheduled task\": \"T1053.005\",\n        \"registry run key\": \"T1547.001\",\n        \"process injection\": \"T1055\",\n        \"dll side-loading\": \"T1574.002\",\n        \"credential dumping\": \"T1003\",\n        \"lsass\": \"T1003.001\",\n        \"kerberoasting\": \"T1558.003\",\n        \"pass the hash\": \"T1550.002\",\n        \"remote desktop\": \"T1021.001\",\n        \"smb\": \"T1021.002\",\n        \"winrm\": \"T1021.006\",\n        \"data staging\": \"T1074\",\n        \"exfiltration over c2\": \"T1041\",\n        \"dns tunneling\": \"T1071.004\",\n        \"web shell\": \"T1505.003\",\n    }\n\n    def parse_report(self, text, report_metadata=None):\n        \"\"\"Parse a CTI report and extract behaviors.\"\"\"\n        sentences = re.split(r'[.!?]\\s+', text)\n        behaviors = []\n\n        for sentence in sentences:\n            sentence_lower = sentence.lower()\n            # Check for behavior indicators\n            for indicator in self.BEHAVIOR_INDICATORS:\n                if indicator in sentence_lower:\n                    behavior = {\n                        \"sentence\": sentence.strip(),\n                        \"action\": indicator,\n                        \"tools\": self._extract_tools(sentence),\n                        \"technique_hints\": self._match_techniques(sentence_lower),\n                    }\n                    if behavior[\"technique_hints\"]:\n                        behaviors.append(behavior)\n                    break\n\n        print(f\"[+] Extracted {len(behaviors)} behavioral indicators from report\")\n        return behaviors\n\n    def _extract_tools(self, text):\n        \"\"\"Extract tool\u002Fmalware names from text.\"\"\"\n        tools = set()\n        for pattern in self.TOOL_PATTERNS:\n            matches = re.findall(pattern, text, re.IGNORECASE)\n            tools.update(matches)\n        return list(tools)\n\n    def _match_techniques(self, text):\n        \"\"\"Match text to ATT&CK technique hints.\"\"\"\n        matches = []\n        for keyword, tech_id in self.TECHNIQUE_KEYWORDS.items():\n            if keyword in text:\n                matches.append({\"keyword\": keyword, \"technique_id\": tech_id})\n        return matches\n\nparser = CTIReportParser()\nsample_report = \"\"\"\nThe threat actor used spearphishing attachments with macro-enabled documents to\ngain initial access. Once inside, they executed PowerShell scripts to download\nadditional tooling. The actor leveraged Mimikatz to dump credentials from LSASS\nmemory. They then used pass the hash techniques for lateral movement via SMB\nto multiple systems. Data was staged in a compressed archive and exfiltrated\nover the existing C2 channel. The actor established persistence through\nscheduled tasks and registry run keys.\n\"\"\"\nbehaviors = parser.parse_report(sample_report)\n```\n\n### Step 2: Map Behaviors to ATT&CK Techniques\n\n```python\nfrom attackcti import attack_client\n\nclass ATTACKMapper:\n    def __init__(self):\n        self.lift = attack_client()\n        self.techniques = {}\n        self._load_techniques()\n\n    def _load_techniques(self):\n        \"\"\"Load all ATT&CK techniques for mapping.\"\"\"\n        all_techs = self.lift.get_enterprise_techniques()\n        for tech in all_techs:\n            tech_id = \"\"\n            for ref in tech.get(\"external_references\", []):\n                if ref.get(\"source_name\") == \"mitre-attack\":\n                    tech_id = ref.get(\"external_id\", \"\")\n                    break\n            if tech_id:\n                self.techniques[tech_id] = {\n                    \"name\": tech.get(\"name\", \"\"),\n                    \"description\": tech.get(\"description\", \"\")[:500],\n                    \"tactics\": [p.get(\"phase_name\") for p in tech.get(\"kill_chain_phases\", [])],\n                    \"platforms\": tech.get(\"x_mitre_platforms\", []),\n                    \"data_sources\": tech.get(\"x_mitre_data_sources\", []),\n                }\n        print(f\"[+] Loaded {len(self.techniques)} ATT&CK techniques\")\n\n    def map_behaviors(self, behaviors):\n        \"\"\"Map extracted behaviors to ATT&CK techniques.\"\"\"\n        mapped = []\n        for behavior in behaviors:\n            for hint in behavior.get(\"technique_hints\", []):\n                tech_id = hint[\"technique_id\"]\n                if tech_id in self.techniques:\n                    tech_info = self.techniques[tech_id]\n                    mapped.append({\n                        \"technique_id\": tech_id,\n                        \"technique_name\": tech_info[\"name\"],\n                        \"tactics\": tech_info[\"tactics\"],\n                        \"source_sentence\": behavior[\"sentence\"],\n                        \"tools_observed\": behavior[\"tools\"],\n                        \"keyword_matched\": hint[\"keyword\"],\n                        \"data_sources\": tech_info[\"data_sources\"],\n                    })\n        print(f\"[+] Mapped {len(mapped)} behaviors to ATT&CK techniques\")\n        return mapped\n\nmapper = ATTACKMapper()\nmapped_behaviors = mapper.map_behaviors(behaviors)\n```\n\n### Step 3: Create STIX 2.1 Attack Pattern Library\n\n```python\nfrom stix2 import AttackPattern, Relationship, Bundle, TLP_GREEN\nfrom datetime import datetime\n\nclass AttackPatternLibrary:\n    def __init__(self):\n        self.patterns = []\n        self.relationships = []\n\n    def add_pattern_from_mapping(self, mapping, report_source=\"CTI Report\"):\n        \"\"\"Create STIX Attack Pattern from mapped behavior.\"\"\"\n        pattern = AttackPattern(\n            name=mapping[\"technique_name\"],\n            description=f\"Observed: {mapping['source_sentence']}\\n\\n\"\n                        f\"Tools: {', '.join(mapping['tools_observed']) or 'None identified'}\\n\"\n                        f\"Source: {report_source}\",\n            external_references=[{\n                \"source_name\": \"mitre-attack\",\n                \"external_id\": mapping[\"technique_id\"],\n                \"url\": f\"https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002F{mapping['technique_id'].replace('.', '\u002F')}\u002F\",\n            }],\n            kill_chain_phases=[{\n                \"kill_chain_name\": \"mitre-attack\",\n                \"phase_name\": tactic,\n            } for tactic in mapping[\"tactics\"]],\n            object_marking_refs=[TLP_GREEN],\n        )\n        self.patterns.append(pattern)\n        return pattern\n\n    def build_library(self, mapped_behaviors, report_source=\"CTI Report\"):\n        \"\"\"Build complete attack pattern library from mappings.\"\"\"\n        seen_techniques = set()\n        for mapping in mapped_behaviors:\n            tech_id = mapping[\"technique_id\"]\n            if tech_id not in seen_techniques:\n                self.add_pattern_from_mapping(mapping, report_source)\n                seen_techniques.add(tech_id)\n\n        bundle = Bundle(objects=self.patterns + self.relationships)\n        print(f\"[+] Library: {len(self.patterns)} attack patterns\")\n        return bundle\n\n    def export_library(self, output_file=\"attack_pattern_library.json\"):\n        bundle = Bundle(objects=self.patterns + self.relationships)\n        with open(output_file, \"w\") as f:\n            f.write(bundle.serialize(pretty=True))\n        print(f\"[+] Library exported to {output_file}\")\n\n    def generate_detection_templates(self, mapped_behaviors):\n        \"\"\"Generate Sigma rule templates from attack patterns.\"\"\"\n        templates = []\n        for mapping in mapped_behaviors:\n            template = {\n                \"title\": f\"Detection: {mapping['technique_name']} ({mapping['technique_id']})\",\n                \"status\": \"experimental\",\n                \"description\": f\"Detects {mapping['technique_name']} based on CTI report observation\",\n                \"references\": [\n                    f\"https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002F{mapping['technique_id'].replace('.', '\u002F')}\u002F\",\n                ],\n                \"tags\": [\n                    f\"attack.{mapping['tactics'][0]}\" if mapping['tactics'] else \"attack.unknown\",\n                    f\"attack.{mapping['technique_id'].lower()}\",\n                ],\n                \"data_sources\": mapping.get(\"data_sources\", []),\n                \"observed_tools\": mapping.get(\"tools_observed\", []),\n                \"source_context\": mapping[\"source_sentence\"],\n            }\n            templates.append(template)\n\n        with open(\"detection_templates.json\", \"w\") as f:\n            json.dump(templates, f, indent=2)\n        print(f\"[+] Generated {len(templates)} detection templates\")\n        return templates\n\nlibrary = AttackPatternLibrary()\nbundle = library.build_library(mapped_behaviors, \"Sample CTI Report\")\nlibrary.export_library()\ntemplates = library.generate_detection_templates(mapped_behaviors)\n```\n\n## Validation Criteria\n\n- CTI report parsed and behavioral indicators extracted\n- Behaviors mapped to ATT&CK techniques with confidence\n- STIX 2.1 Attack Pattern objects created with proper references\n- Library searchable by tactic, technique, and threat actor\n- Detection templates generated from documented patterns\n- Library exportable as STIX bundle for sharing\n\n## References\n\n- [MITRE ATT&CK](https:\u002F\u002Fattack.mitre.org\u002F)\n- [STIX 2.1 Attack Pattern SDO](https:\u002F\u002Fdocs.oasis-open.org\u002Fcti\u002Fstix\u002Fv2.1\u002Fos\u002Fstix-v2.1-os.html#_axjijf603msy)\n- [CISA: Best Practices for ATT&CK Mapping](https:\u002F\u002Fwww.cisa.gov\u002Fsites\u002Fdefault\u002Ffiles\u002F2023-01\u002FBest%20Practices%20for%20MITRE%20ATTCK%20Mapping.pdf)\n- [attackcti Python Library](https:\u002F\u002Fgithub.com\u002FOTRF\u002FATTACK-Python-Client)\n- [Sigma Rules Project](https:\u002F\u002Fgithub.com\u002FSigmaHQ\u002Fsigma)\n- [MITRE ATT&CK STIX Data](https:\u002F\u002Fgithub.com\u002Fmitre\u002Fcti)\n","# Building Attack Pattern Library from CTI Reports\n\n## Overview\n\nCyber threat intelligence (CTI) reports from vendors like Mandiant, CrowdStrike, Talos, and Microsoft contain detailed descriptions of adversary behaviors that can be extracted, normalized, and cataloged into a structured attack pattern library. This skill covers parsing CTI reports to extract adversary techniques, mapping behaviors to MITRE ATT&CK technique IDs, creating STIX 2.1 Attack Pattern objects, building a searchable library indexed by tactic, technique, and threat actor, and generating detection rule templates from documented patterns.\n\n\n## When to Use\n\n- When deploying or configuring building attack pattern library from cti reports capabilities in your environment\n- When establishing security controls aligned to compliance requirements\n- When building or improving security architecture for this domain\n- When conducting security assessments that require this implementation\n\n## Prerequisites\n\n- Python 3.9+ with `stix2`, `mitreattack-python`, `spacy`, `requests` libraries\n- Collection of CTI reports (PDF, HTML, or text format)\n- MITRE ATT&CK STIX data (local or via TAXII)\n- Understanding of ATT&CK technique structure and naming conventions\n- Familiarity with detection engineering concepts (Sigma, YARA)\n\n## Key Concepts\n\n### Attack Pattern Extraction\n\nCTI reports describe adversary behaviors in natural language. Extraction involves identifying action verbs and technical terms that map to ATT&CK techniques, recognizing tool names and malware families, identifying infrastructure indicators, and mapping sequences of behaviors to attack chains (kill chain phases).\n\n### STIX 2.1 Attack Pattern Objects\n\nSTIX defines Attack Pattern as a Structured Domain Object (SDO) that describes ways threat actors attempt to compromise targets. Each pattern links to ATT&CK via external references, includes kill chain phases (tactics), and can be related to Intrusion Sets, Malware, and Tool objects.\n\n### Detection Rule Generation\n\nExtracted attack patterns inform detection engineering by providing: specific procedure examples for Sigma rule creation, behavioral sequences for correlation rules, IOC patterns for YARA and Snort rules, and data source requirements for telemetry gaps.\n\n## Workflow\n\n### Step 1: Parse CTI Reports and Extract Behaviors\n\n```python\nimport re\nimport json\nfrom collections import defaultdict\n\nclass CTIReportParser:\n    \"\"\"Parse CTI reports to extract adversary behaviors.\"\"\"\n\n    BEHAVIOR_INDICATORS = [\n        \"used\", \"executed\", \"deployed\", \"leveraged\", \"exploited\",\n        \"established\", \"created\", \"modified\", \"downloaded\", \"uploaded\",\n        \"exfiltrated\", \"injected\", \"enumerated\", \"spawned\", \"dropped\",\n        \"persisted\", \"escalated\", \"moved laterally\", \"collected\",\n        \"encrypted\", \"compressed\", \"encoded\", \"obfuscated\",\n    ]\n\n    TOOL_PATTERNS = [\n        r'\\b(Cobalt Strike|Mimikatz|PsExec|BloodHound|Rubeus|Impacket)\\b',\n        r'\\b(PowerShell|cmd\\.exe|WMI|WMIC|certutil|bitsadmin)\\b',\n        r'\\b(Metasploit|Empire|Covenant|Sliver|Brute Ratel)\\b',\n        r'\\b(Lazagne|SharpHound|ADFind|Sharphound|Invoke-Obfuscation)\\b',\n    ]\n\n    TECHNIQUE_KEYWORDS = {\n        \"spearphishing\": \"T1566\",\n        \"phishing attachment\": \"T1566.001\",\n        \"phishing link\": \"T1566.002\",\n        \"powershell\": \"T1059.001\",\n        \"command line\": \"T1059.003\",\n        \"scheduled task\": \"T1053.005\",\n        \"registry run key\": \"T1547.001\",\n        \"process injection\": \"T1055\",\n        \"dll side-loading\": \"T1574.002\",\n        \"credential dumping\": \"T1003\",\n        \"lsass\": \"T1003.001\",\n        \"kerberoasting\": \"T1558.003\",\n        \"pass the hash\": \"T1550.002\",\n        \"remote desktop\": \"T1021.001\",\n        \"smb\": \"T1021.002\",\n        \"winrm\": \"T1021.006\",\n        \"data staging\": \"T1074\",\n        \"exfiltration over c2\": \"T1041\",\n        \"dns tunneling\": \"T1071.004\",\n        \"web shell\": \"T1505.003\",\n    }\n\n    def parse_report(self, text, report_metadata=None):\n        \"\"\"Parse a CTI report and extract behaviors.\"\"\"\n        sentences = re.split(r'[.!?]\\s+', text)\n        behaviors = []\n\n        for sentence in sentences:\n            sentence_lower = sentence.lower()\n            # Check for behavior indicators\n            for indicator in self.BEHAVIOR_INDICATORS:\n                if indicator in sentence_lower:\n                    behavior = {\n                        \"sentence\": sentence.strip(),\n                        \"action\": indicator,\n                        \"tools\": self._extract_tools(sentence),\n                        \"technique_hints\": self._match_techniques(sentence_lower),\n                    }\n                    if behavior[\"technique_hints\"]:\n                        behaviors.append(behavior)\n                    break\n\n        print(f\"[+] Extracted {len(behaviors)} behavioral indicators from report\")\n        return behaviors\n\n    def _extract_tools(self, text):\n        \"\"\"Extract tool\u002Fmalware names from text.\"\"\"\n        tools = set()\n        for pattern in self.TOOL_PATTERNS:\n            matches = re.findall(pattern, text, re.IGNORECASE)\n            tools.update(matches)\n        return list(tools)\n\n    def _match_techniques(self, text):\n        \"\"\"Match text to ATT&CK technique hints.\"\"\"\n        matches = []\n        for keyword, tech_id in self.TECHNIQUE_KEYWORDS.items():\n            if keyword in text:\n                matches.append({\"keyword\": keyword, \"technique_id\": tech_id})\n        return matches\n\nparser = CTIReportParser()\nsample_report = \"\"\"\nThe threat actor used spearphishing attachments with macro-enabled documents to\ngain initial access. Once inside, they executed PowerShell scripts to download\nadditional tooling. The actor leveraged Mimikatz to dump credentials from LSASS\nmemory. They then used pass the hash techniques for lateral movement via SMB\nto multiple systems. Data was staged in a compressed archive and exfiltrated\nover the existing C2 channel. The actor established persistence through\nscheduled tasks and registry run keys.\n\"\"\"\nbehaviors = parser.parse_report(sample_report)\n```\n\n### Step 2: Map Behaviors to ATT&CK Techniques\n\n```python\nfrom attackcti import attack_client\n\nclass ATTACKMapper:\n    def __init__(self):\n        self.lift = attack_client()\n        self.techniques = {}\n        self._load_techniques()\n\n    def _load_techniques(self):\n        \"\"\"Load all ATT&CK techniques for mapping.\"\"\"\n        all_techs = self.lift.get_enterprise_techniques()\n        for tech in all_techs:\n            tech_id = \"\"\n            for ref in tech.get(\"external_references\", []):\n                if ref.get(\"source_name\") == \"mitre-attack\":\n                    tech_id = ref.get(\"external_id\", \"\")\n                    break\n            if tech_id:\n                self.techniques[tech_id] = {\n                    \"name\": tech.get(\"name\", \"\"),\n                    \"description\": tech.get(\"description\", \"\")[:500],\n                    \"tactics\": [p.get(\"phase_name\") for p in tech.get(\"kill_chain_phases\", [])],\n                    \"platforms\": tech.get(\"x_mitre_platforms\", []),\n                    \"data_sources\": tech.get(\"x_mitre_data_sources\", []),\n                }\n        print(f\"[+] Loaded {len(self.techniques)} ATT&CK techniques\")\n\n    def map_behaviors(self, behaviors):\n        \"\"\"Map extracted behaviors to ATT&CK techniques.\"\"\"\n        mapped = []\n        for behavior in behaviors:\n            for hint in behavior.get(\"technique_hints\", []):\n                tech_id = hint[\"technique_id\"]\n                if tech_id in self.techniques:\n                    tech_info = self.techniques[tech_id]\n                    mapped.append({\n                        \"technique_id\": tech_id,\n                        \"technique_name\": tech_info[\"name\"],\n                        \"tactics\": tech_info[\"tactics\"],\n                        \"source_sentence\": behavior[\"sentence\"],\n                        \"tools_observed\": behavior[\"tools\"],\n                        \"keyword_matched\": hint[\"keyword\"],\n                        \"data_sources\": tech_info[\"data_sources\"],\n                    })\n        print(f\"[+] Mapped {len(mapped)} behaviors to ATT&CK techniques\")\n        return mapped\n\nmapper = ATTACKMapper()\nmapped_behaviors = mapper.map_behaviors(behaviors)\n```\n\n### Step 3: Create STIX 2.1 Attack Pattern Library\n\n```python\nfrom stix2 import AttackPattern, Relationship, Bundle, TLP_GREEN\nfrom datetime import datetime\n\nclass AttackPatternLibrary:\n    def __init__(self):\n        self.patterns = []\n        self.relationships = []\n\n    def add_pattern_from_mapping(self, mapping, report_source=\"CTI Report\"):\n        \"\"\"Create STIX Attack Pattern from mapped behavior.\"\"\"\n        pattern = AttackPattern(\n            name=mapping[\"technique_name\"],\n            description=f\"Observed: {mapping['source_sentence']}\\n\\n\"\n                        f\"Tools: {', '.join(mapping['tools_observed']) or 'None identified'}\\n\"\n                        f\"Source: {report_source}\",\n            external_references=[{\n                \"source_name\": \"mitre-attack\",\n                \"external_id\": mapping[\"technique_id\"],\n                \"url\": f\"https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002F{mapping['technique_id'].replace('.', '\u002F')}\u002F\",\n            }],\n            kill_chain_phases=[{\n                \"kill_chain_name\": \"mitre-attack\",\n                \"phase_name\": tactic,\n            } for tactic in mapping[\"tactics\"]],\n            object_marking_refs=[TLP_GREEN],\n        )\n        self.patterns.append(pattern)\n        return pattern\n\n    def build_library(self, mapped_behaviors, report_source=\"CTI Report\"):\n        \"\"\"Build complete attack pattern library from mappings.\"\"\"\n        seen_techniques = set()\n        for mapping in mapped_behaviors:\n            tech_id = mapping[\"technique_id\"]\n            if tech_id not in seen_techniques:\n                self.add_pattern_from_mapping(mapping, report_source)\n                seen_techniques.add(tech_id)\n\n        bundle = Bundle(objects=self.patterns + self.relationships)\n        print(f\"[+] Library: {len(self.patterns)} attack patterns\")\n        return bundle\n\n    def export_library(self, output_file=\"attack_pattern_library.json\"):\n        bundle = Bundle(objects=self.patterns + self.relationships)\n        with open(output_file, \"w\") as f:\n            f.write(bundle.serialize(pretty=True))\n        print(f\"[+] Library exported to {output_file}\")\n\n    def generate_detection_templates(self, mapped_behaviors):\n        \"\"\"Generate Sigma rule templates from attack patterns.\"\"\"\n        templates = []\n        for mapping in mapped_behaviors:\n            template = {\n                \"title\": f\"Detection: {mapping['technique_name']} ({mapping['technique_id']})\",\n                \"status\": \"experimental\",\n                \"description\": f\"Detects {mapping['technique_name']} based on CTI report observation\",\n                \"references\": [\n                    f\"https:\u002F\u002Fattack.mitre.org\u002Ftechniques\u002F{mapping['technique_id'].replace('.', '\u002F')}\u002F\",\n                ],\n                \"tags\": [\n                    f\"attack.{mapping['tactics'][0]}\" if mapping['tactics'] else \"attack.unknown\",\n                    f\"attack.{mapping['technique_id'].lower()}\",\n                ],\n                \"data_sources\": mapping.get(\"data_sources\", []),\n                \"observed_tools\": mapping.get(\"tools_observed\", []),\n                \"source_context\": mapping[\"source_sentence\"],\n            }\n            templates.append(template)\n\n        with open(\"detection_templates.json\", \"w\") as f:\n            json.dump(templates, f, indent=2)\n        print(f\"[+] Generated {len(templates)} detection templates\")\n        return templates\n\nlibrary = AttackPatternLibrary()\nbundle = library.build_library(mapped_behaviors, \"Sample CTI Report\")\nlibrary.export_library()\ntemplates = library.generate_detection_templates(mapped_behaviors)\n```\n\n## Validation Criteria\n\n- CTI report parsed and behavioral indicators extracted\n- Behaviors mapped to ATT&CK techniques with confidence\n- STIX 2.1 Attack Pattern objects created with proper references\n- Library searchable by tactic, technique, and threat actor\n- Detection templates generated from documented patterns\n- Library exportable as STIX bundle for sharing\n\n## References\n\n- [MITRE ATT&CK](https:\u002F\u002Fattack.mitre.org\u002F)\n- [STIX 2.1 Attack Pattern SDO](https:\u002F\u002Fdocs.oasis-open.org\u002Fcti\u002Fstix\u002Fv2.1\u002Fos\u002Fstix-v2.1-os.html#_axjijf603msy)\n- [CISA: Best Practices for ATT&CK Mapping](https:\u002F\u002Fwww.cisa.gov\u002Fsites\u002Fdefault\u002Ffiles\u002F2023-01\u002FBest%20Practices%20for%20MITRE%20ATTCK%20Mapping.pdf)\n- [attackcti Python Library](https:\u002F\u002Fgithub.com\u002FOTRF\u002FATTACK-Python-Client)\n- [Sigma Rules Project](https:\u002F\u002Fgithub.com\u002FSigmaHQ\u002Fsigma)\n- [MITRE ATT&CK STIX Data](https:\u002F\u002Fgithub.com\u002Fmitre\u002Fcti)\n",{"name":5,"tags":24,"author":33,"domain":34,"license":15,"version":35,"nist_csf":36,"subdomain":30,"description":7,"mitre_attack":41,"d3fend_techniques":47},[25,26,27,28,29,30,31,32],"attack-pattern","cti-reports","mitre-attack","stix","detection-engineering","threat-intelligence","nlp","extraction","mahipal","cybersecurity","1.0",[37,38,39,40],"ID.RA-01","ID.RA-05","DE.CM-01","DE.AE-02",[42,43,44,45,46],"T1566.001","T1059.001","T1003.001","T1558.003","T1550.002",[48,49,50,51,52],"File Metadata Consistency Validation","Application Protocol Command Analysis","Identifier Analysis","Content Format Conversion","Message Analysis","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fbuilding-attack-pattern-library-from-cti-reports",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill building-attack-pattern-library-from-cti-reports",{"tool":67,"command":68},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill building-attack-pattern-library-from-cti-reports",{"tool":70,"command":71},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill building-attack-pattern-library-from-cti-reports","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fbuilding-attack-pattern-library-from-cti-reports\u002FSKILL.md",true,[75],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fapi-reference.md","REFERENCE","参考文档",1431,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fbuilding-attack-pattern-library-from-cti-reports\u002Freferences\u002Fapi-reference.md",[82,91,96,103,110,117],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":90},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":92,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":90},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":90},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":90},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":90},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":90},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]