feat(v5): enhanced Kali worker, user registration, login UI overhaul

- Dockerfile.kali: add Ghidra 11.2.1 for headless RE analysis, evil-winrm,
  awscli, kubectl, mitmproxy, gdb/ltrace/strace, aircrack-ng, JDK 17
- server.js: add /api/auth/register endpoint (first user = admin),
  fix auth status response keys for login page consistency
- login.html: redesigned login with registration flow, improved
  glassmorphism styling, better error handling and animations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Joas A SantosandClaude Opus 4.6 committed 2026-12-04 10:22:34 -03:00
1 parent eabfffe4c1
commit 796447ab89
3 files changed
+534 -237

No files matched your search

+23 -6
View File
@@ -22,20 +22,27 @@ RUN set -eux; \
# Recon & OSINT
whois fierce dnsenum dnsrecon amass subfinder \
# Web proxying
proxychains4 \
proxychains4 mitmproxy \
# Binary analysis
binwalk radare2 \
binwalk radare2 gdb ltrace strace \
# Scripting
python3 python3-pip python3-venv ruby perl \
# SSL/TLS
sslscan sslyze testssl.sh \
# SMB/Windows
smbclient enum4linux crackmapexec \
smbclient enum4linux crackmapexec evil-winrm \
# Active Directory
bloodhound impacket-scripts \
# Cloud tools
awscli \
# Container / K8s
kubectl 2>/dev/null || true; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# Wireless (if available)
aircrack-ng 2>/dev/null || true; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# Utils
jq git vim-tiny tmux procps bash-completion ca-certificates \
# Nuclei (from GitHub releases if not in repo)
jq git vim-tiny tmux procps bash-completion ca-certificates unzip openjdk-17-jre-headless \
; \
# Install Go-based tools via go install
apt-get install -y --no-install-recommends golang-go 2>/dev/null || true; \
@@ -45,11 +52,21 @@ RUN set -eux; \
# Create unprivileged user
groupadd -g 10001 pentest; \
useradd -u 10001 -g 10001 -d /home/pentest -m -s /bin/bash pentest; \
mkdir -p /workspace /home/pentest/.local; \
mkdir -p /workspace /home/pentest/.local /opt/ghidra; \
chown -R 10001:10001 /workspace /home/pentest; \
# Remove setuid bits
find / -xdev -perm /6000 -type f -exec chmod a-s {} + 2>/dev/null || true
# Install Ghidra for reverse engineering
RUN GHIDRA_VERSION="11.2.1" && \
GHIDRA_DATE="20241105" && \
curl -sL "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_DATE}.zip" -o /tmp/ghidra.zip && \
unzip -q /tmp/ghidra.zip -d /opt/ && \
mv /opt/ghidra_* /opt/ghidra && \
rm /tmp/ghidra.zip && \
ln -s /opt/ghidra/support/analyzeHeadless /usr/local/bin/analyzeHeadless || \
echo "Ghidra download failed — RE will fall back to radare2"
# Install nuclei & httpx (ProjectDiscovery tools)
RUN pip3 install --break-system-packages pipx 2>/dev/null || true; \
# Try installing from kali repos first, fallback to direct download
+495 -230
View File
@@ -6,216 +6,353 @@
<meta name="color-scheme" content="dark" />
<title>NeuroSploit — Login</title>
<link rel="icon" type="image/svg+xml" href="logo.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
--bg:#0a0a0f;--bg2:#12121a;--bg3:#1a1a28;
--surface:#16162a;--surface2:#1e1e35;--surface3:#262645;
--border:#2a2a4a;--border2:#3a3a5a;
--text:#e8e8f0;--text2:#a0a0c0;--text3:#6a6a8a;
--accent:#6366f1;--accent2:#818cf8;--accent3:#4f46e5;
--accent-glow:rgba(99,102,241,.15);--accent-glow2:rgba(99,102,241,.08);
--red:#ef4444;--red-bg:rgba(239,68,68,.1);
--green:#22c55e;--green-bg:rgba(34,197,94,.1);
--radius:12px;--radius-lg:20px;
--bg:#06060c;--bg2:#0c0c18;--bg3:#121225;
--surface:rgba(16,16,36,.88);--surface2:#1a1a38;--surface3:#222250;
--border:rgba(99,102,241,.12);--border2:rgba(99,102,241,.2);--border-focus:rgba(99,102,241,.5);
--text:#eaeaf4;--text2:#a0a0c8;--text3:#5a5a80;
--accent:#6366f1;--accent2:#818cf8;--accent3:#4f46e5;--accent4:#a78bfa;
--accent-glow:rgba(99,102,241,.18);--accent-glow2:rgba(99,102,241,.06);
--red:#f43f5e;--red-bg:rgba(244,63,94,.08);--red-border:rgba(244,63,94,.2);
--green:#10b981;--green-bg:rgba(16,185,129,.08);--green-border:rgba(16,185,129,.2);
--yellow:#eab308;
--radius:12px;--radius-lg:24px;
--mono:'JetBrains Mono',monospace;
}
html,body{height:100%;font-family:'Inter',system-ui,sans-serif;background:var(--bg);color:var(--text);overflow:hidden}
html,body{height:100%;font-family:'Inter',system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);overflow:hidden;-webkit-font-smoothing:antialiased}
/* animated background */
.bg-grid{position:fixed;inset:0;z-index:0;overflow:hidden}
.bg-grid::before{content:'';position:absolute;inset:-50%;
background:repeating-linear-gradient(0deg,transparent,transparent 60px,rgba(99,102,241,.03) 60px,rgba(99,102,241,.03) 61px),
repeating-linear-gradient(90deg,transparent,transparent 60px,rgba(99,102,241,.03) 60px,rgba(99,102,241,.03) 61px);
animation:grid-drift 60s linear infinite}
.bg-grid::after{content:'';position:absolute;inset:0;
background:radial-gradient(ellipse 80% 60% at 50% -20%,rgba(99,102,241,.12),transparent 70%),
radial-gradient(ellipse 60% 40% at 80% 100%,rgba(99,102,241,.06),transparent 60%)}
@keyframes grid-drift{0%{transform:translate(0,0)}100%{transform:translate(60px,60px)}}
/* ── animated mesh gradient background ── */
.bg-mesh{position:fixed;inset:0;z-index:0}
.bg-mesh::before{content:'';position:absolute;inset:0;
background:
radial-gradient(ellipse 100% 80% at 20% 0%,rgba(79,70,229,.14),transparent 50%),
radial-gradient(ellipse 80% 60% at 80% 100%,rgba(139,92,246,.08),transparent 50%),
radial-gradient(ellipse 60% 40% at 50% 50%,rgba(99,102,241,.04),transparent 60%);
animation:mesh-shift 25s ease-in-out infinite alternate}
@keyframes mesh-shift{
0%{filter:hue-rotate(0deg)}
50%{filter:hue-rotate(15deg)}
100%{filter:hue-rotate(-10deg)}
}
/* floating particles */
.particle{position:fixed;border-radius:50%;pointer-events:none;z-index:0}
.p1{width:300px;height:300px;top:-80px;right:-60px;background:radial-gradient(circle,rgba(99,102,241,.08),transparent 70%);animation:float1 20s ease-in-out infinite}
.p2{width:200px;height:200px;bottom:-40px;left:-40px;background:radial-gradient(circle,rgba(139,92,246,.06),transparent 70%);animation:float2 25s ease-in-out infinite}
.p3{width:150px;height:150px;top:40%;left:20%;background:radial-gradient(circle,rgba(99,102,241,.04),transparent 70%);animation:float3 30s ease-in-out infinite}
@keyframes float1{0%,100%{transform:translate(0,0)}50%{transform:translate(-30px,20px)}}
@keyframes float2{0%,100%{transform:translate(0,0)}50%{transform:translate(20px,-30px)}}
@keyframes float3{0%,100%{transform:translate(0,0)}50%{transform:translate(-20px,-20px)}}
/* ── grid overlay ── */
.bg-grid{position:fixed;inset:0;z-index:0;overflow:hidden;opacity:.5}
.bg-grid::before{content:'';position:absolute;inset:-100%;
background:
repeating-linear-gradient(0deg,transparent,transparent 80px,rgba(99,102,241,.025) 80px,rgba(99,102,241,.025) 81px),
repeating-linear-gradient(90deg,transparent,transparent 80px,rgba(99,102,241,.025) 80px,rgba(99,102,241,.025) 81px);
animation:grid-drift 90s linear infinite}
@keyframes grid-drift{0%{transform:translate(0,0)}100%{transform:translate(80px,80px)}}
/* layout */
/* ── particles ── */
.orb{position:fixed;border-radius:50%;pointer-events:none;z-index:0;filter:blur(1px)}
.o1{width:400px;height:400px;top:-120px;right:-100px;background:radial-gradient(circle,rgba(99,102,241,.1),transparent 65%);animation:orb1 22s ease-in-out infinite}
.o2{width:250px;height:250px;bottom:-60px;left:-60px;background:radial-gradient(circle,rgba(167,139,250,.07),transparent 65%);animation:orb2 28s ease-in-out infinite}
.o3{width:180px;height:180px;top:35%;left:15%;background:radial-gradient(circle,rgba(99,102,241,.05),transparent 65%);animation:orb3 35s ease-in-out infinite}
.o4{width:120px;height:120px;bottom:30%;right:20%;background:radial-gradient(circle,rgba(139,92,246,.04),transparent 65%);animation:orb4 18s ease-in-out infinite}
@keyframes orb1{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(-40px,30px) scale(1.1)}}
@keyframes orb2{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(30px,-40px) scale(1.05)}}
@keyframes orb3{0%,100%{transform:translate(0,0)}50%{transform:translate(-25px,-25px)}}
@keyframes orb4{0%,100%{transform:translate(0,0)}50%{transform:translate(15px,20px)}}
/* ── scanline ── */
.scanline{position:fixed;top:0;left:0;right:0;height:2px;z-index:0;
background:linear-gradient(90deg,transparent 20%,rgba(99,102,241,.15) 50%,transparent 80%);
animation:scan 8s linear infinite;opacity:.6}
@keyframes scan{0%{top:0}100%{top:100vh}}
/* ── layout ── */
.login-wrapper{display:flex;align-items:center;justify-content:center;min-height:100vh;position:relative;z-index:1;padding:20px}
.login-card{width:100%;max-width:440px;position:relative}
.login-container{width:100%;max-width:460px;position:relative}
/* glass card */
.card{background:rgba(22,22,42,.85);backdrop-filter:blur(40px) saturate(1.4);
/* ── glass card ── */
.card{background:var(--surface);backdrop-filter:blur(60px) saturate(1.6);
border:1px solid var(--border);border-radius:var(--radius-lg);
padding:48px 40px;position:relative;overflow:hidden;
box-shadow:0 0 0 1px rgba(99,102,241,.05),0 20px 60px rgba(0,0,0,.4),0 0 120px rgba(99,102,241,.03)}
padding:48px 44px;position:relative;overflow:hidden;
box-shadow:0 0 0 1px rgba(99,102,241,.04),0 25px 80px rgba(0,0,0,.5),0 0 160px rgba(99,102,241,.03);
transition:transform .4s cubic-bezier(.4,0,.2,1),opacity .4s ease}
.card::before{content:'';position:absolute;top:0;left:0;right:0;height:1px;
background:linear-gradient(90deg,transparent,rgba(99,102,241,.3),transparent)}
background:linear-gradient(90deg,transparent 10%,rgba(99,102,241,.35) 50%,transparent 90%)}
.card::after{content:'';position:absolute;bottom:0;left:20%;right:20%;height:1px;
background:linear-gradient(90deg,transparent,rgba(99,102,241,.1),transparent)}
.card.exit{transform:scale(.96) translateY(-10px);opacity:0}
/* logo */
/* ── neural network logo SVG ── */
.logo-area{text-align:center;margin-bottom:36px}
.logo-mark{display:inline-flex;align-items:center;justify-content:center;
width:72px;height:72px;border-radius:18px;
background:linear-gradient(135deg,var(--accent3),var(--accent));
box-shadow:0 8px 32px rgba(99,102,241,.3),0 0 0 1px rgba(99,102,241,.2);
margin-bottom:20px;position:relative}
.logo-mark::after{content:'';position:absolute;inset:-2px;border-radius:20px;
background:conic-gradient(from 180deg,transparent,rgba(99,102,241,.3),transparent);
animation:logo-spin 8s linear infinite;z-index:-1}
@keyframes logo-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
.logo-mark svg{width:40px;height:40px;color:#fff}
.logo-title{font-size:26px;font-weight:700;letter-spacing:-.5px;color:var(--text)}
.logo-title span{color:var(--accent2)}
.logo-sub{font-size:13px;color:var(--text3);margin-top:6px;letter-spacing:.3px}
width:76px;height:76px;border-radius:20px;position:relative;
background:linear-gradient(145deg,var(--accent3),var(--accent),var(--accent4));
box-shadow:0 10px 40px rgba(99,102,241,.35),0 0 0 1px rgba(99,102,241,.2)}
.logo-mark::before{content:'';position:absolute;inset:-3px;border-radius:23px;
background:conic-gradient(from 0deg,transparent 0%,rgba(99,102,241,.4) 25%,transparent 50%,rgba(167,139,250,.3) 75%,transparent 100%);
animation:logo-ring 6s linear infinite;z-index:-1}
@keyframes logo-ring{to{transform:rotate(360deg)}}
.logo-mark svg{width:42px;height:42px}
.logo-title{font-size:28px;font-weight:800;letter-spacing:-.6px;margin-top:18px;
background:linear-gradient(135deg,var(--text),var(--accent2));-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
.logo-sub{font-family:var(--mono);font-size:12px;color:var(--text3);margin-top:8px;
letter-spacing:1.5px;text-transform:uppercase;min-height:1.4em}
.cursor-blink{display:inline-block;width:7px;height:14px;background:var(--accent);
margin-left:2px;vertical-align:middle;animation:blink 1s step-end infinite}
@keyframes blink{50%{opacity:0}}
/* form */
/* ── panels (login / register) ── */
.panel{display:none}
.panel.active{display:block;animation:fadeSlide .4s ease}
@keyframes fadeSlide{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
/* ── form ── */
.form-group{margin-bottom:20px;position:relative}
.form-label{display:block;font-size:12px;font-weight:600;color:var(--text2);
letter-spacing:.8px;text-transform:uppercase;margin-bottom:8px}
.form-label{display:block;font-size:11px;font-weight:600;color:var(--text2);
letter-spacing:1px;text-transform:uppercase;margin-bottom:8px}
.input-wrap{position:relative;display:flex;align-items:center}
.input-wrap svg{position:absolute;left:14px;width:18px;height:18px;color:var(--text3);
pointer-events:none;transition:color .2s}
.input-wrap input{width:100%;padding:14px 14px 14px 44px;font-size:15px;font-family:inherit;
.input-wrap .ico{position:absolute;left:14px;width:18px;height:18px;color:var(--text3);
pointer-events:none;transition:color .25s}
.input-wrap input{width:100%;padding:14px 14px 14px 44px;font-size:14px;font-family:inherit;
background:var(--bg2);border:1.5px solid var(--border);border-radius:var(--radius);
color:var(--text);outline:none;transition:all .25s ease}
.input-wrap input::placeholder{color:var(--text3)}
.input-wrap input:focus{border-color:var(--accent);background:var(--bg);
box-shadow:0 0 0 3px var(--accent-glow),0 0 20px var(--accent-glow2)}
.input-wrap input:focus ~ svg,.input-wrap input:focus + svg{color:var(--accent2)}
.input-wrap input::placeholder{color:var(--text3);font-size:13px}
.input-wrap input:focus{border-color:var(--border-focus);background:var(--bg);
box-shadow:0 0 0 3px var(--accent-glow),0 0 24px var(--accent-glow2)}
.input-wrap input:focus ~ .ico{color:var(--accent2)}
.input-wrap .toggle-pw{position:absolute;right:12px;background:none;border:none;
color:var(--text3);cursor:pointer;padding:4px;border-radius:6px;transition:color .2s}
color:var(--text3);cursor:pointer;padding:4px;border-radius:6px;transition:color .2s;line-height:0}
.input-wrap .toggle-pw:hover{color:var(--text)}
/* error */
.error-box{display:none;align-items:center;gap:8px;padding:12px 16px;
background:var(--red-bg);border:1px solid rgba(239,68,68,.2);
border-radius:var(--radius);margin-bottom:20px;font-size:13px;color:#fca5a5}
.error-box.show{display:flex}
.error-box svg{flex-shrink:0;width:16px;height:16px;color:var(--red)}
/* ── remember me ── */
.form-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:24px}
.remember{display:flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;color:var(--text2)}
.remember input{appearance:none;-webkit-appearance:none;width:16px;height:16px;border:1.5px solid var(--border2);
border-radius:4px;background:var(--bg2);cursor:pointer;position:relative;transition:all .2s}
.remember input:checked{background:var(--accent);border-color:var(--accent)}
.remember input:checked::after{content:'';position:absolute;top:2px;left:5px;width:4px;height:8px;
border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}
/* submit */
.btn-login{width:100%;padding:15px;font-size:15px;font-weight:600;font-family:inherit;
color:#fff;border:none;border-radius:var(--radius);cursor:pointer;position:relative;
background:linear-gradient(135deg,var(--accent3),var(--accent));
box-shadow:0 4px 16px rgba(99,102,241,.3);
transition:all .3s ease;overflow:hidden;letter-spacing:.3px}
.btn-login:hover{transform:translateY(-1px);
box-shadow:0 8px 32px rgba(99,102,241,.4);filter:brightness(1.1)}
.btn-login:active{transform:translateY(0);box-shadow:0 2px 8px rgba(99,102,241,.3)}
.btn-login:disabled{opacity:.6;cursor:not-allowed;transform:none}
.btn-login::before{content:'';position:absolute;top:0;left:-100%;width:100%;height:100%;
background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);
transition:left .5s}
.btn-login:hover::before{left:100%}
/* ── alert boxes ── */
.alert{display:none;align-items:flex-start;gap:10px;padding:14px 16px;
border-radius:var(--radius);margin-bottom:20px;font-size:13px;line-height:1.5}
.alert.show{display:flex}
.alert svg{flex-shrink:0;width:16px;height:16px;margin-top:2px}
.alert-error{background:var(--red-bg);border:1px solid var(--red-border);color:#fda4af}
.alert-error svg{color:var(--red)}
.alert-success{background:var(--green-bg);border:1px solid var(--green-border);color:#6ee7b7}
.alert-success svg{color:var(--green)}
.alert-info{background:rgba(99,102,241,.06);border:1px solid rgba(99,102,241,.15);color:var(--accent2)}
.alert-info svg{color:var(--accent)}
/* spinner inside button */
.btn-login .spinner{display:none;width:20px;height:20px;border:2.5px solid rgba(255,255,255,.3);
/* ── generated password box ── */
.gen-pw{display:flex;align-items:center;gap:8px;margin:12px 0;padding:12px 14px;
background:var(--bg);border:1.5px solid var(--border2);border-radius:var(--radius);
font-family:var(--mono);font-size:14px;color:var(--accent2);word-break:break-all}
.gen-pw .copy-btn{flex-shrink:0;background:none;border:1px solid var(--border2);border-radius:8px;
color:var(--text2);cursor:pointer;padding:6px 10px;font-size:11px;font-family:inherit;
font-weight:600;text-transform:uppercase;letter-spacing:.5px;transition:all .2s}
.gen-pw .copy-btn:hover{background:var(--accent-glow);border-color:var(--accent);color:var(--accent2)}
.gen-pw .copy-btn.copied{background:var(--green-bg);border-color:var(--green);color:var(--green)}
/* ── buttons ── */
.btn{width:100%;padding:15px;font-size:14px;font-weight:600;font-family:inherit;
border:none;border-radius:var(--radius);cursor:pointer;position:relative;
transition:all .3s ease;overflow:hidden;letter-spacing:.4px}
.btn-primary{color:#fff;
background:linear-gradient(135deg,var(--accent3),var(--accent),var(--accent4));
box-shadow:0 4px 20px rgba(99,102,241,.3)}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 8px 36px rgba(99,102,241,.4);filter:brightness(1.08)}
.btn-primary:active{transform:translateY(0);box-shadow:0 2px 10px rgba(99,102,241,.3)}
.btn-primary:disabled{opacity:.5;cursor:not-allowed;transform:none;filter:none}
.btn-primary::before{content:'';position:absolute;top:0;left:-100%;width:100%;height:100%;
background:linear-gradient(90deg,transparent,rgba(255,255,255,.08),transparent);transition:left .6s}
.btn-primary:hover::before{left:100%}
.btn-secondary{color:var(--text2);background:var(--bg2);border:1.5px solid var(--border);margin-top:12px}
.btn-secondary:hover{border-color:var(--border2);color:var(--text);background:var(--bg3)}
.btn .spinner{display:none;width:20px;height:20px;border:2.5px solid rgba(255,255,255,.25);
border-top-color:#fff;border-radius:50%;animation:spin .6s linear infinite;margin:0 auto}
.btn-login.loading .btn-text{display:none}
.btn-login.loading .spinner{display:block}
.btn.loading .btn-label{display:none}
.btn.loading .spinner{display:block}
@keyframes spin{to{transform:rotate(360deg)}}
/* footer */
.login-footer{text-align:center;margin-top:28px;font-size:12px;color:var(--text3)}
.login-footer a{color:var(--accent2);text-decoration:none}
.login-footer a:hover{text-decoration:underline}
/* ── switch link ── */
.switch-link{text-align:center;margin-top:24px;font-size:13px;color:var(--text3)}
.switch-link a{color:var(--accent2);text-decoration:none;font-weight:500;cursor:pointer}
.switch-link a:hover{text-decoration:underline}
/* first-login banner */
.first-login{display:none;margin-bottom:20px;padding:14px 16px;
background:var(--green-bg);border:1px solid rgba(34,197,94,.2);
border-radius:var(--radius);font-size:13px;color:#86efac}
.first-login.show{display:block}
.first-login strong{color:#22c55e}
.first-login code{font-family:'JetBrains Mono',monospace;background:rgba(34,197,94,.15);
padding:2px 6px;border-radius:4px;font-size:12px}
/* ── footer ── */
.login-footer{display:flex;align-items:center;justify-content:center;gap:8px;
margin-top:28px;font-size:11px;color:var(--text3);letter-spacing:.3px}
.login-footer .dot{width:5px;height:5px;border-radius:50%;background:var(--green);
box-shadow:0 0 8px rgba(16,185,129,.5);animation:pulse-dot 2s ease-in-out infinite}
@keyframes pulse-dot{50%{box-shadow:0 0 12px rgba(16,185,129,.8)}}
/* session info */
.session-info{display:flex;align-items:center;gap:6px;margin-top:12px;
font-size:11px;color:var(--text3)}
.session-info .dot{width:6px;height:6px;border-radius:50%;background:var(--green);
box-shadow:0 0 8px rgba(34,197,94,.5)}
/* ── password strength ── */
.pw-strength{margin-top:8px;display:flex;gap:4px;height:3px}
.pw-strength .bar{flex:1;border-radius:2px;background:var(--border);transition:background .3s}
.pw-strength .bar.weak{background:var(--red)}
.pw-strength .bar.medium{background:var(--yellow)}
.pw-strength .bar.strong{background:var(--green)}
/* responsive */
/* ── responsive ── */
@media(max-width:480px){
.card{padding:36px 24px;border-radius:16px}
.logo-mark{width:60px;height:60px;border-radius:14px}
.logo-title{font-size:22px}
.card{padding:36px 24px;border-radius:18px}
.logo-mark{width:64px;height:64px;border-radius:16px}
.logo-title{font-size:24px}
.gen-pw{font-size:12px;padding:10px 12px}
}
/* keyboard nav */
.card:focus-within{box-shadow:0 0 0 1px rgba(99,102,241,.1),0 20px 60px rgba(0,0,0,.4),0 0 120px rgba(99,102,241,.05)}
/* ── shake animation ── */
@keyframes shake{0%,100%{transform:translateX(0)}15%,45%,75%{transform:translateX(-8px)}30%,60%,90%{transform:translateX(8px)}}
</style>
</head>
<body>
<div class="bg-mesh"></div>
<div class="bg-grid"></div>
<div class="particle p1"></div>
<div class="particle p2"></div>
<div class="particle p3"></div>
<div class="orb o1"></div>
<div class="orb o2"></div>
<div class="orb o3"></div>
<div class="orb o4"></div>
<div class="scanline"></div>
<div class="login-wrapper">
<div class="login-card">
<div class="card">
<div class="login-container">
<div class="card" id="card">
<!-- Logo -->
<div class="logo-area">
<div class="logo-mark">
<svg viewBox="0 0 48 48" fill="none"><path d="M9 39V11l20 20V11" stroke="currentColor" stroke-width="5.5" stroke-linecap="square"/><path d="M39 9V37" stroke="currentColor" stroke-width="5.5" stroke-linecap="square"/><path d="M41 7L18 41" stroke="#a5b4fc" stroke-width="2.6" stroke-linecap="round"/></svg>
<svg viewBox="0 0 48 48" fill="none">
<!-- neural network icon -->
<circle cx="24" cy="8" r="3" fill="rgba(255,255,255,.9)"/>
<circle cx="12" cy="20" r="2.5" fill="rgba(255,255,255,.7)"/>
<circle cx="36" cy="20" r="2.5" fill="rgba(255,255,255,.7)"/>
<circle cx="8" cy="34" r="2" fill="rgba(255,255,255,.5)"/>
<circle cx="20" cy="34" r="2" fill="rgba(255,255,255,.5)"/>
<circle cx="28" cy="34" r="2" fill="rgba(255,255,255,.5)"/>
<circle cx="40" cy="34" r="2" fill="rgba(255,255,255,.5)"/>
<circle cx="16" cy="44" r="1.5" fill="rgba(255,255,255,.35)"/>
<circle cx="32" cy="44" r="1.5" fill="rgba(255,255,255,.35)"/>
<line x1="24" y1="8" x2="12" y2="20" stroke="rgba(255,255,255,.3)" stroke-width="1"/>
<line x1="24" y1="8" x2="36" y2="20" stroke="rgba(255,255,255,.3)" stroke-width="1"/>
<line x1="12" y1="20" x2="8" y2="34" stroke="rgba(255,255,255,.2)" stroke-width=".8"/>
<line x1="12" y1="20" x2="20" y2="34" stroke="rgba(255,255,255,.2)" stroke-width=".8"/>
<line x1="36" y1="20" x2="28" y2="34" stroke="rgba(255,255,255,.2)" stroke-width=".8"/>
<line x1="36" y1="20" x2="40" y2="34" stroke="rgba(255,255,255,.2)" stroke-width=".8"/>
<line x1="12" y1="20" x2="28" y2="34" stroke="rgba(255,255,255,.1)" stroke-width=".6"/>
<line x1="36" y1="20" x2="20" y2="34" stroke="rgba(255,255,255,.1)" stroke-width=".6"/>
<line x1="8" y1="34" x2="16" y2="44" stroke="rgba(255,255,255,.15)" stroke-width=".6"/>
<line x1="20" y1="34" x2="16" y2="44" stroke="rgba(255,255,255,.15)" stroke-width=".6"/>
<line x1="28" y1="34" x2="32" y2="44" stroke="rgba(255,255,255,.15)" stroke-width=".6"/>
<line x1="40" y1="34" x2="32" y2="44" stroke="rgba(255,255,255,.15)" stroke-width=".6"/>
</svg>
</div>
<div class="logo-title">Neuro<span>Sploit</span></div>
<div class="logo-sub">Autonomous Pentest Engine</div>
<div class="logo-title">NeuroSploit</div>
<div class="logo-sub" id="tagline"><span class="cursor-blink"></span></div>
</div>
<!-- First login banner (shown when default creds are active) -->
<div class="first-login" id="firstLogin">
<strong>First login</strong> — default credentials generated.<br>
Username: <code>neurosploit</code> &nbsp;|&nbsp; Password: check <code>.env</code><br>
Change your password after login.
</div>
<!-- Error -->
<div class="error-box" id="errorBox">
<svg viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M8 4.5v4M8 10.5v.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
<span id="errorText">Invalid credentials</span>
</div>
<!-- Form -->
<form id="loginForm" autocomplete="on">
<div class="form-group">
<label class="form-label" for="username">Username</label>
<div class="input-wrap">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<input type="text" id="username" name="username" placeholder="neurosploit" autocomplete="username" required autofocus>
<!-- ── LOGIN PANEL ── -->
<div class="panel active" id="panelLogin">
<div class="alert alert-info" id="firstLoginBanner">
<svg viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M8 7v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="8" cy="4.5" r=".8" fill="currentColor"/></svg>
<div>
<strong style="color:var(--accent)">First login</strong> &mdash; default credentials have been generated.<br>
User: <code style="font-family:var(--mono);color:var(--accent2)">neurosploit</code> &nbsp;&middot;&nbsp; Password: check <code style="font-family:var(--mono);color:var(--accent2)">.env</code>
</div>
</div>
<div class="form-group">
<label class="form-label" for="password">Password</label>
<div class="input-wrap">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<input type="password" id="password" name="password" placeholder="••••••••••" autocomplete="current-password" required>
<button type="button" class="toggle-pw" id="togglePw" title="Show password" aria-label="Toggle password visibility">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
<div class="alert alert-error" id="loginError">
<svg viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M8 4.5v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="8" cy="11" r=".8" fill="currentColor"/></svg>
<span id="loginErrorText">Invalid credentials</span>
</div>
<form id="loginForm" autocomplete="on">
<div class="form-group">
<label class="form-label" for="loginUser">Username</label>
<div class="input-wrap">
<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<input type="text" id="loginUser" name="username" placeholder="neurosploit" autocomplete="username" required autofocus>
</div>
</div>
<div class="form-group">
<label class="form-label" for="loginPass">Password</label>
<div class="input-wrap">
<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<input type="password" id="loginPass" name="password" placeholder="Enter password" autocomplete="current-password" required>
<button type="button" class="toggle-pw" data-target="loginPass" aria-label="Toggle password visibility">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
</button>
</div>
</div>
<div class="form-row">
<label class="remember"><input type="checkbox" id="rememberMe"> Remember me</label>
</div>
<button type="submit" class="btn btn-primary" id="btnLogin">
<span class="btn-label">Sign In</span>
<div class="spinner"></div>
</button>
</form>
<div class="switch-link">
No account? <a id="goRegister">Create one</a>
</div>
</div>
<!-- ── REGISTER PANEL ── -->
<div class="panel" id="panelRegister">
<div class="alert alert-success" id="regSuccess">
<svg viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M5 8l2 2 4-4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>
<span>Account created! You can now sign in.</span>
</div>
<div class="alert alert-error" id="regError">
<svg viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M8 4.5v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="8" cy="11" r=".8" fill="currentColor"/></svg>
<span id="regErrorText">Registration failed</span>
</div>
<form id="regForm" autocomplete="off">
<div class="form-group">
<label class="form-label" for="regUser">Username</label>
<div class="input-wrap">
<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<input type="text" id="regUser" name="username" placeholder="Choose a username" autocomplete="off" required>
</div>
</div>
<div class="form-group">
<label class="form-label">Generated Password</label>
<div class="gen-pw">
<span id="genPwText"></span>
<button type="button" class="copy-btn" id="copyPw">Copy</button>
</div>
<button type="button" class="btn btn-secondary" id="regenPw" style="margin-top:8px;padding:10px;font-size:12px">
<span class="btn-label">Regenerate Password</span>
</button>
</div>
</div>
<div class="form-group">
<label class="form-label" for="regPassConfirm">Confirm Password</label>
<div class="input-wrap">
<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<input type="password" id="regPassConfirm" name="password" placeholder="Paste or type the generated password" autocomplete="new-password" required>
<button type="button" class="toggle-pw" data-target="regPassConfirm" aria-label="Toggle password visibility">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
</button>
</div>
<div class="pw-strength" id="pwStrength">
<div class="bar"></div><div class="bar"></div><div class="bar"></div><div class="bar"></div>
</div>
</div>
<button type="submit" class="btn btn-primary" id="btnRegister">
<span class="btn-label">Create Account</span>
<div class="spinner"></div>
</button>
</form>
<button type="submit" class="btn-login" id="btnLogin">
<span class="btn-text">Sign in</span>
<div class="spinner"></div>
</button>
<div class="session-info">
<div class="dot"></div>
<span>Encrypted session · 24h token</span>
<div class="switch-link">
Already have an account? <a id="goLogin">Sign in</a>
</div>
</form>
</div>
<div class="login-footer">
NeuroSploit v4.6 &mdash; Authorized security testing only
<div class="dot"></div>
<span>NeuroSploit v5 &mdash; Authorized security testing only</span>
</div>
</div>
</div>
@@ -225,109 +362,237 @@ html,body{height:100%;font-family:'Inter',system-ui,sans-serif;background:var(--
(function() {
'use strict';
const form = document.getElementById('loginForm');
const btn = document.getElementById('btnLogin');
const errorBox = document.getElementById('errorBox');
const errorText = document.getElementById('errorText');
const togglePw = document.getElementById('togglePw');
const pwInput = document.getElementById('password');
/* ── elements ── */
var loginForm = document.getElementById('loginForm');
var regForm = document.getElementById('regForm');
var btnLogin = document.getElementById('btnLogin');
var btnRegister = document.getElementById('btnRegister');
var loginError = document.getElementById('loginError');
var loginErrorText = document.getElementById('loginErrorText');
var regError = document.getElementById('regError');
var regErrorText = document.getElementById('regErrorText');
var regSuccess = document.getElementById('regSuccess');
var panelLogin = document.getElementById('panelLogin');
var panelRegister = document.getElementById('panelRegister');
var card = document.getElementById('card');
var genPwText = document.getElementById('genPwText');
// Check if already authenticated
const token = localStorage.getItem('ns_token');
if (token) {
fetch('/api/auth/verify', {
headers: { 'Authorization': 'Bearer ' + token }
}).then(r => { if (r.ok) window.location.href = '/'; });
/* ── typing animation ── */
var tagline = document.getElementById('tagline');
var text = 'AUTONOMOUS PENETRATION TESTING ENGINE';
var i = 0;
function typeChar() {
if (i < text.length) {
tagline.textContent = text.slice(0, i + 1);
var cursor = document.createElement('span');
cursor.className = 'cursor-blink';
tagline.appendChild(cursor);
i++;
setTimeout(typeChar, 50 + Math.random() * 40);
}
}
setTimeout(typeChar, 600);
// Check if first login (default creds active)
fetch('/api/auth/status').then(r => r.json()).then(data => {
if (data.first_login) document.getElementById('firstLogin').classList.add('show');
}).catch(() => {});
/* ── password generator ── */
function generatePassword() {
var chars = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
var special = '!@#$%&*-_=+?';
var pw = '';
var arr = new Uint8Array(24);
crypto.getRandomValues(arr);
for (var j = 0; j < 20; j++) {
pw += (j === 5 || j === 10 || j === 15) ? special[arr[j] % special.length] : chars[arr[j] % chars.length];
}
return pw;
}
var currentGenPw = generatePassword();
genPwText.textContent = currentGenPw;
// Toggle password visibility
togglePw.addEventListener('click', function() {
const show = pwInput.type === 'password';
pwInput.type = show ? 'text' : 'password';
this.title = show ? 'Hide password' : 'Show password';
this.innerHTML = show
? '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>'
: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>';
document.getElementById('regenPw').addEventListener('click', function() {
currentGenPw = generatePassword();
genPwText.textContent = currentGenPw;
});
// Rate limiting
let attempts = 0;
let lockUntil = 0;
document.getElementById('copyPw').addEventListener('click', function() {
var btn = this;
navigator.clipboard.writeText(currentGenPw).then(function() {
btn.textContent = 'Copied!';
btn.classList.add('copied');
setTimeout(function() { btn.textContent = 'Copy'; btn.classList.remove('copied'); }, 2000);
});
});
form.addEventListener('submit', async function(e) {
/* ── password strength ── */
var regPassConfirm = document.getElementById('regPassConfirm');
regPassConfirm.addEventListener('input', function() {
var pw = this.value;
var score = 0;
if (pw.length >= 8) score++;
if (pw.length >= 14) score++;
if (/[A-Z]/.test(pw) && /[a-z]/.test(pw)) score++;
if (/[0-9]/.test(pw) && /[^a-zA-Z0-9]/.test(pw)) score++;
var bars = document.querySelectorAll('#pwStrength .bar');
for (var b = 0; b < bars.length; b++) {
bars[b].className = 'bar';
if (b < score) bars[b].classList.add(score <= 1 ? 'weak' : score <= 2 ? 'medium' : 'strong');
}
});
/* ── panel switching ── */
document.getElementById('goRegister').addEventListener('click', function() {
panelLogin.classList.remove('active');
panelRegister.classList.add('active');
hideAlerts();
});
document.getElementById('goLogin').addEventListener('click', function() {
panelRegister.classList.remove('active');
panelLogin.classList.add('active');
hideAlerts();
});
/* ── toggle password visibility ── */
document.querySelectorAll('.toggle-pw').forEach(function(btn) {
btn.addEventListener('click', function() {
var target = document.getElementById(this.dataset.target);
var show = target.type === 'password';
target.type = show ? 'text' : 'password';
this.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
this.innerHTML = show
? '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>'
: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" width="18" height="18"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>';
});
});
/* ── helpers ── */
function hideAlerts() {
[loginError, regError, regSuccess, document.getElementById('firstLoginBanner')].forEach(function(el) {
el.classList.remove('show');
});
}
function showAlert(el, msg, textEl) {
if (textEl) textEl.textContent = msg;
el.classList.add('show');
el.style.animation = 'none';
el.offsetHeight;
el.style.animation = el.classList.contains('alert-error') ? 'shake .4s ease' : '';
}
/* ── rate limiting ── */
var attempts = 0;
var lockUntil = 0;
/* ── check existing session ── */
var token = localStorage.getItem('ns_token');
if (token) {
fetch('/api/auth/verify', { headers: { 'Authorization': 'Bearer ' + token } })
.then(function(r) { if (r.ok) window.location.href = '/'; });
}
/* ── check if first login ── */
fetch('/api/auth/status').then(function(r) { return r.json(); }).then(function(data) {
if (data.first_login) {
document.getElementById('firstLoginBanner').classList.add('show');
}
if (data.no_users) {
panelLogin.classList.remove('active');
panelRegister.classList.add('active');
}
}).catch(function() {});
/* ── login ── */
loginForm.addEventListener('submit', function(e) {
e.preventDefault();
errorBox.classList.remove('show');
hideAlerts();
// Client-side rate limit
if (Date.now() < lockUntil) {
const secs = Math.ceil((lockUntil - Date.now()) / 1000);
showError('Too many attempts. Try again in ' + secs + 's');
var secs = Math.ceil((lockUntil - Date.now()) / 1000);
showAlert(loginError, 'Too many attempts. Try again in ' + secs + 's', loginErrorText);
return;
}
const user = document.getElementById('username').value.trim();
const pass = document.getElementById('password').value;
if (!user || !pass) { showError('Please fill in both fields'); return; }
var user = document.getElementById('loginUser').value.trim();
var pass = document.getElementById('loginPass').value;
if (!user || !pass) { showAlert(loginError, 'Please fill in both fields', loginErrorText); return; }
btn.classList.add('loading');
btn.disabled = true;
btnLogin.classList.add('loading');
btnLogin.disabled = true;
try {
const res = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: user, password: pass })
});
const data = await res.json();
if (res.ok && data.token) {
localStorage.setItem('ns_token', data.token);
// Smooth transition
document.querySelector('.card').style.transform = 'scale(0.95)';
document.querySelector('.card').style.opacity = '0';
setTimeout(() => { window.location.href = '/'; }, 300);
fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: user, password: pass })
}).then(function(res) {
return res.json().then(function(data) { return { ok: res.ok, data: data }; });
}).then(function(result) {
if (result.ok && result.data.token) {
localStorage.setItem('ns_token', result.data.token);
if (document.getElementById('rememberMe').checked) {
localStorage.setItem('ns_remember', 'true');
}
card.classList.add('exit');
setTimeout(function() { window.location.href = '/'; }, 350);
} else {
attempts++;
if (attempts >= 5) {
lockUntil = Date.now() + 30000;
showError('Too many failed attempts. Locked for 30 seconds.');
showAlert(loginError, 'Account locked for 30 seconds', loginErrorText);
} else {
showError(data.error || 'Invalid credentials');
showAlert(loginError, result.data.error || 'Invalid credentials', loginErrorText);
}
}
} catch (err) {
showError('Connection failed — is the server running?');
} finally {
btn.classList.remove('loading');
btn.disabled = false;
}
}).catch(function() {
showAlert(loginError, 'Connection failed — is the server running?', loginErrorText);
}).finally(function() {
btnLogin.classList.remove('loading');
btnLogin.disabled = false;
});
});
function showError(msg) {
errorText.textContent = msg;
errorBox.classList.add('show');
// Shake animation
errorBox.style.animation = 'none';
errorBox.offsetHeight; // reflow
errorBox.style.animation = 'shake .4s ease';
}
/* ── register ── */
regForm.addEventListener('submit', function(e) {
e.preventDefault();
hideAlerts();
// Keyboard shortcut: Enter submits from either field
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && document.activeElement.tagName !== 'BUTTON') {
form.dispatchEvent(new Event('submit'));
var user = document.getElementById('regUser').value.trim();
var pass = regPassConfirm.value;
if (!user) { showAlert(regError, 'Please enter a username', regErrorText); return; }
if (user.length < 3) { showAlert(regError, 'Username must be at least 3 characters', regErrorText); return; }
if (!pass) { showAlert(regError, 'Please confirm the password', regErrorText); return; }
if (pass !== currentGenPw) {
showAlert(regError, 'Password does not match the generated one. Copy and paste it.', regErrorText);
return;
}
btnRegister.classList.add('loading');
btnRegister.disabled = true;
fetch('/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: user, password: pass })
}).then(function(res) {
return res.json().then(function(data) { return { ok: res.ok, data: data }; });
}).then(function(result) {
if (result.ok) {
regSuccess.classList.add('show');
setTimeout(function() {
panelRegister.classList.remove('active');
panelLogin.classList.add('active');
hideAlerts();
document.getElementById('loginUser').value = user;
document.getElementById('loginPass').focus();
}, 1500);
} else {
showAlert(regError, result.data.error || 'Registration failed', regErrorText);
}
}).catch(function() {
showAlert(regError, 'Connection failed', regErrorText);
}).finally(function() {
btnRegister.classList.remove('loading');
btnRegister.disabled = false;
});
});
})();
</script>
<style>
@keyframes shake{0%,100%{transform:translateX(0)}20%,60%{transform:translateX(-6px)}40%,80%{transform:translateX(6px)}}
</style>
</body>
</html>
+16 -1
View File
@@ -3174,7 +3174,7 @@ const server = http.createServer(async (req, res) => {
const ip = req.headers['x-forwarded-for']?.split(',')[0]?.trim() || req.socket.remoteAddress || '';
if (req.method === 'GET' && p === '/api/auth/status') {
const users = await loadAuthUsers();
return sendJson(res, 200, { enabled: AUTH_ENABLED, firstLogin: users.length > 0 && users[0].firstLogin === true, hasUsers: users.length > 0 });
return sendJson(res, 200, { enabled: AUTH_ENABLED, first_login: users.length > 0 && users[0].firstLogin === true, no_users: users.length === 0, hasUsers: users.length > 0 });
}
if (req.method === 'POST' && p === '/api/auth/login') {
if (!authRateCheck(ip)) return sendJson(res, 429, { error: 'too many attempts, try again later' });
@@ -3192,6 +3192,21 @@ const server = http.createServer(async (req, res) => {
res.setHeader('Set-Cookie', `ns_token=${token}; HttpOnly; Path=/; SameSite=Strict; Max-Age=${JWT_EXPIRY_HOURS * 3600}`);
return sendJson(res, 200, { token, username: user.username, role: user.role, firstLogin: !!user.firstLogin });
}
if (req.method === 'POST' && p === '/api/auth/register') {
if (!authRateCheck(ip)) return sendJson(res, 429, { error: 'too many attempts, try again later' });
const body = await readBody(req);
const { username, password } = body;
if (!username || username.length < 3) return sendJson(res, 400, { error: 'username must be at least 3 characters' });
if (!password || password.length < 8) return sendJson(res, 400, { error: 'password must be at least 8 characters' });
if (!/^[a-zA-Z0-9_.-]+$/.test(username)) return sendJson(res, 400, { error: 'username may only contain letters, digits, _, . and -' });
const users = await loadAuthUsers();
if (users.find(u => u.username === username)) return sendJson(res, 409, { error: 'username already taken' });
const role = users.length === 0 ? 'admin' : 'operator';
users.push({ username, password: await hashPassword(password), role, firstLogin: false, createdAt: new Date().toISOString() });
await saveAuthUsers(users);
await pgLogActivity(null, 'user_registered', 'user', null, { username, role }, ip);
return sendJson(res, 201, { ok: true, username, role });
}
if (req.method === 'POST' && p === '/api/auth/change-password') {
const auth = requireAuth(req, res); if (!auth) return;
const body = await readBody(req);