def __init__(self, setting): self.log_lock = False self.setting = setting self.resolvs = self.setting['resolvs'] self.logging = self.setting['logging'] self.log_console = not ('console' in self.logging and not self.logging['console']) self.log_file = 'file' in self.logging and open(self.logging['file'], 'a+') host = setting['listen']['host'] port = setting['listen']['port'] DNSServer.__init__(self,server_address=(host, port),DNSQueryHandlerClass=DNSSpoofingHandler) print 'DNS Spoofing Server running at %s:%s'%(host, port)
elif v == 'allow': ip = self.queryip(hostname) else: ip = re.sub(p,v,hostname) print '%s %s %s'%(self.client_address[0], hostname, ip) return ip if __name__ == "__main__": import sys filters = [] # clear # config with dns.cfg with open('dns.cfg') as f: for l in f: l = l.strip() if l.startswith('#') or not l: continue try: rs = re.findall('(\S+)\s+(\S+)',l) p = rs[0][0] m = rs[0][1] print '%s-->%s'%(p,m) filters.append((p,m)) except: print 'err line: %s'%l host, port = '0.0.0.0', len(sys.argv) >= 2 and int(sys.argv[1]) or 53 serv = DNSServer((host, port), DNSQueryHandlerClass=FilterHandler) print 'DNS Server running at %s:%s'%(host, port) serv.serve_forever()
elif v == 'allow': ip = self.queryip(hostname) else: ip = v print '%s %s %s'%(self.client_address[0], hostname, ip) return ip if __name__ == "__main__": import sys filters = [] # clear # config with dns.cfg with open('dns.cfg') as f: for l in f: l = l.strip() if l.startswith('#') or not l: continue try: rs = re.findall('(\S+)\s+(\S+)',l) p = rs[0][0] m = rs[0][1] print '%s-->%s'%(p,m) filters.append((p,m)) except: print 'err line: %s'%l host, port = '0.0.0.0', len(sys.argv) >= 2 and int(sys.argv[1]) or 53 serv = DNSServer((host, port), DNSQueryHandlerClass=FilterHandler) print 'DNS Server running at %s:%s'%(host, port) serv.serve_forever()
def startDnsService(): loadConfigs() host, port = '0.0.0.0', 53 serv = DNSServer((host, port), DNSQueryHandlerClass=FilterHandler) print 'DNS Server running at %s:%s' % (host, port) serv.serve_forever()