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-20 05:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to encrypt & decrypt batch processing View 2,469 Replies 19
Original Poster Posted 2007-06-08 12:47 ·  中国 广东 肇庆 电信
初级用户
Credits 42
Posts 19
Joined 2007-06-08 11:32
19-year member
UID 90653
Gender Male
Status Offline
As the title says
I've only been learning for a few days, hope everyone can help, thank you...!!!
Floor 2 Posted 2007-06-08 13:03 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Floor 3 Posted 2007-06-08 13:18 ·  中国 吉林 吉林市 电信
初级用户
Credits 46
Posts 9
Joined 2007-05-27 21:58
19-year member
UID 89507
Gender Male
Status Offline
Originally posted by jiangnan110 at 2007-6-8 12:47 PM:
As the title
I've only learned for a few days, hope everyone can help, thank you...!!!



Is it to prevent decompilation, that is, to display garbled code????
Floor 4 Posted 2007-06-08 13:22 ·  中国 广东 佛山 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
I think, maybe we can make a batch script that shuffles the batch scripts that need to be encrypted in a certain order or replaces them with other characters, and restores them in a certain order when decrypting. But in this way, the batch script cannot run before decryption, and it can be decrypted by others with only a certain patience.
Or convert it to an EXE, but then it's troublesome to view the source code...
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Floor 5 Posted 2007-06-08 16:17 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 2,000
Posts 621
Joined 2007-01-01 00:00
19-year member
UID 75212
Gender Male
Status Offline
Search it; there are many of them
Floor 6 Posted 2007-06-08 16:18 ·  中国 河北 石家庄 北京神州长城通信技术发展中心中国长城互联网
初级用户
★★
Credits 152
Posts 75
Joined 2007-02-06 22:09
19-year member
UID 78805
Gender Male
Status Offline
(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
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
xixixi +1 2007-06-08 23:48
txratu +2 2008-03-19 19:24
Floor 7 Posted 2007-06-08 17:16 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
I've tried various methods from this forum, but basically none of them work. Either it can't run after encryption, or the source code can be seen with a general editing software after encryption. I haven't found an effective method for the time being.
Windows 一键还原
http://www.yjhy.com
Floor 8 Posted 2007-06-08 18:42 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
I wrote a password - encrypted tool that encrypts a bat file into a vbs file, and after entering the password, restores the bat file.

On Error Resume Next:Dim WshSHell,FSO,EnCText:Set WshSHell = WScript.CreateObject("WScript.Shell"):Set FSO = CreateObject("Scripting.FileSystemObject"):EnCText="71575206^l\]\lcaZo]^2\din]h4^beZr6]bpg紊皽剁搭惰范若顿返蕊钝范:皽iYln^":outmm=Inputbox(vbcr&vbcr&"Please enter the encryption password: (3 - 8 - digit number)","Encrypt/Decrypt Text File - By baomaboy","25926183"):If outmm = "" then:WScript.Quit(0):end if:Lcode = len(outmm):outcode = outmm & mid(EnCText,1,8 - Lcode):Dim KeyArr(8):KeyArr(0) = Lcode:for i = 1 to 8:KeyArr(i) = Mid(outcode,i,1):next
Execute("EnCText=Mid(EnCText,9,Len(EnCText) - 8):For i = 1 To Len(EnCText)"&vbCrLf&"TempNum = Asc(Mid(EnCText,i,1))"&vbCrLf&"if TempNum = 18 Then"&vbCrLf&" TempNum = 34 "&vbCrLf&" end if "&vbCrLf&"TempNum = TempNum + KeyArr(i Mod 9)"&vbCrLf&"If TempNum = 28 Then"&vbCrLf&"TempNum = 13"&vbCrLf&"ElseIf TempNum = 29 Then"&vbCrLf&"TempNum = 10"&vbCrLf&"End If"&vbCrLf&"If TempNum > 23 and TempNum < 28 Then"&vbCrLf&"TempNum = TempNum - 20"&vbCrLf&"end if"&vbCrLf&"OCText = OCText & chr(TempNum)"&vbCrLf&"Next")
Set OutFile = FSO.OpenTextFile("Temp.bat",2,true):OutFile.WriteLine(OCText):OutFile.Close:Set WshSHell = Nothing:Set FSO = Nothing:WScript.Quit(0)
Floor 9 Posted 2007-06-08 18:46 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Originally posted by baomaboy at 2007-6-8 18:42:
Wrote one encrypted with a password, encrypting a bat to a vbs, entering the password to restore the bat file,

On Error Resume Next:Dim WshSHell,FSO,EnCText:Set WshSHell = WScript.CreateObject("WScript.Shel ...

Is there any special requirement for the operating system?
It flashes by and doesn't pass under win xp.
Windows 一键还原
http://www.yjhy.com
Floor 10 Posted 2007-06-08 19:08 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
There are no requirements for the system. You left, which means you saved the above as a bat, right? You need to save the code as a vbs instead.
Floor 11 Posted 2007-06-08 19:09 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Floor 12 Posted 2007-06-08 19:53 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by qinbuer at 2007-6-8 13:22:
I think, perhaps we can make a batch file, scramble the batch files that need to be encrypted in a certain order or replace them with other characters, and when decrypting, restore them in a certain order. But in this way, before decrypting, the batch ...

Not necessarily all can be decrypted!

http://www.cn-dos.net/forum/viewthread.php?tid=28829&fpage=1&highlight=%E5%8A%A0%E5%AF%86

If you can decrypt this, I'll f you
Floor 13 Posted 2007-06-08 20:45 ·  中国 广东 广州 联通
新手上路
Credits 17
Posts 8
Joined 2007-06-05 10:55
19-year member
UID 90305
Gender Male
Status Offline
Use a bat-to-exe ghost program.
Floor 14 Posted 2007-06-08 20:48 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Brother vkill, did you notice that your new version http://www.cn-dos.net/forum/viewthread.php?tid=28829&fpage=1&highlight=%E5%8A%A0%E5%AF%86 has started to be reported as a trojan virus by Kaspersky.

[ Last edited by baomaboy on 2007-6-8 at 08:50 PM ]
Floor 15 Posted 2007-06-08 21:17 ·  中国 江苏 南京 电信
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Originally posted by qinbuer at 2007-6-8 13:22:
I think, perhaps a batch file can be made to scramble the batch files that need to be encrypted in a certain order or replace them with other characters, and when decrypting, restore them in a certain order. But in this way, before decrypting, the batch ...


I feel that when it comes to the essence, there are only two types. One is the so-called smokescreen that looks like garbled code but can be executed directly. It seems that the tools in the special discussion thread of this forum can deal with it. The other type is the one that requires a password. Currently, it seems that only brute-force cracking is used. The theory is crackable, but in reality, it is very, very difficult.
The discussion about Ghost is no longer there. Let's talk about it when the temp file is solved.
Forum Jump: