<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
---
name: performing-cryptographic-protocol-analysis
description: >-
  Analyze cryptographic protocols for design flaws, implementation weaknesses,
  and downgrade attacks. Covers TLS handshake analysis, Kerberos ticket
  inspection, SSH key exchange evaluation, VPN protocol assessment, and
  formal verification concepts using Wireshark and protocol-specific tools.
domain: cybersecurity
subdomain: cryptography
tags:
  - protocol-analysis
  - tls-handshake
  - kerberos
  - ssh
  - vpn
  - wireshark
  - downgrade-attacks
  - key-exchange
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1557"]
---

# Performing Cryptographic Protocol Analysis

## Overview

Cryptographic protocol analysis examines the security of protocol designs and
implementations, identifying vulnerabilities like downgrade attacks, replay
attacks, and key exchange weaknesses. This skill covers practical analysis
of TLS, SSH, Kerberos, and VPN protocols using packet capture and
protocol-specific tooling.

## Prerequisites

| Requirement | Install |
|---|---|
| Wireshark / tshark | `apt install wireshark tshark` |
| OpenSSL 3.x | `apt install openssl` |
| ssh-audit | `pip install ssh-audit` |
| nmap | `apt install nmap` |
| Python 3.10+ | For agent tooling |

## Key Concepts

### TLS Handshake Analysis

```bash
# Capture TLS handshake with tshark
tshark -i eth0 -f "tcp port 443" -Y "tls.handshake" \
  -T fields -e tls.handshake.type -e tls.handshake.ciphersuite \
  -e tls.handshake.version -c 50

# Decode TLS ClientHello details
tshark -r capture.pcap -Y "tls.handshake.type == 1" \
  -T fields -e ip.src -e tls.handshake.ciphersuite \
  -e tls.handshake.extensions.supported_version

# Check for TLS downgrade indicators
tshark -r capture.pcap -Y "tls.handshake.version < 0x0303" \
  -T fields -e ip.src -e ip.dst -e tls.handshake.version

# Analyze negotiated cipher suite
openssl s_client -connect example.com:443 -brief < /dev/null 2>&1 | \
  grep -E "Protocol|Ciphersuite"

# Test specific TLS versions
openssl s_client -connect example.com:443 -tls1_2 < /dev/null 2>&1
openssl s_client -connect example.com:443 -tls1_3 < /dev/null 2>&1
```

### SSH Protocol Analysis

```bash
# Audit SSH server configuration
ssh-audit example.com

# Check key exchange algorithms
ssh -vv example.com 2>&1 | grep -E "kex:|server host key:|cipher:|mac:"

# nmap SSH enumeration
nmap --script ssh2-enum-algos -p 22 example.com

# List SSH host key fingerprints
ssh-keyscan -t ed25519,rsa,ecdsa example.com 2>/dev/null | \
  ssh-keygen -l -f -
```

### Kerberos Analysis

```bash
# Capture Kerberos traffic
tshark -i eth0 -f "tcp port 88 or udp port 88" -Y "kerberos" \
  -T fields -e kerberos.msg_type -e kerberos.CNameString \
  -e kerberos.etype

# Check for weak encryption types (RC4/DES)
tshark -r capture.pcap -Y "kerberos.etype == 23 or kerberos.etype == 3" \
  -T fields -e ip.src -e kerberos.CNameString -e kerberos.etype

# Kerberos etype reference
# 17 = AES128-CTS-HMAC-SHA1 (acceptable)
# 18 = AES256-CTS-HMAC-SHA1 (recommended)
# 23 = RC4-HMAC (weak — Kerberoastable)
# 3  = DES-CBC-MD5 (broken — must disable)
```

### VPN Protocol Assessment

```bash
# IKE/IPSec analysis
nmap --script ike-version -sU -p 500 example.com

# Capture IKE negotiation
tshark -i eth0 -f "udp port 500 or udp port 4500" -Y "isakmp" \
  -T fields -e isakmp.exchangetype -e isakmp.payload

# WireGuard key validation
wg show all dump

# OpenVPN cipher check
openvpn --show-ciphers | grep -E '(AES-256-GCM|CHACHA20)'
```

### Protocol Weakness Patterns

| Weakness | Protocol | Detection |
|---|---|---|
| Downgrade attack | TLS | ClientHello with only old versions |
| Weak key exchange | SSH | diffie-hellman-group1-sha1 negotiated |
| RC4-HMAC tickets | Kerberos | etype 23 in AS-REP/TGS-REP |
| Null cipher | TLS | Cipher suite with NULL encryption |
| Static DH | TLS | Non-ephemeral DH key exchange |
| Replay | Kerberos | Duplicate AP-REQ timestamps |

## Workflow

1. **Capture** — Record protocol traffic with tshark or Wireshark
2. **Decode** — Parse protocol messages and extract parameters
3. **Evaluate** — Compare negotiated algorithms against best practices
4. **Identify** — Flag weak algorithms, downgrade opportunities, known attacks
5. **Report** — Document findings with MITRE ATT&CK mapping
6. **Harden** — Recommend configuration changes to eliminate weaknesses

## Verification

| Check | Method |
|---|---|
| No TLS downgrade | Only TLS 1.2+ in handshakes |
| Strong SSH algorithms | ssh-audit shows no warnings |
| No RC4 Kerberos | etype 23 absent from Kerberos traffic |
| PFS enabled | Only ECDHE/DHE key exchange methods |
| No null/weak ciphers | tshark filter for weak suites returns empty |

## References

- [Wireshark TLS Dissection](https://wiki.wireshark.org/TLS)
- [ssh-audit GitHub](https://github.com/jtesta/ssh-audit)
- [RFC 8446 — TLS 1.3](https://datatracker.ietf.org/doc/html/rfc8446)
- [MITRE ATT&CK T1557 — Adversary-in-the-Middle](https://attack.mitre.org/techniques/T1557/)
