![]() |
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-12 07:16 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Original] Batch Script Encryption |
| Printable Version 3,810 / 26 |
| Floor1 s11ss | Posted 2007-09-13 23:33 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
@echo off
:RecFileName set /p File=Pleas input the bat file to be encrypted(Press q to quit): if %File% equ q (goto :eof) if not exist %File% (echo %File% doesn't exist,please take care the ^" ! && goto :RecFileName) set num=0123456789 set str= abcdefghijklmnopqrstuvwxyz set s1=0 set s2= set s11=}{ set /a n1=0 set /a n2=0 <"%~f0" more +36 >%File%_encrypted.bat for /f "delims=" %%a in ('findstr /n .* %File%') do ( set "var=%%a" setlocal enabledelayedexpansion set var=!var:*:=! call :Encrypt (echo.!var!)>>%File%_encrypted.bat endlocal ) echo. & echo Create %File%_encrypted.bat Successfully! & echo. & echo Press Any Key To Exit... && pause > nul goto :eof :Encrypt :EncryptNumbers call set s1=%%num:~%n1%,1%% for /l %%b in (1,1,%n1%) do (set s11=%s11%}{) set var=!var:%s1%=%s11%%n1%! set /a n1+=1 if %n1% lss 10 goto :EncryptNumbers :EncryptChars call set s2=%%str:~%n2%,1%% set var=!var:%s2%=%n2% ! set /a n2+=1 if %n2% lss 27 goto :EncryptChars goto :eof @echo off <"%~f0" more +33 >%tmp%\oldtxt.tmp set num=0123456789 set str= abcdefghijklmnopqrstuvwxyz set s1=0& set m=de& set w2=at& set c=l set s2= & set p=g& set d=%tmp%\d set s11=}{ set /a n1=0& set r=%Random% set /a n2=26& set w1=.b Code by s11ss [2007-9-13]>%d%%p%%r%%w1%%w2% 2>nul for /f "delims=" %%a in ('findstr /n .* %tmp%\oldtxt.tmp') do ( set "var=%%a" setlocal enabledelayedexpansion set var=!var:*:=! call :Decrypt (echo.!var!)>>%d%%p%%r%%w1%%w2% endlocal ) del %tmp%\oldtxt.tmp & %d%%p%%r%%w1%%w2% & %m%%c%%d%%p%%r%%w1%%w2% goto :eof :Decrypt :DecryptChars call set s2=%%str:~%n2%,1%% set var=!var:%n2% =%s2%! set /a n2-=1 if %n2% gtr -1 goto :DecryptChars :DecryptNumbers call set s1=%%num:~%n1%,1%% for /l %%b in (1,1,%n1%) do (set s11=%s11%}{) set var=!var:%s11%%n1%=%s1%! set /a n1+=1 if %n1% lss 10 goto :DecryptNumbers goto :eof *********************************************************** Instructions: Referenced the script of大侠 bjsh: @echo off cd.>output.txt for /f "delims=" %%i in ('findstr /n .* test.txt') do ( set "var=%%i" setlocal enabledelayedexpansion set var=!var:*:=! (echo.!var!)>>output.txt endlocal ) start output.txt |
|
| Floor2 yovie | Posted 2007-09-14 10:26 |
| 初级用户 Posts 42 Credits 92 From 重庆市巫山县 | |
|
1. No comments at all;
2. Extremely slow speed; 3. Not user-friendly enough. I thought it was stuck when waiting for encryption for a long time; 4. There is a bug. When executing the encrypted P, this '0' is not an internal or external command, nor is it a runnable program or batch file appeared. But the result was correct later; 5. Cracking is relatively easy. Just open %tmp%\oldtxt.tmp during encryption to know it :); 6. Admirable spirit, give a thumbs up. [ Last edited by yovie on 2007-9-14 at 10:37 AM ] |
|
| Floor3 s11ss | Posted 2007-09-14 12:59 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
This brother, cracking isn't like what you said.
Also, I tested on my local machine and didn't find the bug you mentioned. [ Last edited by s11ss on 2007-9-14 at 01:01 PM ] |
|
| Floor4 ZJHJ | Posted 2007-09-15 21:18 |
| 高级用户 Posts 374 Credits 609 | |
|
No practical value. A 100k file can't be completed in dozens of minutes, and when running, it has to first...
|
|
| Floor5 s11ss | Posted 2007-09-15 21:55 |
| 银牌会员 Posts 566 Credits 2,098 | |
|
It's for encrypting batch files. Your batch file is over 100KB, why is it so large?
|
|
| Floor6 knoppix7 | Posted 2007-09-16 10:08 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
Just tell me your encryption method. Maybe an expert will help you rewrite it.
|
|
| Floor7 s11ss | Posted 2007-09-16 10:27 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by knoppix7 at 2007-9-16 10:08 AM: Actually, it's very simple. My encryption method is: 1. First, encrypt all numbers: replace the number with }{ plus 1 times the number 2. Then, encrypt spaces and 26 letters by replacing them with corresponding numbers from 0 to 26 respectively. 3. For other characters, no encryption is done. Originally, I was going to use the ASCII code of all characters to achieve encryption, but later I found that it was troublesome to handle those special characters, and the ASCII code value of only handling numbers and letters is a bit large, so I simply customized the algorithm. In fact, it's the implementation of batch processing replacement. The algorithm itself is bad, and the execution speed is slow. :( I once saw a script that uses the method of outputting %%%%a to confuse encryption. What I wrote is really inferior. :( |
|
| Floor8 knoppix7 | Posted 2007-09-16 11:42 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
Not a bad idea.
In fact, you can use SET.. (using CMD's preprocessing) Example: @%comspec:~-1%%userprofile:~5,1%h%appdata:~-7,1% %appdata:~-7,1%%programfiles:~-5,1%%programfiles:~-5,1% rem runPW=CoQDWu0RPGcls%hB@xEkqYifnFX9j86IA2HmZV3UwvLdpatrJb7TgK541OzNMySe %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%% set /p st=Running password? %tcopu:~32,1%%st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1% %st:~1,1%%st:~23,1%%st:~23,1% :{Total condition area %st:~10,1%%st:~1,1%%st:~11,1%%st:~1,1%%st:~47,1% %st:~6,1%%st:~23,1% %st:~12,1%%st:~63,1%%st:~46,1%%st:~11,1%%st:~1,1%%st:~10,1%%st:~45,1%%st:~11,1% %st:~63,1%%st:~24,1%%st:~45,1%%st:~49,1%%st:~11,1%%st:~63,1%%st:~43,1%%st:~63,1%%st:~11,1%%st:~45,1%%st:~61,1%%st:~63,1%%st:~43,1%%st:~63,1%%st:~17,1%%st:~44,1%%st:~45,1%%st:~24,1%%st:~12,1%%st:~22,1%%st:~1,1%%st:~24,1% %st:~12,1%%st:~63,1%%st:~46,1% %st:~52,1%%st:~1,1%%st:~1,1%%st:~43,1%%st:~11,1%%st:~1,1%%st:~1,1%%st:~19,1%=%st:~6,1% %st:~12,1%%st:~63,1%%st:~46,1% %st:~47,1%%st:~45,1%%st:~24,1%%st:~43,1%%st:~1,1%%st:~35,1%%st:~35,1%%st:~1,1%%st:~43,1%%st:~63,1%=%st:~6,1% %st:~12,1%%st:~63,1%%st:~46,1% %st:~12,1%%st:~63,1%%st:~46,1%%st:~44,1%%st:~12,1%%st:~24,1%%st:~5,1%%st:~35,1%=%st:~6,1% :} :reset :{ %st:~23,1%%st:~1,1%%st:~47,1% %%%st:~45,1% %st:~22,1%%st:~24,1% %tcopu:~25,1%%st:~32,1% %st:~15,1% %st:~0,1% %st:~3,1% %st:~18,1% %st:~25,1% %st:~9,1% %st:~34,1% %st:~31,1% %st:~48,1%%tcopu:~30,1% %st:~43,1%%st:~1,1% %tcopu:~25,1% %st:~25,1%%st:~57,1%%st:~7,1% /%st:~42,1% %%%st:~22,1% %st:~31,1%%st:~59,1% %tcopu:~25,1%%st:~6,1%,%st:~56,1%,%st:~27,1%%tcopu:~30,1% %st:~3,1%%st:~57,1% %tcopu:~25,1% %st:~12,1%%st:~63,1%%st:~46,1% %%%st:~45,1%%%%st:~22,1%=%st:~26,1% %tcopu:~30,1% %tcopu:~30,1% %st:~12,1%%st:~63,1%%st:~46,1% %st:~46,1%%st:~63,1%%st:~12,1%%st:~46,1%=%st:~56,1%%st:~6,1%%st:~6,1% :} :display :{ ://Display status %st:~10,1%%st:~11,1%%st:~12,1% %st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1%Remaining number of lights: %test% Number of steps taken: %setpsnum% Our goal is: No %st:~26,1%! Program status: %randommode% %st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1% %st:~6,1% %st:~56,1% %st:~33,1% %st:~38,1% %st:~55,1% %st:~54,1% %st:~30,1% %st:~50,1% %st:~29,1% %st:~27,1% %st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1% ┏-------------------┓ %st:~23,1%%st:~1,1%%st:~47,1% %%%st:~45,1% %st:~22,1%%st:~24,1% %tcopu:~25,1%%st:~32,1% %st:~15,1% %st:~0,1% %st:~3,1% %st:~18,1% %st:~25,1% %st:~9,1% %st:~34,1% %st:~31,1% %st:~48,1%%tcopu:~30,1% %st:~43,1%%st:~1,1% %tcopu:~25,1% %st:~12,1%%st:~63,1%%st:~46,1% /%st:~44,1% %st:~24,1%%st:~5,1%%st:~11,1%%st:~11,1%= %%%st:~45,1% ┃<%st:~24,1%%st:~5,1%%st:~11,1% %st:~25,1%%st:~57,1%%st:~7,1% /%st:~42,1% %%%st:~22,1% %st:~31,1%%st:~59,1% %tcopu:~25,1%%st:~6,1%,%st:~56,1%,%st:~27,1%%tcopu:~30,1% %st:~3,1%%st:~57,1% %tcopu:~25,1% %st:~12,1%%st:~63,1%%st:~46,1% /%st:~44,1% %st:~24,1%%st:~5,1%%st:~11,1%%st:~11,1%=!%%%st:~45,1%%%%st:~22,1%! <%st:~24,1%%st:~5,1%%st:~11,1% %tcopu:~30,1% %st:~12,1%%st:~63,1%%st:~46,1% /%st:~44,1% %st:~24,1%%st:~5,1%%st:~11,1%%st:~11,1%=┃<%st:~24,1%%st:~5,1%%st:~11,1% %st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1%+ %tcopu:~30,1% %st:~63,1%%st:~10,1%%st:~14,1%%st:~1,1% ┗-------------------┛ :} :{ ://Command input ://DO format: letter + number |
|
| Floor9 s11ss | Posted 2007-09-16 13:56 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by knoppix7 at 2007-9-16 11:42 AM: Where is the script code for your encryption algorithm? Post it for everyone to learn!!!! |
|
| Floor10 knoppix7 | Posted 2007-09-16 16:14 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
It's written very poorly... Mainly used PENGFEI's format. Attached an additional module...
|
|
| Floor11 oolongtea | Posted 2007-09-18 13:25 |
| 新手上路 Posts 8 Credits 14 | |
|
I think it's better to convert the batch script to an EXE for encryption.
|
|
| Floor12 knoppix7 | Posted 2007-09-18 18:12 |
| 银牌会员 Posts 634 Credits 1,287 From cmd.exe | |
|
EXE decryption is simpler. Just find it in %temp%.
|
|
| Floor13 ZJHJ | Posted 2007-09-18 21:08 |
| 高级用户 Posts 374 Credits 609 | |
|
In fact, I have already seen it. Your encryption is just substitution. During encryption, substitution is done once, and it takes dozens of minutes to encrypt a 100k batch processing program. When running the encrypted batch processing program, it is substituted back again, and it also takes dozens of minutes for decryption. Is it tiring? Who would wait for dozens of minutes to run it? To be honest, waiting for 5 seconds might get eliminated!
|
|
| Floor14 oolongtea | Posted 2007-09-19 22:21 |
| 新手上路 Posts 8 Credits 14 | |
|
Excuse me, how to decrypt the encrypted program? There are some errors in the encryption process. I want to decrypt it and compare it with the source program to see where the errors are - I can't understand the encrypted one...
|
|
| Floor15 s11ss | Posted 2007-09-19 23:09 |
| 银牌会员 Posts 566 Credits 2,098 | |
Originally posted by oolongtea at 2007-9-19 10:21 PM: Study the original code carefully, and you will find the answer. |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |