How to use the censys.query function in censys

To help you get started, we’ve selected a few censys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shaanen / osint-combiner / debug / test-censys-SQL-query.py View on Github external
#!/usr/bin/env python3
import censys.query
import configparser
import censysobject

config = configparser.ConfigParser()
config.read("config.ini")
CENSYS_API_ID = (config['SectionOne']['CENSYS_API_ID'])
CENSYS_API_KEY = (config['SectionOne']['CENSYS_API_KEY'])
nrOfResults = 0

c = censys.query.CensysQuery(api_id=CENSYS_API_ID, api_secret=CENSYS_API_KEY)
censys_object = censysobject.CensysObject()
print(c.get_series_details("ipv4"))
query = "select ip from ipv4." + censys_object.get_latest_ipv4_tables(censys_object) + " where ip = \"8.8.8.8\""

# Start SQL job
res = c.new_job(query)
job_id = res["job_id"]

# Wait for job to finish and get job metadata
print(c.check_job_loop(job_id))

# Iterate over the results from that job
print(c.get_results(job_id, page=1))
github shaanen / osint-combiner / censysfunctions.py View on Github external
def new_api_obj(str_type):
    """Returns initialised Censys SQL query API object"""
    config = configparser.ConfigParser()
    config.read(os.path.dirname(os.path.realpath(__file__)) + "/config.ini")
    censys_id = (config['osint_sources']['CENSYS_API_ID'])
    censys_key = (config['osint_sources']['CENSYS_API_KEY'])
    if str_type == 'SQL_QUERY':
        return censys.query.CensysQuery(api_id=censys_id, api_secret=censys_key)
    elif str_type == 'SQL_EXPORT':
        return censys.export.CensysExport(api_id=censys_id, api_secret=censys_key)
github shaanen / osint-combiner / censysfunctions.py View on Github external
def new_api_obj(str_type):
    """Returns initialised Censys SQL query API object"""
    config = configparser.ConfigParser()
    config.read(os.path.dirname(os.path.realpath(__file__)) + "/config.ini")
    censys_id = (config['osint_sources']['CENSYS_API_ID'])
    censys_key = (config['osint_sources']['CENSYS_API_KEY'])
    if str_type == 'SQL_QUERY':
        return censys.query.CensysQuery(api_id=censys_id, api_secret=censys_key)
    elif str_type == 'SQL_EXPORT':
        return censys.export.CensysExport(api_id=censys_id, api_secret=censys_key)