config parameters are now exposed via the meta information

config uses a specific list of values exposed via the
introspection of the module. config is now passed as an additional
dictionary to the request. MISP attributes include only MISP attributes.
pull/2/head
Alexandre Dulaunoy 2016-03-16 07:43:44 +01:00
parent ab7d93292e
commit 340d506b7c
1 changed files with 11 additions and 3 deletions

View File

@ -4,14 +4,21 @@ import requests
misperrors = {'error' : 'Error'} misperrors = {'error' : 'Error'}
mispattributes = {'input': ['hostname', 'domain', 'ip-src', 'ip-dst', 'module-username','module-password'], 'output': ['ip-src', 'ip-dst', 'hostname', 'domain']} mispattributes = {'input': ['hostname', 'domain', 'ip-src', 'ip-dst', 'module-username','module-password'], 'output': ['ip-src', 'ip-dst', 'hostname', 'domain']}
moduleinfo = {'version': '0.1', 'author': 'Alexandre Dulaunoy', 'description': 'PassiveTotal expansion service to expand values with multiple Passive DNS sources'} moduleinfo = {'version': '0.1', 'author': 'Alexandre Dulaunoy', 'description': 'PassiveTotal expansion service to expand values with multiple Passive DNS sources'}
moduleconfig = ['username', 'password']
passivetotal_url = 'https://api.passivetotal.org/v2/dns/passive?query=' passivetotal_url = 'https://api.passivetotal.org/v2/dns/passive?query='
def handler(q=False): def handler(q=False):
if q is False: if q is False:
return False return False
request = json.loads(q) request = json.loads(q)
if (request.get('module-username') is False) or (request.get('module-password') is False):
misperrors['error'] = 'Passivetotal authentication is missing' if (request.get('config')):
if (request['config'].get('username') is None) or (request['config'].get('password') is None):
misperrors['error'] = 'Passivetotal authentication is missing'
return misperrors
else:
misperrors['error'] = 'config is missing'
return misperrors return misperrors
if request.get('hostname'): if request.get('hostname'):
toquery = request['hostname'] toquery = request['hostname']
@ -28,7 +35,7 @@ def handler(q=False):
else: else:
return False return False
r = requests.get(passivetotal_url+toquery, auth=(request.get('module-username'),request.get('module-password'))) r = requests.get(passivetotal_url+toquery, auth=(request['config'].get('username'),request['config'].get('password')))
if r.status_code == 200: if r.status_code == 200:
x = json.loads(r.text) x = json.loads(r.text)
a = [] a = []
@ -58,4 +65,5 @@ def introspection():
def version(): def version():
moduleinfo['config'] = moduleconfig
return moduleinfo return moduleinfo