Skip to content

Instantly share code, notes, and snippets.

@NicholasLeader
Last active September 3, 2019 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasLeader/b13697039d4a1f7288bf4635d4301bfd to your computer and use it in GitHub Desktop.
Save NicholasLeader/b13697039d4a1f7288bf4635d4301bfd to your computer and use it in GitHub Desktop.
PowerShell PoC to grab the 'CN' common name of the SSL/TLS cert of an IP - leveraging NMAP SSL-cert script
<#
Nicholas Leader
9.3.2019
PowerShell PoC to grab the 'CN' common name of the SSL/TLS cert of an IP
Script takes an array of IPs as input in the script, but could be modified to pull from a CSV, etc
Script is leveraging 'Invoke-Command' to run an NMAP script
Using 'Select-string' to pull the relevent line of the NMAP script output
Requires:
PowerShell
NMAP (need to be callable via PATH environmental variable)
#>
## these example IPs are Twitter IPs
$ips = @("199.59.148.10","199.59.148.11")
$ips |
ForEach-Object {Invoke-Command {nmap --script ssl-cert $_} |
select-string "ssl-cert: Subject: commonName="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment