Pular para o conteúdo

testssl.sh

testssl.sh is a powerful bash-based SSL/TLS testing utility that performs comprehensive security assessments. It checks for protocol support, cipher vulnerabilities, certificate validity, and known TLS exploits more thoroughly than lighter tools like sslscan.

Installation

Clone from GitHub

git clone --depth 1 https://github.com/drwetter/testssl.sh.git
cd testssl.sh
chmod +x testssl.sh

Quick Install (macOS)

brew install testssl.sh

Docker

docker pull drwetter/testssl.sh
docker run --rm drwetter/testssl.sh https://example.com

Dependencies

# Most systems have these. testssl.sh may warn if missing:
apt-get install openssl curl dnsutils socat
# On Alpine/minimal systems: apk add openssl curl bind-tools socat

Basic Testing

Quick Test

./testssl.sh https://example.com
./testssl.sh --quick https://example.com

Test Specific Port

./testssl.sh https://example.com:8443
./testssl.sh example.com:443
testssl.sh -t smtp mail.example.com:587  # STARTTLS
CommandDescription
./testssl.sh https://example.comFull comprehensive scan
./testssl.sh --quick https://example.comFast scan (essential checks only)
./testssl.sh example.com:443Custom port
./testssl.sh -t smtp mail.example.com:587SMTP with STARTTLS
./testssl.sh -t xmpp example.com:5222XMPP STARTTLS

Protocol Testing

Check Protocol Support

./testssl.sh --protocols https://example.com
./testssl.sh --ssl-v2 https://example.com    # SSLv2 (deprecated)
./testssl.sh --ssl-v3 https://example.com    # SSLv3 (deprecated)
./testssl.sh --tls1 https://example.com      # TLS 1.0
./testssl.sh --tls1-1 https://example.com    # TLS 1.1
./testssl.sh --tls1-2 https://example.com    # TLS 1.2
./testssl.sh --tls1-3 https://example.com    # TLS 1.3
CommandDescription
--protocolsTest all supported protocols
--ssl-v2Test SSLv2 support (should fail)
--ssl-v3Test SSLv3 support (should fail)
--tls1Test TLS 1.0 support (legacy)
--tls1-1Test TLS 1.1 support (legacy)
--tls1-2Test TLS 1.2 support (modern)
--tls1-3Test TLS 1.3 support (latest)

Cipher and Cryptography Testing

Cipher Suites

./testssl.sh --ciphers https://example.com
./testssl.sh --ciphers --strength https://example.com
./testssl.sh --weak https://example.com        # Find weak ciphers
./testssl.sh --rc4 https://example.com         # Check for RC4
CommandDescription
--ciphersList all supported ciphers
--ciphers --strengthShow cipher strength ratings
--weakHighlight weak ciphers only
--rc4Test specifically for RC4 support
--nullTest for NULL ciphers
--exportTest for export-grade ciphers

Key Exchange and Hash Algorithms

./testssl.sh --sigalgs https://example.com
./testssl.sh --eccbrainpool https://example.com
./testssl.sh --curves https://example.com
CommandDescription
--sigalgsShow signature algorithms
--eccbrainpoolTest ECC Brainpool curves
--curvesList supported elliptic curves
--dsaCheck DSA key support

Vulnerability Testing

Heartbleed (CVE-2014-0160)

./testssl.sh --heartbleed https://example.com
CommandDescription
--heartbleedTest OpenSSL Heartbleed vulnerability

CCS Injection (CVE-2014-0224)

./testssl.sh --ccs https://example.com
CommandDescription
--ccsTest CCS Injection vulnerability

ROBOT (CVE-2017-13099)

./testssl.sh --robot https://example.com
CommandDescription
--robotTest ROBOT decryption vulnerability

POODLE (CVE-2014-3566)

./testssl.sh --poodle https://example.com
CommandDescription
--poodleTest POODLE downgrade vulnerability

BEAST (CVE-2011-3389)

./testssl.sh --beast https://example.com
CommandDescription
--beastTest BEAST cipher block chaining issue

CRIME (CVE-2012-4929)

./testssl.sh --crime https://example.com
CommandDescription
--crimeTest CRIME compression attack

BREACH (CVE-2013-3566)

./testssl.sh --breach https://example.com
CommandDescription
--breachTest HTTP compression vulnerability

Lucky13 (CVE-2013-0169)

./testssl.sh --lucky13 https://example.com
CommandDescription
--lucky13Test Lucky13 timing attack

FREAK (CVE-2015-0204)

./testssl.sh --freak https://example.com
CommandDescription
--freakTest FREAK export key vulnerability

Logjam (CVE-2015-4000)

./testssl.sh --logjam https://example.com
CommandDescription
--logjamTest Logjam DHE downgrade attack

DROWN (CVE-2016-0800)

./testssl.sh --drown https://example.com
CommandDescription
--drownTest DROWN SSLv2 attack

Sweet32 (CVE-2016-2183)

./testssl.sh --sweet32 https://example.com
CommandDescription
--sweet32Test 64-bit block cipher vulnerability

OpenSSL Padding Oracle (CVE-2016-2107)

./testssl.sh --padding-oracle https://example.com
CommandDescription
--padding-oracleTest padding oracle vulnerability

Ticketbleed (CVE-2016-9244)

./testssl.sh --ticketbleed https://example.com
CommandDescription
--ticketbleedTest TLS session ticket vulnerability

Certificate Analysis

Check Certificate Details

./testssl.sh --cert https://example.com
./testssl.sh --cert-validity https://example.com
./testssl.sh --cert-chain https://example.com
CommandDescription
--certDisplay full certificate information
--cert-validityCheck certificate expiration and validity
--cert-chainShow certificate chain (CA hierarchy)
--cert-signalgDisplay signature algorithm
--cert-extensionsShow certificate extensions

Certificate Issues

./testssl.sh --cert-info https://example.com  # Full analysis
./testssl.sh --self-signed https://example.com
./testssl.sh --verify-hostname https://example.com
CommandDescription
--cert-infoDetailed certificate information
--self-signedCheck if certificate is self-signed
--verify-hostnameVerify hostname matches certificate
--wildcardCheck for wildcard certificate

Security Headers

HTTP Security Headers

./testssl.sh --hsts https://example.com
./testssl.sh --headers https://example.com
CommandDescription
--hstsCheck HSTS header
--headersCheck security-related HTTP headers
--hpkpCheck HTTP Public Key Pinning

STARTTLS Testing

Test STARTTLS Services

./testssl.sh -t smtp mail.example.com:587
./testssl.sh -t pop3 mail.example.com:110
./testssl.sh -t imap mail.example.com:143
./testssl.sh -t xmpp example.com:5222
./testssl.sh -t ldap ldap.example.com:389
CommandDescription
-t smtp host:587Test SMTP with STARTTLS
-t pop3 host:110Test POP3 with STARTTLS
-t imap host:143Test IMAP with STARTTLS
-t xmpp host:5222Test XMPP with STARTTLS
-t ldap host:389Test LDAP with STARTTLS
-t ftp host:21Test FTP with STARTTLS

Output Formats

JSON Output

./testssl.sh --json https://example.com > results.json
./testssl.sh --json --outfile results.json https://example.com
CommandDescription
--jsonOutput results in JSON format
--json --outfile file.jsonSave JSON output to file

CSV Output

./testssl.sh --csv https://example.com > results.csv
./testssl.sh --csv --outfile results.csv https://example.com
CommandDescription
--csvOutput results in CSV format
--csv --outfile file.csvSave CSV to file

HTML Output

./testssl.sh --html https://example.com > results.html
./testssl.sh --html --outfile results.html https://example.com
CommandDescription
--htmlGenerate HTML report
--html --outfile file.htmlSave HTML report to file

Logging

./testssl.sh --logfile results.log https://example.com
./testssl.sh --append https://example.com  # Append to existing log
CommandDescription
--logfile file.logSave output to log file
--appendAppend to log instead of overwriting

Batch and Mass Testing

Test Multiple Hosts

./testssl.sh --file hosts.txt
CommandDescription
--file hosts.txtTest list of hosts (one per line)

Batch Testing Script

while IFS= read -r host; do
  ./testssl.sh --json --outfile "${host//\//_}.json" "https://$host"
done < hosts.txt

Parallel Testing

cat hosts.txt | parallel ./testssl.sh --json --outfile {}.json https://{}

CI/CD Integration

GitHub Actions Example

