This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
name: Deploy drhider
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: linux_amd64
|
||||||
|
steps:
|
||||||
|
- name: Test runner
|
||||||
|
run: |
|
||||||
|
echo "OK"
|
||||||
|
python3 --version
|
||||||
+96
@@ -0,0 +1,96 @@
|
|||||||
|
import os
|
||||||
|
import io
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import zipfile
|
||||||
|
from flask import Flask, render_template, request, send_file, jsonify
|
||||||
|
|
||||||
|
# Добавляем корень в sys.path чтобы import drhider работал
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
from drhider import obfuscate_files
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
VERSION = "1.0.0"
|
||||||
|
|
||||||
|
MAX_BODY = 200 * 1024 * 1024 # 200 MB
|
||||||
|
|
||||||
|
|
||||||
|
class LLMClient:
|
||||||
|
"""LLM-клиент для drhider (обнаружение компаний/ФИО)."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
import httpx
|
||||||
|
self._httpx = httpx
|
||||||
|
|
||||||
|
def complete(self, prompt: str) -> str:
|
||||||
|
key = os.environ.get("LLM_KEY") or os.environ.get("LLM_API_KEY", "")
|
||||||
|
r = self._httpx.post(
|
||||||
|
os.environ.get("LLM_URL", "https://api.aillm.ru/v1/chat/completions"),
|
||||||
|
json={
|
||||||
|
"model": os.environ.get("LLM_MODEL", "gpt-oss-120b"),
|
||||||
|
"messages": [{"role": "user", "content": prompt}],
|
||||||
|
"max_tokens": 8000,
|
||||||
|
"temperature": 0.1,
|
||||||
|
},
|
||||||
|
headers={
|
||||||
|
"Authorization": f"Bearer {key}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
timeout=120,
|
||||||
|
)
|
||||||
|
r.raise_for_status()
|
||||||
|
return r.json()["choices"][0]["message"]["content"]
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def index():
|
||||||
|
return render_template("index.html", version=VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/health")
|
||||||
|
def health():
|
||||||
|
return jsonify({"ok": True, "version": VERSION})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/drhider", methods=["POST"])
|
||||||
|
def api_drhider():
|
||||||
|
"""Обфускация: multipart/form-data с файлами → ZIP."""
|
||||||
|
uploaded = request.files.getlist("files")
|
||||||
|
if not uploaded:
|
||||||
|
return jsonify({"ok": False, "error": "Нет файлов"}), 400
|
||||||
|
|
||||||
|
files = []
|
||||||
|
for f in uploaded:
|
||||||
|
if f.filename:
|
||||||
|
files.append((f.filename, f.read(), f.mimetype or ""))
|
||||||
|
|
||||||
|
if not files:
|
||||||
|
return jsonify({"ok": False, "error": "Нет файлов"}), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
llm = LLMClient()
|
||||||
|
zip_data, _csv = obfuscate_files(files, llm_client=llm)
|
||||||
|
return send_file(
|
||||||
|
io.BytesIO(zip_data),
|
||||||
|
mimetype="application/zip",
|
||||||
|
as_attachment=True,
|
||||||
|
download_name="drhider_output.zip",
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
return jsonify({"ok": False, "error": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import subprocess
|
||||||
|
subprocess.run([
|
||||||
|
sys.executable, "-m", "gunicorn", "app:app",
|
||||||
|
"--bind", "0.0.0.0:5000",
|
||||||
|
"--worker-class", "gevent",
|
||||||
|
"--workers", "1",
|
||||||
|
"--worker-connections", "1000",
|
||||||
|
"--timeout", "300",
|
||||||
|
])
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="120"
|
||||||
|
height="120"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
|
||||||
|
sodipodi:docname="favicon.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="5.6"
|
||||||
|
inkscape:cx="91.428571"
|
||||||
|
inkscape:cy="54.910714"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1027"
|
||||||
|
inkscape:window-x="-8"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
width="120px" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Calque 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-80.000001,-1018.2599)">
|
||||||
|
<path
|
||||||
|
style="fill:#004d00;stroke-width:0.100353;fill-opacity:1"
|
||||||
|
d="m 144.12346,1127.3527 c -14.7384,-15.4935 -17.30029,-23.203 -14.91709,-44.8912 1.78418,-16.2372 1.43961,-18.7434 -3.2949,-23.9623 -4.60141,-5.0725 -4.72472,-5.8285 -0.95017,-5.8285 5.32989,0 5.67331,-6.0284 0.58406,-10.2519 -4.3155,-3.5819 -10.08626,-19.468 -8.64375,-23.7956 1.09412,-3.2824 21.29169,27.0158 23.93661,35.9068 0.94001,3.1601 8.83542,12.1943 17.54536,20.0767 11.55761,10.4589 14.47966,14.331 10.81518,14.331 -2.7616,0 -9.48553,-3.0338 -14.94204,-6.7417 -6.36215,-4.323 -10.81609,-5.8461 -12.41642,-4.2461 -1.60033,1.6005 3.29311,7.7342 13.64167,17.0989 8.87547,8.0322 15.48529,15.2553 14.68853,16.052 -0.79676,0.7967 -7.93147,-2.6984 -15.85488,-7.7667 -16.57177,-10.6009 -17.2489,-10.7849 -17.23587,-4.6824 0.0132,5.7346 7.77953,18.5635 16.5486,27.3327 3.71587,3.7157 6.75613,7.9746 6.75613,9.4643 0,5.5255 -6.27497,2.4016 -16.26102,-8.096 z"
|
||||||
|
id="path3974"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,209 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>DrHider — обфускация документов</title>
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #f5f5f5;
|
||||||
|
--card: #ffffff;
|
||||||
|
--border: #e0e0e0;
|
||||||
|
--text: #1a1a1a;
|
||||||
|
--muted: #888;
|
||||||
|
--brand: #2563eb;
|
||||||
|
--red: #ef4444;
|
||||||
|
--green: #22c55e;
|
||||||
|
}
|
||||||
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
|
body { font: 14px system-ui, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; }
|
||||||
|
.topbar {
|
||||||
|
background: var(--card); border-bottom: 1px solid var(--border);
|
||||||
|
padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 12px;
|
||||||
|
font-weight: 600; font-size: 15px;
|
||||||
|
}
|
||||||
|
.content { max-width: 780px; margin: 28px auto; padding: 0 16px; }
|
||||||
|
.card {
|
||||||
|
background: var(--card); border-radius: 10px;
|
||||||
|
border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.05);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.card-header {
|
||||||
|
background: #fafafa; padding: 10px 16px;
|
||||||
|
font-weight: 600; font-size: 14px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.card-body { padding: 16px; }
|
||||||
|
|
||||||
|
.file-input-wrap { margin-bottom: 12px; }
|
||||||
|
.file-input-wrap input[type="file"] { width: 100%; font-size: 14px; }
|
||||||
|
|
||||||
|
.table-wrap {
|
||||||
|
border: 1px solid var(--border); border-radius: 6px;
|
||||||
|
overflow-y: auto; max-height: 60vh;
|
||||||
|
}
|
||||||
|
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||||
|
th {
|
||||||
|
background: #fafafa; text-transform: uppercase; padding: 6px 10px;
|
||||||
|
border-right: 1px solid var(--border); text-align: left;
|
||||||
|
font-weight: 600; font-size: 11px; color: var(--muted);
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 6px 10px; border-right: 1px solid var(--border);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
tr:hover td { background: rgba(37,99,235,.03); }
|
||||||
|
.name-cell { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.num-cell { text-align: right; white-space: nowrap; }
|
||||||
|
.empty-row td { color: var(--muted); text-align: center; padding: 24px; }
|
||||||
|
|
||||||
|
.remove-btn {
|
||||||
|
cursor: pointer; color: #f87171; background: none; border: none;
|
||||||
|
padding: 2px 6px; font-size: 15px; line-height: 1;
|
||||||
|
}
|
||||||
|
.remove-btn:hover { color: var(--red); }
|
||||||
|
|
||||||
|
.footer-bar {
|
||||||
|
margin-top: 12px; display: flex; justify-content: space-between; align-items: center;
|
||||||
|
font-size: 13px; color: var(--muted);
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
height: 34px; border-radius: 6px; padding: 0 16px; font-size: 13px;
|
||||||
|
font-family: inherit; cursor: pointer; border: 1px solid var(--border);
|
||||||
|
background: var(--card); color: var(--text);
|
||||||
|
display: inline-flex; align-items: center; gap: 6px;
|
||||||
|
}
|
||||||
|
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
|
||||||
|
.btn-primary:hover { opacity: .9; }
|
||||||
|
.btn:disabled { opacity: .4; cursor: not-allowed; }
|
||||||
|
|
||||||
|
.status { margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 13px; display: none; }
|
||||||
|
.status.success { background: #dcfce7; color: #166534; display: block; }
|
||||||
|
.status.error { background: #fef2f2; color: #991b1b; display: block; }
|
||||||
|
.status.info { background: #eff6ff; color: #1e40af; display: block; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="topbar">
|
||||||
|
🛡️ DrHider — обфускация документов
|
||||||
|
<span style="font-weight:400;color:var(--muted);font-size:12px;margin-left:auto;">v{{ version }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Выбор файлов</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p style="color:var(--muted);margin-bottom:12px;font-size:13px;">
|
||||||
|
Загрузите документы (.docx, .xlsx, .pptx, .pdf, .txt).<br>
|
||||||
|
DrHider заменит все персональные данные, реквизиты компаний, телефоны, email на фиктивные значения.
|
||||||
|
</p>
|
||||||
|
<div class="file-input-wrap">
|
||||||
|
<input type="file" id="fileInput" multiple accept=".docx,.xlsx,.pptx,.pdf,.txt,.doc,.xls,.ppt">
|
||||||
|
</div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Имя</th>
|
||||||
|
<th style="width:90px;">Размер</th>
|
||||||
|
<th style="width:40px;"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="fileList">
|
||||||
|
<tr class="empty-row"><td colspan="3">Нет выбранных файлов</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="footer-bar">
|
||||||
|
<span id="fileCount">0 файлов</span>
|
||||||
|
<button class="btn btn-primary" id="uploadBtn" disabled onclick="uploadFiles()">
|
||||||
|
🛡️ Обфусцировать
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="status" id="status"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const fileInput = document.getElementById('fileInput');
|
||||||
|
const fileList = document.getElementById('fileList');
|
||||||
|
const fileCount = document.getElementById('fileCount');
|
||||||
|
const uploadBtn = document.getElementById('uploadBtn');
|
||||||
|
const status = document.getElementById('status');
|
||||||
|
let selectedFiles = [];
|
||||||
|
|
||||||
|
function formatSize(bytes) {
|
||||||
|
if (bytes < 1024) return bytes + ' B';
|
||||||
|
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||||
|
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderFiles() {
|
||||||
|
if (selectedFiles.length === 0) {
|
||||||
|
fileList.innerHTML = '<tr class="empty-row"><td colspan="3">Нет выбранных файлов</td></tr>';
|
||||||
|
} else {
|
||||||
|
fileList.innerHTML = selectedFiles.map((f, i) =>
|
||||||
|
'<tr>' +
|
||||||
|
'<td class="name-cell">' + f.name + '</td>' +
|
||||||
|
'<td class="num-cell">' + formatSize(f.size) + '</td>' +
|
||||||
|
'<td><button class="remove-btn" onclick="removeFile(' + i + ')">✕</button></td>' +
|
||||||
|
'</tr>'
|
||||||
|
).join('');
|
||||||
|
}
|
||||||
|
fileCount.textContent = selectedFiles.length + ' файлов';
|
||||||
|
uploadBtn.disabled = selectedFiles.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFile(i) {
|
||||||
|
selectedFiles.splice(i, 1);
|
||||||
|
// Пересоздаём FileList через DataTransfer
|
||||||
|
const dt = new DataTransfer();
|
||||||
|
selectedFiles.forEach(f => dt.items.add(f));
|
||||||
|
fileInput.files = dt.files;
|
||||||
|
renderFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
fileInput.addEventListener('change', () => {
|
||||||
|
selectedFiles = Array.from(fileInput.files);
|
||||||
|
renderFiles();
|
||||||
|
});
|
||||||
|
|
||||||
|
function uploadFiles() {
|
||||||
|
if (selectedFiles.length === 0) return;
|
||||||
|
status.className = 'status info';
|
||||||
|
status.textContent = 'Обфускация...';
|
||||||
|
uploadBtn.disabled = true;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
selectedFiles.forEach(f => formData.append('files', f));
|
||||||
|
|
||||||
|
fetch('/api/drhider', { method: 'POST', body: formData })
|
||||||
|
.then(res => {
|
||||||
|
if (!res.ok) return res.json().then(e => { throw new Error(e.error || 'Ошибка сервера'); });
|
||||||
|
const disp = res.headers.get('Content-Disposition') || '';
|
||||||
|
const nameMatch = disp.match(/filename="?(.+?)"?$/);
|
||||||
|
const filename = nameMatch ? nameMatch[1] : 'drhider_output.zip';
|
||||||
|
return res.blob().then(blob => ({ blob, filename }));
|
||||||
|
})
|
||||||
|
.then(({ blob, filename }) => {
|
||||||
|
status.className = 'status success';
|
||||||
|
status.textContent = 'Готово! Скачивание началось.';
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
uploadBtn.disabled = false;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
status.className = 'status error';
|
||||||
|
status.textContent = 'Ошибка: ' + err.message;
|
||||||
|
uploadBtn.disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user