Initial commit of the Python library · curiouspython1/client-python@214b342 · GitHub
Skip to content

Commit 214b342

Browse files
author
Samuel Hassine
committed
Initial commit of the Python library
0 parents  commit 214b342

9 files changed

Lines changed: 4119 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions

examples/stix2/config.yml.sample

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
opencti:
2+
api_url: 'http://opencti.example.com'
3+
api_key : 'XXxxXxXXxxX'
4+
verbose: true
5+
6+
mitre:
7+
repository_path_cti: '/home/user/git/cti'

examples/stix2/export.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# coding: utf-8
2+
3+
import os
4+
import yaml
5+
import json
6+
7+
from python.pycti.opencti import OpenCTI
8+
9+
# Load configuration
10+
config = yaml.load(open(os.path.dirname(__file__) + '/config.yml'))
11+
12+
# Export file
13+
export_file = './exports/IntrusionSets.json'
14+
15+
# OpenCTI initialization
16+
opencti = OpenCTI(config['opencti']['api_url'], config['opencti']['api_key'], config['opencti']['log_file'], config['opencti']['verbose'])
17+
18+
# Import the bundle
19+
bundle = opencti.stix2_export_entity('report', '466872bd-41d0-3d38-af2f-0b964b7ff993', 'full')
20+
21+
with open(export_file, 'w') as file:
22+
json.dump(bundle, file, indent=4)

examples/stix2/import.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# coding: utf-8
2+
3+
import os
4+
import yaml
5+
6+
from python.pycti.opencti import OpenCTI
7+
8+
# Load configuration
9+
config = yaml.load(open(os.path.dirname(__file__) + '/config.yml'))
10+
11+
# File to import
12+
file_to_import = config['mitre']['repository_path_cti'] + '/enterprise-attack/enterprise-attack.json'
13+
14+
# OpenCTI initialization
15+
opencti = OpenCTI(config['opencti']['api_url'], config['opencti']['api_key'], config['opencti']['log_file'], config['opencti']['verbose'])
16+
17+
# Import the bundle
18+
opencti.stix2_import_bundle_from_file(file_to_import)

pycti/__init__.py

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)