Skip to content

Instantly share code, notes, and snippets.

View jwarwick-bry's full-sized avatar

Justin Warwick jwarwick-bry

View GitHub Profile
@jwarwick-bry
jwarwick-bry / ssl_service_scan.sh
Created December 11, 2025 21:18
Scan HTTP-ish ports for SSL/TLS and print certificate expiration dates
#!/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}'
@jwarwick-bry
jwarwick-bry / fix_repeated_filename_extensions.ps1
Created August 13, 2025 21:24
Fix accidentally repeated filename extensions in Windows. For instance, if your Windows Explorer had the hide filename extensions option turned on, so you added filename extensions which then were actually extraneous.
get-ChildItem -recurse |?{ $_.name -match "(\.[A-Z]{1,5}){2,}" } |%{ $FIXED = $_ -replace "(\.[A-Z]{1,5}){2,}",'$1' ; move-Item -verbose "$_" "${FIXED}" }
@jwarwick-bry
jwarwick-bry / s_client.ps1
Last active June 14, 2024 20:33 — forked from IISResetMe/s_client.ps1
PowerShell semi-clone of openssl s_client tool
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