mirror of https://github.com/MISP/misp-modules
Fix path to config file
parent
29bedc7faa
commit
064c3e3649
|
@ -1,5 +1,8 @@
|
||||||
import json, pygeoip
|
import json
|
||||||
import sys, logging
|
import pygeoip
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
log = logging.getLogger('geoip_country')
|
log = logging.getLogger('geoip_country')
|
||||||
|
@ -20,9 +23,10 @@ moduleinfo = {'version': '0.1', 'author': 'Andreas Muehlemann',
|
||||||
|
|
||||||
# get current db from http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
|
# get current db from http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('geoip_country.cfg')
|
config.read(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'geoip_country.cfg'))
|
||||||
gi = pygeoip.GeoIP(config.get('GEOIP', 'database'))
|
gi = pygeoip.GeoIP(config.get('GEOIP', 'database'))
|
||||||
|
|
||||||
|
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
return False
|
return False
|
||||||
|
@ -35,7 +39,7 @@ def handler(q=False):
|
||||||
elif request.get('domain|ip'):
|
elif request.get('domain|ip'):
|
||||||
toquery = request['domain|ip'].split('|')[1]
|
toquery = request['domain|ip'].split('|')[1]
|
||||||
else:
|
else:
|
||||||
return false
|
return False
|
||||||
|
|
||||||
log.debug(toquery)
|
log.debug(toquery)
|
||||||
|
|
||||||
|
@ -45,14 +49,15 @@ def handler(q=False):
|
||||||
misperrors['error'] = "GeoIP resolving error"
|
misperrors['error'] = "GeoIP resolving error"
|
||||||
return misperrors
|
return misperrors
|
||||||
|
|
||||||
r = {'results': [{'types': mispattributes['output'],
|
r = {'results': [{'types': mispattributes['output'], 'values': [str(answer)]}]}
|
||||||
'values': [str(answer)]}]}
|
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def introspection():
|
def introspection():
|
||||||
return mispattributes
|
return mispattributes
|
||||||
|
|
||||||
|
|
||||||
def version():
|
def version():
|
||||||
moduleinfo['config'] = moduleconfig
|
# moduleinfo['config'] = moduleconfig
|
||||||
return moduleinfo
|
return moduleinfo
|
||||||
|
|
Loading…
Reference in New Issue