Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 214b342

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

File tree

9 files changed

+4119
-0
lines changed

9 files changed

+4119
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# OpenCTI - Official Python client
2+
3+
The official OpenCTI Python client helps developers to use the OpenCTI API by providing a lot of easy to use methods and utils.
4+
5+
## Python client
6+
7+
```bash
8+
$ pip3 install pycti
9+
```
10+
11+
## Documentation
12+
13+
*TODO*
14+
15+
## About
16+
17+
OpenCTI is a product powered by the [Luatix](https://www.luatix.org) non-profit organization.

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .opencti import OpenCTI

0 commit comments

Comments
 (0)