mirror of https://github.com/MISP/misp-modules
Handling of error added
parent
6c0e905737
commit
dd3195eff8
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
|
||||||
|
misperrors = {'error' : 'Error'}
|
||||||
mispattributes = {'input': ['hostname', 'domain'], 'output': ['ip-src', 'ip-dst']}
|
mispattributes = {'input': ['hostname', 'domain'], 'output': ['ip-src', 'ip-dst']}
|
||||||
moduleinfo = "0.1"
|
moduleinfo = "0.1"
|
||||||
|
|
||||||
|
@ -16,13 +17,20 @@ def handler(q=False):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
r = dns.resolver.Resolver()
|
r = dns.resolver.Resolver()
|
||||||
r.nameservers = ['8.8.8.8']
|
r.timeout = 2
|
||||||
|
r.lifetime = 2
|
||||||
|
r.nameservers = ['8.1.8.7']
|
||||||
try:
|
try:
|
||||||
answer = r.query(toquery, 'A')
|
answer = r.query(toquery, 'A')
|
||||||
except dns.resolver.NXDOMAIN:
|
except dns.resolver.NXDOMAIN:
|
||||||
return False
|
misperrors['error'] = "NXDOMAIN"
|
||||||
|
return misperrors
|
||||||
except dns.exception.Timeout:
|
except dns.exception.Timeout:
|
||||||
return False
|
misperrors['error'] = "Timeout"
|
||||||
|
return misperrors
|
||||||
|
except:
|
||||||
|
misperrors['error'] = "DNS resolving error"
|
||||||
|
return misperrors
|
||||||
r = {'results': [{'types': mispattributes['output'], 'values':[str(answer[0])]}]}
|
r = {'results': [{'types': mispattributes['output'], 'values':[str(answer[0])]}]}
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue