I'm grepping for anything that contains ssl-cert, this is so I can get the IP and ports for any certificates in use. Also I'm grepping 11 lines above the "ssl-cert" which gives me this output( the command used - grep -B 11 ssl-cert filename ):
Nmap scan report for myip26.add-192-168-100.com (192.168.100.26) Host is up (0.030s latency). PORT STATE SERVICE 443/tcp open https |_http-favicon: Unknown favicon MD5: 403C0A0F5AA689D51D9ED13FE852A171 | http-methods: |_ Supported Methods: GET HEAD POST OPTIONS | http-robots.txt: 1 disallowed entry |_/ |_http-title: Site doesn't have a title (text/html). | ssl-cert: Subject: commonName=*.mywebsite.com -- | Public Key type: rsa | Public Key bits: 2048 | Signature Algorithm: sha256WithRSAEncryption | Not valid before: 2018-11-23T08:54:04 | Not valid after: 2019-02-21T08:54:04 | MD5: da8d db5d c15b 9512 2c3d a3ff 0d45 1b3b |_SHA-1: e2e2 bee4 181c c60e cf19 63db 53c4 5323 d99f 04ae |_ssl-date: 2019-02-19T13:42:07+00:00; 0s from scanner time. |_sstp-discover: SSTP is supported. 465/tcp open smtps |_smtp-commands: Hello, | ssl-cert: Subject: commonName=*mywebsite.com -- |_ssl-date: 2019-02-19T13:42:06+00:00; 0s from scanner time. 8443/tcp closed https-alt Nmap scan report for myip23.add-192-16-101.com (220.127.116.11) Host is up (0.023s latency). PORT STATE SERVICE 443/tcp closed https 465/tcp closed smtps 8443/tcp open https-alt |_http-title: 400 No required SSL certificate was sent | ssl-cert: Subject: commonName=*.mywebsite.com"
The desired output would be to return the IP and port of any services that use a SSL cert in this format:
18.104.22.168:443 22.214.171.124:465 126.96.36.199:8443
I've tried using grep, awk and sed to no avail.