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 07:49
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] [Discussion] Non-compiled Batch Processing Encryption Scheme and Code DigestI View 110,345 Replies 364
Floor 346 Posted 2008-09-17 15:29 ·  中国 辽宁 沈阳 联通
新手上路
Credits 4
Posts 2
Joined 2008-09-17 14:21
17-year member
UID 125862
Gender Male
Status Offline
Take a look and have a try
Floor 347 Posted 2008-09-27 14:31 ·  中国 贵州 黔东南苗族侗族自治州 凯里市 电信
新手上路
Credits 2
Posts 1
Joined 2008-09-25 02:47
17-year member
UID 126555
Gender Male
Status Offline
The method is very good, but what about the sequel...? Looking forward to it...
Floor 348 Posted 2008-09-28 13:03 ·  中国 江苏 苏州 电信
初级用户
Credits 56
Posts 21
Joined 2007-02-01 13:46
19-year member
UID 78326
Gender Male
Status Offline
I daren't use it at all!!!!!
Floor 349 Posted 2008-10-03 01:07 ·  中国 广东 电信
新手上路
Credits 9
Posts 5
Joined 2007-05-04 21:32
19-year member
UID 87489
Gender Male
Status Offline
Unexpectedly, a chance encounter allowed me to see so many wonderful things
Floor 350 Posted 2008-10-05 14:38 ·  中国 山东 淄博 电信
初级用户
Credits 63
Posts 37
Joined 2008-08-09 11:46
17-year member
UID 123026
Gender Male
Status Offline
Strong support, meeting each other late...
Floor 351 Posted 2008-10-18 16:22 ·  中国 河南 郑州 联通
贫困用户
Credits -1
Posts 1
Joined 2008-05-30 13:32
18-year member
UID 120087
Gender Male
Status Offline
Nice
Floor 352 Posted 2008-10-18 18:23 ·  中国 四川 成都 电信
初级用户
Credits 21
Posts 21
Joined 2008-10-18 17:51
17-year member
UID 128679
Gender Male
Status Offline
Really learned something new, study study ^_^
Floor 353 Posted 2008-10-18 22:36 ·  中国 上海 电信
新手上路
Credits 11
Posts 7
Joined 2007-09-16 17:03
18-year member
UID 97544
Gender Male
Status Offline
Learninging....
Floor 354 Posted 2008-10-18 23:33 ·  中国 湖南 衡阳 电信
初级用户
★★
Credits 149
Posts 57
Joined 2006-10-26 11:39
19-year member
UID 68362
Gender Male
From 湖南
Status Offline
1. Create a new text file "a.txt", open it, hold down the alt key and then type 159, release the alt key, and the character "Ÿ" will appear. Save this text with Unicode encoding.
2. Leave a few lines blank before the batch file code to be encrypted, otherwise an error will occur.
3. CMD command: copy /a a.txt + /b b.bat = c.bat. This method works very well. Everyone can give it a try.
Floor 355 Posted 2008-10-19 00:30 ·  中国 江西 联通
初级用户
Credits 41
Posts 32
Joined 2008-10-16 00:11
17-year member
UID 128490
Gender Male
Status Offline
Learning
Floor 356 Posted 2008-10-30 14:38 ·  中国 广东 广州 海珠区 电信
新手上路
Credits 2
Posts 2
Joined 2008-10-30 12:32
17-year member
UID 129539
Gender Male
Status Offline
Good stuff
Floor 357 Posted 2008-10-30 14:38 ·  中国 广东 广州 海珠区 电信
新手上路
Credits 2
Posts 2
Joined 2008-10-30 12:32
17-year member
UID 129539
Gender Male
Status Offline
Good stuff
Floor 358 Posted 2008-10-31 01:46 ·  中国 北京 鹏博士BGP
高级用户
★★★
据说是李先生
Credits 609
Posts 400
Joined 2008-04-23 15:55
18-year member
UID 116706
Gender Male
Status Offline
Very rewarding!
I also want to write an encryptor
Floor 359 Posted 2008-10-31 03:51 ·  中国 北京 鹏博士BGP
高级用户
★★★
据说是李先生
Credits 609
Posts 400
Joined 2008-04-23 15:55
18-year member
UID 116706
Gender Male
Status Offline
Usage method:
Drag the file that needs to be encrypted to this program with the mouse, and the encrypted file will be automatically generated in the current folder.

Explanation:
Thanks to willsort, zh159, xjj2007 and others for providing the principle. Later, after many tests, I found that:
As long as an ASCII-encoded file is appended to the end of a UNICODE-encoded file in binary mode, the content behind will be displayed as garbled characters.
Therefore, the program I wrote does not actually perform the method mentioned by the above几位, but uses VBSCRIPT to directly create a UNICODE-encoded file header (it can be any content, for details, see the comments in the source code), and then combine it with the file we need to encrypt.

Features:
There will be no errors if there are spaces or other special characters in the file name and file path.
Some places can be modified more personalized (see the comments in the source code)

Precautions:
1. The original BAT file must be in ASCII encoding. Otherwise, it will not be successful
2. The encrypted file generated by this program is larger than the original file. Specifically, how much larger it is depends on how much is written in the tmpstr.WriteLine statement when creating the UNICODE-encoded file header. You can define it yourself.
3. The attached "BAT Encryptor VBS Version.vbs" and "BAT Encryptor Keep Copyright Version.vbs" have exactly the same functions. Those who are interested can open them with Notepad to see the differences, hehe...
4. BUG: Because the code for deleting the file uses the CMD command, it is currently found that it cannot be deleted only when the file is in the root directory of the disk, but it does not affect normal use and can be deleted manually. Since time is limited, it will not be corrected.

VBSCRIPT script source code:
'''''''''''''''''''''''''''''''''''
'' (P)2008 Jv Ching (qinchun36) ''
'' Powed by 中国DOS联盟 ''
'' http://www.cn-dos.net/forum/ ''
'''''''''''''''''''''''''''''''''''
on error resume next
if Wscript.Arguments(0)="" then
msgbox "Drag the target file to me with the mouse!!!",16,"Usage method"
else

dim origfile,tmpstr,ching,fso,orig,fname,fpath
origfile=Wscript.Arguments(0)
Set fso=CreateObject("Scripting.FileSystemObject")
set ching=wscript.createobject("wscript.shell")
set tmpstr=fso.getfile(origfile)
fpath=tmpstr.parentfolder&"\"

fname="new_"&tmpstr.name 'Define the encrypted file name as new_original file, you can change it to other.

'If new_original file already exists, delete it.
if (fso.fileexists(fpath&fname)) then
Set tmpstr=fso.getfile(fpath&fname)
tmpstr.Delete
end if

'Create a UNICODE-encoded file header. In WINDOWS, you will only see these non-garbled characters when opened with Notepad.
Set tmpstr=fso.CreateTextFile(fpath&"unihead.txt",1,-1)
tmpstr.WriteLine "Grass, what the hell are you looking at, I've been garbled by qinchun36!" 'You can write anything in the double quotes in front
tmpstr.close

'Add two blank lines and CLS clear screen statement at the beginning of the converted file
Set tmpstr=fso.CreateTextFile(fpath&"bathead.txt",1)
tmpstr.writeBlankLines 2
tmpstr.writeline("cls") 'Clear the error message at the beginning, you can also remove this line.
tmpstr.close

'For simplicity, call the CMD command to merge files and delete excessive files
tmpstr="cmd /c copy /b "&chr(34)&fpath&"unihead.txt"&chr(34)&"+"&chr(34)&fpath&"bathead.txt"&chr(34)&"+"&chr(34)&origfile&chr(34)&" "&chr(34)&fpath&fname&chr(34)&chr(38)&"del "&chr(34)&fpath&"unihead.txt"&chr(34)&chr(38)&"del "&chr(34)&fpath&"bathead.txt"&chr(34)
ching.run tmpstr,0

msgbox "The encrypted file is:"&chr(13)&chr(13)&fpath&fname,64,"Mr. Ching reminds you"

end if


[ Last edited by qinchun36 on 2008-11-1 at 21:59 ]
Attachments
BAT加密器VBS版.rar (2.13 KiB, Downloads: 53)
Floor 360 Posted 2008-11-04 23:54 ·  中国 广东 中山 电信
新手上路
Credits 12
Posts 12
Joined 2008-11-04 22:48
17-year member
UID 130007
Gender Male
Status Offline
Good stuff! Thanks!!!
Forum Jump: