(转)BAT加密和解密文章
-----------------------------------------------------------
这是一段bat加密器代码
author:pengfei@
www.cn-dos.net
%%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a
cls
@echo off
color 27
:start
cls
echo *******************************************************************************
echo * *
echo * BAT 加 密 最 终 版 *
echo * *
echo *******************************************************************************
echo.
echo.
echo BAT加密最终版为"BAT加密工具"的更新版本, 较上一版加密工具而言有诸多优势:
echo.
echo ★ 可以一次性成功加密任何批处理文件, 更省事.
echo.
echo ★ 可以由您输入任意需要加密的批处理, 加密灵活性更大.
echo.
echo ★ 能够自动判断错误输入, 更加人性化.
echo.
echo 说明: 在下面输入需要加密的批处理文件, 直接输入批处理文件名为加密当前目录下的BAT,也可以带路径指定任意BAT. 当前目录下生成的encrypt.bat文件即为加密的批处理.
echo.
echo 作者:木林森 QQ:573381312 BYE
echo.
echo.
echo.
set /p file=请输入需要加密的批处理后按回车键(q=退出):
if "%file%"=="q" goto quit
echo %file%|findstr /i "\.bat$">nul && goto go
echo %file%|findstr /i "\.cmd$">nul && goto go
cls
echo ==============
echo 请正确输入!
echo ==============
echo.
echo.
echo 按任意键重新输入......
pause>nul
goto start
:go
if not exist "%file%" goto newly
if exist encrypt.bat copy encrypt.bat encryptbak.bat
echo %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a >"%tmp%\encrypt.tmp"
echo cls>>"%tmp%\encrypt.tmp"
type "%file%">>"%tmp%\encrypt.tmp"
setlocal enabledelayedexpansion
for %%i in ("%tmp%\encrypt.tmp") do (
echo %%~zi >nul 2>nul
set size=%%~zi
set num=!size:~-1!
set /a mod=!num!%%2
if !mod! equ 0 (goto even) else (goto odd)
)
:even
copy "%tmp%\encrypt.tmp" encrypt.bat
del "%tmp%\encrypt.tmp"
cls
echo ==========================
echo 恭喜你, 批处理加密成功^^!
echo ==========================
echo.
echo.
echo 按任意键退出......
pause>nul
goto quit
:odd
echo. >>"%tmp%\encrypt.tmp"
copy "%tmp%\encrypt.tmp" encrypt.bat
del "%tmp%\encrypt.tmp"
cls
echo ==========================
echo 恭喜你, 批处理加密成功^^!
echo ==========================
echo.
echo.
echo 按任意键退出......
pause>nul
goto quit
:newly
cls
echo ================================
echo 找不到批处理文件, 请重新输入!
echo ================================
echo.
echo.
echo 按任意键开始......
pause>nul
goto start
:quit
exit
---------------------------------------------------------------------------------------------
下面是bat解密器代码
---------------------------------------------------------------------------------------------
@echo off
mode con: cols=80 lines=25
:index
color 27
cls
echo ╭───────────────╮
echo │ │
echo ╭─────────┤ BAT 解 密 工 具 ├─────────╮
echo │ │ │ │
echo │ ╰───────────────╯ │
echo │ │
echo │ │
echo │ 本工具用来对混淆文本编码类型的加密批处理进行解密! │
echo │ │
echo │ 在下面填入需要解密的批处理按回车键即可. │
echo │ │
echo │ 建议直接把待解密的批处理文件拖曳至本窗口释放. │
echo │ │
echo │ 解密成功后会在本程序目录下生成"new_待解密文件名.文件后缀名" │
echo │ 格式的文件. │
echo │ │
echo │ 注意: 如果本目录下存在"new_待解密文件名.文件后缀名"的文件, │
echo │ 将会被替换. │
echo │ │
echo │ │
echo ╰───────────────────────────────────╯
echo.
set route=%cd%
set ravel=
set /p ravel= 请输入要解密的批处理:
set "ravel=%ravel:"=%"
if /i "%ravel:~-4%"==".bat" if exist "%ravel%" goto go
if /i "%ravel:~-4%"==".cmd" if exist "%ravel%" goto go
cls
echo ╭──────────╮
echo ╭─────────┤ 文 件 错 误 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ 指定文件不存在或文件不是批处理类型! │
echo │ │
echo │ 按任意键重新输入... │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo 按任意键重新输入...
pause >nul
goto index
:go
for /f "tokens=*" %%c in ("%ravel%") do (
cd /d "%%~dpc"
if exist "%route%\new_%%~nxc" attrib -s -h -r -a "%route%\new_%%~nxc"
echo author:pengfei@
www.cn-dos.net>"%route%\new_%%~nxc"
for /f "tokens=*" %%i in (%%~nxc) do (
echo %%i>>"%route%\new_%%~nxc"
)
)
cls
echo ╭──────────╮
echo ╭─────────┤ 解 密 成 功 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ 恭喜, 批处理解密成功! │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo 按任意键退出...
pause >nul
exit
(Transfer)BAT Encryption and Decryption Article
-----------------------------------------------------------
This is a piece of bat encryptor code
author:pengfei@
www.cn-dos.net
%%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a
cls
@echo off
color 27
:start
cls
echo *******************************************************************************
echo * *
echo * BAT 加 密 最 终 版 *
echo * *
echo *******************************************************************************
echo.
echo.
echo BAT encryption final version is an updated version of "BAT encryption tool". Compared with the previous version of the encryption tool, it has many advantages:
echo.
echo ★ Can successfully encrypt any batch processing file at one time, which is more convenient.
echo.
echo ★ You can input any batch processing that needs to be encrypted, and the encryption flexibility is greater.
echo.
echo ★ Can automatically judge wrong input, more humanized.
echo.
echo Description: Enter the batch processing file that needs to be encrypted below, directly enter the batch processing file name to encrypt the BAT in the current directory, or you can specify any BAT with a path. The encrypt.bat file generated in the current directory is the encrypted batch processing.
echo.
echo Author: Mulinsen QQ:573381312 BYE
echo.
echo.
echo.
set /p file=Please enter the batch processing that needs to be encrypted and press Enter (q=quit):
if "%file%"=="q" goto quit
echo %file%|findstr /i "\.bat$">nul && goto go
echo %file%|findstr /i "\.cmd$">nul && goto go
cls
echo ==============
echo Please enter correctly!
echo ==============
echo.
echo.
echo Press any key to re-enter......
pause>nul
goto start
:go
if not exist "%file%" goto newly
if exist encrypt.bat copy encrypt.bat encryptbak.bat
echo %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a %%%%a >"%tmp%\encrypt.tmp"
echo cls>>"%tmp%\encrypt.tmp"
type "%file%">>"%tmp%\encrypt.tmp"
setlocal enabledelayedexpansion
for %%i in ("%tmp%\encrypt.tmp") do (
echo %%~zi >nul 2>nul
set size=%%~zi
set num=!size:~-1!
set /a mod=!num!%%2
if !mod! equ 0 (goto even) else (goto odd)
)
:even
copy "%tmp%\encrypt.tmp" encrypt.bat
del "%tmp%\encrypt.tmp"
cls
echo ==========================
echo Congratulations, batch processing encryption is successful^^!
echo ==========================
echo.
echo.
echo Press any key to exit......
pause>nul
goto quit
:odd
echo. >>"%tmp%\encrypt.tmp"
copy "%tmp%\encrypt.tmp" encrypt.bat
del "%tmp%\encrypt.tmp"
cls
echo ==========================
echo Congratulations, batch processing encryption is successful^^!
echo ==========================
echo.
echo.
echo Press any key to exit......
pause>nul
goto quit
:newly
cls
echo ================================
echo Batch processing file not found, please re-enter!
echo ================================
echo.
echo.
echo Press any key to start......
pause>nul
goto start
:quit
exit
---------------------------------------------------------------------------------------------
The following is the bat decryptor code
---------------------------------------------------------------------------------------------
@echo off
mode con: cols=80 lines=25
:index
color 27
cls
echo ╭───────────────╮
echo │ │
echo ╭─────────┤ BAT 解 密 工 具 ├─────────╮
echo │ │ │ │
echo │ ╰───────────────╯ │
echo │ │
echo │ │
echo │ This tool is used to decrypt encrypted batch processing with confused text encoding type! │
echo │ │
echo │ Fill in the batch processing that needs to be decrypted below and press Enter. │
echo │ │
echo │ It is recommended to directly drag and drop the batch processing file to be decrypted into this window to release. │
echo │ │
echo │ After successful decryption, a file in the format "new_original file name.file suffix name" will be generated in the directory of this program │
echo │ format file. │
echo │ │
echo │ Note: If there is a file "new_original file name.file suffix name" in this directory, │
echo │ will be replaced. │
echo │ │
echo │ │
echo ╰───────────────────────────────────╯
echo.
set route=%cd%
set ravel=
set /p ravel= Please enter the batch processing to be decrypted:
set "ravel=%ravel:"=%"
if /i "%ravel:~-4%"==".bat" if exist "%ravel%" goto go
if /i "%ravel:~-4%"==".cmd" if exist "%ravel%" goto go
cls
echo ╭──────────╮
echo ╭─────────┤ 文 件 错 误 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ The specified file does not exist or the file is not a batch processing type! │
echo │ │
echo │ Press any key to re-enter... │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo Press any key to re-enter...
pause >nul
goto index
:go
for /f "tokens=*" %%c in ("%ravel%") do (
cd /d "%%~dpc"
if exist "%route%\new_%%~nxc" attrib -s -h -r -a "%route%\new_%%~nxc"
echo author:pengfei@
www.cn-dos.net>"%route%\new_%%~nxc"
for /f "tokens=*" %%i in (%%~nxc) do (
echo %%i>>"%route%\new_%%~nxc"
)
)
cls
echo ╭──────────╮
echo ╭─────────┤ 解 密 成 功 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ Congratulations, batch processing decryption is successful! │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo Press any key to exit...
pause >nul
exit