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
| #!/bin/bash | |
| # Scan ports for SSL/TLS and print certificate expiration dates | |
| PORTS=( $(netstat -tuln | grep -oP ':\K[0-9]+' | sort -nu) ) | |
| for port in "${PORTS[@]}"; do | |
| echo -n "Checking port $port... " | |
| result=$(timeout 5 bash -c "echo | openssl s_client -connect 127.0.0.1:$port 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null") | |
| if [[ $result == notAfter* ]]; then | |
| echo "$result" | sed 's/notAfter=/\tExpires: /' | |
| #TODO: parse date and show days remaining, or if expired, output loud warning message to STDERR | |
| sudo lsof -i :${port} -sTCP:LISTEN -nP | awk '{print "\t\t\t",$1,$3,$9}' |
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
| get-ChildItem -recurse |?{ $_.name -match "(\.[A-Z]{1,5}){2,}" } |%{ $FIXED = $_ -replace "(\.[A-Z]{1,5}){2,}",'$1' ; move-Item -verbose "$_" "${FIXED}" } |
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
| using namespace System.Net.Sockets | |
| using namespace System.Net.Security | |
| using namespace System.Security.Cryptography.X509Certificates | |
| #based on https://blog.iisreset.me/openssl-s_client-but-in-powershell/ | |
| function ConvertFrom-X509Certificate { | |
| param( | |
| [Parameter(ValueFromPipeline)] | |
| [X509Certificate2]$Certificate |