Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Tools/GitHubGitHub/mr-whiskerss/ssh-terrapin-prefix-truncation-weakness-cve-2023-48795-checker
ReconnaissanceVulnerability ScannersExploitationInformation GatheringNetwork SecurityPenetration Testing
GitHubmr-whiskerss/ssh-terrapin-prefix-truncation-weakness-cve-2023-48795-checker

SSH-Terrapin-Prefix-Truncation-Weakness-CVE-2023-48795-Checker

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share
View Repository
12 months agoNot yet reviewed

terrapin_check.py

A lightweight Python scanner for CVE-2023-48795 — the SSH Terrapin Prefix Truncation vulnerability.

Terrapin is a protocol-level vulnerability in SSH that allows an attacker performing an active MitM to truncate the negotiated extension information, downgrading connection security — most critically disabling ext-info (used for server signature algorithms) and ping (used by OpenSSH's no-auth extension).


📋 Table of Contents

  • About the Vulnerability
  • How It Works
  • Requirements
  • Installation
  • Usage
  • Output
  • Vulnerable Conditions
  • Remediation
  • Disclaimer

About the Vulnerability

FieldDetail
CVECVE-2023-48795
CVSS5.9 (Medium)
TypeSSH Protocol — Prefix Truncation / Integrity Bypass
DisclosureDecember 2023
AffectedOpenSSH < 9.6, PuTTY < 0.80, libssh < 0.10.6, and many others
Referencesterrapin-attack.com

The vulnerability exists because certain SSH cipher/MAC combinations — specifically chacha20-poly1305 and CBC-mode ciphers with Encrypt-then-MAC — allow an active MitM attacker to inject and remove SSH sequence numbers during the handshake, truncating the negotiated extension data without detection.

The fix introduced a strict KEX extension (kex-strict-*[email protected]) that both client and server must advertise to be immune.


How It Works

The script performs a passive banner grab and KEXINIT parse only — no full SSH handshake, no authentication, no exploitation:

  1. Opens a TCP connection to the target SSH port
  2. Exchanges SSH identification banners
  3. Receives and parses the server's SSH_MSG_KEXINIT packet
  4. Inspects the advertised algorithm name-lists for vulnerable combinations
  5. Checks for the strict-KEX mitigation extension
  6. Closes the connection

Because the check occurs entirely within the key exchange phase, it is non-intrusive and leaves no meaningful trace beyond a normal TCP connection attempt.


Requirements

  • Python 3.8+
  • No third-party dependencies — stdlib only (socket, struct, argparse, concurrent.futures)

Installation

root@kitploit:~
git clone https://github.com/Mr-Whiskerss/terrapin_check
cd terrapin_check
chmod +x terrapin_check.py

Usage

Single host

root@kitploit:~
python3 terrapin_check.py <host> [port]
root@kitploit:~
python3 terrapin_check.py 192.168.1.10
python3 terrapin_check.py 192.168.1.10 2222

Bulk scan from file

One target per line — accepts host or host:port format.

root@kitploit:~
python3 terrapin_check.py -f targets.txt
python3 terrapin_check.py -f targets.txt --threads 20 --timeout 3

Summary-only output (useful for large scans)

root@kitploit:~
python3 terrapin_check.py -f targets.txt --summary

Full options

root@kitploit:~
usage: terrapin_check.py [-h] [-f FILE] [-p PORT] [--threads THREADS] [--timeout TIMEOUT] [--summary] [host] [port]

positional arguments:
  host                  Target host
  port                  SSH port (default: 22)

options:
  -h, --help            Show this help message and exit
  -f, --file FILE       File containing hosts (host or host:port per line)
  -p, --port-flag PORT  Default port when using -f (default: 22)
  --threads THREADS     Concurrent threads for bulk scan (default: 10)
  --timeout TIMEOUT     Socket timeout in seconds (default: 5.0)
  --summary             Print one-line summary per host only

Exit codes

CodeMeaning
0No vulnerable hosts found
1One or more vulnerable hosts detected

This allows the script to be used cleanly in pipelines and automated workflows.


Output

Single host (detailed)

root@kitploit:~
────────────────────────────────────────────────────────────
  Target : 192.168.1.10:22
  Banner : SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
  Status : VULNERABLE

  Strict-KEX : No
  ✗ ChaCha20-Poly1305 advertised → prefix-truncation possible
  ✗ CBC+ETM combination advertised
      CBC ciphers : aes128-cbc, aes256-cbc
      ETM MACs    : [email protected], [email protected]

  KEX algorithms:
    curve25519-sha256
    ecdh-sha2-nistp256
    diffie-hellman-group14-sha256
────────────────────────────────────────────────────────────

Bulk scan (summary)

root@kitploit:~
  [VULN]  192.168.1.10:22                  VULNERABLE (CVE-2023-48795)
  [SAFE]  192.168.1.20:22                  Not vulnerable
  [MIT]   192.168.1.30:22                  Algorithms present but strict-KEX mitigates
  [?]     192.168.1.99:22                  ERROR: Connection refused

Vulnerable Conditions

The script flags a host as VULNERABLE if either of the following is true, and the strict-KEX extension is not advertised:

1. ChaCha20-Poly1305

The server advertises [email protected] in either encryption direction.

2. CBC cipher + ETM MAC combination

The server advertises any CBC-mode cipher and any ETM MAC together:

CBC ciphers checked: aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, idea-cbc, arcfour, arcfour128, arcfour256, [email protected]

ETM MACs checked: [email protected], [email protected], [email protected], [email protected], and variants

Mitigation — Strict KEX

If the server advertises [email protected] in its KEX algorithm list, the connection is protected regardless of which ciphers and MACs are offered. The script will report MITIGATED rather than VULNERABLE in this case.


Remediation

Action
root@kitploit:~
# /etc/ssh/sshd_config
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
MACs hmac-sha2-256,hmac-sha2-512

Algorithm removal reduces cipher agility. Upgrading is always the preferred remediation.


Disclaimer

This tool is intended for authorised security assessments only. Only use it against systems you own or have explicit written permission to test. The author accepts no liability for misuse.


Part of the Mr-Whiskerss pentesting toolkit.

Download Tool
Detail
Upgrade OpenSSHUpgrade to ≥ 9.6 on both client and server. Strict KEX is enabled by default.
Patch other implementationsPuTTY ≥ 0.80, libssh ≥ 0.10.6, Paramiko ≥ 3.4.0, AsyncSSH ≥ 2.14.2
Remove vulnerable algorithmsIf upgrading is not immediately possible, remove chacha20-poly1305 and CBC ciphers + ETM MACs from sshd_config: