/
devEmailToKey.py
42 lines (31 loc) · 1.1 KB
/
devEmailToKey.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Search apps by developer email.
:param field: email to find
:return: keys from the apps founds.
"""
from tacyt import TacytApp
from maltego.MaltegoTransform import *
from APIManagement import Tacyt
from maltego.Entities import TacytEntities as te
api = TacytApp.TacytApp(Tacyt.APP_ID, Tacyt.SECRET_KEY)
m = MaltegoTransform()
field = sys.argv[1]
try:
query = "developerEmail:%s"%field
result = api.search_apps(query=query,maxResults=100)
data = result.get_data()
if 'result' in data and data['result'] is not None and 'applications' in data['result'] and data['result']['applications']:
for data in data['result']['applications']:
if 'key' in data and data['key'] is not None:
application = data['key']
m.addEntity(te.KEY, application.encode('utf-8'))
else:
m.addUIMessage("The key is not found in the results")
else:
m.addUIMessage("The search returns null results")
except Exception as e:
m.addException(str(e))
m.throwExceptions()
m.returnOutput()