PAN-OS GlobalProtect version fingerprinting in R
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
995 B

#!env Rscript
library(purrr)
gg <- glue::glue
# we also use {httr}, {readr}, {lubridate}, {anytime}, and {jsonlite}
args <- commandArgs(trailingOnly = TRUE)
stopifnot(
c(
"Must supply both IP address and port" = length(args) == 2
)
)
ip <- args[1]
port <- args[2]
httr::HEAD(
url = gg("https://{ip}:{port}/global-protect/login.esp"),
config = httr::config(
ssl_verifyhost =FALSE,
ssl_verifypeer = FALSE
)
) -> res
httr::headers(res) %>%
pluck("etag") %>%
gsub('"', '', .) %>%
substr(5, 12) %>%
as.hexmode() %>%
as.integer() %>%
anytime::anytime(tz = "GMT") %>%
as.Date() -> version_date
panos_trans <- readr::read_csv("panos-versions.txt", col_types = "cD")
res <- panos_trans[panos_trans[["date"]] == version_date,]
if (nrow(res) == 0) {
cat(gg('{{"ip":"{ip}","port":"{port}","version"=null,"date"=null}}\n'))
} else {
res$ip <- ip
res$port <- port
jsonlite::stream_out(res[,c("ip", "port", "version", "date")], verbose = FALSE)
}