Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on example script #645

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions examples/get_indicators_of_malware.py
Original file line number Diff line number Diff line change
@@ -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"])
2 changes: 1 addition & 1 deletion examples/get_malwares_of_intrusion_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])