Exploit databaseDownload repository ZIP
GH-496697cfcb1532cc7ab8d2db45011131
xun404/spd_dump-macos
Sources for CVE-2022-38694
14 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
xun404/spd_dump-macosRevision 066e14b1c065
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scripts/ttyd_client.py
Python · 2,292 bytes#!/usr/bin/env python3
"""Minimal headless client for tsl0922/ttyd web terminals (protocol notes).
ttyd websocket protocol (reverse-engineered from its bundled frontend):
* connect with subprotocol "ttyd" to ws://host:port/ws
* FIRST client frame = RAW JSON (no opcode prefix):
{"AuthToken": <token>, "columns": N, "rows": M}
token comes from GET /token (JSON {"token": "..."}); omit when ttyd
runs without credentials
* subsequent frames: '0' + text = terminal input
* server frames: '0' + bytes = terminal output
Frames may arrive as binary; always handle bytes and str.
If the server-side command is a login wrapper, drive it before commands
(see login() hook below).
Usage:
ttyd_client.py run "id; uname -a" # one-shot
ttyd_client.py prog /tmp/ui.xml # dump output 10s
"""
import json, sys, time, urllib.request
import websocket # pip install websocket-client
URL = "http://127.0.0.1:1146" # or adb forward tcp:1146 tcp:1146
LOGIN_PASSWORD = None # set if the server wraps a login.sh
def connect():
tok = json.load(urllib.request.urlopen(URL + "/token", timeout=5))["token"]
ws = websocket.create_connection(URL.replace("http", "ws") + "/ws",
timeout=5, subprotocols=["tty"])
ws.settimeout(1)
ws.send(json.dumps({"AuthToken": tok, "columns": 200, "rows": 50}).encode())
return ws
def drain(ws, t):
out = b""; end = time.time() + t
while time.time() < end:
try:
m = ws.recv()
except Exception:
continue
if isinstance(m, str):
m = m.encode()
if m[:1] == b'0':
out += m[1:]
return out.decode(errors="replace")
def run(cmd, wait=8):
ws = connect()
drain(ws, 2.5) # banner / password prompt
if LOGIN_PASSWORD:
ws.send(('0' + LOGIN_PASSWORD + '\n').encode())
drain(ws, 2.0)
ws.send(('0' + cmd + '\n').encode())
out = drain(ws, wait)
try: ws.close()
except Exception: pass
return out
if __name__ == "__main__":
if sys.argv[1] == "run":
print(run(sys.argv[2], float(sys.argv[3]) if len(sys.argv) > 3 else 8))
else:
ws = connect(); print(drain(ws, 10))