Skip to content

Commit ef0ac82

Browse files
authored
Add example script
1 parent bab59bd commit ef0ac82

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# coding: utf-8
2+
import datetime
3+
4+
from pycti import OpenCTIApiClient
5+
6+
# Variables
7+
api_url = "http://opencti:4000"
8+
api_token = "bfa014e0-e02e-4aa6-a42b-603b19dcf159"
9+
malware = "Emotet"
10+
11+
# OpenCTI initialization
12+
opencti_api_client = OpenCTIApiClient(api_url, api_token)
13+
14+
# Get the malware set in variable
15+
malware = opencti_api_client.malware.read(
16+
filters={
17+
"mode": "and",
18+
"filters": [{"key": "name", "values": [malware]}],
19+
"filterGroups": [],
20+
}
21+
)
22+
23+
# Get the relations from the malware to indicators
24+
stix_relations = opencti_api_client.stix_core_relationship.list(
25+
fromTypes=["Indicator"], toId=malware["id"]
26+
)
27+
28+
# Print
29+
for stix_relation in stix_relations:
30+
print("[" + stix_relation["from"]["standard_id"] + "] " + stix_relation["from"]["name"])

examples/get_malwares_of_intrusion_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535

3636
# Print
3737
for stix_relation in stix_relations:
38-
print("[" + stix_relation["to"]["stix_id"] + "] " + stix_relation["to"]["name"])
38+
print("[" + stix_relation["to"]["standard_id"] + "] " + stix_relation["to"]["name"])

0 commit comments

Comments
 (0)