Skip to content

Commit 57e0789

Browse files
authored
Merge pull request #15 from fr0gger/master
Fixed the PIP package
2 parents 380d1aa + 3db3e84 commit 57e0789

File tree

4 files changed

+48
-141
lines changed

4 files changed

+48
-141
lines changed

LICENSE renamed to LICENSE.md

File renamed without changes.

README.md

+32-129
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
1-
# pyeti
2-
Python bindings for Yeti's API
1+
# pyeti-python3
2+
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.
3+
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.
34

4-
## Installation
5+
## Getting Started
6+
To install it you can clone the repo and run the following command:
57

6-
`$ python3 setup.py install` should get you started. After this gets a little more maturity, we will submit it to Pypy for usage with `pip`.
8+
```
9+
$ python3 setup.py install
10+
```
11+
12+
You can also install it with pip:
13+
```
14+
$ pip3 install pyeti-python3
15+
```
16+
17+
Once installed the first thing to do is to get your API key from the Yeti interface.
18+
<img src="https://raw.githubusercontent.com/fr0gger/pyeti/master/yeti_api.png">
19+
20+
Then you can configure your script with the following information to test the connection:
21+
```python
22+
server="<IPofYETI>"
23+
key="<APIKEY>"
24+
tag="<NameoftheObservable>" # example: 'lokibot'
25+
26+
api = pyeti.YetiApi("http://%s:5000/api/" % server, api_key=key)
27+
request = api.observable_search(tags=tag, count=50)
28+
```
729

830
## Testing
931

@@ -14,22 +36,21 @@ You can run tests from the root directory by running:
1436

1537
**Note that most tests require a full running install of Yeti on localhost:5000**
1638

17-
## Some examples
39+
## Use cases
1840

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

2143
```python
2244
import pyeti, json # json is only used for pretty printing in the examples below
23-
api = pyeti.YetiApi("http://localhost:5000/api/")
45+
api = pyetix.YetiApi("http://localhost:5000/api/")
2446
```
2547

26-
If you are using a self signed cert on your yeti instance you can set the `verify_ssl` parameter to `True` to false to ignore warnings.
48+
If you are using a self signed cert on your yeti instance you can set the `verify_ssl` parameter to `True` to ignore warnings.
2749
Otherwise all ssl connections are verified by default.
2850

2951
```python
3052
import pyeti, json # json is only used for pretty printing in the examples below
3153
api = pyeti.YetiApi("http://localhost:5000/api/", verify_ssl=False)
32-
3354
```
3455

3556

@@ -38,52 +59,14 @@ api = pyeti.YetiApi("http://localhost:5000/api/", verify_ssl=False)
3859
```python
3960
results = api.observable_add("google.com", ['google'])
4061
print(json.dumps(results, indent=4, sort_keys=True))
41-
{
42-
"context": [],
43-
"created": "2017-06-25T17:33:51.735000",
44-
"description": null,
45-
"human_url": "http://localhost:5000/observable/594ff3ffbf365e53fbae38c9",
46-
"id": "594ff3ffbf365e53fbae38c9",
47-
"last_analyses": {},
48-
"sources": [
49-
"API"
50-
],
51-
"tags": [
52-
{
53-
"first_seen": "2017-06-25T17:33:51.746000",
54-
"fresh": true,
55-
"last_seen": "2017-06-25T17:33:51.746000",
56-
"name": "google"
57-
}
58-
],
59-
"type": "Hostname",
60-
"url": "http://localhost:5000/api/observable/594ff3ffbf365e53fbae38c9",
61-
"value": "google.com"
62-
}
6362
```
64-
6563
### Bulk add
6664

6765
```python
6866
results = api.observable_bulk_add(["google.com", "bing.com", "yahoo.com"])
6967
print(len(results))
7068
3
7169
print(json.dumps(results[1], indent=4, sort_keys=True))
72-
{
73-
"context": [],
74-
"created": "2017-06-25T17:39:31.051000",
75-
"description": null,
76-
"human_url": "http://localhost:5000/observable/594ff553bf365e53fbae38cc",
77-
"id": "594ff553bf365e53fbae38cc",
78-
"last_analyses": {},
79-
"sources": [
80-
"API"
81-
],
82-
"tags": [],
83-
"type": "Hostname",
84-
"url": "http://localhost:5000/api/observable/594ff553bf365e53fbae38cc",
85-
"value": "bing.com"
86-
}
8770
```
8871

