def parse_query(self): if not self.query: return None if '|' in self.query: name = self.query.split("|")[0] value = self.query.split("|")[1] if 'asn' in name: ips = self.get_asn_ip(value) utils.just_write(self.options['output'], "\n".join(ips)) utils.just_cleanup(self.options['output'])
def asnlookup(self, company): utils.print_banner(f"Starting scraping {company} from asnlookup.com") url = f'http://asnlookup.com/api/lookup?org={company}' r = sender.send_get(self.options, url, None) data = r.json() if not data: utils.print_bad('No IP found') else: content = "\n".join(data) print(content) utils.just_write(self.options['output'], content) utils.just_cleanup(self.options['output'])
def get_asn(self): ip_target = utils.resolve_input(self.target) if not ip_target: return False utils.print_banner(f"Starting scraping detail ASN of {ip_target}") utils.print_info(f'Get ASN from IP: {ip_target}') url = f'https://ipinfo.io/{ip_target}/json' r = sender.send_get(self.options, url, None) org_info = r.json().get('org') asn = utils.get_asn(org_info) if asn: utils.print_info(f"Detect target running on {asn}") ips = self.get_asn_ip(asn) utils.just_write(self.options['output'], "\n".join(ips)) utils.just_cleanup(self.options['output']) else: return False
def write_result(self, item, kind='code'): # for item in real_results: self.writing_raw(item) if kind != 'user': utils.just_write( self.options['repo_output'], item.get('repo_url') + "\n") # store user user = self.user_or_org(item.get('user')) if user.get('user'): utils.just_write( self.options['user_output'], user.get('user') + "\n") elif user.get('org'): utils.just_write( self.options['org_output'], user.get('org') + "\n") utils.just_cleanup(self.options['repo_output'], verbose=False) utils.just_cleanup(self.options['user_output'], verbose=False) utils.just_cleanup(self.options['org_output'], verbose=False)
def conclude(self): utils.just_cleanup(self.output)