def detector(domain, ip, cname): if APEX_VALUES: if ip in APEX_VALUES: return True if filter(lambda x: x in cname, CNAME_VALUE): try: if resolve_host_ip(cname): return True except Exception as e: pass return False
def process_subdomain(self): helper.install_domains() sqlitepath = os.path.join(config.OUTPUT_DIR, 'domains.db') conn = db.connect(sqlitepath) conn.text_factory = str cursor = conn.cursor() sql = "INSERT INTO domains(domain, ip, cname, cdn, internal) VALUES(?, ?, ?, ?, ?)" ips = set() cdn_ip = set() self.subdomains.update(self.domains) for domain in self.subdomains: cname = tools.get_cname(domain) cdn = tools.get_cdn(domain, cname) ipl = self.domain_ip.get(domain, None) if cdn: self.cdn_domain.add(domain) if not ipl: ipl = tools.resolve_host_ip(domain) else: ipl = ipl.split(",") for ip in ipl: internal = tools.is_internal_ip(ip) if not cdn and not internal: ips.add(ip) elif cdn: self.takeover_domain_check.add((domain, ip, cname)) cdn_ip.add(ip) if not internal: self.internal_domain.add(domain) try: status = cursor.execute(sql, (domain, ip, cname, cdn, internal)) conn.commit() except Exception as e: print e self.ips = ips - cdn_ip with open(os.path.join(config.OUTPUT_DIR, config.IPS), 'w') as f: f.write('\n'.join(self.ips).strip())
conn.text_factory = str cursor = conn.cursor() sql = "INSERT INTO domains(domain, ip, cname, cdn, internal) VALUES(?, ?, ?, ?, ?)" ips = set() cdn_ip = set() cdn_domain = set() for domain in subdomains: cname = tools.get_cname(domain) cdn = tools.get_cdn(domain, cname) ipl = domain_ip.get(domain, None) if cdn: cdn_domain.add(domain) if not ipl: ipl = tools.resolve_host_ip(domain) else: ipl = ipl.split(",") for ip in ipl: internal = tools.is_internal_ip(ip) if not cdn and not internal: ips.add(ip) elif cdn: cdn_ip.add(ip) try: status = cursor.execute(sql, (domain, ip, cname, cdn, internal)) conn.commit() except Exception as e: print e conn.close()