iwla/plugins/post_analysis/reverse_dns.py
Grégory Soutadé 9fbc5448bc Add conf_requires.
Load plugins in order
2014-11-27 12:34:42 +01:00

32 lines
931 B
Python

import socket
from iwla import IWLA
from iplugin import IPlugin
class IWLAPostAnalysisReverseDNS(IPlugin):
DEFAULT_DNS_TIMEOUT = 0.5
def __init__(self, iwla):
super(IWLAPostAnalysisReverseDNS, self).__init__(iwla)
self.API_VERSION = 1
def load(self):
timeout = self.iwla.getConfValue('reverse_dns_timeout',
IWLAPostAnalysisReverseDNS.DEFAULT_DNS_TIMEOUT)
socket.setdefaulttimeout(timeout)
return True
def hook(self):
hits = self.iwla.getValidVisitors()
for (k, hit) in hits.items():
if hit.get('dns_analysed', False): continue
try:
name, _, _ = socket.gethostbyaddr(k)
hit['remote_addr'] = name
hit['dns_name_replaced'] = True
except:
pass
finally:
hit['dns_analysed'] = True