Last active
February 19, 2019 22:32
-
-
Save pastranastevenaz/072b36dafa526bfe8efdb8694fab5d2f to your computer and use it in GitHub Desktop.
SSL Lookup Script. Queries a site's SSL information using the openSSL tool in Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function getssldata( $d ){ | |
| $domain = $d; | |
| $url = "www." . $domain; | |
| $ip = gethostbyname($url); | |
| $commonName = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -subject | sed -e 's/.*CN=\*.//'"); | |
| $sans = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -text | grep DNS | sed -e 's/DNS://g'"); | |
| $expireDate = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed -e s#notAfter=##"); | |
| $issuer = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -issuer | sed -e 's/.*CN=//' -e 's/\/OU.*//'"); | |
| $signatureAlgorith = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -text | grep 'Signature Algorithm' | head -1 | sed -e 's/.*m://'"); | |
| $serialNumber = shell_exec("openssl s_client -servername {$domain} -connect {$domain}:443 2>/dev/null | openssl x509 -noout -serial | sed -e 's/.*al=//'"); | |
| return array( | |
| "ip" => $ip, | |
| "commonName" => $commonName, | |
| "sans" => $sans, | |
| "expireDate" => $expireDate, | |
| "issuer" => $issuer, | |
| "signatureAlgorith" => $signatureAlgorith, | |
| "serialNumber" => $serialNumber, | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment