Get subdomains from Security Trails

This quick little R function will get a list of sub-domains from a given top level domain. This is typically called subdomain enumeration.

Thank you to Security Trails for a great service.

library(rvest)
library(tidyverse)
library(knitr)

get_subdomains_security_trails <- function(chk_domain) {
  # Security Trails is very good. Limited to 100 results at the moment.
  thisurl <- paste0("https://securitytrails.com/list/apex_domain/", chk_domain)
  webpage <- read_html(thisurl)
  ht <- html_table(webpage)
  domain_df <- as_tibble(ht[[1]])
  if (domain_df[[1,1]] == 'apex_domain = \"google.com\"') {
    stop("error_getting_domain_from_security_trails", call. = FALSE)
  } else {
    return(domain_df)
  }
}

To get the domain information for your domain just change the “securitytrails.com” to your domain.

mydomain <- "securitytrails.com"
df <- get_subdomains_security_trails(mydomain)
kable(df)
Domain Rank Hosting Provider Mail Provider
securitytrails.com 93,867 Highwinds Network Group, Inc. Google LLC
asr.securitytrails.com Amazon.com, Inc.
o1.rev-sg.securitytrails.com SendGrid, Inc.
dmarc.securitytrails.com Amazon.com, Inc.
app.securitytrails.com Amazon.com, Inc.
docs.securitytrails.com Cloudflare, Inc.
api.securitytrails.com Amazon.com, Inc.
sl.securitytrails.com Amazon.com, Inc.
auth.asr.securitytrails.com Cloudflare, Inc.
www.securitytrails.com Highwinds Network Group, Inc.
ftp.securitytrails.com Highwinds Network Group, Inc.
bo.securitytrails.com
blog.securitytrails.com Highwinds Network Group, Inc.
changelog.securitytrails.com Google LLC
support.securitytrails.com
order.securitytrails.com Highwinds Network Group, Inc.
stage.securitytrails.com Highwinds Network Group, Inc.
img.securitytrails.com Amazon.com, Inc.
status.securitytrails.com Highwinds Network Group, Inc.
dev.securitytrails.com Highwinds Network Group, Inc.

Reference:

securitytrails library – If you are looking for a full fledged api access to the Security Trails information please utilize Bob Rudis’ library.

Leave a Reply 0

Your email address will not be published. Required fields are marked *