China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 18:43
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] Please ask what is the principle of the following BAT encryption and decryption? View 2,220 Replies 9
Original Poster Posted 2007-04-01 22:47 ·  中国 广东 汕头 电信
初级用户
Credits 37
Posts 18
Joined 2007-04-01 08:57
19-year member
UID 83600
Gender Male
Status Offline
BAT Encryption and Decryption Tools

(Transferred) An article about BAT encryption and decryption published by a friend
-----------------------------------------------------------
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", and 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 labor-saving.
echo.
echo ★ You can enter any batch processing that needs to be encrypted, and the encryption flexibility is greater.
echo.
echo ★ Can automatically judge wrong input, which is 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, and you can also 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 The batch processing file is 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 the encrypted batch processing of the confused text encoding type! │
echo │ │
echo │ Enter 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 to this window to release. │
echo │ │
echo │ After successful decryption, a file in the format "new_original file name.file extension" will be generated in the directory of this program │
echo │ Format file. │
echo │ │
echo │ Note: If there is a file with "new_original file name.file extension" in this directory, │
echo │ It 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 ╭─────────┤ File error ├────────╮
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 ╭─────────┤ Decryption successful ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ Congratulations, batch processing decryption is successful! │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo Press any key to exit...
pause >nul
exit

I'm a newbie, I can't understand it, especially that long %%... code, it's dizzy~~~~
May I ask the principle of the above BAT encryption and decryption, can any expert explain the principle?

[ Last edited by HAT on 2008-11-2 at 10:25 ]
Floor 2 Posted 2007-04-05 12:25 ·  中国 四川 泸州 联通
高级用户
★★★
Credits 609
Posts 374
Joined 2006-08-02 22:38
20-year member
UID 59720
Status Offline
In fact, encryption and decryption don't need to be that complicated. In fact, it's just writing a file in ANSI encoding into a file in Unicode encoding.
Floor 3 Posted 2007-04-08 11:30 ·  中国 江苏 南京 电信
初级用户
★★
Credits 138
Posts 50
Joined 2007-01-23 10:59
19-year member
UID 77428
Gender Male
Status Offline
I have tested it. Only adding a line of boring %%a... before the original batch code...
There is no other effect!!!!!
Floor 4 Posted 2007-04-09 10:59 ·  中国 辽宁 丹东 联通
初级用户
★★
Credits 116
Posts 56
Joined 2007-03-07 04:53
19-year member
UID 80966
Gender Male
Status Offline
Please provide the full content that needs to be translated. Just the single word "倒" is too incomplete for translation.
QQ=3391617
Floor 5 Posted 2007-08-10 10:15 ·  中国 内蒙古 赤峰 联通
新手上路
Credits 2
Posts 1
Joined 2007-08-10 09:51
19-year member
UID 94912
Gender Male
Status Offline
Floor 6 Posted 2007-08-12 10:23 ·  中国 广东 深圳 腾讯云
初级用户
Credits 54
Posts 24
Joined 2007-07-08 09:58
19-year member
UID 93434
Gender Male
Status Offline
Hehe, you can also convert it into EXE and add a shell
俺很菜,但俺很好学。
Floor 7 Posted 2007-08-12 21:37 ·  中国 宁夏 银川 电信
初级用户
Credits 89
Posts 40
Joined 2007-05-13 11:15
19-year member
UID 88380
Gender Male
Status Offline
I can't understand, please master to guide...
Never stop!!!
Love DOS !Love Computer!
Floor 8 Posted 2008-11-02 01:25 ·  中国 广西 南宁 电信
新手上路
Credits 13
Posts 6
Joined 2008-07-21 13:10
18-year member
UID 121828
Gender Male
Status Offline
This encryption method can be easily viewed with WinRAR.
Floor 9 Posted 2010-02-10 12:58 ·  中国 广东 深圳 电信
新手上路
Credits 19
Posts 13
Joined 2010-02-08 09:46
16-year member
UID 160332
Gender Male
Status Offline
Floor 10 Posted 2010-02-10 20:49 ·  中国 广东 广州 中移铁通
初级用户
★★
Credits 66
Posts 53
Joined 2009-10-09 20:51
16-year member
UID 152852
Gender Male
Status Offline
This is using a "Notepad" bug. The so-called encryption is only for "Notepad", and it will be clear at a glance when opened with "WordPad".
Forum Jump: