forked from OpenCTI-Platform/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_observable_exact_match.py
55 lines (49 loc) · 1.45 KB
/
get_observable_exact_match.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# coding: utf-8
from pycti import OpenCTIApiClient
# Variables
api_url = "http://opencti:4000"
api_token = "bfa014e0-e02e-4aa6-a42b-603b19dcf159"
# OpenCTI initialization
opencti_api_client = OpenCTIApiClient(api_url, api_token)
# Exact IP match
opencti_api_client.stix_cyber_observable.create(
simple_observable_key="IPv4-Addr.value", simple_observable_value="110.172.180.180"
)
print("IP ADDRESS")
observable = opencti_api_client.stix_cyber_observable.read(
filters={
"mode": "and",
"filters": [{"key": "value", "values": ["110.172.180.180"]}],
"filterGroups": [],
}
)
print(observable)
# Exact File name match
opencti_api_client.stix_cyber_observable.create(
simple_observable_key="File.name", simple_observable_value="activeds.dll"
)
print("FILE NAME")
observable = opencti_api_client.stix_cyber_observable.read(
filters={
"mode": "and",
"filters": [{"key": "name", "values": ["activeds.dll"]}],
"filterGroups": [],
}
)
print(observable)
# Exact File name match
opencti_api_client.stix_cyber_observable.create(
simple_observable_key="File.hashes.MD5",
simple_observable_value="3aad33e025303dbae12c12b4ec5258c1",
)
print("FILE MD5")
observable = opencti_api_client.stix_cyber_observable.read(
filters={
"mode": "and",
"filters": [
{"key": "hashes.MD5", "values": ["3aad33e025303dbae12c12b4ec5258c1"]}
],
"filterGroups": [],
}
)
print(observable)