Exploit databaseDownload repository ZIP
GH-7bb6db2dcaefafa9ad105ede8f7e2591
avi99999/sshhole-scanner
Sources for CVE-2026-123158
29 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files6
avi99999/sshhole-scannerRevision 3b0e902876f0
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
test_sshhole_scan.py
Python · 3,885 bytes"""Offline tests: build fake Alpine/Debian filesystems and run the scanner with --root."""
import os
import subprocess
import sys
import tempfile
import unittest
HERE = os.path.dirname(os.path.abspath(__file__))
SCANNER = os.path.join(HERE, "sshhole_scan.py")
PASSWD = """root:x:0:0:root:/root:/bin/sh
alpine:x:1000:1000::/home/alpine:/bin/sh
bob:x:1001:1001::/home/bob:/bin/ash
svc:x:1002:1002::/var/svc:/sbin/nologin
"""
SHADOW_VULN = """root:*:20000:0:::::
alpine:*:20000:0:99999:7:::
bob:$6$abcdefgh$Zm9vYmFy:20000:0:99999:7:::
svc:!:20000:0:99999:7:::
"""
def build(root, *, libc="musl", alpine="3.22.3", pkg="10.0_p1-r10", shadow=SHADOW_VULN,
sshd_config="", pam_pkg=False, logs=""):
def w(path, data, mode="w"):
full = os.path.join(root, path.lstrip("/"))
os.makedirs(os.path.dirname(full), exist_ok=True)
with open(full, mode) as f:
f.write(data)
loader = b"/lib/ld-musl-x86_64.so.1" if libc == "musl" else b"/lib64/ld-linux-x86-64.so.2"
w("/usr/sbin/sshd", b"\x7fELF" + b"\0" * 60 + loader + b"\0libcrypto.so.3\0OpenSSH_10.0p1\0", "wb")
w("/etc/passwd", PASSWD)
w("/etc/shadow", shadow)
w("/etc/ssh/sshd_config", "Include /etc/ssh/sshd_config.d/*.conf\n" + sshd_config)
if alpine:
w("/etc/alpine-release", alpine + "\n")
name = "openssh-server-pam" if pam_pkg else "openssh-server"
w("/lib/apk/db/installed", f"P:musl\nV:1.2.5-r9\n\nP:{name}\nV:{pkg}\n\n")
if logs:
w("/var/log/messages", logs)
def scan(root):
r = subprocess.run([sys.executable, "-I", SCANNER, "--root", root, "--no-color"],
capture_output=True, text=True)
return r.returncode, r.stdout
class T(unittest.TestCase):
def run_case(self, expect_rc, expect_text=None, **kw):
with tempfile.TemporaryDirectory() as d:
build(d, **kw)
rc, out = scan(d)
self.assertEqual(rc, expect_rc, out)
if expect_text:
self.assertIn(expect_text, out)
return out
def test_vulnerable_alpine(self):
out = self.run_case(1, "VULNERABLE")
self.assertIn("alpine", out)
self.assertIn("root (blocked)", out) # PermitRootLogin default blocks root
def test_root_reachable_with_permitrootlogin_yes(self):
out = self.run_case(1, sshd_config="PermitRootLogin yes\n")
self.assertIn("logs in as: root, alpine", out)
def test_patched_package(self):
self.run_case(0, "contains the fix", pkg="10.0_p1-r11")
def test_password_auth_disabled_via_include(self):
with tempfile.TemporaryDirectory() as d:
build(d)
p = os.path.join(d, "etc/ssh/sshd_config.d")
os.makedirs(p)
with open(os.path.join(p, "00-no-passwords.conf"), "w") as f:
f.write("PasswordAuthentication no\n")
rc, out = scan(d)
self.assertEqual(rc, 0, out)
self.assertIn("mitigated", out)
def test_pam(self):
self.run_case(0, "PAM", pam_pkg=True, sshd_config="UsePAM yes\n")
def test_glibc(self):
self.run_case(0, "glibc", libc="glibc", alpine=None)
def test_no_salt_source(self):
self.run_case(0, "no $5$/$6$ hash", shadow="root:*:1::::::\nalpine:*:1::::::\n")
def test_no_star_accounts(self):
self.run_case(2, "POTENTIALLY", shadow="root:!:1::::::\nbob:$6$x$y:1::::::\n")
def test_eol_branch(self):
self.run_case(1, "EOL", alpine="3.15.11", pkg="8.8_p1-r1")
def test_log_ioc(self):
out = self.run_case(1, "LIKELY COMPROMISE",
logs="Nov 9 03:12:44 host sshd[812]: Accepted password for alpine "
"from 203.0.113.7 port 51522 ssh2\n")
self.assertIn("203.0.113.7", out)
if __name__ == "__main__":
unittest.main(verbosity=2)