A Command line tool for Censys Enterprise Customers that allows BQ access via the command line.
Project description
Censys BigQuery Command Line Tool
This script allows users to query the data in Censys Data BigQuery Project from the command line. The results from the query can be exported as JSON, CSV, or viewed from the terminal screen.
Note: the Censys Data BigQuery Project is available to enterprise customers and approved academic researchers. For more information on product tiers, contact sales@censys.io.
Setting Up a Service Account in BigQuery:
Prior to using the BiqQuery Command Line Tool, you'll need to set up a service account that is associated with your Google Cloud Platform.
Google provides documentation on how to create a service account, either via the GCP Console or the Command Line. Visit https://cloud.google.com/docs/authentication/getting-started for full documentation.
Be sure to set the GOOGLE_APPLICATION_CREDENTIALS environmental variable.
$ export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
Installation:
pip install censys_bigquery_cli
Or
pip install git+https://github.com/censys/bigquery-cli
Usage:
The script allows you to input SQL queries as arguments in the script, returning the results as screen output (default), JSON, or CSV.
Here are some example queries:
$ censys_bq 'SELECT ip, ports, protocols, tags FROM `censys-io.ipv4_public.current` WHERE location.city = "Ann Arbor" and REGEXP_CONTAINS(TO_JSON_STRING(tags), r"rsa-export") LIMIT 25'
$ censys_bq 'with user_ports as (
SELECT [443, 3306, 6379] as selected_ports
)
SELECT DISTINCT ip, TO_JSON_STRING(user_ports.selected_ports)
FROM `censys-io.ipv4_banners_public.current`, user_ports, UNNEST(services) as s
WHERE (SELECT LOGICAL_AND(a_i IN (SELECT port_number FROM UNNEST(services))) FROM UNNEST(user_ports.selected_ports) a_i) LIMIT 15' --output csv
$ censys_bq 'SELECT COUNT(ip), p80.http.get.body_sha256
FROM `censys-io.ipv4_public.current`
WHERE REGEXP_CONTAINS(p80.http.get.body, r"(?i)coinhive.min.js>")
GROUP BY p80.http.get.body_sha256
ORDER BY 1 DESC' --output json
$ censys_bq 'with Data as (SELECT
distinct fingerprint_sha256
FROM
`censys-io.certificates_public.certificates`, UNNEST(parsed.subject.organization) as po, UNNEST(parsed.names) as parsed_names
WHERE
REGEXP_CONTAINS(TO_JSON_STRING(parsed.names), r"[.]example[.]")
)
SELECT
distinct ip
FROM
`censys-io.ipv4_banners_public.current` as c, UNNEST(services)
JOIN Data as d on d.fingerprint_sha256 = certificate.fingerprints.sha256
LIMIT 20' --output json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for censys_bigquery_cli-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f659d6ae868f0aef107f9a2c26fad0bb480162737e37fa0912924f8bded63226 |
|
MD5 | 60ef1d33cdf016c066fc82172b2bae6c |
|
BLAKE2b-256 | 9b2fdc2abbd25ba2d431a041422e9c34b1924aa072d7000b42776570eee3fa16 |
Hashes for censys_bigquery_cli-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 192e64ed2603b4273b5c99c1cb5c90b994f6d544943a17315e801448f21022ae |
|
MD5 | b4bd228490c4e25c6fc0289be30387ac |
|
BLAKE2b-256 | 2fdbd01d78d929f5013a8a079dd34c6e2bfcd93a1b1a33b2d94c087f0e8eac5e |