Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 277e68a

Browse files
author
Samuel Hassine
committed
[examples] Add examples for searching observables
1 parent 8a486b8 commit 277e68a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding: utf-8
2+
3+
from pycti import OpenCTIApiClient
4+
5+
# Variables
6+
api_url = "https://demo.opencti.io"
7+
api_token = "YOUR_TOKEN"
8+
9+
# OpenCTI initialization
10+
opencti_api_client = OpenCTIApiClient(api_url, api_token)
11+
12+
# Exact IP match
13+
print("IP ADDRESS")
14+
observable = opencti_api_client.stix_cyber_observable.read(
15+
filters=[{"key": "value", "values": ["110.172.180.180"]}]
16+
)
17+
print(observable)
18+
19+
# Exact File name match
20+
print("FILE NAME")
21+
observable = opencti_api_client.stix_cyber_observable.read(
22+
filters=[{"key": "name", "values": ["activeds.dll"]}]
23+
)
24+
print(observable)
25+
26+
# Exact File name match
27+
print("FILE MD5")
28+
observable = opencti_api_client.stix_cyber_observable.read(
29+
filters=[{"key": "hashes_MD5", "values": ["3aad33e025303dbae12c12b4ec5258c1"]}]
30+
)
31+
print(observable)

examples/get_observables_search.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# coding: utf-8
2+
3+
from pycti import OpenCTIApiClient
4+
5+
# Variables
6+
api_url = "https://demo.opencti.io"
7+
api_token = "YOUR_TOKEN"
8+
9+
# OpenCTI initialization
10+
opencti_api_client = OpenCTIApiClient(api_url, api_token)
11+
12+
# Search
13+
observables = opencti_api_client.stix_cyber_observable.list(search="65.89.87.4")
14+
15+
print(observables)

0 commit comments

Comments
 (0)