def import_asset_file(project, type_, input_file): orca_dbconn = OrcaDbConnector(project) if type_ == "ip": for line in input_file: ipaddr = line.rstrip('\r\n') if orca_helpers.is_ipaddr(ipaddr): add_asset(orca_dbconn, ipaddr, 'ipaddr', source='file') elif type_ == "cidr": for line in input_file: cidr = line.rstrip('\r\n') if orca_helpers.is_cidr(cidr): add_asset(orca_dbconn, cidr, 'cidr', source='file') elif type_ == "hostname": for line in input_file: add_asset(orca_dbconn, line.rstrip('\r\n'), 'hostname', source='file') elif type_ == "domain": for line in input_file: add_asset(orca_dbconn, line.rstrip('\r\n'), 'domain', source='file') else: click.secho("No asset data provided!", fg='red') ctx = click.get_current_context() click.echo(ctx.get_help())
def add_asset(orca_dbconn, asset, asset_type, source): # click.echo("Processing asset {}".format(asset)) if asset_type == 'ipaddr': if orca_helpers.is_ipaddr(asset): orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'cidr': if orca_helpers.is_cidr(asset): orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'hostname': orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'domain': orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) else: click.secho("[!] No valid asset data type provided", bg='red')
def add_asset(orca_dbconn, asset, asset_type, source): click.echo( click.style("[+]", fg='green') + " Adding asset: {}".format(asset)) if asset_type == 'ipaddr': if orca_helpers.is_ipaddr(asset): orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'cidr': if orca_helpers.is_cidr(asset): orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'hostname': orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) elif asset_type == 'domain': orca_dbconn.store_asset(asset, asset_type=asset_type, source=source) else: click.secho("[+] No valid asset data type provided", bg='red')
def enumerate_bgp_domain(orca_dbconn, domain): url = "https://api.bgpview.io/search?query_term={}".format(domain.split('.')[0]) source = "bgpview" asset_type = "cidr" res = requests.get(url) if res.status_code == 200: json_results = res.json() for result in json_results['data']['ipv4_prefixes']: email_addrs = [] for email_addr in result['email_contacts']: if domain in email_addr: email_addrs.append(email_addr) asset = result['prefix'] print("Prefix: {}".format(asset)) print("Email addrs: {}".format(','.join(email_addrs))) if orca_helpers.is_cidr(asset): orca_dbconn.store_asset(asset, asset_type=asset_type, source=source)