Skip to content

Instantly share code, notes, and snippets.

@manasmbellani
Created November 5, 2021 00:44
Show Gist options
  • Save manasmbellani/bb130e8ef453be223d3bc336808c0d19 to your computer and use it in GitHub Desktop.
Save manasmbellani/bb130e8ef453be223d3bc336808c0d19 to your computer and use it in GitHub Desktop.
get_domain_from_ssl_info_on_host.sh - Gets information from SSL cert information on host via openssl s_client
#!/bin/bash
USAGE="[-] $0 <hostname>"
if [ $# -lt 1 ]; then
echo "$USAGE"
exit 1
fi
hostname="$1"
echo | openssl s_client -connect $hostname:443 2>&1 | grep -iE "0 s:.*CN = " | grep -ioE "CN = .*" | cut -d "=" -f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment