forked from OpenCTI-Platform/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_reports_about_intrusion_set.py
56 lines (48 loc) · 1.31 KB
/
get_reports_about_intrusion_set.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
56
# coding: utf-8
import datetime
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)
# Create the Intrusion Set
opencti_api_client.intrusion_set.create(
name="Sandworm Team",
description="Evil hackers",
first_seen=datetime.date.today().strftime("%Y-%m-%dT%H:%M:%S+00:00"),
last_seen=datetime.date.today().strftime("%Y-%m-%dT%H:%M:%S+00:00"),
update=True,
)
# Get the intrusion set Sandworm
intrusion_set = opencti_api_client.intrusion_set.read(
filters={
"mode": "and",
"filters": [{"key": "name", "values": ["Sandworm Team"]}],
"filterGroups": [],
}
)
# Get all reports
reports = opencti_api_client.report.list(
filters={
"mode": "and",
"filters": [{"key": "objects", "values": [intrusion_set["id"]]}],
"filterGroups": [],
},
orderBy="published",
orderMode="asc",
)
# Print
if not reports:
print(f"No {intrusion_set['name']} reports available")
else:
for report in reports:
print(
"["
+ report["standard_id"]
+ "] "
+ report["name"]
+ " ("
+ report["published"]
+ ")"
)