批处理文件 – BATCH:阻止某人使用CTRL c或CTRL BREAK绕过我的密码脚本

@echo off
:home
cd c:/
IF EXIST "%PROGRAMFILES(X86)%" (set bit=x64) ELSE (set bit=x86)
title Log in to CMD
color f0
cls
echo.
echo              Cmd Accounts
echo ======================================
echo.
echo [1]  Log In  (access existing Account)
echo.
echo [2]  Register (add an account)
echo.
echo [3]  Delete Account (remove an account)
echo.
echo ============Ethans Security===========
echo.
set RegisterVal=0
set DeleteAcc=0
set /p op=
if %op%==1 goto Login
if %op%==2 goto setReg
if %op%==3 goto setDel
goto home
:setReg
set RegisterVal=1
goto Login
:setDel
set DeleteAcc=1
goto Login
:Login
cls
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo              Cmd Login
echo ======================================
echo.
set /p logName="Enter your username:"
EditV64 -m -p 'Enter your Password:' logPass
EditV32 -m -p 'Enter your Password:' logPass
if exist %logName%.txt goto continue
cls
color fc
echo              Cmd Login
echo ======================================
echo.
echo Acces Denied
pause
goto home
:continue
set /p var= <%logName%.txt
set actPass=%var%
call enx actPass actPass
if %logPass%==%actPass% goto logdone
color fc
cls
echo              Cmd Login
echo ======================================
echo.
echo Acces Denied
pause
goto home
:Register
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo              Cmd Register
echo ======================================
echo.
set /p regName="Enter new username:"
set /p regPass="Enter new password:"
set regName=%regName%
set regPass=%regPass%
call enx regPass regPass
echo %regPass%>%regName%.txt
set regName=NUL
set regPass=NUL
cls
echo             Cmd Register
echo ======================================
echo.
echo Acount Successfully Created
echo.
pause
goto home
:DelAccount
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo            Cmd Delete Account
echo ======================================
echo.
echo Account List
echo ------------
for %%a in ("c:\enxlogin\*") do @echo %%~na
echo.
echo Enter the Account you want to delete:
set /p deletingAcc="Account Name:"
if exist %deletingAcc%.txt goto delaccountnow
cls

echo Account not found
pause
goto DelAccount
echo            Cmd Delete Account
echo ======================================
echo.
:delaccountnow
del %deletingAcc%.txt
cls
echo            Cmd Delete Account
echo ======================================
echo.
echo Successfully Deleted Account
pause
goto home
:logdone
if %RegisterVal%==1 goto Register
if %DeleteAcc%==1 goto DelAccount
set Register=0
set actPass=NUL
set logPass=NUL
cls
echo              Cmd Login
echo ======================================
echo.
echo Successfully logged in!
echo.
pause
color 0f
cd "%userprofile%\Desktop"
cls
exit

这是我在cmd或批处理文件启动时运行的批量密码脚本,但是当用户按下ctrl-c或ctrl-break时,它会绕过登录脚本

这是发生了什么我运行cmd它启动所有工作,但当我按CTRL-C它退出并返回正常CMD所以你可以搞乱cmd这是为了保护人们不要搞砸我的cmd在一个很酷的时尚

最佳答案 Ctrl-C无法取消下面的批处理文件,如果通过Ctrl-Break取消,则cmd.exe窗口将关闭,因此用户永远无法通过此批处理文件访问正常的cmd.exe命令行会话.

@echo off
setlocal

if "%~1" equ "NonCancelable" goto NonCancelable
start "" /B cmd /C "%~F0" NonCancelable
exit

:NonCancelable
echo You can NOT cancel me!
echo/
set "var="
set /P "var=Enter password (enter Exit to end): "
if /I "%var%" neq "exit" goto :NonCancelable
echo Terminating non cancelable...
pause
exit
点赞