def build_domain_info(self, domains): """ 构建domain_info_list 带去重功能 """ fake_list = [] domains_set = set() for item in domains: domain = item if isinstance(item, dict): domain = item["domain"] domain = domain.lower().strip() if domain in domains_set: continue domains_set.add(domain) if utils.check_domain_black(domain): continue fake = { "domain": domain, "type": "CNAME", "record": [], "ips": [] } fake_info = modules.DomainInfo(**fake) if fake_info not in self.domain_info_list: fake_list.append(fake_info) if self.task_tag == "monitor": return fake_list domain_info_list = services.build_domain_info(fake_list) return domain_info_list
def run(self): start_time = time.time() logger.info("start brute {} with dict {}".format( self.base_domain, len(self.dicts))) self._brute_domain() elapse = time.time() - start_time logger.info("end brute {}, result {}, elapse {}".format( self.base_domain, len(self.brute_out), elapse)) self._resolver() for domain in self.resolver_map: ips = self.resolver_map[domain] if self.resolver_map[domain]: if domain in self.domain_cnames: item = { "domain": domain, "type": "CNAME", "record": [self.brute_domain_map[domain]], "ips": ips } else: item = { "domain": domain, "type": "A", "record": ips, "ips": ips } self.domain_info_list.append(modules.DomainInfo(**item)) self.domain_info_list = list(set(self.domain_info_list)) return self.domain_info_list
def build_single_domain_info(self, domain): _type = "A" cname = utils.get_cname(domain) if cname: _type = 'CNAME' ips = utils.get_ip(domain) if _type == "A": record = ips else: record = cname if not ips: return item = {"domain": domain, "type": _type, "record": record, "ips": ips} return modules.DomainInfo(**item)
def work(self, target): domain = target if hasattr(target, "domain"): domain = target.domain ips = utils.get_ip(domain) if not ips: return cnames = utils.get_cname(domain, False) info = {"domain": domain, "type": "A", "record": ips, "ips": ips} if cnames: info["type"] = 'CNAME' info["record"] = cnames self.domain_info_list.append(modules.DomainInfo(**info))