https://github.com/hrbrmstr/censys
  
  
    R interface to the Censys "cyber"/scans search engine • https://www.censys.io/tutorial 
    https://github.com/hrbrmstr/censys
  
censys-api censys-data r r-cyber rstats
        Last synced: 8 months ago 
        JSON representation
    
R interface to the Censys "cyber"/scans search engine • https://www.censys.io/tutorial
- Host: GitHub
 - URL: https://github.com/hrbrmstr/censys
 - Owner: hrbrmstr
 - License: other
 - Created: 2016-01-11T17:58:35.000Z (almost 10 years ago)
 - Default Branch: master
 - Last Pushed: 2022-08-09T22:15:59.000Z (about 3 years ago)
 - Last Synced: 2025-03-18T01:11:14.708Z (8 months ago)
 - Topics: censys-api, censys-data, r, r-cyber, rstats
 - Language: R
 - Homepage: https://hrbrmstr.github.io/censys/
 - Size: 669 KB
 - Stars: 15
 - Watchers: 2
 - Forks: 11
 - Open Issues: 1
 - 
            Metadata Files:
            
- Readme: README.Rmd
 - License: LICENSE
 
 
Awesome Lists containing this project
- awesome-ip-search-engines - Censys R Package
 
README
          ---
output:
  html_document:
    keep_md: true
  md_document:
    variant: markdown_github
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-",
  fig.retina = 2
)
```
[](https://travis-ci.org/hrbrmstr/censys) [](https://cran.r-project.org/package=censys)
`censys` is an R package interface to the [Censys API](https://censys.io/api)
Censys is a search engine that enables researchers to ask questions about the hosts and networks that compose the Internet. Censys collects data on hosts and websites through daily [ZMap](https://zmap.io/) and [ZGrab](https://github.com/zmap/zgrab) scans of the IPv4 address space, in turn maintaining a database of how hosts and websites are configured. Researchers can interact with this data through a search interface, report builder, and SQL engine.
[Censys tutorial](https://www.censys.io/tutorial).
The following functions are implemented:
- `censys_export_download`:	Download export job files to a specified directory
- `censys_export_job_status`:	Get status of a Censys export job
- `censys_get_job_result`:	Get results of completed Censys SQL query job
- `censys_get_job_status`:	Get status of a Censys SQL query job
- `censys_query`:	Issue SQL Queries against the Censys API
- `censys_report`:	Create aggregate reports on the breakdown of a field in the result set of a query
- `censys_search`:	Perform queries against Censys data
- `censys_series`:	List all series that can be queried from the SQL interface
- `censys_series_details`:	Get details about a series, including the list of tables and schema for the series
- `censys_start_export`:	Export large datasets and structured records from Censys to JSON or CSV files
- `get_series`:	Retrieve data on the types of scans Censys regularly performs ("series").
- `view_document`:	Retrieve data that Censys has about a specific host, website, or certificate.
- `view_result`:	Retrieve data on a particular scan "result"
- `view_series`:	Retrieve data that Censys has about a particular series
### Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/censys")
```
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
options(width=120)
```
### Usage
```{r message=FALSE, cache=TRUE}
library(censys)
# current verison
packageVersion("censys")
library(purrr)
library(dplyr)
res <- censys_query("
SELECT p80.http.get.headers.server, p80.http.get.headers.www_authenticate, location.country, autonomous_system.asn
FROM ipv4.20161206
WHERE REGEXP_MATCH(p80.http.get.headers.server, r'gen[56]')
")
inf <- censys_get_job_status(res$job_id)
Sys.sleep(10) # giving it some time to process for the README
map(1:3, ~censys_get_job_result(inf$job_id, .)) %>% 
  map(c("rows", "f")) %>% 
  flatten() %>% 
  map("v") %>% 
  map_df(~setNames(as.list(.), c("server", "auth", "geo", "asn"))) %>% 
  count(geo, sort=TRUE)
```
### Test Results
```{r}
library(censys)
library(testthat)
date()
test_dir("tests/")
```
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). 
By participating in this project you agree to abide by its terms.