中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-07 03:46
48,040 topics / 350,125 posts / today 1 new / 48,252 members
DOS批处理 & 脚本技术(批处理室) » [Original] [Discussion] Non-compiled Batch Processing Encryption Scheme and Code
Printable Version  113,590 / 364
Floor1 biobio Posted 2006-07-10 10:52
初级用户 Posts 44 Credits 162
Although .bat files are convenient to use, their security is too weak. Anyone can open them to view or even modify the content. Is there a way to keep the file as a .bat without converting it to .exe, .com, or other formats, while preventing others from viewing and modifying its content? Is there any self-encryption method available? Experts, please provide a solution思路.


───────────────── Moderator's Note ─────────────────
The currently discussed solutions are as follows:
1. Inserting Unicode feature strings into batch code (Floor 7, yuanyong630)
Related discussions can be found on Floors 24, 25, 45, 48, etc.

Download link for the code implementation (Floor 27, pengfei):
Click to download: BAT Encryption Tool.rar

Effective for programs that use the IsTextUnicode function to identify encoding types, such as Notepad.
Ineffective for programs that do not use the IsTextUnicode function, such as type/edit/EditPlus/UltraEdit.

2. Adding a Unicode Byte Order Mark (BOM) to the header of batch code (Floor 40, zxcv)
Related discussions can be found on Floors 41, 43, 69, etc.

Download link for the code implementation (Floor 71, zxcv):
EncryBat.rar (zxcv)

Effective for programs that support Unicode encoding, such as Notepad, Word, UltraEdit, and type.
Ineffective for programs that do not support Unicode encoding, such as edit and WinRAR internal viewer.

3. Replacing carriage return-line feed characters in batch code with carriage return characters (Floor 17, electronixtar)
Related discussions can be found on Floor 26.

Effective for editors that separately recognize carriage return-line feed characters, such as edit.

4. Dictionary-based conversion of batch code (Floor 11, 3742668)
Related discussions and code implementations can be found on Floors 11 and 15.

The code is dynamically generated during plaintext execution, so this solution is independent of the editor.

Points Reward:
yuanyong630, 3742668, pengfei, and zxcv will each receive 8 points.
electronixtar will receive 4 points.
───────────────── Moderator's Note ─────────────────


[ Last edited by willsort on 2006-8-6 at 04:02 ]
Floor2 electronixtar Posted 2006-07-10 11:27
铂金会员 Posts 2,672 Credits 7,493
I knew this thread would become popular a long time ago, so I claimed the first comment spot, haha

[ Last edited by electronixtar on 2007-5-8 at 08:36 PM ]
Floor3 kcdsw Posted 2006-07-10 17:34
中级用户 Posts 179 Credits 404
QuickBFC.EXE

After searching, this program essentially embeds batch files, so it can execute correctly as long as the environment is appropriate.
Floor4 zhaxi Posted 2006-07-10 19:19
初级用户 Posts 40 Credits 112
This QuickBFC.EXE can only package one batch file into an executable, which is not very useful.

Is there a tool that can package a group of batch files into an executable? This is because programs often consist of multiple batch files.
Floor5 kcdsw Posted 2006-07-10 19:22
中级用户 Posts 179 Credits 404
Then go find something useful. Why don't you just write one for everyone? Spouting such nonsense.
Floor6 asbai Posted 2006-07-11 21:04
高级用户 Posts 252 Credits 653
Originally posted by kcdsw at 2006-7-10 19:22:
Then go find something useful. Why don't you just write one for everyone?
What nonsense are you talking about?


hoho, is that necessary? Why are you so angry?
Floor7 yuanyong630 Posted 2006-07-13 11:28
初级用户 Posts 13 Credits 49
BAT File Encryption Method (Better than the Bat2Com software because that software does not support Chinese)

The method is:

Open "Notepad" and write the following statement at the beginning of the file

for /l %%a in (1,1,10) do ren *.jpg %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a %%a
Floor8 flying008 Posted 2006-07-13 11:44
中级用户 Posts 103 Credits 245
Valid... Supported... Thank you... It is an absolute crystallization of wisdom and technology! Then, may I ask the person above, how can the content be displayed again? Where there is a shield, there must be a spear, right?
Floor9 wang6610 Posted 2006-07-13 12:47
银牌会员 Posts 488 Credits 1,246
The 7th floor tested it and confirmed it works.
Floor10 bagpipe Posted 2006-07-13 12:57
银牌会员 Posts 425 Credits 1,144 From 北京
Let's all calm down. Zhaxi on the 4th floor, tasks that can be completed with multiple batch files can also be written into a single batch file; it just differs in terms of code volume.
Floor11 3742668 Posted 2006-07-13 15:41
荣誉版主 Posts 718 Credits 2,013

『Floor 8』:

Effective... Supported... Thank you... It is definitely a crystallization of wisdom and technology!
May I ask the person above, how can I redisplay the content? Where there is a shield, there must be a spear, right?
『Floor 9』:

Tested on the 7th floor, it works.

I am too inexperienced; I can't figure out how the code on the 7th floor can实现加密代码的作用.
Could it be that friends on the 8th and 9th floors pasted the code from the 7th floor at the beginning of their own scripts, saved it, and then couldn't see their own code when they opened it? It seems a bit sensational.
Since everyone is so interested in encryption, I'll join in too:


Regarding BAT encryption, I也曾憧憬过 it a long time ago. However, due to the limitations of BAT, if you purely use BAT to encrypt BAT, even after encryption, others might still be able to view the source code very easily. But if the people you want to deal with are just unskilled beginners, the following method might be helpful:
In our system, there are quite a few default environment variables. For example, in my XP SP2, running the SET command gives the following list of variables:

ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\**\Application Data
CLIENTNAME=Console
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=GOOGLE
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\**
LOGONSERVER=\\GOOGLE
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;"C:\Program Files\S
ymantec\Norton Ghost 2003\"
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0209
ProgramFiles=C:\Program Files
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\**\LOCALS~1\Temp
TMP=C:\DOCUME~1\**\LOCALS~1\Temp
USERDOMAIN=GOOGLE
USERNAME=**
USERPROFILE=C:\Documents and Settings\**
windir=C:\WINDOWS

In addition, there are some variable variables:

%CD% - Expands to the current directory string.
%DATE% - Expands to the current date in the same format as the DATE command.
%TIME% - Expands to the current time in the same format as the TIME command.
%RANDOM% - Expands to a random decimal number between 0 and 32767.
%ERRORLEVEL% - Expands to the current ERRORLEVEL value.
%CMDEXTVERSION% - Expands to the current command processor extension version number.
%CMDCMDLINE% - Expands to the original command line that invoked the command processor.

Using these environment variables, we can completely transform our scripts beyond recognition. For example:

I believe everyone can immediately see that its function is to print the string bbs.cn-dos.net to the screen. Then can you immediately see the function of the following code? (It is only one line)

Or define your own variables:

How about it, a bit dazzling, isn't it?
Veterans will snicker: Just add echo before the %, % line and run it, and the code will display itself...
Oh no, fortunately, I am not to be trifled with either:

To deal with beginners, the above method will already make them dazzled. However, this is just the beginning. There are also methods such as inserting misleading garbage code, advanced variable encryption, and automatic code modification after one run. The best is yet to come.
(To be continued)
Floor12 buddiyar Posted 2006-07-15 01:06
初级用户 Posts 75 Credits 160
Is this really effective?

Then why is that?

Could the experts please explain first?
Floor13 flying008 Posted 2006-07-21 14:24
中级用户 Posts 103 Credits 245
That's strange. Now when pasting code, the BAT content can't be hidden again. It was working just a few days ago.
Floor14 雨露 Posted 2006-07-21 15:32
管理员 Posts 2,601 Credits 6,215
The method in the 7th floor does not seem to work at all.
Floor15 namejm Posted 2006-07-21 15:48
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Moderator 3742668's encryption uses character truncation and character substitution. It seems necessary to master common cryptographic methods, but writing code this way requires manually maintaining a character substitution table, which is somewhat tedious.
1 2 3 425  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023