8972
### Get a single observable
@@ -93,28 +76,6 @@ results = api.observable_add("google.com")
9376
print(results['id'])
9477
info = api.observable_details(results['id'])
9578
print(json.dumps(info, indent=4, sort_keys=True))
96-
{
97-
"context": [],
98-
"created": "2017-06-25T17:33:51.735000",
99-
"description": null,
100-
"human_url": "http://localhost:5000/observable/594ff3ffbf365e53fbae38c9",
101-
"id": "594ff3ffbf365e53fbae38c9",
102-
"last_analyses": {},
103-
"sources": [
104-
"API"
105-
],
106-
"tags": [
107-
{
108-
"first_seen": "2017-06-25T17:33:51.746000",
109-
"fresh": true,
110-
"last_seen": "2017-06-25T17:33:51.746000",
111-
"name": "google"
112-
}
113-
],
114-
"type": "Hostname",
115-
"url": "http://localhost:5000/api/observable/594ff3ffbf365e53fbae38c9",
116-
"value": "google.com"
117-
}
11879
```
11980

12081
### Search for observables
@@ -123,75 +84,17 @@ print(json.dumps(info, indent=4, sort_keys=True))
12384
api.observable_add("search-domain.com")
12485
result = api.observable_search(value="search-dom[a-z]+", regex=True)
12586
print(json.dumps(result, indent=4, sort_keys=True))
126-
[
127-
{
128-
"context": [],
129-
"created": "2017-06-25T17:57:28.994000",
130-
"description": null,
131-
"human_url": "http://localhost:5000/observable/594ff988bf365e58c4c2b8ef",
132-
"id": "594ff988bf365e58c4c2b8ef",
133-
"last_analyses": {},
134-
"sources": [
135-
"API"
136-
],
137-
"tags": [],
138-
"type": "Hostname",
139-
"url": "http://localhost:5000/api/observable/594ff988bf365e58c4c2b8ef",
140-
"value": "search-domain.com"
141-
}
142-
]
143-
14487
```
14588

146-
### Add files
147-
89+
### Add observables
14890
```python
14991
result = api.observable_file_add("/tmp/hello.txt", tags=['benign'])
15092
print(json.dumps(result, indent=4, sort_keys=True))
151-
[
152-
{
153-
"context": [],
154-
"created": "2017-06-25T18:23:02.471000",
155-
"description": null,
156-
"hashes": [
157-
{
158-
"hash": "sha256",
159-
"value": "b22b009134622b6508d756f1062455d71a7026594eacb0badf81f4f677929ebe"
160-
},
161-
{
162-
"hash": "sha512",
163-
"value": "eb22d991d6d86641d95e01a804025fc210491286a30f3114dd1469c7457c03e807506f5615bc9065f47a6ee2208364f643837f2298738b4f5c53797124f41f60"
164-
},
165-
{
166-
"hash": "md5",
167-
"value": "e134ced312b3511d88943d57ccd70c83"
168-
},
169-
{
170-
"hash": "sha1",
171-
"value": "a8d191538209e335154750d2df575b9ddfb16fc7"
172-
}
173-
],
174-
"human_url": "http://localhost:5000/observable/594fff86bf365e6270f8914b",
175-
"id": "594fff86bf365e6270f8914b",
176-
"last_analyses": {},
177-
"mime_type": "text/plain",
178-
"sources": [],
179-
"tags": [
180-
{
181-
"first_seen": "2017-06-25T18:23:02.544000",
182-
"fresh": true,
183-
"last_seen": "2017-06-25T18:23:02.544000",
184-
"name": "benign"
185-
}
186-
],
187-
"type": "File",
188-
"url": "http://localhost:5000/api/observable/594fff86bf365e6270f8914b",
189-
"value": "FILE:b22b009134622b6508d756f1062455d71a7026594eacb0badf81f4f677929ebe"
190-
}
191-
]
19293
# Get file contents
19394
api.observable_file_contents(objectid="594fff86bf365e6270f8914b")
19495
'Hello!\n'
19596
api.observable_file_contents(filehash="e134ced312b3511d88943d57ccd70c83") # you can also use any hash computed above
19697
'Hello!\n'
19798
```
99+
# License
100+
This project is licensed under the Apache License - see the [LICENSE.md](https://github.com/fr0gger/pyeti/blob/master/LICENSE.md) file for details

setup.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
from setuptools import setup
44
from setuptools import find_packages
55

6+
"""Packaging tool for the Yeti python bindings and CLI utility."""
7+
8+
from setuptools import setup
9+
from setuptools import find_packages
610

7-
def readme():
8-
"""Returns contents of README.md."""
9-
with open('README.md') as readme_fp:
10-
return readme_fp.read()
11+
"""Returns contents of README.md."""
12+
with open("README.md", "r", encoding="utf-8") as readme_fp:
13+
long_description = readme_fp.read()
1114

12-
setup(name='pyeti',
13-
version="0.0.1",
14-
description='Python bindings for Yeti\'s API',
15-
long_description=readme(),
15+
setup(name='pyeti-python3',
16+
version="1.0",
17+
description='Revival version of pyeti, the API for Yeti Threat Intel Platform.',
18+
long_description=long_description,
19+
long_description_content_type='text/markdown',
1620
classifiers=[
1721
'License :: OSI Approved :: Apache Software License',
18-
'Development Status :: 3 - Alpha',
19-
'Programming Language :: Python :: 3.0',
20-
'Topic :: Threat Intelligence Platform',
22+
'Development Status :: 5 - Production/Stable',
23+
'Programming Language :: Python :: 3',
2124
],
2225
keywords='yeti threat intel api',
2326
url='https://github.com/yeti-platform/pyeti',
24-
author='Yeti core developers',
27+
author='Yeti core developers | packaged by Thomas Roccia @fr0gger_',
2528
license='Apache',
2629
packages=find_packages(),
2730
install_requires=[
@@ -37,4 +40,5 @@ def readme():
3740
'console_scripts': ['yeticli=pyeti.scripts.cli:main'],
3841
},
3942
include_package_data=True,
43+
python_requires='>=3.6',
4044
zip_safe=False)

yeti_api.png

47.9 KB
Loading

0 commit comments

Comments
 (0)