Ubuntu/Scripts/SSL Expire

From r00tedvw.com wiki
Revision as of 02:54, 19 January 2017 by R00t (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#!/bin/bash

https_port=('443')
smtp_port=('25')
imap_port=('993')

declare -a webservers=(
web.server.com
)

declare -a smtpservers=(
smtp.server.com
)

declare -a imapservers=(
imap.server.com
)

function websrv {
        for i in "${webservers[@]}"
        do
                web="$(openssl s_client -showcerts -connect $i:$https_port < /dev/null 2>/dev/null | openssl x509 -text)"
                echo "$web" | grep "CN\=[A-Za-z]*\.[A-Za-z]*\.[A-Za-z]*" | sed 's/.*CN=//'
                echo "$web" | grep "Validity" -A 2 | sed '/Validity/d' | sed 's/^[ \t]*//'
        done
}

function smtpsrv {
        for i in "${smtpservers[@]}"
        do
                smtp="$(openssl s_client -showcerts -starttls smtp -connect $i:$smtp_port < /dev/null 2>/dev/null | openssl x509 -text)"
                echo "$smtp" | grep "CN\=[A-Za-z]*\.[A-Za-z]*\.[A-Za-z]*" | sed 's/.*CN=//'
                echo "$smtp" | grep "Validity" -A 2 | sed '/Validity/d' | sed 's/^[ \t]*//'
        done
}

function imapsrv {
        for i in "${imapservers[@]}"
        do
                imap="$(openssl s_client -showcerts -connect $i:$imap_port < /dev/null 2>/dev/null | openssl x509 -text)"
                echo "$imap" | grep "CN\=[A-Za-z]*\.[A-Za-z]*\.[A-Za-z]*" | sed 's/.*CN=//'
                echo "$imap" | grep "Validity" -A 2 | sed '/Validity/d' | sed 's/^[ \t]*//'
        done
}

printf 'Web Severs\n'
websrv
printf '\n'
printf 'SMTP Servers\n'
smtpsrv
printf '\n'
printf 'IMAP Servers\n'
imapsrv

Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox