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-06-21 09:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] [Discussion] Non-compiled Batch Processing Encryption Scheme and Code DigestI View 110,351 Replies 364
Floor 91 Posted 2006-10-20 20:03 ·  中国 湖北 武汉 洪山区 电信
初级用户
Credits 48
Posts 23
Joined 2006-02-23 22:11
20-year member
UID 50842
Status Offline
Just discovered that it can be like this originally, learning...
Floor 92 Posted 2006-10-21 04:37 ·  中国 黑龙江 哈尔滨 联通
新手上路
Credits 8
Posts 4
Joined 2006-10-19 02:50
19-year member
UID 66667
Status Offline
Effective...Support...Thanks...! An absolute masterpiece of wisdom and technology!
Then may I ask the person above, how to re-display the content? Where there is a shield, there must be a spear, right?
Floor 93 Posted 2006-10-21 11:31 ·  中国 江苏 宿迁 电信
新手上路
Credits 3
Posts 2
Joined 2006-10-19 00:17
19-year member
UID 66588
Status Offline
It's so complicated~ I can't understand it~
Floor 94 Posted 2006-10-21 14:37 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
  Still not quite clear about the principles of encryption and decryption. Please哪位 expert口述一下. Thanks.

  In addition, for the code of encryption and decryption by Brother pengfei in F82, I tested it myself and found that only the line "author:pengfei@www.cn-dos.net" was added at the first line of the batch file, which seems to have no effect on encryption and decryption. I don't know the reason, hope the experts can give instruction.
Floor 95 Posted 2006-10-31 13:07 ·  中国 山东 济南 联通
新手上路
Credits 1
Posts 4
Joined 2006-10-12 01:49
19-year member
UID 65389
Status Offline
I'm very noob, don't laugh at me by the old hands heh heh~~
I saw a method before very simple
That is to use a 16-bit editor to add the FFEF file header to the BAT, so that text editors like Notepad can open the batch file in UNICODE mode
But after adding it, it will cause the first command of the encrypted batch file to execute incorrectly,
We can add a 0D0A after FFFE, which is carriage return and line feed,
Although it doesn't affect the execution of the first command, but there will be an error message on the screen "It is not an internal or external command, nor is it a runnable program or batch file",
Here we can add 63 6C 73 0D 0A which is cls (carriage return)
Floor 96 Posted 2006-10-31 22:33 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Good method from the poster above!

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 97 Posted 2006-11-01 22:22 ·  中国 广东 深圳 龙岗区 电信
新手上路
Credits 12
Posts 6
Joined 2006-03-29 16:03
20-year member
UID 52996
Status Offline
Reading this post has made me understand a lot of things, thank you for sharing.
Floor 98 Posted 2006-11-03 01:23 ·  中国 山东 烟台 莱阳市 联通
初级用户
Credits 31
Posts 15
Joined 2006-11-02 04:46
19-year member
UID 69254
Gender Male
Status Offline
Learned something new!
Floor 99 Posted 2006-11-19 09:43 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
Sweat... Just now the forum couldn't be accessed, and when I submitted it, it actually posted two posts.

[ Last edited by pengfei on 2006-11-19 at 09:50 AM ]
Floor 100 Posted 2006-11-19 09:49 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
In the past few months on the DOS Union, I've learned a lot. I'm very touched to see that everyone here is so enthusiastic. In today's era of Windows popularity, there are still so many people who are passionately in love with DOS.

Through such a long discussion, everyone has gained a certain understanding of the encryption scheme that confuses text encoding and also learned a lot of knowledge. The encryption programs made by this encryption scheme are relatively mature and easy to use. "bat加密最终版.bat" (Final Edition of bat Encryption.bat) and "bat强制加密程序.exe" (Forced bat Encryption Program.exe)

At the same time, decryption programs for these two encryption methods have also been written. "bat解密程序.bat" (bat Decryption Program.bat)

Recently, I suddenly thought of the method of encrypting with variables. Theoretically, it seemed feasible, so I started to write "bat变量加密程序.bat" (bat Variable Encryption Program.bat). Only when I started writing did I realize it wasn't that easy. First, there was the unification of password conversion codes, and then many problems were encountered.

This algorithm is not yet very mature. Although no errors were found during testing, if control characters, operators, escape characters and other special characters; as well as symbol pairs like quotes, parentheses, environment variables, replacement variables, parameters, etc., appear in different orders in the same line, there may be encryption failures.

This is just the test code I randomly wrote. If the batch processing files that everyone actually encrypts contain such sets of characters, I think the reliability of the encrypted batch processing will be uncertain. Hehe~ Don't be afraid to use it when I say this...

I have tested dozens of batch processing files, including scripts with as many as a thousand lines. Some batch processing files also have a large number of special characters, and no errors were found after encryption. It's just that some characters may affect each other and cause unknown errors. More widespread testing by everyone is needed to find out.

Suddenly, I found that after discussing for so long, the version master of 11th floor 3742668 has already studied this encryption method. Hehe~

It is suggested that everyone first use the variable encryption method to encrypt, and then use "批处理加密解密工具集.rar" (Batch Processing Encryption and Decryption Tool Set.rar) "BAT加密最终版" (Final Edition of BAT Encryption) or "BAT强制加密程序" (Forced BAT Encryption Program) to encrypt again. This can achieve a relatively good encryption effect. If you want to see the source code, the other party needs to decrypt twice.

The defect of uppercase letters becoming lowercase after encryption has been corrected. Everyone is welcome to test~


@echo off
title bat变量加密程序
mode con: cols=80 lines=25
color 27
set route=%cd%
if not %1*==* set ravel=%1&goto jmp
:index
cls
echo ╭───────────────╮
echo │ │
echo ╭─────────┤ BAT 变 量 加 密 程 序 ├─────────╮
echo │ │ │ │
echo │ 测试版: ╰───────────────╯ │
echo │ │
echo │ 本工具采用变量截取加密算法, 加密后文件大小会增加5-10倍, 批处理 │
echo │ 的运行效率不会有任何影响. │
echo │ │
echo │ 在下面输入需要加密的批处理按回车键即可, 建议直接把待加密的 │
echo │ 批处理文件拖曳至本窗口释放. │
echo │ │
echo │ 加密成功后会在本程序目录下生成"new_待加密文件名.bat"格式的文件. │
echo │ │
echo │ 注意: 1. 屏幕如无"加密成功"的提示或中间退出, 说明加密失败. │
echo │ 2. 此加密算法要处理的数据量很大, 速度比较慢, 请耐心等待. │
echo │ 3. 可能还存在其他未知缺陷, 加密后请自行检测错误. │
echo │ 4. 修正了加密后大写字母变小写的缺陷. │
echo │ │
echo │ pengfei@www.cn-dos.net │
echo ╰───────────────────────────────────╯
echo.
set ravel=
set /p ravel= 请输入要加密的批处理(q=exit):
:jmp
set "ravel=%ravel:"=%"
if /i "%ravel%"=="q" exit
echo %ravel% | findstr /c:( /c:) >nul 2>nul && goto :nay
if /i "%ravel:~-4%"==".bat" if exist "%ravel%" goto go
if /i "%ravel:~-4%"==".cmd" if exist "%ravel%" goto go
:nay
cls
echo ╭──────────╮
echo ╭─────────┤ 文 件 错 误 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ 1. 指定文件不存在或文件不是批处理类型. │
echo │ │
echo │ 2. 文件路径中含有括号. │
echo │ │
echo │ 3. 文件名中存在空格. │
echo │ │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
echo 按任意键重新输入...
pause >nul
goto index
:go
for /f "tokens=*" %%c in ("%ravel%") do (
cd /d "%%~dpc"
set root="%route%\new_%%~nxc"
set file=%%~nxc
)
for %%i in (%file%) do if not "%%i"=="%file%" goto nay
if exist %root% call :exist
if exist %root% attrib -s -h -r -a %root%
call :caput
cls
echo.
echo         \\\^|///
echo         \\ .-.- //
echo         ( .@.@ )
echo +-------oOOo-----(_)-----oOOo---------+
echo ^|                   ^|
echo ^|  正在加密中, 请稍等......    ^|
echo ^|                   ^|
echo +----------oooO-------Oooo------------+
echo.
echo.
for /f "delims=" %%i in (%file%) do (
set x=%%i■
call :start
)
cls
echo.
echo         \\\^|///
echo         \\ .-.- //
echo         ( .@.@ )
echo +-------oOOo-----(_)-----oOOo---------+
echo ^|                   ^|
echo ^|  恭喜, 加密成功!    ^|
echo ^|                   ^|
echo +----------oooO-------Oooo------------+
echo.
echo.
echo 按任意键退出...
pause >nul
goto :eof
:start
set term=0
set vcd=0
set "x=%x:"=◎%"
set "y=%x%"
set num=0
:follow
if not "%y%"=="" (
set "y=%y:~1%"
if "%y:~0,1%"=="◎" set /a num+=1
goto :follow
)
set /a z=%num%%%2
if "%x:~0,1%"==":" if not "%x:~0,2%"==":" set term=1
set result=
:next
if not "%x:~0,1%"=="■" (
if "%term%"=="1" (
if "%x:~0,1%"=="%%" set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set term=0&goto next
if "%x:~0,1%"==" " set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set term=0&goto next
if "%x:~0,1%"=="=" set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set term=0&goto next
if "%x:~0,1%"==")" set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set term=0&goto next
set "result=%result%%x:~0,1%"&set "x=%x:~1%"&goto next
)
if "%x:~0,1%"=="%%" set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set term=1&goto next
if "%x:~0,1%"==" " set "result=%result% "&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="a" set "result=%result%%%appdata:~-1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="b" set "result=%result%%%tcopu:~1,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="c" set "result=%result%%%userprofile:~5,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="d" set "result=%result%%%appdata:~15,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="e" set "result=%result%%%comspec:~-1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="f" set "result=%result%%%tcopu:~11,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="g" set "result=%result%%%programfiles:~6,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="h" set "result=%result%%%tcopu:~2,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="i" set "result=%result%%%programfiles:~-4,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="j" set "result=%result%%%tcopu:~4,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="k" set "result=%result%%%tcopu:~5,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="l" set "result=%result%%%appdata:~-13,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="m" set "result=%result%%%appdata:~7,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="n" set "result=%result%%%userprofile:~14,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="o" set "result=%result%%%appdata:~-7,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="p" set "result=%result%%%appdata:~-15,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="q" set "result=%result%%%tcopu:~6,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="r" set "result=%result%%%programfiles:~4,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="s" set "result=%result%%%comspec:~-16,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="t" set "result=%result%%%comspec:~-13,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="u" set "result=%result%%%userprofile:~6,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="v" set "result=%result%%%tcopu:~8,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="w" set "result=%result%%%os:~5,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="x" set "result=%result%%%comspec:~-2,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="y" set "result=%result%%%comspec:~12,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="z" set "result=%result%%%tcopu:~9,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="0" set "result=%result%%%tcopu:~17,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="1" set "result=%result%%%tcopu:~21,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="2" set "result=%result%%%comspec:~-9,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="3" set "result=%result%%%comspec:~-10,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="4" set "result=%result%%%tcopu:~14,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="5" set "result=%result%%%tcopu:~16,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="6" set "result=%result%%%tcopu:~33,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="7" set "result=%result%%%tcopu:~12,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="8" set "result=%result%%%tcopu:~23,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="9" set "result=%result%%%tcopu:~29,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="(" set "result=%result%%%tcopu:~25,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"==")" set "result=%result%%%tcopu:~30,1%%"&set "x=%x:~1%"&goto next
if "%x:~0,1%"=="@" set "result=%result%%%tcopu:~32,1%%"&set "x=%x:~1%"&goto next
if "%vcd%"=="1" (
if "%x:~0,1%"=="◎" set vcd=0
if "%x:~0,1%"=="^" (
set "result=%result%^^^^^"&set "x=%x:~1%"&goto next
) else (
set "result=%result%%x:~0,1%"&set "x=%x:~1%"&goto next
)
)
if "%x:~0,1%"=="◎" set "result=%result%%x:~0,1%"&set "x=%x:~1%"&set vcd=1&goto next
set "result=%result%%x:~0,1%"&set "x=%x:~1%"&goto next
)
set "result=%result:◎="%"
if "%z%"=="0" (
set /p "auot=%result%"<nul>>%root%
echo.>>%root%
goto :eof
)
>>%root% echo %result%
goto :eof
:caput
(echo @%%comspec:~-1%%%%userprofile:~5,1%%h%%appdata:~-7,1%% %%appdata:~-7,1%%%%programfiles:~-5,1%%%%programfiles:~-5,1%%
echo %%comspec:~-16,1%%%%comspec:~-1%%%%comspec:~-13,1%% %%comspec:~-13,1%%%%userprofile:~5,1%%%%appdata:~-7,1%%%%appdata:~-15,1%%%%userprofile:~6,1%%=%%%%bh%%%%jkq%%%%vz%%%%f7%%%%4c50t%%%%u1w8%%%%^(cdf9^)%%%%@6tc%%%%)>%root%
goto :eof
:exist
cls
echo ╭──────────╮
echo ╭─────────┤ 替 换 文 件 ├────────╮
echo │ ╰──────────╯ │
echo │ │
echo │ 注意: 当前目录存在待加密批处理的同一更名文件. │
echo │ │
echo │ 1: 替换 2: 重新输入 │
echo │ │
echo │ │
echo ╰─────────────────────────────╯
echo.
echo.
set choice=
set /p choice= 请选择(1 2)回车:
if "%choice%"=="1" goto :eof
if "%choice%"=="2" goto index
goto exist


I have rewritten these several encryption schemes and decryptions, unified the interface, etc., and the functions are more complete. The test environment is Windows XP sp2

[ Last edited by pengfei on 2007-3-6 at 04:16 AM ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
lxmxn +7 2006-11-19 10:48
hxuan999 +1 2006-11-23 04:46
axi +2 2007-03-23 10:45
Attachments
批处理加密解密工具集.rar (64.09 KiB, Credits to download 1 pts, Downloads: 328)
业精于勤而荒于嬉,形成于思而毁于随。
Floor 101 Posted 2006-11-20 04:06 ·  中国 上海 浦东新区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
Originally posted by willsort at 2006-7-23 14:36:
Re pengfei:

This encryption mechanism has low versatility, is too narrow in applicable platforms, and has side effects (it will rename jpg files). Therefore, it is recommended that you do not spend too much effort on this solution.


Tested, no JPG files were renamed!
个人主页-找餐厅:http://www.canting.cc
Floor 102 Posted 2006-11-20 04:39 ·  中国 上海 浦东新区 电信
初级用户
★★
Credits 153
Posts 68
Joined 2006-10-12 22:25
19-year member
UID 65507
From 上海
Status Offline
Originally posted by zxcv at 2006-7-23 16:10:
Simpler:
Create a new "a.txt" text file, open it, copy 【ൡ挊獬਍】(excluding 【】), paste it into "a.txt" and when saving, it prompts "Contains Unicode characters...." select "Cancel", edit..


This trick is awesome, but there is an error prompt!


Addendum: Leave the first line of the BAT to be encrypted blank, and there will be no error! ! !
:lol:
个人主页-找餐厅:http://www.canting.cc
Floor 103 Posted 2006-11-21 03:10 ·  中国 浙江 金华 电信
新手上路
Credits 9
Posts 6
Joined 2005-07-15 13:51
20-year member
UID 40737
Gender Male
Status Offline
If it's a master, it might not be difficult... Just for novices it can be...
Floor 104 Posted 2006-11-21 03:14 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Moderator, this post has too much water. Can you delete some of the spam posts, including my post, to facilitate viewing and learning?
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 105 Posted 2006-11-21 15:29 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
On the basis of building in floor 74, use "2>nul" to shield the error output of the first encrypted line
Attachments
EncryBat.rar (427 bytes, Credits to download 1 pts, Downloads: 201)
‹ Prev 1 5 6 7 8 9 25 Next ›
Forum Jump: