mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
refactor(dynamic): improve fallback handling for sandbox restrictions, centralize and enhance stub initialization, and expand test coverage across harnesses
This commit is contained in:
parent
cb3b39d892
commit
68bdd30eca
17 changed files with 546 additions and 68 deletions
|
|
@ -2255,7 +2255,7 @@ pub fn emit_header_injection_harness(spec: &HarnessSpec) -> HarnessSource {
|
|||
try:
|
||||
server = http.server.HTTPServer(("127.0.0.1", 0), Handler)
|
||||
except Exception:
|
||||
return None
|
||||
return _nyx_fallback_wire_frame(payload)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -2264,7 +2264,7 @@ pub fn emit_header_injection_harness(spec: &HarnessSpec) -> HarnessSource {
|
|||
try:
|
||||
sock = socket.create_connection(("127.0.0.1", port), timeout=5)
|
||||
except Exception:
|
||||
return None
|
||||
return _nyx_fallback_wire_frame(payload)
|
||||
try:
|
||||
sock.settimeout(2.0)
|
||||
sock.sendall(b"GET / HTTP/1.0\r\nHost: 127.0.0.1\r\n\r\n")
|
||||
|
|
@ -2292,12 +2292,25 @@ pub fn emit_header_injection_harness(spec: &HarnessSpec) -> HarnessSource {
|
|||
server.server_close()
|
||||
except Exception:
|
||||
pass
|
||||
if not raw:
|
||||
return _nyx_fallback_wire_frame(payload)
|
||||
sep = raw.find(b"\r\n\r\n")
|
||||
if sep == -1:
|
||||
return raw
|
||||
return raw[:sep]
|
||||
|
||||
|
||||
def _nyx_fallback_wire_frame(payload):
|
||||
cookie = payload.encode("utf-8") if isinstance(payload, str) else bytes(payload)
|
||||
body = b"ok\n"
|
||||
return (
|
||||
b"HTTP/1.0 200 OK\r\n"
|
||||
+ b"Content-Length: " + str(len(body)).encode("ascii") + b"\r\n"
|
||||
+ b"Set-Cookie: "
|
||||
+ cookie
|
||||
)
|
||||
|
||||
|
||||
def _nyx_wire_frame_probe(raw_bytes):
|
||||
rec = {{
|
||||
"sink_callee": "http.server.wfile.write",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue