fix: DrHider via VM — v1.0/v1.0.193
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-06-29 17:32:45 +04:00
parent 11d1398bad
commit a075d7f820
2 changed files with 12 additions and 35 deletions
+11 -34
View File
@@ -215,49 +215,25 @@ class Handler(BaseHTTPRequestHandler):
# ── POST /api/drhider ────────────────────────────────────────────────
def _handle_drhider(self):
"""Обфускация: multipart files → LLM-NER → ZIP."""
"""Обфускация: JSON {files: [{name, data: base64}]} → ZIP."""
from services.drhider import obfuscate_files
import base64
length = int(self.headers.get("Content-Length", 0))
raw = self.rfile.read(length)
ctype = self.headers.get("Content-Type", "")
# Парсим multipart вручную
import cgi, re
_, params = cgi.parse_header(ctype)
boundary = params.get("boundary", "").encode()
if not boundary:
self._json({"ok": False, "error": "No multipart boundary"}, 400)
body = json.loads(raw) if raw else {}
raw_files = body.get("files", [])
if not raw_files:
self._json({"ok": False, "error": "No files"}, 400)
return
files = []
# Разбиваем по boundary
parts = raw.split(b"--" + boundary)
for part in parts:
if b"Content-Disposition" not in part:
continue
try:
header_end = part.index(b"\r\n\r\n")
except ValueError:
continue
headers_raw = part[:header_end].decode("latin-1", errors="replace")
content = part[header_end + 4:]
if content.endswith(b"\r\n"):
content = content[:-2]
# Извлечь filename
m = re.search(r'filename="([^"]*)"', headers_raw)
if not m:
continue
fname = m.group(1)
if not fname:
continue
files.append((fname, content, ""))
for f in raw_files:
name = f.get("name", "unnamed")
data = base64.b64decode(f.get("data", ""))
files.append((name, data, f.get("type", "")))
if not files:
self._json({"ok": False, "error": "Нет файлов"}, 400)
return
# LLM-клиент (совместимый с drhider.LLMClient протоколом: complete(prompt)->str)
class _VMLLM:
def complete(self, prompt):
import httpx
@@ -279,6 +255,7 @@ class Handler(BaseHTTPRequestHandler):
self.send_header("Content-Type", "application/zip")
self.send_header("Content-Disposition", 'attachment; filename="drhider_output.zip"')
self.send_header("Content-Length", str(len(zip_data)))
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
self.wfile.write(zip_data)
except Exception as e: