From ffa7eac11ce2d0c004940513ad74aa680c5edb6a Mon Sep 17 00:00:00 2001 From: Lhorus6 <70956706+Lhorus6@users.noreply.github.com> Date: Thu, 16 May 2024 03:55:53 +0200 Subject: [PATCH 1/2] Fix get_malwares_of_intrusion_set.py --- examples/get_malwares_of_intrusion_set.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/get_malwares_of_intrusion_set.py b/examples/get_malwares_of_intrusion_set.py index edce20eb8..574327354 100644 --- a/examples/get_malwares_of_intrusion_set.py +++ b/examples/get_malwares_of_intrusion_set.py @@ -35,4 +35,4 @@ # Print for stix_relation in stix_relations: - print("[" + stix_relation["to"]["stix_id"] + "] " + stix_relation["to"]["name"]) + print("[" + stix_relation["to"]["standard_id"] + "] " + stix_relation["to"]["name"]) From 0471cb8df7151bf098e847ba167ed7c01522e246 Mon Sep 17 00:00:00 2001 From: Lhorus6 <70956706+Lhorus6@users.noreply.github.com> Date: Thu, 16 May 2024 03:57:23 +0200 Subject: [PATCH 2/2] Add new example --- examples/get_indicators_of_malware.py | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/get_indicators_of_malware.py diff --git a/examples/get_indicators_of_malware.py b/examples/get_indicators_of_malware.py new file mode 100644 index 000000000..84cc2e1e5 --- /dev/null +++ b/examples/get_indicators_of_malware.py @@ -0,0 +1,30 @@ +# coding: utf-8 +import datetime + +from pycti import OpenCTIApiClient + +# Variables +api_url = "http://opencti:4000" +api_token = "bfa014e0-e02e-4aa6-a42b-603b19dcf159" +malware = "Emotet" + +# OpenCTI initialization +opencti_api_client = OpenCTIApiClient(api_url, api_token) + +# Get the malware set in variable +malware = opencti_api_client.malware.read( + filters={ + "mode": "and", + "filters": [{"key": "name", "values": [malware]}], + "filterGroups": [], + } +) + +# Get the relations from the malware to indicators +stix_relations = opencti_api_client.stix_core_relationship.list( + fromTypes=["Indicator"], toId=malware["id"] +) + +# Print +for stix_relation in stix_relations: + print("[" + stix_relation["from"]["standard_id"] + "] " + stix_relation["from"]["name"]) \ No newline at end of file