[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78J10RP77P3N14YDSQT1SWX":3,"skill-same:01M78J10RP77P3N14YDSQT1SWX":76},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M78J10RP77P3N14YDSQT1SWX","building-ioc-defanging-and-sharing-pipeline",null,"Build an automated pipeline to defang indicators of compromise (URLs, IPs, domains, emails) for safe sharing and distribute them in STIX format through TAXII feeds and threat intelligence platforms.","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbuilding-ioc-defanging-and-sharing-pipeline\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbuilding-ioc-defanging-and-sharing-pipeline\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: building-ioc-defanging-and-sharing-pipeline\ndescription: Build an automated pipeline to defang indicators of compromise (URLs, IPs, domains, emails) for safe sharing and distribute them in STIX format through TAXII feeds and threat intelligence platforms.\ndomain: cybersecurity\nsubdomain: threat-intelligence\ntags: [ioc, defanging, threat-sharing, stix, pipeline, indicator, automation, threat-intelligence]\nversion: \"1.0\"\nauthor: mahipal\nlicense: Apache-2.0\n---\n# Building IOC Defanging and Sharing Pipeline\n\n## Overview\n\nIOC defanging modifies potentially malicious indicators (URLs, IP addresses, domains, email addresses) to prevent accidental clicks or execution while preserving readability for analysis and sharing. This skill covers building an automated pipeline that ingests raw IOCs from multiple sources, normalizes and deduplicates them, applies defanging for safe human consumption, converts them to STIX 2.1 format for machine consumption, and distributes through TAXII servers, MISP instances, and email reports.\n\n\n## When to Use\n\n- When deploying or configuring building ioc defanging and sharing pipeline 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 `defang`, `ioc-fanger`, `stix2`, `requests`, `validators` libraries\n- MISP instance or TAXII server for automated sharing\n- Understanding of IOC types: IPv4\u002FIPv6, domains, URLs, email addresses, file hashes\n- Familiarity with STIX 2.1 Indicator patterns and TLP marking definitions\n- Access to threat intelligence feeds for IOC ingestion\n\n## Key Concepts\n\n### IOC Defanging Standards\n\nDefanging replaces active protocol and domain components to prevent execution: `http:\u002F\u002F` becomes `hxxp:\u002F\u002F`, `https:\u002F\u002F` becomes `hxxps:\u002F\u002F`, dots in domains\u002FIPs become `[.]`, `@` in emails becomes `[@]`. This is critical for sharing IOCs in reports, emails, Slack channels, and paste sites where auto-linking could trigger network connections to malicious infrastructure.\n\n### IOC Normalization\n\nRaw IOCs from different sources come in inconsistent formats. Normalization involves converting to lowercase, removing trailing slashes and whitespace, extracting domains from URLs, resolving URL encoding, validating format correctness, and deduplicating across sources.\n\n### STIX 2.1 Indicator Patterns\n\nSTIX patterns express IOCs in a standardized format: `[ipv4-addr:value = '203.0.113.1']`, `[domain-name:value = 'malicious.example.com']`, `[url:value = 'http:\u002F\u002Fevil.com\u002Fpayload']`, `[file:hashes.'SHA-256' = 'abc123...']`. Each indicator includes valid_from, indicator_types, confidence, and optional TLP markings.\n\n## Workflow\n\n### Step 1: Build IOC Extraction and Normalization\n\n```python\nimport re\nimport hashlib\nfrom urllib.parse import urlparse, unquote\nfrom datetime import datetime\n\nclass IOCExtractor:\n    \"\"\"Extract and normalize IOCs from text.\"\"\"\n\n    PATTERNS = {\n        \"ipv4\": r'\\b(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\b',\n        \"domain\": r'\\b(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}\\b',\n        \"url\": r'https?:\u002F\u002F[^\\s\u003C>\"{}|\\\\^`\\[\\]]+',\n        \"email\": r'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b',\n        \"md5\": r'\\b[a-fA-F0-9]{32}\\b',\n        \"sha1\": r'\\b[a-fA-F0-9]{40}\\b',\n        \"sha256\": r'\\b[a-fA-F0-9]{64}\\b',\n    }\n\n    WHITELIST_DOMAINS = {\n        \"google.com\", \"microsoft.com\", \"amazon.com\", \"github.com\",\n        \"cloudflare.com\", \"akamai.com\", \"example.com\",\n    }\n\n    def extract_from_text(self, text):\n        \"\"\"Extract all IOC types from free text.\"\"\"\n        # Refang any already-defanged indicators first\n        text = self._refang(text)\n        iocs = {\"ipv4\": set(), \"domain\": set(), \"url\": set(),\n                \"email\": set(), \"md5\": set(), \"sha1\": set(), \"sha256\": set()}\n\n        for ioc_type, pattern in self.PATTERNS.items():\n            matches = re.findall(pattern, text)\n            for match in matches:\n                normalized = self._normalize(match, ioc_type)\n                if normalized and not self._is_whitelisted(normalized, ioc_type):\n                    iocs[ioc_type].add(normalized)\n\n        # Remove domains that are part of URLs\n        url_domains = set()\n        for url in iocs[\"url\"]:\n            parsed = urlparse(url)\n            url_domains.add(parsed.netloc)\n        iocs[\"domain\"] -= url_domains\n\n        total = sum(len(v) for v in iocs.values())\n        print(f\"[+] Extracted {total} unique IOCs from text\")\n        return {k: sorted(v) for k, v in iocs.items()}\n\n    def _refang(self, text):\n        \"\"\"Convert defanged indicators back to active form.\"\"\"\n        text = text.replace(\"hxxp:\u002F\u002F\", \"http:\u002F\u002F\").replace(\"hxxps:\u002F\u002F\", \"https:\u002F\u002F\")\n        text = text.replace(\"[.]\", \".\").replace(\"[@]\", \"@\")\n        text = text.replace(\"[:\u002F\u002F]\", \":\u002F\u002F\").replace(\"(.)\", \".\")\n        return text\n\n    def _normalize(self, value, ioc_type):\n        \"\"\"Normalize an IOC value.\"\"\"\n        value = value.strip().lower()\n        if ioc_type == \"url\":\n            value = unquote(value).rstrip(\"\u002F\")\n        elif ioc_type == \"domain\":\n            value = value.rstrip(\".\")\n        return value\n\n    def _is_whitelisted(self, value, ioc_type):\n        \"\"\"Check if IOC is in whitelist.\"\"\"\n        if ioc_type == \"domain\":\n            return value in self.WHITELIST_DOMAINS\n        if ioc_type == \"url\":\n            parsed = urlparse(value)\n            return parsed.netloc in self.WHITELIST_DOMAINS\n        return False\n\nextractor = IOCExtractor()\nsample_text = \"\"\"\nMalware C2: hxxps:\u002F\u002Fevil-domain[.]com\u002Fbeacon\nDrops payload from 192.168.1.100 and contacts 10[.]0[.]0[.]1\nSHA256: 275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f\nPhishing email from attacker[@]phishing-domain[.]com\n\"\"\"\niocs = extractor.extract_from_text(sample_text)\n```\n\n### Step 2: Defanging Engine\n\n```python\nclass IOCDefanger:\n    \"\"\"Defang IOCs for safe sharing in reports and communications.\"\"\"\n\n    def defang_url(self, url):\n        return url.replace(\"http:\u002F\u002F\", \"hxxp:\u002F\u002F\").replace(\"https:\u002F\u002F\", \"hxxps:\u002F\u002F\").replace(\".\", \"[.]\")\n\n    def defang_domain(self, domain):\n        return domain.replace(\".\", \"[.]\")\n\n    def defang_ip(self, ip):\n        return ip.replace(\".\", \"[.]\")\n\n    def defang_email(self, email):\n        return email.replace(\"@\", \"[@]\").replace(\".\", \"[.]\")\n\n    def defang_all(self, iocs):\n        \"\"\"Defang all IOCs in a dictionary.\"\"\"\n        defanged = {}\n        for ioc_type, values in iocs.items():\n            if ioc_type == \"url\":\n                defanged[ioc_type] = [self.defang_url(v) for v in values]\n            elif ioc_type == \"domain\":\n                defanged[ioc_type] = [self.defang_domain(v) for v in values]\n            elif ioc_type == \"ipv4\":\n                defanged[ioc_type] = [self.defang_ip(v) for v in values]\n            elif ioc_type == \"email\":\n                defanged[ioc_type] = [self.defang_email(v) for v in values]\n            else:\n                defanged[ioc_type] = values  # Hashes don't need defanging\n        return defanged\n\n    def generate_sharing_report(self, iocs, defanged, report_name=\"IOC Report\"):\n        \"\"\"Generate a human-readable defanged IOC report.\"\"\"\n        report = f\"# {report_name}\\n\"\n        report += f\"Generated: {datetime.now().isoformat()}\\n\\n\"\n\n        for ioc_type in [\"url\", \"domain\", \"ipv4\", \"email\", \"sha256\", \"sha1\", \"md5\"]:\n            values = defanged.get(ioc_type, [])\n            if values:\n                report += f\"## {ioc_type.upper()} ({len(values)})\\n\"\n                for v in values:\n                    report += f\"- `{v}`\\n\"\n                report += \"\\n\"\n\n        return report\n\ndefanger = IOCDefanger()\ndefanged = defanger.defang_all(iocs)\nreport = defanger.generate_sharing_report(iocs, defanged, \"Malware Campaign IOCs\")\nprint(report)\n```\n\n### Step 3: Convert to STIX 2.1 Format\n\n```python\nfrom stix2 import Indicator, Bundle, TLP_WHITE, TLP_GREEN, TLP_AMBER\nfrom datetime import datetime\n\nclass STIXConverter:\n    \"\"\"Convert raw IOCs to STIX 2.1 Indicator objects.\"\"\"\n\n    TLP_MAP = {\"white\": TLP_WHITE, \"green\": TLP_GREEN, \"amber\": TLP_AMBER}\n\n    def iocs_to_stix(self, iocs, tlp=\"green\", confidence=75):\n        \"\"\"Convert IOC dictionary to STIX 2.1 bundle.\"\"\"\n        stix_objects = []\n        marking = self.TLP_MAP.get(tlp, TLP_GREEN)\n\n        for ip in iocs.get(\"ipv4\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious IP: {ip}\",\n                pattern=f\"[ipv4-addr:value = '{ip}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for domain in iocs.get(\"domain\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious Domain: {domain}\",\n                pattern=f\"[domain-name:value = '{domain}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for url in iocs.get(\"url\", []):\n            escaped = url.replace(\"'\", \"\\\\'\")\n            stix_objects.append(Indicator(\n                name=f\"Malicious URL: {url[:60]}\",\n                pattern=f\"[url:value = '{escaped}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for sha256 in iocs.get(\"sha256\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious File Hash: {sha256[:16]}...\",\n                pattern=f\"[file:hashes.'SHA-256' = '{sha256}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        bundle = Bundle(objects=stix_objects)\n        print(f\"[+] Created STIX bundle with {len(stix_objects)} indicators\")\n        return bundle\n\nconverter = STIXConverter()\nstix_bundle = converter.iocs_to_stix(iocs, tlp=\"amber\", confidence=80)\nwith open(\"iocs_stix_bundle.json\", \"w\") as f:\n    f.write(stix_bundle.serialize(pretty=True))\n```\n\n### Step 4: Distribute Through MISP and TAXII\n\n```python\nimport requests\nimport json\n\nclass IOCDistributor:\n    \"\"\"Distribute IOCs through various channels.\"\"\"\n\n    def push_to_misp(self, iocs, misp_url, misp_key, event_info):\n        \"\"\"Push IOCs to MISP as a new event.\"\"\"\n        headers = {\n            \"Authorization\": misp_key,\n            \"Content-Type\": \"application\u002Fjson\",\n            \"Accept\": \"application\u002Fjson\",\n        }\n        event = {\n            \"Event\": {\n                \"info\": event_info,\n                \"distribution\": \"1\",  # This community only\n                \"threat_level_id\": \"2\",  # Medium\n                \"analysis\": \"2\",  # Completed\n                \"Attribute\": [],\n            }\n        }\n\n        type_mapping = {\n            \"ipv4\": \"ip-dst\",\n            \"domain\": \"domain\",\n            \"url\": \"url\",\n            \"email\": \"email-src\",\n            \"md5\": \"md5\",\n            \"sha1\": \"sha1\",\n            \"sha256\": \"sha256\",\n        }\n\n        for ioc_type, values in iocs.items():\n            misp_type = type_mapping.get(ioc_type)\n            if misp_type:\n                for value in values:\n                    event[\"Event\"][\"Attribute\"].append({\n                        \"type\": misp_type,\n                        \"value\": value,\n                        \"category\": \"Network activity\" if ioc_type in (\"ipv4\", \"domain\", \"url\") else \"Payload delivery\",\n                        \"to_ids\": True,\n                    })\n\n        resp = requests.post(\n            f\"{misp_url}\u002Fevents\",\n            headers=headers,\n            json=event,\n            verify=not os.environ.get(\"SKIP_TLS_VERIFY\", \"\").lower() == \"true\",  # Set SKIP_TLS_VERIFY=true for self-signed certs in lab environments\n        )\n        if resp.status_code == 200:\n            event_id = resp.json().get(\"Event\", {}).get(\"id\", \"\")\n            print(f\"[+] MISP event created: {event_id}\")\n            return event_id\n        else:\n            print(f\"[-] MISP error: {resp.status_code} - {resp.text[:200]}\")\n            return None\n\n    def push_to_taxii(self, stix_bundle, taxii_url, collection_id, username, password):\n        \"\"\"Push STIX bundle to TAXII 2.1 collection.\"\"\"\n        from taxii2client.v21 import Collection\n        collection = Collection(\n            f\"{taxii_url}\u002Fcollections\u002F{collection_id}\u002F\",\n            user=username, password=password,\n        )\n        response = collection.add_objects(stix_bundle.serialize())\n        print(f\"[+] TAXII: Published bundle, status: {response.status}\")\n        return response\n\ndistributor = IOCDistributor()\ndistributor.push_to_misp(\n    iocs,\n    misp_url=\"https:\u002F\u002Fmisp.organization.com\",\n    misp_key=\"YOUR_MISP_API_KEY\",\n    event_info=\"Malware Campaign IOCs - 2025\",\n)\n```\n\n## Validation Criteria\n\n- IOCs extracted correctly from free text with refanging support\n- Defanging produces safe, non-clickable indicators\n- STIX 2.1 bundle contains valid indicator patterns\n- IOCs distributed to MISP and TAXII successfully\n- Deduplication prevents duplicate indicators\n- Whitelisting prevents false positives on known-good domains\n\n## References\n\n- [CISA: Cybersecurity Automation and Threat Intelligence Sharing](https:\u002F\u002Fwww.cisa.gov\u002Fsites\u002Fdefault\u002Ffiles\u002Fpublications\u002FOperational%20Value%20of%20IOCs_508c.pdf)\n- [Defang Python Library](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdefang\u002F)\n- [ioc-fanger](https:\u002F\u002Fpypi.org\u002Fproject\u002Fioc-fanger\u002F)\n- [STIX 2.1 Indicator Specification](https:\u002F\u002Fdocs.oasis-open.org\u002Fcti\u002Fstix\u002Fv2.1\u002Fos\u002Fstix-v2.1-os.html)\n- [Grokipedia: Defanging](https:\u002F\u002Fgrokipedia.com\u002Fpage\u002Fdefanging)\n- [Hunt.io: Best IOC Feeds](https:\u002F\u002Fhunt.io\u002Fglossary\u002Fbest-ioc-feeds)\n","# Building IOC Defanging and Sharing Pipeline\n\n## Overview\n\nIOC defanging modifies potentially malicious indicators (URLs, IP addresses, domains, email addresses) to prevent accidental clicks or execution while preserving readability for analysis and sharing. This skill covers building an automated pipeline that ingests raw IOCs from multiple sources, normalizes and deduplicates them, applies defanging for safe human consumption, converts them to STIX 2.1 format for machine consumption, and distributes through TAXII servers, MISP instances, and email reports.\n\n\n## When to Use\n\n- When deploying or configuring building ioc defanging and sharing pipeline 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 `defang`, `ioc-fanger`, `stix2`, `requests`, `validators` libraries\n- MISP instance or TAXII server for automated sharing\n- Understanding of IOC types: IPv4\u002FIPv6, domains, URLs, email addresses, file hashes\n- Familiarity with STIX 2.1 Indicator patterns and TLP marking definitions\n- Access to threat intelligence feeds for IOC ingestion\n\n## Key Concepts\n\n### IOC Defanging Standards\n\nDefanging replaces active protocol and domain components to prevent execution: `http:\u002F\u002F` becomes `hxxp:\u002F\u002F`, `https:\u002F\u002F` becomes `hxxps:\u002F\u002F`, dots in domains\u002FIPs become `[.]`, `@` in emails becomes `[@]`. This is critical for sharing IOCs in reports, emails, Slack channels, and paste sites where auto-linking could trigger network connections to malicious infrastructure.\n\n### IOC Normalization\n\nRaw IOCs from different sources come in inconsistent formats. Normalization involves converting to lowercase, removing trailing slashes and whitespace, extracting domains from URLs, resolving URL encoding, validating format correctness, and deduplicating across sources.\n\n### STIX 2.1 Indicator Patterns\n\nSTIX patterns express IOCs in a standardized format: `[ipv4-addr:value = '203.0.113.1']`, `[domain-name:value = 'malicious.example.com']`, `[url:value = 'http:\u002F\u002Fevil.com\u002Fpayload']`, `[file:hashes.'SHA-256' = 'abc123...']`. Each indicator includes valid_from, indicator_types, confidence, and optional TLP markings.\n\n## Workflow\n\n### Step 1: Build IOC Extraction and Normalization\n\n```python\nimport re\nimport hashlib\nfrom urllib.parse import urlparse, unquote\nfrom datetime import datetime\n\nclass IOCExtractor:\n    \"\"\"Extract and normalize IOCs from text.\"\"\"\n\n    PATTERNS = {\n        \"ipv4\": r'\\b(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\b',\n        \"domain\": r'\\b(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}\\b',\n        \"url\": r'https?:\u002F\u002F[^\\s\u003C>\"{}|\\\\^`\\[\\]]+',\n        \"email\": r'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b',\n        \"md5\": r'\\b[a-fA-F0-9]{32}\\b',\n        \"sha1\": r'\\b[a-fA-F0-9]{40}\\b',\n        \"sha256\": r'\\b[a-fA-F0-9]{64}\\b',\n    }\n\n    WHITELIST_DOMAINS = {\n        \"google.com\", \"microsoft.com\", \"amazon.com\", \"github.com\",\n        \"cloudflare.com\", \"akamai.com\", \"example.com\",\n    }\n\n    def extract_from_text(self, text):\n        \"\"\"Extract all IOC types from free text.\"\"\"\n        # Refang any already-defanged indicators first\n        text = self._refang(text)\n        iocs = {\"ipv4\": set(), \"domain\": set(), \"url\": set(),\n                \"email\": set(), \"md5\": set(), \"sha1\": set(), \"sha256\": set()}\n\n        for ioc_type, pattern in self.PATTERNS.items():\n            matches = re.findall(pattern, text)\n            for match in matches:\n                normalized = self._normalize(match, ioc_type)\n                if normalized and not self._is_whitelisted(normalized, ioc_type):\n                    iocs[ioc_type].add(normalized)\n\n        # Remove domains that are part of URLs\n        url_domains = set()\n        for url in iocs[\"url\"]:\n            parsed = urlparse(url)\n            url_domains.add(parsed.netloc)\n        iocs[\"domain\"] -= url_domains\n\n        total = sum(len(v) for v in iocs.values())\n        print(f\"[+] Extracted {total} unique IOCs from text\")\n        return {k: sorted(v) for k, v in iocs.items()}\n\n    def _refang(self, text):\n        \"\"\"Convert defanged indicators back to active form.\"\"\"\n        text = text.replace(\"hxxp:\u002F\u002F\", \"http:\u002F\u002F\").replace(\"hxxps:\u002F\u002F\", \"https:\u002F\u002F\")\n        text = text.replace(\"[.]\", \".\").replace(\"[@]\", \"@\")\n        text = text.replace(\"[:\u002F\u002F]\", \":\u002F\u002F\").replace(\"(.)\", \".\")\n        return text\n\n    def _normalize(self, value, ioc_type):\n        \"\"\"Normalize an IOC value.\"\"\"\n        value = value.strip().lower()\n        if ioc_type == \"url\":\n            value = unquote(value).rstrip(\"\u002F\")\n        elif ioc_type == \"domain\":\n            value = value.rstrip(\".\")\n        return value\n\n    def _is_whitelisted(self, value, ioc_type):\n        \"\"\"Check if IOC is in whitelist.\"\"\"\n        if ioc_type == \"domain\":\n            return value in self.WHITELIST_DOMAINS\n        if ioc_type == \"url\":\n            parsed = urlparse(value)\n            return parsed.netloc in self.WHITELIST_DOMAINS\n        return False\n\nextractor = IOCExtractor()\nsample_text = \"\"\"\nMalware C2: hxxps:\u002F\u002Fevil-domain[.]com\u002Fbeacon\nDrops payload from 192.168.1.100 and contacts 10[.]0[.]0[.]1\nSHA256: 275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f\nPhishing email from attacker[@]phishing-domain[.]com\n\"\"\"\niocs = extractor.extract_from_text(sample_text)\n```\n\n### Step 2: Defanging Engine\n\n```python\nclass IOCDefanger:\n    \"\"\"Defang IOCs for safe sharing in reports and communications.\"\"\"\n\n    def defang_url(self, url):\n        return url.replace(\"http:\u002F\u002F\", \"hxxp:\u002F\u002F\").replace(\"https:\u002F\u002F\", \"hxxps:\u002F\u002F\").replace(\".\", \"[.]\")\n\n    def defang_domain(self, domain):\n        return domain.replace(\".\", \"[.]\")\n\n    def defang_ip(self, ip):\n        return ip.replace(\".\", \"[.]\")\n\n    def defang_email(self, email):\n        return email.replace(\"@\", \"[@]\").replace(\".\", \"[.]\")\n\n    def defang_all(self, iocs):\n        \"\"\"Defang all IOCs in a dictionary.\"\"\"\n        defanged = {}\n        for ioc_type, values in iocs.items():\n            if ioc_type == \"url\":\n                defanged[ioc_type] = [self.defang_url(v) for v in values]\n            elif ioc_type == \"domain\":\n                defanged[ioc_type] = [self.defang_domain(v) for v in values]\n            elif ioc_type == \"ipv4\":\n                defanged[ioc_type] = [self.defang_ip(v) for v in values]\n            elif ioc_type == \"email\":\n                defanged[ioc_type] = [self.defang_email(v) for v in values]\n            else:\n                defanged[ioc_type] = values  # Hashes don't need defanging\n        return defanged\n\n    def generate_sharing_report(self, iocs, defanged, report_name=\"IOC Report\"):\n        \"\"\"Generate a human-readable defanged IOC report.\"\"\"\n        report = f\"# {report_name}\\n\"\n        report += f\"Generated: {datetime.now().isoformat()}\\n\\n\"\n\n        for ioc_type in [\"url\", \"domain\", \"ipv4\", \"email\", \"sha256\", \"sha1\", \"md5\"]:\n            values = defanged.get(ioc_type, [])\n            if values:\n                report += f\"## {ioc_type.upper()} ({len(values)})\\n\"\n                for v in values:\n                    report += f\"- `{v}`\\n\"\n                report += \"\\n\"\n\n        return report\n\ndefanger = IOCDefanger()\ndefanged = defanger.defang_all(iocs)\nreport = defanger.generate_sharing_report(iocs, defanged, \"Malware Campaign IOCs\")\nprint(report)\n```\n\n### Step 3: Convert to STIX 2.1 Format\n\n```python\nfrom stix2 import Indicator, Bundle, TLP_WHITE, TLP_GREEN, TLP_AMBER\nfrom datetime import datetime\n\nclass STIXConverter:\n    \"\"\"Convert raw IOCs to STIX 2.1 Indicator objects.\"\"\"\n\n    TLP_MAP = {\"white\": TLP_WHITE, \"green\": TLP_GREEN, \"amber\": TLP_AMBER}\n\n    def iocs_to_stix(self, iocs, tlp=\"green\", confidence=75):\n        \"\"\"Convert IOC dictionary to STIX 2.1 bundle.\"\"\"\n        stix_objects = []\n        marking = self.TLP_MAP.get(tlp, TLP_GREEN)\n\n        for ip in iocs.get(\"ipv4\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious IP: {ip}\",\n                pattern=f\"[ipv4-addr:value = '{ip}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for domain in iocs.get(\"domain\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious Domain: {domain}\",\n                pattern=f\"[domain-name:value = '{domain}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for url in iocs.get(\"url\", []):\n            escaped = url.replace(\"'\", \"\\\\'\")\n            stix_objects.append(Indicator(\n                name=f\"Malicious URL: {url[:60]}\",\n                pattern=f\"[url:value = '{escaped}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        for sha256 in iocs.get(\"sha256\", []):\n            stix_objects.append(Indicator(\n                name=f\"Malicious File Hash: {sha256[:16]}...\",\n                pattern=f\"[file:hashes.'SHA-256' = '{sha256}']\",\n                pattern_type=\"stix\",\n                valid_from=datetime.now(),\n                indicator_types=[\"malicious-activity\"],\n                confidence=confidence,\n                object_marking_refs=[marking],\n            ))\n\n        bundle = Bundle(objects=stix_objects)\n        print(f\"[+] Created STIX bundle with {len(stix_objects)} indicators\")\n        return bundle\n\nconverter = STIXConverter()\nstix_bundle = converter.iocs_to_stix(iocs, tlp=\"amber\", confidence=80)\nwith open(\"iocs_stix_bundle.json\", \"w\") as f:\n    f.write(stix_bundle.serialize(pretty=True))\n```\n\n### Step 4: Distribute Through MISP and TAXII\n\n```python\nimport requests\nimport json\n\nclass IOCDistributor:\n    \"\"\"Distribute IOCs through various channels.\"\"\"\n\n    def push_to_misp(self, iocs, misp_url, misp_key, event_info):\n        \"\"\"Push IOCs to MISP as a new event.\"\"\"\n        headers = {\n            \"Authorization\": misp_key,\n            \"Content-Type\": \"application\u002Fjson\",\n            \"Accept\": \"application\u002Fjson\",\n        }\n        event = {\n            \"Event\": {\n                \"info\": event_info,\n                \"distribution\": \"1\",  # This community only\n                \"threat_level_id\": \"2\",  # Medium\n                \"analysis\": \"2\",  # Completed\n                \"Attribute\": [],\n            }\n        }\n\n        type_mapping = {\n            \"ipv4\": \"ip-dst\",\n            \"domain\": \"domain\",\n            \"url\": \"url\",\n            \"email\": \"email-src\",\n            \"md5\": \"md5\",\n            \"sha1\": \"sha1\",\n            \"sha256\": \"sha256\",\n        }\n\n        for ioc_type, values in iocs.items():\n            misp_type = type_mapping.get(ioc_type)\n            if misp_type:\n                for value in values:\n                    event[\"Event\"][\"Attribute\"].append({\n                        \"type\": misp_type,\n                        \"value\": value,\n                        \"category\": \"Network activity\" if ioc_type in (\"ipv4\", \"domain\", \"url\") else \"Payload delivery\",\n                        \"to_ids\": True,\n                    })\n\n        resp = requests.post(\n            f\"{misp_url}\u002Fevents\",\n            headers=headers,\n            json=event,\n            verify=not os.environ.get(\"SKIP_TLS_VERIFY\", \"\").lower() == \"true\",  # Set SKIP_TLS_VERIFY=true for self-signed certs in lab environments\n        )\n        if resp.status_code == 200:\n            event_id = resp.json().get(\"Event\", {}).get(\"id\", \"\")\n            print(f\"[+] MISP event created: {event_id}\")\n            return event_id\n        else:\n            print(f\"[-] MISP error: {resp.status_code} - {resp.text[:200]}\")\n            return None\n\n    def push_to_taxii(self, stix_bundle, taxii_url, collection_id, username, password):\n        \"\"\"Push STIX bundle to TAXII 2.1 collection.\"\"\"\n        from taxii2client.v21 import Collection\n        collection = Collection(\n            f\"{taxii_url}\u002Fcollections\u002F{collection_id}\u002F\",\n            user=username, password=password,\n        )\n        response = collection.add_objects(stix_bundle.serialize())\n        print(f\"[+] TAXII: Published bundle, status: {response.status}\")\n        return response\n\ndistributor = IOCDistributor()\ndistributor.push_to_misp(\n    iocs,\n    misp_url=\"https:\u002F\u002Fmisp.organization.com\",\n    misp_key=\"YOUR_MISP_API_KEY\",\n    event_info=\"Malware Campaign IOCs - 2025\",\n)\n```\n\n## Validation Criteria\n\n- IOCs extracted correctly from free text with refanging support\n- Defanging produces safe, non-clickable indicators\n- STIX 2.1 bundle contains valid indicator patterns\n- IOCs distributed to MISP and TAXII successfully\n- Deduplication prevents duplicate indicators\n- Whitelisting prevents false positives on known-good domains\n\n## References\n\n- [CISA: Cybersecurity Automation and Threat Intelligence Sharing](https:\u002F\u002Fwww.cisa.gov\u002Fsites\u002Fdefault\u002Ffiles\u002Fpublications\u002FOperational%20Value%20of%20IOCs_508c.pdf)\n- [Defang Python Library](https:\u002F\u002Fpypi.org\u002Fproject\u002Fdefang\u002F)\n- [ioc-fanger](https:\u002F\u002Fpypi.org\u002Fproject\u002Fioc-fanger\u002F)\n- [STIX 2.1 Indicator Specification](https:\u002F\u002Fdocs.oasis-open.org\u002Fcti\u002Fstix\u002Fv2.1\u002Fos\u002Fstix-v2.1-os.html)\n- [Grokipedia: Defanging](https:\u002F\u002Fgrokipedia.com\u002Fpage\u002Fdefanging)\n- [Hunt.io: Best IOC Feeds](https:\u002F\u002Fhunt.io\u002Fglossary\u002Fbest-ioc-feeds)\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"subdomain":33,"description":7},[26,27,28,29,30,31,32,33],"ioc","defanging","threat-sharing","stix","pipeline","indicator","automation","threat-intelligence","mahipal","cybersecurity","1.0","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fbuilding-ioc-defanging-and-sharing-pipeline",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill building-ioc-defanging-and-sharing-pipeline",{"tool":52,"command":53},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill building-ioc-defanging-and-sharing-pipeline",{"tool":55,"command":56},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill building-ioc-defanging-and-sharing-pipeline","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbuilding-ioc-defanging-and-sharing-pipeline\u002FSKILL.md",true,[60,64,70],{"path":61,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fapi-reference.md","REFERENCE","参考文档",1563,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbuilding-ioc-defanging-and-sharing-pipeline\u002Freferences\u002Fapi-reference.md",{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},"scripts\u002Fagent.py","SCRIPT","脚本",7028,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fbuilding-ioc-defanging-and-sharing-pipeline\u002Fscripts\u002Fagent.py",[77,85,92,99,106,114],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":20},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":20},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":20},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":20},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]