txt2stix 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- txt2stix-0.0.4/.env.example +16 -0
- txt2stix-0.0.4/.env.markdown +52 -0
- txt2stix-0.0.4/.github/workflows/create-release.yml +71 -0
- txt2stix-0.0.4/.github/workflows/run-tests.yml +65 -0
- txt2stix-0.0.4/.gitignore +11 -0
- txt2stix-0.0.4/LICENSE +202 -0
- txt2stix-0.0.4/PKG-INFO +190 -0
- txt2stix-0.0.4/README.md +152 -0
- txt2stix-0.0.4/docs/README.md +86 -0
- txt2stix-0.0.4/docs/stix-mapping.md +2061 -0
- txt2stix-0.0.4/docs/txt2stix.png +0 -0
- txt2stix-0.0.4/includes/__init__.py +0 -0
- txt2stix-0.0.4/includes/extractions/ai/config.yaml +1023 -0
- txt2stix-0.0.4/includes/extractions/lookup/config.yaml +393 -0
- txt2stix-0.0.4/includes/extractions/pattern/config.yaml +609 -0
- txt2stix-0.0.4/includes/helpers/mimetype_filename_extension_list.csv +936 -0
- txt2stix-0.0.4/includes/helpers/stix_relationship_types.txt +41 -0
- txt2stix-0.0.4/includes/helpers/tlds.txt +1446 -0
- txt2stix-0.0.4/includes/helpers/windows_registry_key_prefix.txt +12 -0
- txt2stix-0.0.4/includes/lookups/_README.md +11 -0
- txt2stix-0.0.4/includes/lookups/_generate_lookups.py +247 -0
- txt2stix-0.0.4/includes/lookups/attack_pattern.txt +1 -0
- txt2stix-0.0.4/includes/lookups/campaign.txt +1 -0
- txt2stix-0.0.4/includes/lookups/country_iso3166_alpha2.txt +249 -0
- txt2stix-0.0.4/includes/lookups/course_of_action.txt +1 -0
- txt2stix-0.0.4/includes/lookups/disarm_id_v1_5.txt +345 -0
- txt2stix-0.0.4/includes/lookups/disarm_name_v1_5.txt +347 -0
- txt2stix-0.0.4/includes/lookups/extensions.txt +78 -0
- txt2stix-0.0.4/includes/lookups/identity.txt +1 -0
- txt2stix-0.0.4/includes/lookups/infrastructure.txt +1 -0
- txt2stix-0.0.4/includes/lookups/intrusion_set.txt +1 -0
- txt2stix-0.0.4/includes/lookups/malware.txt +2 -0
- txt2stix-0.0.4/includes/lookups/mitre_atlas_id_v4_5_2.txt +116 -0
- txt2stix-0.0.4/includes/lookups/mitre_atlas_name_v4_5_2.txt +117 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_enterprise_aliases_v16_0.txt +1502 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_enterprise_id_v16_0.txt +1656 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_enterprise_name_v16_0.txt +1765 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_ics_aliases_v16_0.txt +141 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_ics_id_v16_0.txt +254 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_ics_name_v16_0.txt +293 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_mobile_aliases_v16_0.txt +159 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_mobile_id_v16_0.txt +277 -0
- txt2stix-0.0.4/includes/lookups/mitre_attack_mobile_name_v16_0.txt +296 -0
- txt2stix-0.0.4/includes/lookups/mitre_capec_id_v3_9.txt +559 -0
- txt2stix-0.0.4/includes/lookups/mitre_capec_name_v3_9.txt +560 -0
- txt2stix-0.0.4/includes/lookups/mitre_cwe_id_v4_15.txt +939 -0
- txt2stix-0.0.4/includes/lookups/mitre_cwe_name_v4_15.txt +939 -0
- txt2stix-0.0.4/includes/lookups/threat_actor.txt +1 -0
- txt2stix-0.0.4/includes/lookups/tld.txt +1422 -0
- txt2stix-0.0.4/includes/lookups/tool.txt +1 -0
- txt2stix-0.0.4/includes/tests/test_cases.yaml +695 -0
- txt2stix-0.0.4/pyproject.toml +63 -0
- txt2stix-0.0.4/requirements.txt +368 -0
- txt2stix-0.0.4/tests/README.md +31 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_country.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_mitre_attack_enterprise.txt +12 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_mitre_attack_ics.txt +4 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_mitre_attack_mobile.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_mitre_capec.txt +4 -0
- txt2stix-0.0.4/tests/data/extraction_types/ai_mitre_cwe.txt +5 -0
- txt2stix-0.0.4/tests/data/extraction_types/all_cases.txt +185 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_autonomous_system_number.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_all.txt +18 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_amex.txt +4 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_diners.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_discover.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_jcb.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_mastercard.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_union_pay.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_bank_card_visa.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_country_alpha2.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cpe_uri.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_btc_transaction.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_btc_wallet.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_eth_transaction.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_eth_wallet.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_xmr_transaction.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cryptocurrency_xmr_wallet.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_cve_id.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_directory_unix.txt +12 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_directory_unix_file.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_directory_windows.txt +15 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_directory_windows_with_file.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_disarm.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_disarm_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_domain_name_only.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_domain_name_subdomain.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_email_address.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_md5.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_sha_1.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_sha_224.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_sha_256.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_sha_384.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_hash_sha_512.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_file_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_host_name.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_host_name_file.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_host_name_path.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_host_name_subdomain.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_host_name_url.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_iban_number.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv4_address_cidr.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv4_address_only.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv4_address_port.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv6_address_cidr.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv6_address_only.txt +12 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_ipv6_address_port.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mac_address.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_atlas.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_atlas_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_enterprise.txt +14 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_enterprise_aliases.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_enterprise_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_ics.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_ics_aliases.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_ics_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_mobile.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_mobile_aliases.txt +10 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_attack_mobile_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_capec.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_capec_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_cwe.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_mitre_cwe_name.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_phone_number.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_url.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_url_file.txt +12 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_url_path.txt +11 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_user_agent.txt +9 -0
- txt2stix-0.0.4/tests/data/extraction_types/generic_windows_registry_key.txt +12 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_attack_pattern.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_campaign.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_course_of_action.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_identity.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_infrastructure.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_intrusion_set.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_malware.txt +8 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_threat_actor.txt +7 -0
- txt2stix-0.0.4/tests/data/extraction_types/lookup_tool.txt +7 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/attack_flow_demo.txt +7 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/basic_relationship.txt +3 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/char_length_too_long.txt +582 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/descriptive_for_ai_relationships_1.txt +7 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/disarm_demo.txt +7 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/embedded_img_ignore.txt +5 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/embedded_link_ignore.txt +3 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/ip1.txt +1 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/ip2.txt +1 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/known_whitelist_match.txt +3 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/mitre_attack_enterprise_ai_demo.txt +1 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/mitre_attack_enterprise_lookup_demo.txt +7 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/mixed_extractions.txt +2 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/test_ai_hash_error_with_stix2_lib.txt +2 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/test_aliases.txt +5 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/test_extraction_boundary.txt +1 -0
- txt2stix-0.0.4/tests/data/manually_generated_reports/test_extraction_escapes.txt +15 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/APT28-Center-of-Storm-2017.txt +856 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/Bitdefender-Labs-Report-X-creat6958-en-EN.txt +969 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/FireEyeAPT39.txt +104 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/France_CERT_APT31_Pakdoor_TLPWHITE.txt +381 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/Group-IB_Ransomware_Uncovered_whitepaper_eng.txt +0 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/JOINT_CSA_HUNTING_RU_INTEL_SNAKE_MALWARE_20230509.txt +0 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/TA22-0126-QAKBOT-analysis-TLP-GREEN.txt +1450 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/dinners_card.txt +6 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/mandiant-apt1.txt +2235 -0
- txt2stix-0.0.4/tests/data/real_intel_reports/mykings_report_final.txt +2016 -0
- txt2stix-0.0.4/tests/manual-tests/cases-ai-relationships.md +115 -0
- txt2stix-0.0.4/tests/manual-tests/cases-extraction-type-ai.md +946 -0
- txt2stix-0.0.4/tests/manual-tests/cases-extraction-type-lookup.md +350 -0
- txt2stix-0.0.4/tests/manual-tests/cases-extraction-type-pattern.md +625 -0
- txt2stix-0.0.4/tests/manual-tests/cases-standard-tests.md +452 -0
- txt2stix-0.0.4/tests/scripts/generate_simple_extraction_test_cases_txt_files.py +57 -0
- txt2stix-0.0.4/tests/src/__init__.py +3 -0
- txt2stix-0.0.4/tests/src/test_attack_flow.py +135 -0
- txt2stix-0.0.4/tests/src/test_bundler.py +105 -0
- txt2stix-0.0.4/tests/src/test_extractors.py +49 -0
- txt2stix-0.0.4/tests/src/test_indicator.py +460 -0
- txt2stix-0.0.4/tests/src/test_lookups.py +98 -0
- txt2stix-0.0.4/tests/src/test_main.py +136 -0
- txt2stix-0.0.4/tests/src/test_run_txt2stix.py +128 -0
- txt2stix-0.0.4/tests/src/test_utils.py +70 -0
- txt2stix-0.0.4/tests/src/utils.py +30 -0
- txt2stix-0.0.4/txt2stix/__init__.py +33 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/__init__.py +15 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/anthropic.py +12 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/base.py +87 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/deepseek.py +19 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/gemini.py +18 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/openai.py +15 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/openrouter.py +20 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/prompts.py +164 -0
- txt2stix-0.0.4/txt2stix/ai_extractor/utils.py +85 -0
- txt2stix-0.0.4/txt2stix/attack_flow.py +101 -0
- txt2stix-0.0.4/txt2stix/bundler.py +428 -0
- txt2stix-0.0.4/txt2stix/common.py +23 -0
- txt2stix-0.0.4/txt2stix/extractions.py +59 -0
- txt2stix-0.0.4/txt2stix/indicator.py +860 -0
- txt2stix-0.0.4/txt2stix/lookups.py +68 -0
- txt2stix-0.0.4/txt2stix/pattern/__init__.py +13 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/__init__.py +0 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/base_extractor.py +167 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/README.md +34 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/__init__.py +15 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/amex_card_extractor.py +52 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/diners_card_extractor.py +47 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/discover_card_extractor.py +48 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/jcb_card_extractor.py +43 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/master_card_extractor.py +63 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/union_card_extractor.py +38 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/card/visa_card_extractor.py +46 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/crypto/__init__.py +3 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/crypto/btc_extractor.py +38 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/directory/__init__.py +10 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/directory/unix_directory_extractor.py +40 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/directory/unix_file_path_extractor.py +42 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/directory/windows_directory_path_extractor.py +47 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/directory/windows_file_path_extractor.py +42 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/domain/__init__.py +8 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/domain/domain_extractor.py +39 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/domain/hostname_extractor.py +36 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/domain/sub_domain_extractor.py +49 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/__init__.py +16 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/md5_extractor.py +16 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha1_extractor.py +14 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha224_extractor.py +18 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha2_256_exactor.py +14 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha2_512_exactor.py +13 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha3_256_exactor.py +15 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/hashes/sha3_512_exactor.py +16 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/helper.py +64 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/__init__.py +14 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv4_cidr_extractor.py +49 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv4_extractor.py +18 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv4_port_extractor.py +42 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv6_cidr_extractor.py +18 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv6_extractor.py +16 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/ip/ipv6_port_extractor.py +46 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/__init__.py +22 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/asn_extractor.py +14 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/cpe_extractor.py +29 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/cve_extractor.py +14 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/email_extractor.py +21 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/filename_extractor.py +17 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/iban_extractor.py +15 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/mac_address_extractor.py +13 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/phonenumber_extractor.py +41 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/user_agent_extractor.py +20 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/others/windows_registry_key_extractor.py +18 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/url/__init__.py +7 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/url/url_extractor.py +22 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/url/url_file_extractor.py +21 -0
- txt2stix-0.0.4/txt2stix/pattern/extractors/url/url_path_extractor.py +74 -0
- txt2stix-0.0.4/txt2stix/retriever.py +126 -0
- txt2stix-0.0.4/txt2stix/stix.py +1 -0
- txt2stix-0.0.4/txt2stix/txt2stix.py +336 -0
- txt2stix-0.0.4/txt2stix/utils.py +86 -0
- txt2stix-0.0.4/txt2stix.py +3 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
## AI Settings
|
2
|
+
INPUT_TOKEN_LIMIT=
|
3
|
+
OPENAI_API_KEY=
|
4
|
+
ANTHROPIC_API_KEY=
|
5
|
+
GOOGLE_API_KEY=
|
6
|
+
OPENROUTER_API_KEY=
|
7
|
+
DEEPSEEK_API_KEY=
|
8
|
+
TEMPERATURE=
|
9
|
+
## BIN LIST
|
10
|
+
BIN_LIST_API_KEY=
|
11
|
+
## CTIBUTLER
|
12
|
+
CTIBUTLER_BASE_URL=
|
13
|
+
CTIBUTLER_API_KEY=
|
14
|
+
## VULMATCH
|
15
|
+
VULMATCH_BASE_URL=
|
16
|
+
VULMATCH_API_KEY=
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Environment file info
|
2
|
+
|
3
|
+
If you're running in production, you should set these securely.
|
4
|
+
|
5
|
+
However, if you just want to experiment, set the following values
|
6
|
+
|
7
|
+
## AI Settings
|
8
|
+
|
9
|
+
* `INPUT_TOKEN_LIMIT`: `15000`
|
10
|
+
* (REQUIRED IF USING AI MODES) Ensure the input/output token count meets requirements and is supported by the model selected. Will not allow files with more than tokens specified to be processed
|
11
|
+
* `TEMPERATURE`: `0.0`
|
12
|
+
* The temperature value ranges from 0 to 2, with lower values indicating greater determinism and higher values indicating more randomness in responses.
|
13
|
+
|
14
|
+
**A small note on selecting a provider**
|
15
|
+
|
16
|
+
Below are the models you can use.
|
17
|
+
|
18
|
+
We strongly recommend using OpenAI because of it's use of structured outputs. Whilst the other models should work, they can often ignore prompts for our expected response structured leading to failures.
|
19
|
+
|
20
|
+
* `OPENAI_API_KEY`: YOUR_API_KEY
|
21
|
+
* (REQUIRED IF USING OPENAI MODELS DIRECTLY IN AI MODES) get it from: https://platform.openai.com/api-keys
|
22
|
+
* `OPENROUTER_API_KEY`=
|
23
|
+
* (REQUIRED IF USING MODELS PROVIDED BY OPENROUTER IN AI MODES) get it from: https://openrouter.ai/settings/keys
|
24
|
+
* `DEEPSEEK_API_KEY`=
|
25
|
+
* (REQUIRED IF USING DEEPSEEK MODELS DIRECTLY IN AI MODES) get it from: https://platform.deepseek.com/api-key
|
26
|
+
* `ANTHROPIC_API_KEY`: YOUR_API_KEY
|
27
|
+
* (REQUIRED IF USING ANTHROPIC MODELS DIRECTLY IN AI MODES) get it from" https://console.anthropic.com/settings/keys
|
28
|
+
* `GOOGLE_API_KEY`:
|
29
|
+
* (REQUIRED IF USING GOOGLE GEMINI MODELS DIRECTLY IN AI MODES) get it from the Google Cloud Platform (making sure the Gemini API is enabled for the project)
|
30
|
+
|
31
|
+
## BIN List
|
32
|
+
|
33
|
+
* `BIN_LIST_API_KEY`: BLANK
|
34
|
+
* for enriching credit card extractions needed for extracting credit card information. You get an API key here https://rapidapi.com/trade-expanding-llc-trade-expanding-llc-default/api/bin-ip-checker
|
35
|
+
|
36
|
+
## CTIBUTLER
|
37
|
+
|
38
|
+
txt2stix requires [ctibutler](https://github.com/muchdogesec/ctibutler) to lookup ATT&CK, CAPEC, CWE, ATLAS, and locations in blogs
|
39
|
+
|
40
|
+
* `CTIBUTLER_BASE_URL`: `'http://api.ctibutler.com'` (recommended)
|
41
|
+
* If you are running CTI Butler locally, be sure to set `'http://host.docker.internal:8006/api/'` in the `.env` file otherwise you will run into networking errors.
|
42
|
+
* `CTIBUTLER_API_KEY`:
|
43
|
+
* If using `'http://api.ctibutler.com'`, [get your API key here](http://app.ctibutler.com). Can be left blank if running locally.
|
44
|
+
|
45
|
+
## VULMATCH FOR CVE AND CPE LOOKUPS
|
46
|
+
|
47
|
+
txt2stix requires [vulmatch](https://github.com/muchdogesec/vulmatch) to lookup CVEs and CPEs in blogs
|
48
|
+
|
49
|
+
* `VULMATCH_BASE_URL`: `'http://api.vulmatch.com'` (recommended)
|
50
|
+
* If you are running Vulmatch locally, be sure to set `'http://host.docker.internal:8005/api/'` in the `.env` file otherwise you will run into networking errors.
|
51
|
+
* `VULMATCH_API_KEY`:
|
52
|
+
* If using `'http://api.vulmatch.com'`, [get your API key here](http://app.vulmatch.com). Can be left blank if running locally.
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: Create Release
|
2
|
+
run-name: Creating release
|
3
|
+
|
4
|
+
on:
|
5
|
+
workflow_dispatch:
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- 'main'
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
create-release:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: write
|
15
|
+
id-token: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
|
20
|
+
- name: Set up Python
|
21
|
+
uses: actions/setup-python@v5
|
22
|
+
with:
|
23
|
+
python-version: "3.11"
|
24
|
+
|
25
|
+
- name: Install build dependencies
|
26
|
+
run: python3 -m pip install build hatchling
|
27
|
+
|
28
|
+
- name: Extract version from pyproject.toml
|
29
|
+
id: get-version
|
30
|
+
run: |
|
31
|
+
VERSION=$(python -m hatchling version)
|
32
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
33
|
+
|
34
|
+
- name: Build package
|
35
|
+
run: python3 -m build
|
36
|
+
|
37
|
+
- name: Determine release tag
|
38
|
+
id: release-tag
|
39
|
+
run: |
|
40
|
+
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
41
|
+
echo "tag=${{ steps.get-version.outputs.version }}" >> $GITHUB_OUTPUT
|
42
|
+
else
|
43
|
+
echo "tag=${{ steps.get-version.outputs.version }}-beta-$(date +"%Y-%m-%d-%H-%M-%S")" >> $GITHUB_OUTPUT
|
44
|
+
fi
|
45
|
+
|
46
|
+
- name: Create GitHub Release
|
47
|
+
env:
|
48
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
49
|
+
run: |
|
50
|
+
TAG="${{ steps.release-tag.outputs.tag }}"
|
51
|
+
gh release create "$TAG" --repo "${{ github.repository }}" --notes ""
|
52
|
+
gh release upload "$TAG" dist/** --repo "${{ github.repository }}"
|
53
|
+
|
54
|
+
- name: Clean up old beta releases (keep latest 10)
|
55
|
+
if: github.ref_name != 'main'
|
56
|
+
env:
|
57
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
58
|
+
run: |
|
59
|
+
gh release list --limit 100 --repo "${{ github.repository }}" --json tagName,createdAt \
|
60
|
+
| jq -r '.[] | select(.tagName | test("-beta-")) | [.tagName, .createdAt] | @tsv' \
|
61
|
+
| sort -k2 -r \
|
62
|
+
| tail -n +11 \
|
63
|
+
| cut -f1 \
|
64
|
+
| while read old_tag; do
|
65
|
+
echo "Deleting old beta release: $old_tag"
|
66
|
+
gh release delete "$old_tag" --repo "${{ github.repository }}" --cleanup-tag --yes
|
67
|
+
done
|
68
|
+
|
69
|
+
- name: Publish package distributions to PyPI
|
70
|
+
if: github.ref_name == 'main'
|
71
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
@@ -0,0 +1,65 @@
|
|
1
|
+
name: Run Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
run-tests:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
environment: txt2stix_tests
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- name: Checkout repository
|
18
|
+
uses: actions/checkout@v4
|
19
|
+
with:
|
20
|
+
fetch-depth: 1
|
21
|
+
|
22
|
+
- name: Set up Python
|
23
|
+
uses: actions/setup-python@v5
|
24
|
+
with:
|
25
|
+
python-version: "3.11"
|
26
|
+
|
27
|
+
|
28
|
+
- name: Set .env testing purpose
|
29
|
+
run: |
|
30
|
+
echo > .env
|
31
|
+
echo "CTIBUTLER_BASE_URL=${{ secrets.CTIBUTLER_BASE_URL }}" >> .env
|
32
|
+
echo "CTIBUTLER_API_KEY=${{ secrets.CTIBUTLER_API_KEY }}" >> .env
|
33
|
+
echo "VULMATCH_BASE_URL=${{ secrets.VULMATCH_BASE_URL }}" >> .env
|
34
|
+
echo "VULMATCH_API_KEY=${{ secrets.VULMATCH_API_KEY }}" >> .env
|
35
|
+
echo "TEST_AI_MODEL=${{ secrets.TEST_AI_MODEL }}" >> .env
|
36
|
+
echo "INPUT_TOKEN_LIMIT=1000" >> .env
|
37
|
+
|
38
|
+
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY}}" >> .env
|
39
|
+
echo "ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY}}" >> .env
|
40
|
+
echo "GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY}}" >> .env
|
41
|
+
echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY}}" >> .env
|
42
|
+
|
43
|
+
echo "BIN_LIST_API_KEY=${{ secrets.BIN_LIST_API_KEY }}" >> .env
|
44
|
+
|
45
|
+
- name: unit tests
|
46
|
+
id: unit-test
|
47
|
+
run: |
|
48
|
+
set -a;
|
49
|
+
source .env;
|
50
|
+
set +a;
|
51
|
+
pip install -e .[tests]
|
52
|
+
|
53
|
+
pytest --cov --cov-branch --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
|
54
|
+
|
55
|
+
- name: Upload coverage reports to Codecov
|
56
|
+
if: ${{ !cancelled() }}
|
57
|
+
uses: codecov/codecov-action@v5
|
58
|
+
with:
|
59
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
60
|
+
|
61
|
+
- name: Upload test results to Codecov
|
62
|
+
if: ${{ !cancelled() }}
|
63
|
+
uses: codecov/test-results-action@v1
|
64
|
+
with:
|
65
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
txt2stix-0.0.4/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2020 DOGESEC (https://www.dogesec.com/)
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
txt2stix-0.0.4/PKG-INFO
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: txt2stix
|
3
|
+
Version: 0.0.4
|
4
|
+
Summary: txt2stix is a Python script that is designed to identify and extract IoCs and TTPs from text files, identify the relationships between them, convert them to STIX 2.1 objects, and output as a STIX 2.1 bundle.
|
5
|
+
Project-URL: Homepage, https://github.com/muchdogesec/txt2stix
|
6
|
+
Project-URL: Issues, https://github.com/muchdogesec/txt2stix/issues
|
7
|
+
Author-email: DOGESEC <support@dogesec.com>
|
8
|
+
License-File: LICENSE
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Requires-Python: >=3.9
|
13
|
+
Requires-Dist: base58>=2.1.1
|
14
|
+
Requires-Dist: beautifulsoup4>=4.12.3
|
15
|
+
Requires-Dist: llama-index-core>=0.12.42
|
16
|
+
Requires-Dist: llama-index-llms-anthropic>=0.7.2
|
17
|
+
Requires-Dist: llama-index-llms-deepseek>=0.1.2
|
18
|
+
Requires-Dist: llama-index-llms-gemini>=0.5.0
|
19
|
+
Requires-Dist: llama-index-llms-openai-like>=0.4.0
|
20
|
+
Requires-Dist: llama-index-llms-openai>=0.4.5
|
21
|
+
Requires-Dist: llama-index-llms-openrouter>=0.3.2
|
22
|
+
Requires-Dist: mistune>=3.0.2
|
23
|
+
Requires-Dist: pathvalidate>=3.2.0
|
24
|
+
Requires-Dist: phonenumbers>=8.13.39
|
25
|
+
Requires-Dist: python-dotenv>=1.0.1
|
26
|
+
Requires-Dist: requests>=2.32.4
|
27
|
+
Requires-Dist: schwifty>=2024.6.1
|
28
|
+
Requires-Dist: stix2extensions
|
29
|
+
Requires-Dist: tld>=0.13
|
30
|
+
Requires-Dist: tldextract>=5.1.2
|
31
|
+
Requires-Dist: validators>=0.28.3
|
32
|
+
Provides-Extra: tests
|
33
|
+
Requires-Dist: pytest; extra == 'tests'
|
34
|
+
Requires-Dist: pytest-cov; extra == 'tests'
|
35
|
+
Requires-Dist: pytest-subtests; extra == 'tests'
|
36
|
+
Requires-Dist: requests; extra == 'tests'
|
37
|
+
Description-Content-Type: text/markdown
|
38
|
+
|
39
|
+
# txt2stix
|
40
|
+
|
41
|
+
[](https://codecov.io/gh/muchdogesec/txt2stix)
|
42
|
+
|
43
|
+
## Before you begin...
|
44
|
+
|
45
|
+
We have build two products on-top of txt2stix that provide more user-friendly experience:
|
46
|
+
|
47
|
+
* [Stixify: Extract machine readable cyber threat intelligence from unstructured data](https://github.com/muchdogesec/stixify)
|
48
|
+
* [Obstracts: Turn any blog into structured threat intelligence](https://github.com/muchdogesec/obstracts)
|
49
|
+
|
50
|
+
## Overview
|
51
|
+
|
52
|
+

|
53
|
+
|
54
|
+
txt2stix is a Python script that is designed to identify and extract IoCs and TTPs from text files, identify the relationships between them, convert them to STIX 2.1 objects, and output as a STIX 2.1 bundle.
|
55
|
+
|
56
|
+
The general design goal of txt2stix was to keep it flexible, but simple, so that new extractions could be added or modified over time.
|
57
|
+
|
58
|
+
In short txt2stix;
|
59
|
+
|
60
|
+
1. takes a txt file input
|
61
|
+
2. extracts observables for enabled extractions (ai, pattern, or lookup)
|
62
|
+
3. converts extracted observables to STIX 2.1 objects
|
63
|
+
4. generates the relationships between extracted observables (ai, standard)
|
64
|
+
5. converts extracted relationships to STIX 2.1 SRO objects
|
65
|
+
6. outputs a STIX 2.1 bundle
|
66
|
+
|
67
|
+
## tl;dr
|
68
|
+
|
69
|
+
[](https://www.youtube.com/watch?v=TWVGCou9oGk)
|
70
|
+
|
71
|
+
[Watch the demo](https://www.youtube.com/watch?v=TWVGCou9oGk).
|
72
|
+
|
73
|
+
## Usage
|
74
|
+
|
75
|
+
### Setup
|
76
|
+
|
77
|
+
Install the required dependencies using:
|
78
|
+
|
79
|
+
```shell
|
80
|
+
# clone the latest code
|
81
|
+
git clone https://github.com/muchdogesec/txt2stix
|
82
|
+
cd txt2stix
|
83
|
+
# create a venv
|
84
|
+
python3 -m venv txt2stix-venv
|
85
|
+
source txt2stix-venv/bin/activate
|
86
|
+
# install requirements
|
87
|
+
pip3 install .
|
88
|
+
```
|
89
|
+
|
90
|
+
### Set variables
|
91
|
+
|
92
|
+
txt2stix has various settings that are defined in an `.env` file.
|
93
|
+
|
94
|
+
To create a template for the file:
|
95
|
+
|
96
|
+
```shell
|
97
|
+
cp .env.example .env
|
98
|
+
```
|
99
|
+
|
100
|
+
To see more information about how to set the variables, and what they do, read the `.env.markdown` file.
|
101
|
+
|
102
|
+
### Usage
|
103
|
+
|
104
|
+
```shell
|
105
|
+
python3 txt2stix.py \
|
106
|
+
--relationship_mode MODE \
|
107
|
+
--input_file FILE.txt \
|
108
|
+
...
|
109
|
+
```
|
110
|
+
|
111
|
+
The following arguments are available:
|
112
|
+
|
113
|
+
#### Input settings
|
114
|
+
|
115
|
+
* `--input_file` (REQUIRED): the file to be converted. Must be `.txt`
|
116
|
+
|
117
|
+
#### STIX Report generation settings
|
118
|
+
|
119
|
+
|
120
|
+
* `--name` (REQUIRED): name of file, max 72 chars. Will be used in the STIX Report Object created.
|
121
|
+
* `--report_id` (OPTIONAL): Sometimes it is required to control the id of the `report` object generated. You can therefore pass a valid UUIDv4 in this field to be assigned to the report. e.g. passing `2611965-930e-43db-8b95-30a1e119d7e2` would create a STIX object id `report--2611965-930e-43db-8b95-30a1e119d7e2`. If this argument is not passed, the UUID will be randomly generated.
|
122
|
+
* `--tlp_level` (OPTIONAL): Options are `clear`, `green`, `amber`, `amber_strict`, `red`. Default if not passed, is `clear`.
|
123
|
+
* `--confidence` (OPTIONAL): value between 0-100. Default if not passed is null.
|
124
|
+
* `--labels` (OPTIONAL): comma seperated list of labels. Case-insensitive (will all be converted to lower-case). Allowed `a-z`, `0-9`. e.g.`label1,label2` would create 2 labels.
|
125
|
+
* `--created` (OPTIONAL): by default all object `created` times will take the time the script was run. If you want to explicitly set these times you can do so using this flag. Pass the value in the format `YYYY-MM-DDTHH:MM:SS.sssZ` e.g. `2020-01-01T00:00:00.000Z`
|
126
|
+
* `--use_identity` (OPTIONAL): can pass a full STIX 2.1 identity object (make sure to properly escape). Will be validated by the STIX2 library.
|
127
|
+
* `--external_refs` (OPTIONAL): txt2stix will automatically populate the `external_references` of the report object it creates for the input. You can use this value to add additional objects to `external_references`. Note, you can only add `source_name` and `external_id` values currently. Pass as `source_name=external_id`. e.g. `--external_refs txt2stix=demo1 source=id` would create the following objects under the `external_references` property: `{"source_name":"txt2stix","external_id":"demo1"},{"source_name":"source","external_id":"id"}`
|
128
|
+
|
129
|
+
#### Output settings
|
130
|
+
|
131
|
+
How the extractions are performed
|
132
|
+
|
133
|
+
* `--use_extractions` (REQUIRED): if you only want to use certain extraction types, you can pass their slug found in either `includes/ai/config.yaml`, `includes/lookup/config.yaml` `includes/pattern/config.yaml` (e.g. `pattern_ipv4_address_only`). Default if not passed, no extractions applied. You can also pass a catch all wildcard `*` which will match all extraction paths (e.g. `'pattern_*'` would run all extractions starting with `pattern_` -- make sure to use quotes when using a wildcard)
|
134
|
+
* Important: if using any AI extractions (`ai_*`), you must set an AI API key in your `.env` file
|
135
|
+
* Important: if you are using any MITRE ATT&CK, CAPEC, CWE, ATLAS or Location extractions you must set `CTIBUTLER` or NVD CPE or CVE extractions you must set `VULMATCH` settings in your `.env` file
|
136
|
+
* `--relationship_mode` (REQUIRED): either.
|
137
|
+
* `ai`: AI provider must be enabled. extractions performed by either regex or AI for extractions user selected. Rich relationships created from AI provider from extractions.
|
138
|
+
* `standard`: extractions performed by either regex or AI (AI provider must be enabled) for extractions user selected. Basic relationships created from extractions back to master Report object generated.
|
139
|
+
* `--ignore_extraction_boundary` (OPTIONAL, default `false`, not compatible with AI extractions): in some cases the same string will create multiple extractions depending on extractions set (e.g. `https://www.google.com/file.txt` could create a url, url with file, domain, subdomain, and file). The default behaviour is for txt2stix to take the longest extraction and ignore everything else (e.g. only extract url with file, and ignore url, file, domain, subdomain, and file). If you want to override this behaviour and get all extractions in the output, set this flag to `true`.
|
140
|
+
* `--ignore_image_refs` (default `true`): images references in documents don't usually need extracting. e.g. `<img src="https://example.com/image.png" alt="something">` you would not want domain or file extractions extracting `example.com` and `image.png`. Hence these are ignored by default (they are removed from text sent to extraction). Note, only the `img src` is ignored, all other values e.g. `alt` are considered. If you want extractions to consider this data, set it to `false`
|
141
|
+
* `--ignore_link_refs` (default `true`): link references in documents don't usually need extracting e.g. `<a href="https://example.com/link.html" title="something">Bad Actor</a>` you would only want `Bad actor` to be considered for extraction. Hence these part of the link are ignored by default (they are removed from text sent to extraction). Note, only the `a href` is ignored, all other values e.g. `title` are considered. Setting this to `false` will also include everything inside the link tag (e.g. `example.com` would extract as a domain)
|
142
|
+
|
143
|
+
#### AI settings
|
144
|
+
|
145
|
+
If any AI extractions, or AI relationship mode is set, you must set the following accordingly
|
146
|
+
|
147
|
+
* `--ai_settings_extractions`:
|
148
|
+
* defines the `provider:model` to be used for extractions. You can supply more than one provider. Seperate with a space (e.g. `openrouter:openai/gpt-4o` `openrouter:deepseek/deepseek-chat`) If more than one provider passed, txt2stix will take extractions from all models, de-dupelicate them, and them package them in the output. Currently supports:
|
149
|
+
* Provider (env var required `OPENROUTER_API_KEY`): `openrouter:`, providers/models `openai/gpt-4o`, `deepseek/deepseek-chat` ([More here](https://openrouter.ai/models))
|
150
|
+
* Provider (env var required `OPENAI_API_KEY`): `openai:`, models e.g.: `gpt-4o`, `gpt-4o-mini`, `gpt-4-turbo`, `gpt-4` ([More here](https://platform.openai.com/docs/models))
|
151
|
+
* Provider (env var required `ANTHROPIC_API_KEY`): `anthropic:`, models e.g.: `claude-3-5-sonnet-latest`, `claude-3-5-haiku-latest`, `claude-3-opus-latest` ([More here](https://docs.anthropic.com/en/docs/about-claude/models))
|
152
|
+
* Provider (env var required `GOOGLE_API_KEY`): `gemini:models/`, models: `gemini-1.5-pro-latest`, `gemini-1.5-flash-latest` ([More here](https://ai.google.dev/gemini-api/docs/models/gemini))
|
153
|
+
* Provider (env var required `DEEPSEEK_API_KEY`): `deepseek:`, models `deepseek-chat` ([More here](https://api-docs.deepseek.com/quick_start/pricing))
|
154
|
+
* See `tests/manual-tests/cases-ai-extraction-type.md` for some examples
|
155
|
+
* `--ai_settings_relationships`:
|
156
|
+
* similar to `ai_settings_extractions` but defines the model used to generate relationships. Only one model can be provided. Passed in same format as `ai_settings_extractions`
|
157
|
+
* See `tests/manual-tests/cases-ai-relationships.md` for some examples
|
158
|
+
* `--ai_content_check_provider`: Passing this flag will get the AI to try and classify the text in the input to 1) determine if it is talking about threat intelligence, and 2) what type of threat intelligence it is talking about. For context, we use this to filter out non-threat intel posts in Obstracts and Stixify. You pass `provider:model` with this flag to determine the AI model you wish to use to perform the check.
|
159
|
+
* `--ai_create_attack_flow`: passing this flag will also prompt the AI model (the same entered for `--ai_settings_relationships`) to generate an [Attack Flow](https://center-for-threat-informed-defense.github.io/attack-flow/) for the MITRE ATT&CK extractions to define the logical order in which they are being described. You must pass `--ai_settings_relationships` for this to work.
|
160
|
+
|
161
|
+
## Adding new extractions
|
162
|
+
|
163
|
+
It is very likely you'll want to extend txt2stix to include new extractions to;
|
164
|
+
|
165
|
+
* Add a new lookup extraction: add your lookup to `includes/lookups` as a `.txt` file. Lookups should be a list of items seperated by new lines to be searched for in documents. Once this is added, update `includes/extractions/lookup/config.yaml` with a new record pointing to your lookup. You can now use this lookup time at script run-time.
|
166
|
+
* Add a new AI extraction: Edit `includes/extractions/ai/config.yaml` with a new record for your extraction. You can craft the prompt used in the config to control how the LLM performs the extraction.
|
167
|
+
|
168
|
+
Currently it is not possible to easily add any other types of extractions (without modifying the logic at a code level).
|
169
|
+
|
170
|
+
## Detailed documentation
|
171
|
+
|
172
|
+
If you would like to understand how txt2stix works in more detail, please refer to the documentation in `/docs/README.md`.
|
173
|
+
|
174
|
+
This documentation is paticularly helpful to read for those of you wanting to add your own custom extractions.
|
175
|
+
|
176
|
+
## Useful supporting tools
|
177
|
+
|
178
|
+
* [A Quick Start Guide to txt2stix](https://www.dogesec.com/blog/txt2stix_quickstart_guide/)
|
179
|
+
* [An example of how to use txt2stix with Attack Flows](https://www.dogesec.com/blog/understading_structure_attack_flows/)
|
180
|
+
* [STIX2 Python Library](https://pypi.org/project/stix2/): APIs for serializing and de-serializing STIX2 JSON content
|
181
|
+
* [STIX 2 Pattern Validator](https://pypi.org/project/stix2-patterns/): a tool for checking the syntax of the Cyber Threat Intelligence (CTI) STIX Pattern expressions
|
182
|
+
* [STIX Viewer](https://github.com/traut/stixview): Quickly load bundles produced from your report
|
183
|
+
|
184
|
+
## Support
|
185
|
+
|
186
|
+
[Minimal support provided via the DOGESEC community](https://community.dogesec.com/).
|
187
|
+
|
188
|
+
## License
|
189
|
+
|
190
|
+
[Apache 2.0](/LICENSE).
|