(self, target)
| 27 | raise NotImplementedError() |
| 28 | |
| 29 | def query(self, target): |
| 30 | t1 = time.time() |
| 31 | self.logger.info("start query {} on {}".format(target, self.source_name)) |
| 32 | try: |
| 33 | domains = self.sub_domains(target) |
| 34 | except Exception as e: |
| 35 | self.logger.error("{} error: {}".format(self.source_name, e)) |
| 36 | return [] |
| 37 | |
| 38 | if not isinstance(domains, list): |
| 39 | self.logger.warning("{} is not list".format(domains)) |
| 40 | return [] |
| 41 | |
| 42 | """下面是过滤掉不合法的数据""" |
| 43 | subdomains = [] |
| 44 | |
| 45 | for domain in domains: |
| 46 | domain = domain.strip("*.") |
| 47 | domain = domain.lower() |
| 48 | if not domain: |
| 49 | continue |
| 50 | |
| 51 | if not domain.endswith(".{}".format(target)): |
| 52 | continue |
| 53 | |
| 54 | # 删除掉过长的域名 |
| 55 | if len(domain) - len(target) >= Config.DOMAIN_MAX_LEN: |
| 56 | continue |
| 57 | |
| 58 | if not utils.is_valid_domain(domain): |
| 59 | continue |
| 60 | |
| 61 | # 屏蔽和谐域名和黑名单域名 |
| 62 | if utils.check_domain_black(domain): |
| 63 | continue |
| 64 | |
| 65 | if utils.domain_parsed(domain): |
| 66 | subdomains.append(domain) |
| 67 | |
| 68 | subdomains = list(set(subdomains)) |
| 69 | |
| 70 | t2 = time.time() |
| 71 | self.logger.info("end query {} on {}, source result:{}, real result:{} ({:.2f}s)".format( |
| 72 | target, self.source_name, len(domains), len(subdomains), t2 - t1)) |
| 73 | |
| 74 | return subdomains |
| 75 | |
| 76 | |
| 77 | def run_plugin(p, target) -> (str, list): |
no test coverage detected