|
3 | 3 | from pycti import OpenCTIApiClient
|
4 | 4 |
|
5 | 5 | # Variables
|
6 |
| -api_url = 'https://demo.opencti.io' |
7 |
| -api_token = 'bb4aca90-b98c-49ee-9582-7eac92b61b82' |
| 6 | +api_url = "https://demo.opencti.io" |
| 7 | +api_token = "bb4aca90-b98c-49ee-9582-7eac92b61b82" |
8 | 8 |
|
9 | 9 | # OpenCTI initialization
|
10 | 10 | opencti_api_client = OpenCTIApiClient(api_url, api_token)
|
11 | 11 |
|
12 | 12 | # Create observables
|
13 | 13 | hash_md5 = opencti_api_client.stix_observable.create(
|
14 |
| - type='File-MD5', |
15 |
| - observable_value='16b3f663d0f0371a4706642c6ac04e42', |
16 |
| - description='Hash linked to Emotet', |
17 |
| - update=True |
| 14 | + type="File-MD5", |
| 15 | + observable_value="16b3f663d0f0371a4706642c6ac04e42", |
| 16 | + description="Hash linked to Emotet", |
| 17 | + update=True, |
18 | 18 | )
|
19 | 19 | print(hash_md5)
|
20 | 20 | hash_sha1 = opencti_api_client.stix_observable.create(
|
21 |
| - type='File-SHA1', |
22 |
| - observable_value='3a1f908941311fc357051b5c35fd2a4e0c834e37', |
23 |
| - description='Hash linked to Emotet', |
24 |
| - update=True |
| 21 | + type="File-SHA1", |
| 22 | + observable_value="3a1f908941311fc357051b5c35fd2a4e0c834e37", |
| 23 | + description="Hash linked to Emotet", |
| 24 | + update=True, |
25 | 25 | )
|
26 | 26 | print(hash_sha1)
|
27 | 27 | hash_sha256 = opencti_api_client.stix_observable.create(
|
28 |
| - type='File-SHA256', |
29 |
| - observable_value='bcc70a49fab005b4cdbe0cbd87863ec622c6b2c656987d201adbb0e05ec03e56', |
30 |
| - description='Hash linked to Emotet', |
31 |
| - update=True |
| 28 | + type="File-SHA256", |
| 29 | + observable_value="bcc70a49fab005b4cdbe0cbd87863ec622c6b2c656987d201adbb0e05ec03e56", |
| 30 | + description="Hash linked to Emotet", |
| 31 | + update=True, |
32 | 32 | )
|
33 | 33 | print(hash_sha256)
|
34 | 34 |
|
35 | 35 | # Create relations
|
36 | 36 | opencti_api_client.stix_observable_relation.create(
|
37 |
| - relationship_type='corresponds', |
38 |
| - fromType='File-MD5', |
39 |
| - fromId=hash_md5['id'], |
40 |
| - toType='File-SHA1', |
41 |
| - toId=hash_sha1['id'], |
42 |
| - ignore_dates=True |
| 37 | + relationship_type="corresponds", |
| 38 | + fromType="File-MD5", |
| 39 | + fromId=hash_md5["id"], |
| 40 | + toType="File-SHA1", |
| 41 | + toId=hash_sha1["id"], |
| 42 | + ignore_dates=True, |
43 | 43 | )
|
44 | 44 | opencti_api_client.stix_observable_relation.create(
|
45 |
| - relationship_type='corresponds', |
46 |
| - fromType='File-MD5', |
47 |
| - fromId=hash_md5['id'], |
48 |
| - toType='File-SHA256', |
49 |
| - toId=hash_sha256['id'], |
50 |
| - ignore_dates=True |
| 45 | + relationship_type="corresponds", |
| 46 | + fromType="File-MD5", |
| 47 | + fromId=hash_md5["id"], |
| 48 | + toType="File-SHA256", |
| 49 | + toId=hash_sha256["id"], |
| 50 | + ignore_dates=True, |
51 | 51 | )
|
52 | 52 | opencti_api_client.stix_observable_relation.create(
|
53 |
| - relationship_type='corresponds', |
54 |
| - fromType='File-SHA1', |
55 |
| - fromId=hash_sha1['id'], |
56 |
| - toType='File-SHA256', |
57 |
| - toId=hash_sha256['id'], |
58 |
| - ignore_dates=True |
| 53 | + relationship_type="corresponds", |
| 54 | + fromType="File-SHA1", |
| 55 | + fromId=hash_sha1["id"], |
| 56 | + toType="File-SHA256", |
| 57 | + toId=hash_sha256["id"], |
| 58 | + ignore_dates=True, |
59 | 59 | )
|
0 commit comments