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

Commit e014f06

Browse files
author
Samuel Hassine
committed
[examples] Add a new example Domain/IP resolution
1 parent c862dbc commit e014f06

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
observable_domain = opencti_api_client.stix_cyber_observable.create(
13+
observableData={
14+
"type": "domain-name",
15+
"value": "dns.google",
16+
}
17+
)
18+
19+
observable_ip = opencti_api_client.stix_cyber_observable.create(
20+
observableData={
21+
"type": "ipv4-addr",
22+
"value": "8.8.8.8",
23+
}
24+
)
25+
26+
opencti_api_client.stix_cyber_observable_relationship.create(
27+
fromId=observable_domain["id"],
28+
toId=observable_ip["id"],
29+
relationship_type="resolves-to",
30+
)
31+
32+
relationships = opencti_api_client.stix_cyber_observable_relationship.list(
33+
elementId=observable_domain["id"]
34+
)
35+
36+
print(relationships)

0 commit comments

Comments
 (0)