Skip to main content

Client python for YETI Platform

Project description

pyeti-python3

Pyeti-Python (pyeti) is the bundle uses to interface with the YETI API. This is the new package that can be installed directly with pip. Pyeti-python allows you to extract data from YETI such as specific observables (malware, IP, domains...). It can be used to plug in your own tool and enrich your Threat Intelligence feed with Yeti.

Getting Started

To install it you can clone the repo and run the following command:

poetry install

You can also install it with pip:

pip install yeti-python

Once installed the first thing to do is to get your API key from the Yeti interface. image

Then you can configure your script with the following information to test the connection:

server="<IPofYETI>"
key="<APIKEY>"
tag="<NameoftheObservable>" # example: 'lokibot'

api = pyeti.YetiApi(url="http://%s:5000/api/" % server, api_key=key)
request = api.observable_search(tags=tag, count=50)

Testing

You can run tests from the root directory by running:

To test client api python of yeti setup a pyeti.conf in folder tests.

In pyeti.conf

[yeti]
url = http://127.0.0.1:5000/api
api_key = your_api_key
cd tests
python test_observables.py

Note that most tests require a full running install of Yeti on localhost:5000.

Use cases

First thing is to import the library and instantiate a client.

import pyeti, json    # json is only used for pretty printing in the examples below 
api = pyeti.YetiApi(url="http://localhost:5000/api/")

If you are using a self signed cert on your yeti instance you can set the verify_ssl parameter to True to ignore warnings. Otherwise all ssl connections are verified by default.

import pyeti, json    # json is only used for pretty printing in the examples below 
api = pyeti.YetiApi(url="http://localhost:5000/api/", verify_ssl=False)

Adding observables

results = api.observable_add("google.com", ['google'])
print(json.dumps(results, indent=4, sort_keys=True))

Bulk add

results = api.observable_bulk_add(["google.com", "bing.com", "yahoo.com"])
print(len(results))
3
print(json.dumps(results[1], indent=4, sort_keys=True))

Get a single observable

results = api.observable_add("google.com")
print(results['id'])
info = api.observable_details(results['id'])
print(json.dumps(info, indent=4, sort_keys=True))

Search for observables

api.observable_add("search-domain.com")
result = api.observable_search(value="search-dom[a-z]+", regex=True)
print(json.dumps(result, indent=4, sort_keys=True))

Add observables

result = api.observable_file_add("/tmp/hello.txt", tags=['benign'])
print(json.dumps(result, indent=4, sort_keys=True))
# Get file contents
api.observable_file_contents(objectid="594fff86bf365e6270f8914b")
'Hello!\n'
api.observable_file_contents(filehash="e134ced312b3511d88943d57ccd70c83") # you can also use any hash computed above
'Hello!\n'

License

This project is licensed under the Apache License - see the LICENSE.md file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yeti_python-1.4.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

yeti_python-1.4-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file yeti_python-1.4.tar.gz.

File metadata

  • Download URL: yeti_python-1.4.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.5 Windows/10

File hashes

Hashes for yeti_python-1.4.tar.gz
Algorithm Hash digest
SHA256 9bcf48e989806821fdf8c3cc3cb738417f6e9cdcbe8f50d41ccf6564d46dfae4
MD5 54ac52aca02377382c64e4b95b0eeffb
BLAKE2b-256 5167152dc9ad909b88ceac3abc6535390e4e589ed60c769f594efd9069657da0

See more details on using hashes here.

File details

Details for the file yeti_python-1.4-py3-none-any.whl.

File metadata

  • Download URL: yeti_python-1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.5 Windows/10

File hashes

Hashes for yeti_python-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 808082188c022a84bcd092dfcad6e00c2d9174f780bb5f319fd6bb6b0077dfc8
MD5 137bd6362ea73727f464b5489697440c
BLAKE2b-256 671c86a58bd3c41a9f238e2701fa1d84803d18cadee52aaddd3ab9d54b4c0107

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page