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.
3
4
4
- ## Installation
5
+ ## Getting Started
6
+ To install it you can clone the repo and run the following command:
5
7
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
+ ```
7
29
8
30
## Testing
9
31
@@ -14,22 +36,21 @@ You can run tests from the root directory by running:
14
36
15
37
** Note that most tests require a full running install of Yeti on localhost:5000**
16
38
17
- ## Some examples
39
+ ## Use cases
18
40
19
41
First thing is to import the library and instantiate a client.
20
42
21
43
``` python
22
44
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/" )
24
46
```
25
47
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.
27
49
Otherwise all ssl connections are verified by default.
28
50
29
51
``` python
30
52
import pyeti, json # json is only used for pretty printing in the examples below
31
53
api = pyeti.YetiApi(" http://localhost:5000/api/" , verify_ssl = False )
32
-
33
54
```
34
55
35
56
@@ -38,52 +59,14 @@ api = pyeti.YetiApi("http://localhost:5000/api/", verify_ssl=False)
38
59
``` python
39
60
results = api.observable_add(" google.com" , [' google' ])
40
61
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
- }
63
62
```
64
-
65
63
### Bulk add
66
64
67
65
``` python
68
66
results = api.observable_bulk_add([" google.com" , " bing.com" , " yahoo.com" ])
69
67
print (len (results))
70
68
3
71
69
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
- }
87
70
```
88
71
89
72
### Get a single observable
@@ -93,28 +76,6 @@ results = api.observable_add("google.com")
93
76
print (results[' id' ])
94
77
info = api.observable_details(results[' id' ])
95
78
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
- }
118
79
```
119
80
120
81
### Search for observables
@@ -123,75 +84,17 @@ print(json.dumps(info, indent=4, sort_keys=True))
123
84
api.observable_add(" search-domain.com" )
124
85
result = api.observable_search(value = " search-dom[a-z]+" , regex = True )
125
86
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
-
144
87
```
145
88
146
- ### Add files
147
-
89
+ ### Add observables
148
90
``` python
149
91
result = api.observable_file_add(" /tmp/hello.txt" , tags = [' benign' ])
150
92
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
- ]
192
93
# Get file contents
193
94
api.observable_file_contents(objectid = " 594fff86bf365e6270f8914b" )
194
95
' Hello!\n '
195
96
api.observable_file_contents(filehash = " e134ced312b3511d88943d57ccd70c83" ) # you can also use any hash computed above
196
97
' Hello!\n '
197
98
```
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
0 commit comments