name: SSL/TLS Testing
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Clone testssl.sh
        run: git clone --depth 1 https://github.com/drwetter/testssl.sh.git
      - name: Run testssl
        run: |
          ./testssl.sh/testssl.sh --json \
            --outfile results.json \
            https://example.com
      - name: Upload results
        uses: actions/upload-artifact@v2
        with:
          name: ssl-test-results
          path: results.json

Jenkins Integration

stage('SSL/TLS Security Scan') {
  steps {
    sh '''
      git clone --depth 1 https://github.com/drwetter/testssl.sh.git
      ./testssl.sh/testssl.sh --json \
        --outfile results.json \
        https://example.com
    '''
    archiveArtifacts artifacts: 'results.json'
  }
}

GitLab CI

ssl_tls_scan:
  stage: security
  script:
    - git clone --depth 1 https://github.com/drwetter/testssl.sh.git
    - ./testssl.sh/testssl.sh --json --outfile results.json https://example.com
  artifacts:
    paths:
      - results.json

Performance and Advanced Options

Tuning Scan Performance

./testssl.sh --fast https://example.com      # Skip slow tests
./testssl.sh --slow https://example.com      # Run additional slow tests
./testssl.sh --nofallback https://example.com  # Skip fallback checks
CommandDescription
--fastFaster scan, skip slower vulnerability tests
--slowInclude additional slow/thorough tests
--nofallbackDisable protocol fallback testing
--servername nameTLS SNI (needed for shared hosting)

Severity Levels

./testssl.sh --severity HIGH https://example.com
./testssl.sh --severity CRITICAL https://example.com
CommandDescription
--severity HIGHShow only high/critical findings
--severity CRITICALShow only critical findings

Comparison with Other Tools

Featuretestssl.shsslscansslyze
Protocol vulnerability checksComprehensiveBasicGood
Cipher analysisDetailedDetailedDetailed
Certificate analysisFullLimitedModerate
SpeedSlowerFastFast
LanguageBashCPython
STARTTLS supportYesYesYes
Output formatsJSON/CSV/HTMLXMLJSON/CSV
Automation friendlyVeryModerateGood
CVE detectionYes (Heartbleed, POODLE, etc.)LimitedModerate

When to Use What

# Quick scan for major issues
./testssl.sh --quick https://example.com

# Detailed compliance audit
./testssl.sh --severity HIGH https://example.com

# Integration with monitoring
./testssl.sh --json --outfile scan.json https://example.com

# Compare against baseline
./testssl.sh --json https://example.com | jq .findings[]

# Check certificate renewal alerts
./testssl.sh --cert-validity https://example.com

Common Workflows

Full Security Audit

#!/bin/bash
host=$1
./testssl.sh --html --outfile "${host}_report.html" "https://$host"
./testssl.sh --json --outfile "${host}_data.json" "https://$host"
echo "Report saved: ${host}_report.html"

Monitor Certificate Expiry

#!/bin/bash
for host in $(cat hosts.txt); do
  days_left=$(./testssl.sh --cert-validity "https://$host" | grep -oP '\d+(?= days)')
  if [ "$days_left" -lt 30 ]; then
    echo "ALERT: $host expires in $days_left days"
  fi
done

Track Cipher Strength Over Time

#!/bin/bash
host=$1
timestamp=$(date +%s)
./testssl.sh --ciphers --strength "https://$host" > "ciphers_${timestamp}.txt"
# Compare with previous runs
diff ciphers_*.txt

Interpreting Results

FindingSeverityAction
SSLv2/v3 enabledCRITICALDisable immediately
TLS 1.0/1.1 enabledHIGHDisable or plan removal
Weak ciphers (RC4, DES)HIGHRemove from supported ciphers
Self-signed certificateMEDIUMUse CA-signed certificate
Expired certificateCRITICALRenew certificate
Certificate chain issuesMEDIUMComplete chain configuration
Missing HSTS headerMEDIUMAdd HSTS header
Known vulnerabilitiesCRITICALPatch immediately

Tips and Best Practices

# Test with SNI for multi-domain hosting
./testssl.sh --servername example.com https://shared-ip.com

# Save baseline for comparison
./testssl.sh --json https://example.com > baseline.json

# Test only without certificate validation (dev environments)
./testssl.sh --noverify https://test.internal:8443

# Enable verbose logging for debugging
./testssl.sh -v https://example.com

# Run specific test only
./testssl.sh --heartbleed https://example.com
./testssl.sh --drown https://example.com

Resources and Documentation