- run.bat: call scripts/ensure-vnc-password.ps1 so the password typed once also sets the UltraVNC service VNC password (UAC only when it differs); skip --spawn when 5900 is already taken (don't launch a 2nd winvnc). - scripts/ensure-vnc-password.ps1: new - compares the password against %ProgramData%\UltraVNC\ultravnc.ini (reverse-engineered UltraVNC DES obfuscation) and only writes+restarts the service when it differs. - scripts/set-vnc-password.bat: set UltraVNC service VNC password as admin (createpassword/setpasswd + verify, GUI fallback). Manual fallback. - internal/server/static/vnc.html: don't let the generic 'disconnect' banner overwrite the specific 'securityfailure' reason (noVNC's disconnect event has no reason field, so it always said 'unknown'). - AGENTS.md: document the above (scripts, run.bat, UltraVNC service note).
133 lines
4.6 KiB
Batchfile
133 lines
4.6 KiB
Batchfile
@echo off
|
||
REM ============================================================
|
||
REM web-vnc launcher - § ¯ã᪠¢ ®¤¨ ª«¨ª. ‘¯à 訢 ¥â ⮫쪮 ¯ ஫ì.
|
||
REM ============================================================
|
||
chcp 866 >nul
|
||
cd /d "%~dp0"
|
||
|
||
echo.
|
||
echo === web-vnc: VNC ¢ ¡à 㧥ॠ===
|
||
echo.
|
||
|
||
REM --- 1. �¨ ਪ ---
|
||
if exist "web-vnc.exe" goto havebin
|
||
where go >nul 2>nul
|
||
if not errorlevel 1 goto dogobuild
|
||
echo [®è¨¡ª ] web-vnc.exe ¥ ©¤¥, Go ¥ ãáâ ®¢«¥.
|
||
echo “áâ ®¢¨â¥ Go á https://go.dev/dl/ «¨¡® ¯®«®¦¨â¥ ᮡà ë© web-vnc.exe à冷¬.
|
||
echo.
|
||
pause
|
||
exit /b 1
|
||
:dogobuild
|
||
echo ‘®¡¨à î web-vnc.exe ...
|
||
go build -o web-vnc.exe .\cmd\web-vnc
|
||
if errorlevel 1 goto buildfail
|
||
:havebin
|
||
|
||
REM --- 2. noVNC-ª«¨¥â ---
|
||
if exist "internal\server\static\core\rfb.js" goto havenovnc
|
||
echo noVNC-ª«¨¥â ¥éñ ¥ ¢áâ஥. �ëâ îáì ᪠ç âì ...
|
||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-novnc.ps1"
|
||
if errorlevel 1 goto novncfail
|
||
echo �¥à¥á®¡¨à î á noVNC ...
|
||
go build -o web-vnc.exe .\cmd\web-vnc
|
||
goto havenovnc
|
||
:novncfail
|
||
echo [¯à¥¤ã¯à¥¦¤¥¨¥] �¥ 㤠«®áì ᪠ç âì noVNC (¥â ¨â¥à¥â ?).
|
||
echo ‚ ¡à 㧥ॠ®âªà®¥âáï áâà ¨æ á ¯®¤áª §ª®©. �®¢â®à¨â¥ ¯®§¦¥: scripts\get-novnc.ps1
|
||
echo.
|
||
:havenovnc
|
||
|
||
REM --- 3. VNC-á¥à¢¥à (¯®¨áª/§ £à㧪 ) ---
|
||
set "SPAWNARGS="
|
||
set "SPAWN_CMD="
|
||
if exist "vnc\winvnc.exe" goto uselocalvnc
|
||
if exist "vnc\tvnserver.exe" goto uselocalvnc
|
||
if exist "C:\Program Files\UltraVNC\winvnc.exe" goto autodetectvnc
|
||
if exist "C:\Program Files (x86)\UltraVNC\winvnc.exe" goto autodetectvnc
|
||
if exist "C:\Program Files\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
|
||
if exist "C:\Program Files (x86)\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
|
||
if exist "C:\Program Files\TightVNC\tvnserver.exe" goto autodetectvnc
|
||
if exist "C:\Program Files (x86)\TightVNC\tvnserver.exe" goto autodetectvnc
|
||
echo VNC-á¥à¢¥à ¥ ©¤¥. �ëâ îáì ᪠ç âì ¯®àâ â¨¢ë© UltraVNC ...
|
||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-vnc.ps1"
|
||
if errorlevel 1 goto novncserver
|
||
if exist "vnc\winvnc.exe" goto uselocalvnc
|
||
if exist "vnc\tvnserver.exe" goto uselocalvnc
|
||
goto novncserver
|
||
:uselocalvnc
|
||
if exist "vnc\winvnc.exe" set "SPAWN_CMD=vnc\winvnc.exe -run"
|
||
if exist "vnc\tvnserver.exe" if not defined SPAWN_CMD set "SPAWN_CMD=vnc\tvnserver.exe -run"
|
||
set "SPAWNARGS=--spawn-command "%SPAWN_CMD%""
|
||
echo � ©¤¥ «®ª «ìë© VNC-á¥à¢¥à: %SPAWN_CMD%
|
||
goto vncdone
|
||
:autodetectvnc
|
||
echo VNC-á¥à¢¥à ©¤¥ ¢ á¨á⥬¥ ( ¢â®-®¯à¥¤¥«¥¨¥ ¯à¨ § ¯ã᪥).
|
||
goto vncdone
|
||
:novncserver
|
||
echo [¯à¥¤ã¯à¥¦¤¥¨¥] VNC-á¥à¢¥à ¥ 㤠«®áì ¯®«ãç¨âì.
|
||
echo �¥§ VNC-á¥à¢¥à à ¡®ç¨© á⮫ ¥ ¡ã¤¥â âà ᫨஢ âìáï.
|
||
echo “áâ ®¢¨â¥ UltraVNC/TightVNC ¢àãçãî ¨«¨ ¯®¢â®à¨â¥: scripts\get-vnc.ps1
|
||
echo.
|
||
:vncdone
|
||
|
||
REM --- 4. � ஫ì ---
|
||
:getpw
|
||
set "PW="
|
||
set /p "PW=‚¢¥¤¨â¥ ¯ à®«ì ¤®áâ㯠: "
|
||
if "%PW%"=="" goto emptypw
|
||
goto gotpw
|
||
:emptypw
|
||
echo � à®«ì ¥ ¬®¦¥â ¡ëâì ¯ãáâë¬.
|
||
goto getpw
|
||
:gotpw
|
||
|
||
REM --- 4b. Sync UltraVNC password with the one entered (only when it differs) ---
|
||
echo ‘¨åந§¨àãî ¯ ஫ì UltraVNC á ¢¢¥¤ñë¬. �ਠ¥á®¢¯ ¤¥¨¨ § ¯à®á¨â ¯à ¢ ¤¬¨¨áâà â®à ...
|
||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\ensure-vnc-password.ps1" -Password "%PW%"
|
||
if errorlevel 1 echo [¯à¥¤ã¯à¥¦¤¥¨¥] �¥ 㤠«®áì á¨åந§¨à®¢ âì ¯ ஫ì UltraVNC - ¯à®¤®«¦ î.
|
||
|
||
REM --- 5. •íè ¯ ஫ï + â®â ¦¥ ¯ à®«ì ¤«ï VNC-á¥à¢¥à ---
|
||
echo ƒ¥¥à¨àãî åíè ¯ ஫ï ...
|
||
for /f "delims=" %%i in ('web-vnc.exe --gen-hash "%PW%"') do set "HASH=%%i"
|
||
if "%HASH%"=="" goto hashfail
|
||
REM ’®â ¦¥ ¯ à®«ì ¡ã¤¥â ¢â®¬ â¨ç¥áª¨ ¯¥à¥¤ noVNC ¤«ï ¢â®à¨§ 樨 VNC-á¥à¢¥à¥.
|
||
set "WEBVNC_VNC_PASSWORD=%PW%"
|
||
set "PW="
|
||
|
||
REM --- 6. „®áâã¯ë¥ ¤à¥á ---
|
||
echo.
|
||
echo === €¤à¥á ¤«ï ¯®¤ª«î票ï (¯®àâ 8080) ===
|
||
echo http://localhost:8080
|
||
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\list-ips.ps1"') do echo http://%%a:8080
|
||
echo.
|
||
echo …᫨ á ¤à㣮© ¬ è¨ë ¥ ®âªàë¢ ¥âáï - ®¤¨ à § ¢ë¯®«¨â¥ ®â ¨¬¥¨
|
||
echo ¤¬¨¨áâà â®à : scripts\open-firewall.bat
|
||
echo.
|
||
|
||
REM --- 7. ‡ ¯ã᪠---
|
||
echo ‡ ¯ã᪠î web-vnc http://localhost:8080
|
||
echo Žáâ ®¢¨âì: Ctrl+C
|
||
echo.
|
||
REM --- 6b. 5900 already listening? -> do NOT spawn a 2nd VNC server (avoid conflict with the UltraVNC service) ---
|
||
set "SPAWNFLAG=--spawn"
|
||
powershell -NoProfile -Command "try{$c=New-Object Net.Sockets.TcpClient('127.0.0.1',5900);$c.Close();exit 0}catch{exit 1}"
|
||
if not errorlevel 1 (
|
||
echo VNC-á¥à¢¥à 㦥 á«ãè ¥â 127.0.0.1:5900 - ¯®¤ª«îç îáì ª ¥¬ã ¡¥§ --spawn.
|
||
set "SPAWNFLAG="
|
||
)
|
||
web-vnc.exe --password-hash "%HASH%" %SPAWNARGS% %SPAWNFLAG% --listen :8080
|
||
echo.
|
||
echo ‘¥à¢¥à ®áâ ®¢«¥.
|
||
pause
|
||
exit /b
|
||
|
||
:buildfail
|
||
echo ‘¡®àª ¥ 㤠« áì.
|
||
pause
|
||
exit /b 1
|
||
|
||
:hashfail
|
||
echo [®è¨¡ª ] �¥ 㤠«®áì ᣥ¥à¨à®¢ âì åíè ¯ ஫ï.
|
||
pause
|
||
exit /b 1 |