|
19 | 19 | observable_refs = [] |
20 | 20 |
|
21 | 21 | # Create the incident |
22 | | -incident = opencti_api_client.x_opencti_incident.create( |
| 22 | +incident = opencti_api_client.incident.create( |
23 | 23 | name="My new incident", |
24 | 24 | description="We have been compromised", |
25 | 25 | objective="Espionage", |
|
39 | 39 | ttp1 = opencti_api_client.attack_pattern.read( |
40 | 40 | filters=[{"key": "external_id", "values": ["T1193"]}] |
41 | 41 | ) |
42 | | -ttp1_relation = opencti_api_client.stix_domain_object.create( |
43 | | - fromType="Incident", |
| 42 | +ttp1_relation = opencti_api_client.stix_core_relationship.create( |
44 | 43 | fromId=incident["id"], |
45 | | - toType="Attack-Pattern", |
46 | 44 | toId=ttp1["id"], |
47 | 45 | relationship_type="uses", |
48 | 46 | description="We saw the attacker use Spearphishing Attachment.", |
49 | | - first_seen=date, |
50 | | - last_seen=date, |
| 47 | + start_time=date, |
| 48 | + stop_time=date, |
51 | 49 | ) |
52 | 50 | # Add kill chain phases to the relation |
53 | 51 | for kill_chain_phase_id in ttp1["killChainPhasesIds"]: |
|
64 | 62 | indicator_ttp1 = observable_ttp1["indicators"][0] |
65 | 63 | # Indicates the relation Incident => uses => TTP |
66 | 64 | indicator_ttp1_relation = opencti_api_client.stix_core_relationship.create( |
67 | | - fromType="Indicator", |
68 | 65 | fromId=indicator_ttp1["id"], |
69 | | - toType="stix_relation", |
70 | 66 | toId=ttp1_relation["id"], |
71 | 67 | relationship_type="indicates", |
72 | 68 | description="This email address is the sender of the spearphishing.", |
73 | | - first_seen=date, |
74 | | - last_seen=date, |
| 69 | + start_time=date, |
| 70 | + stop_time=date, |
75 | 71 | ) |
76 | 72 |
|
77 | 73 | # Prepare elements for the report |
|
91 | 87 | ) |
92 | 88 | # Create the relation |
93 | 89 | ttp2_relation = opencti_api_client.stix_core_relationship.create( |
94 | | - fromType="Incident", |
95 | 90 | fromId=incident["id"], |
96 | | - toType="Attack-Pattern", |
97 | 91 | toId=ttp2["id"], |
98 | 92 | relationship_type="uses", |
99 | 93 | description="We saw the attacker use Registry Run Keys / Startup Folder.", |
100 | | - first_seen=date, |
101 | | - last_seen=date, |
| 94 | + start_time=date, |
| 95 | + stop_time=date, |
102 | 96 | ) |
103 | 97 | # Add kill chain phases to the relation |
104 | 98 | for kill_chain_phase_id in ttp2["killChainPhasesIds"]: |
|
115 | 109 | indicator_ttp2 = observable_ttp2["indicators"][0] |
116 | 110 | # Indicates the relation Incident => uses => TTP |
117 | 111 | indicator_ttp2_relation = opencti_api_client.stix_core_relationship.create( |
118 | | - fromType="Indicator", |
119 | 112 | fromId=indicator_ttp2["id"], |
120 | | - toType="stix_relation", |
121 | 113 | toId=ttp2_relation["id"], |
122 | 114 | relationship_type="indicates", |
123 | 115 | description="This registry key is used for persistence of tools.", |
124 | | - first_seen=date, |
125 | | - last_seen=date, |
| 116 | + start_time=date, |
| 117 | + stop_time=date, |
126 | 118 | ) |
127 | 119 | # Elements for the report |
128 | 120 | object_refs.extend( |
|
140 | 132 | filters=[{"key": "external_id", "values": ["T1022"]}] |
141 | 133 | ) |
142 | 134 | ttp3_relation = opencti_api_client.stix_core_relationship.create( |
143 | | - fromType="Incident", |
144 | 135 | fromId=incident["id"], |
145 | | - toType="Attack-Pattern", |
146 | 136 | toId=ttp3["id"], |
147 | 137 | relationship_type="uses", |
148 | 138 | description="We saw the attacker use Data Encrypted.", |
149 | | - first_seen=date, |
150 | | - last_seen=date, |
| 139 | + start_time=date, |
| 140 | + stop_time=date, |
151 | 141 | ) |
152 | 142 | # Add kill chain phases to the relation |
153 | 143 | for kill_chain_phase_id in ttp3["killChainPhasesIds"]: |
|
167 | 157 | id=report["id"], report=report, stix_observable_id=observable_ref |
168 | 158 | ) |
169 | 159 | opencti_api_client.stix_core_relationship.create( |
170 | | - fromType="Stix-Observable", |
171 | 160 | fromId=observable_ref, |
172 | | - toType="Incident", |
173 | 161 | toId=incident["id"], |
174 | 162 | relationship_type="related-to", |
175 | 163 | description="This observable is related to the incident.", |
176 | | - first_seen=date, |
177 | | - last_seen=date, |
| 164 | + start_time=date, |
| 165 | + stop_time=date, |
178 | 166 | ) |
0 commit comments