View Source CensysEx

Tiny Elixir ⚗️ wrapper for the Censys Search 2.0 API

ci mit commits 1.2.3 downloads PRs Welcome Sick as hell

Note: this is NOT an official Censys library, and is not supported by or affiliated with Censys at this time. I do not own Censys Trademarks or Copyrights

installation

Installation

Available in Hex, the package can be installed by adding censys_ex to your list of dependencies in mix.exs:

def deps do
  [
    {:censys_ex, "~> 1.2.3"}
  ]
end

setup

Setup

via environment variables

export CENSYS_API_ID="*****"
export CENSYS_API_SECRET="*****"
iex(1)> CensysEx.API.start_link()
{:ok, #PID<0.253.0>}

or directly

iex(1)> CensysEx.API.start_link("*****", "*****")
{:ok, #PID<0.252.0>}
iex(1)> CensysEx.API.start_link([id: "*****", secret: "*****"])
{:ok, #PID<0.252.0>}

API secrets can be found here

hosts

Hosts

view-a-host

View a host

View all the data on an IP at a given time.

CensysEx.Hosts.view("127.0.0.1")

# Lookup the host as it was at a certain time
CensysEx.Hosts.view("127.0.0.1", ~U[2021-06-07 12:53:27.450073Z])

get-host-names

Get host names

Returns a stream of names for that IP.

iex(1)> CensysEx.Hosts.names("127.0.0.1") |>
...(1)> Stream.take(25) |>
...(1)> Enum.to_list()
["example.com", "foo.net", ...]

search-hosts

Search hosts

Search returns a stream of results using the cursors provided by the API.

iex(1)> CensysEx.Hosts.search("same_service(service_name: SSH and not port: 22)") |>
...(1)> Stream.take(25) |>
...(1)> Stream.map(&Map.get(&1, "ip")) |>
...(1)> Enum.to_list()
["10.0.0.6", "10.2.0.1", ...]

aggregate-hosts

Aggregate hosts

Aggregate data about hosts on the internet.

CensysEx.Hosts.aggregate("location.country_code", "services.service_name: MEMCACHED")

CensysEx.Hosts.aggregate("location.country_code", "services.service_name: MEMCACHED", 10)

diff-hosts

Diff hosts

Diff hosts at given times

# diff the current host with it self 🤷
CensysEx.Hosts.diff("8.8.8.8")

# diff two hosts
CensysEx.Hosts.diff("8.8.8.8", "1.1.1.1")

# diff a host with itself at a time in the past
CensysEx.Hosts.diff("8.8.8.8", nil, ~U[2021-06-07 12:53:27.450073Z])

# diff two hosts in the past
CensysEx.Hosts.diff("8.8.8.8", "8.8.4.4" ~U[2021-06-07 12:53:27.450073Z], ~U[2021-06-07 12:53:27.450073Z])

hosts-api-docs

Hosts API Docs

certs

Certs

view-a-cert-by-fingerprint

View a cert by fingerprint

# NOTE this actually a V1 API
CensysEx.Certs.view("fb444eb8e68437bae06232b9f5091bccff62a768ca09e92eb5c9c2cf9d17c426")

get-hosts-that-present-a-cert

Get hosts that present a cert

CensysEx.Certs.get_hosts_by_cert("fb444eb8e68437bae06232b9f5091bccff62a768ca09e92eb5c9c2cf9d17c426")
|> Stream.take(25)
|> Stream.map(&Map.get(&1, "ip"))
|> Enum.to_list()
["10.0.0.6", "10.2.0.1", ...]

certs-api-docs

Certs API Docs

experimental

Experimental

CensysEx.Experimental.host_events("127.0.0.1")
|> Stream.take(25)
|> Stream.map(&Map.get(&1, "_event"))
|> Enum.to_list()
["service_observed", "location_updated", ...]

experimental-v2-api-docs

Experimental V2 API Docs

metadata

Metadata

CensysEX.Metadata.host_metadata()
{:ok, %{
  "code": 200,
  "status": "OK",
  "result": {
    "services": [
      "HTTP",
      "IMAP",
      "MQTT",
      "SSH",
      "..."
    ]
  }
}}

metadata-api-docs

Metadata API Docs


other-languages

Other Languages

official

Official

unofficial

Unofficial