标题: [文本处理] 批处理文本文件加解密器(带密码) [打印本页]
作者: 0000 时间: 2017-2-1 12:07 标题: 批处理文本文件加解密器(带密码)
本帖最后由 0000 于 2017-2-2 15:53 编辑
批处理文本文件加解密器(带密码)
注:加密很长的中文文件时可能会不稳定。
算法有点长,请耐心浏览
已补上2楼的坑,请放心使用
加密:
- @echo off
- title 纯文本加解密工具1.0(加密)
- rem 退格符
- rem 标记感叹号
- set exc=!
- rem 标记引号
- set quo="
- rem 标记caret号
- set car=^^
- setlocal ENABLEDELAYEDEXPANSION
- rem 标记大写字母
- set CAP=ABCDEFGHIJKLMNOPQRSTUVWXYZ
- for /l %%n in (0,1,25) do (set CAP_!CAP:~%%n,1!=!CAP:~%%n,1!)
-
- echo 纯文本加解密工具1.0(加密) BY 0000
- :setfile
- set /p file=文件名称:
- if "!file!"=="" (echo 无效的文件名&goto setfile)
- set file=!file:"=!
- if "!file!"=="" (echo 无效的文件名&goto setfile)
- echo "!file!"|findstr /R /C:"[*?]">nul&&(echo 无效的文件名&goto setfile)
- set file_1=!file:~-1!
- if "!file_1!"=="/" (echo 无效的文件名&goto setfile)
- if "!file_1!"=="\" (echo 无效的文件名&goto setfile)
- dir /a-d "!file!">nul 2>nul||(echo 无效的文件名&goto setfile)
- dir /a-d "!file!\">nul 2>nul&&(echo 无效的文件名&goto setfile)
- :setpswd
- call :inputpswd 6 *
- rem 获取密码内容
- set /a pswd_a=1%pswd:~0,3%-900
- set /a pswd_b=1%pswd:~3,3%-900
-
- call :getfile2
-
- set /p =分析中. . . *****/*****( 0%%)<nul
- call :getline "!file!"
-
- set ln_n=0
- for /f "usebackq tokens=* eol= delims=" %%L in ($tmp$.txt) do (
- set /a ln_n=!ln_n!+1
- set ln_!ln_n!=%%L
- )
- del $tmp$.txt
- rem 去引号
- for /l %%n in (1,1,%ln_n%) do (
- set "ln_%%n=!ln_%%n:~1,-1!"
- set "ln_%%n=!ln_%%n:""="!"
- )
-
-
- set _n=1
- set ln=!ln_1!
- set chars=
- set chars_n=0
-
- :getchars
- if %_n% gtr %ln_n% goto getc0
- if "!ln!"=="" goto getc1
- set lna=!ln:~0,1!
- set ln=!ln:~1!
- rem 先考虑引号,感叹号,等号和冒号
- if "!lna!" == "!quo!" (
- rem 判断字母是否存在
- if not "!char_qu!"=="-1" (
- set chars=!chars!!quo!
- set /a chars_n=!chars_n!+1
- rem 字母已存在标志
- set char_qu=-1
- )
- goto getchars
- )
- if "!lna!"=="!exc!" (
- if not "!char_ex!"=="-1" (
- set chars=!chars!!exc!
- set /a chars_n=!chars_n!+1
- set char_ex=-1
- )
- goto getchars
- )
- if "!lna!"=="=" (
- if not "!char_eq!"=="-1" (
- set chars=!chars!=
- set /a chars_n=!chars_n!+1
- set char_eq=-1
- )
- goto getchars
- )
- if "!lna!"==":" (
- if not "!char_as!"=="-1" (
- set chars=!chars!:
- set /a chars_n=!chars_n!+1
- set char_as=-1
- )
- goto getchars
- )
- rem 大写字母判断
- if "!CAP_%lna%!"=="%lna%" (
- if not "!charCAP_%lna%!"=="-1" (
- set chars=!chars!!lna!
- set /a chars_n=!chars_n!+1
- set charCAP_!lna!=-1
- )
- ) else (
- if not "!char_%lna%!"=="-1" (
- set chars=!chars!!lna!
- set /a chars_n=!chars_n!+1
- set char_!lna!=-1
- )
- )
- goto getchars
-
- :getc1
- set sh1= %_n%
- set sh2= %ln_n%
- set /a sh3=%_n%*100/%ln_n%
- set sh3= %sh3%
- set /p =分析中. . . %sh1:~-5%/%sh2:~-5%(%sh3:~-2%%%)<nul
- set /a _n=%_n%+1
- set ln=!ln_%_n%!
- goto getchars
-
- :getc0
-
-
- set /p =正在加密. . . 0/%sh2:~-5%( 0%%)<nul
- set _n=%chars_n%
-
- rem 打乱字符表
- :randchars
- if %_n% lss 0 goto ran0
- set /a k=%random%*%_n%/32768
- set /a k1=%k%+1
- set chars=!chars:~0,%k%!!chars:~%k1%!!chars:~%k%,1!
- set /a _n=%_n%-1
- goto randchars
- :ran0
-
-
- set _n=%chars_n%
- rem 标记字符位置
- :setcharnum
- set /a _n=%_n%-1
- if %_n% lss 0 goto setcn0
- set _c=!chars:~%_n%,1!
- rem 先考虑引号,感叹号,等号和冒号
- if "!_c!" == "!quo!" (
- set char_qu=!_n!
- goto setcharnum
- )
- if "!_c!"=="!exc!" (
- set char_ex=!_n!
- goto setcharnum
- )
- if "!_c!"=="=" (
- set char_eq=!_n!
- goto setcharnum
- )
- if "!_c!"==":" (
- set char_as=!_n!
- goto setcharnum
- )
- rem 大写字母判断
- if "!CAP_%_c%!"=="%_c%" (
- set charCAP_!_c!=!_n!
- ) else (
- set char_!_c!=!_n!
- )
- goto setcharnum
- :setcn0
-
- rem 随机产生字符平移参数
- set /a move_max=%chars_n%/2
- if %move_max% gtr 30 set move_max=30
- :setmove
- set /a move_a=%move_max%*%random%/32767+1
- set /a move_b=%move_max%*%random%/32767+1
- if %random% lss 16384 set /a move_a=-%move_a%
- if %random% lss 16384 set /a move_b=-%move_b%
- rem 通过复数运算得到密码数[ (字符平移参数a + 字符平移参数b * i) * ((密码前三位 + 100) + (密码后三位 + 100) * i) = 密码数]
- call :complex %move_a% %move_b% * %pswd_a% %pswd_b% seed_a seed_b
- call :complex %seed_a% %seed_b% / %pswd_a% %pswd_b% a b
- rem 检查运算是否正确
- if not "%a%"=="%move_a%" goto setmove
- if not "%b%"=="%move_b%" goto setmove
- rem 检查字符平移参数是否互质(保证密码唯一性)
- if %a% lss 0 set /a a=-%a%
- if %b% lss 0 set /a b=-%b%
- :setm1
- if %a% gtr %b% (set /a a=%a% %% %b%) else (set /a b=%b% %% %a%)
- set /a ab=%a%*%b%
- if "%ab%"=="0" (
- set /a a_b=%a%+%b%
- if not "!a_b!"=="1" goto setmove
- ) else (
- goto setm1
- )
-
-
- set _n=1
- set ln=!ln_1!
- set enc=
- set enc_n=0
- set /a move=-%move_a%
- (
- echo TXT_ENCRIPT_1.0 BY 0000
- echo %seed_a%_%seed_b%
- echo;!chars!
- )>"!file2!"
-
- :encriptline
- if %_n% gtr %ln_n% goto enc0
- if "!ln!"=="" goto enc1
- set lna=!ln:~0,1!
- set ln=!ln:~1!
- rem 先考虑引号,感叹号,等号和冒号
- if "!lna!"=="!quo!" (call :setenc "!char_qu!"&goto encriptline)
- if "!lna!"=="!exc!" (call :setenc "!char_ex!"&goto encriptline)
- if "!lna!"=="=" (call :setenc "!char_eq!"&goto encriptline)
- if "!lna!"==":" (call :setenc "!char_as!"&goto encriptline)
- rem 大写字母判断
- if "!CAP_%lna%!"=="%lna%" (call :setenc "!charCAP_%lna%!") else (call :setenc "!char_%lna%!")
- goto encriptline
- :enc1
- call :setenc "-1"
- set sh1= %_n%
- set sh2= %ln_n%
- set /a sh3=%_n%*100/ln_n
- set sh3= %sh3%
- set /p =正在加密. . . %sh1:~-5%/%sh2:~-5%(%sh3:~-2%%%)<nul
- set /a _n=%_n%+1
- set ln=!ln_%_n%!
- goto encriptline
-
- :enc0
- echo;%enc%>>"!file2!"
- echo 加密成功!
- echo 已保存到 !file2! !exc!
- echo ay|choice>nul
- pause
- goto end
-
- rem Functions
-
- :getline
- rem 禁止延迟变量
- setlocal DISABLEDELAYEDEXPANSION
- (
- for /f "usebackq tokens=* eol= delims=" %%L in (%1) do (
- set _L=%%L
- rem 加引号
- call set _L="%%_L:"=""%%"
- call set _L=%%_L:!=!exc!%%
- call :getecho
- )
- )>$tmp$.txt
- goto end
-
- :getecho
- echo;%_L:^=!car!%
- goto end
-
- :setenc
- set m=%1
- set m=!m:~1,-1!
- if "!m!"=="-1" goto sete1
- set /a m=%m%+%move%
- if %m% lss 0 set /a m=%m%+%chars_n%
- if %m% geq %chars_n% set /a m=%m%-%chars_n%
- :sete1
- set enc=!enc!%m%_
- set /a enc_n=%enc_n%+1
- if "%enc_n%"=="8" (
- echo;!enc!>>"!file2!"
- set enc=
- set enc_n=0
- set /a move=!move!-!move_b!
- if !move! lss 0 set /a move=!move!+!chars_n!
- if !move! gtr !chars_n! set /a move=!move!-!chars_n!
- )
- goto end
-
- :complex
- rem complex a实 a虚 符号 b实 b虚 实变量名 虚变量名
- if "%3"=="*" (
- set /a comp_x=%1*%4-%2*%5
- set /a comp_y=%1*%5+%2*%4
- set /a comp_k=1
- )
- if "%3"=="/" (
- set /a comp_x=%2*%5+%1*%4
- set /a comp_y=%2*%4-%1*%5
- set /a comp_k=%4*%4+%5*%5
- )
- set /a %6=%comp_x%/%comp_k%
- set /a %7=%comp_y%/%comp_k%
- goto end
-
- :inputpswd
- set pswd=
- set pswdkey=
- set pswdblank=
- set pswdstar=
- set /a pswdn1=%1-1
- set /p =密码(6位数字):<nul
- for /l %%n in (1,1,%1) do (set pswdblank= !pswdblank!)
- :inp1
- if not "%pswd%"=="" if not "!pswd:~%pswdn1%,1!"=="" (
- echo;
- goto end
- )
- for /f "tokens=*" %%f in ('xcopy /w . . 2^>nul') do (
- set pswdkey=%%f
- goto inp2
- )
- :inp2
- set pswdkey=!pswdkey:~-1!
- if "!pswdkey!"=="" (
- if not "!pswd!"=="" (
- set pswd=!pswd:~0,-1!
- set pswdstar=!pswdstar:~1,-1!
- )
- )
- for /l %%n in (0,1,9) do (
- if "!pswdkey!"=="%%n" (
- set pswd=!pswd!!pswdkey!
- set pswdstar=%2!pswdstar!
- )
- )
- set /p =密码(6位数字):!pswdblank!!pswdstar!<nul
- goto inp1
-
- :getfile2
- setlocal DISABLEDELAYEDEXPANSION
- for %%F in ("%file%") do (set "file2=%%~dpnF_Encript%%~xF")
- set "file2=%file2:!=!exc!%"
- endlocal&set "file2=%file2%"
- goto :end
-
- :end
复制代码
解密
- @echo off
- title 纯文本加解密工具1.0(解密)
- rem 退格符
- setlocal ENABLEDELAYEDEXPANSION
-
- echo 纯文本加解密工具1.0(解密) BY 0000
- :setfile
- set /p file=文件名称:
- if "!file!"=="" (echo 无效的文件名&goto setfile)
- set file=!file:"=!
- if "!file!"=="" (echo 无效的文件名&goto setfile)
- echo "!file!"|findstr /R /C:"[*?]">nul&&(echo 无效的文件名&goto setfile)
- set file_1=!file:~-1!
- if "!file_1!"=="/" (echo 无效的文件名&goto setfile)
- if "!file_1!"=="\" (echo 无效的文件名&goto setfile)
- dir /a-d "!file!">nul 2>nul||(echo 无效的文件名&goto setfile)
- dir /a-d "!file!\">nul 2>nul&&(echo 无效的文件名&goto setfile)
- for /f "usebackq tokens=* delims=" %%t in ("!file!") do (
- if not "%%t"=="TXT_ENCRIPT_1.0 BY 0000" (
- echo 该文件未被加密
- goto setfile
- ) else (
- rem 直接跳出for循环
- goto setpswd
- )
- )
- :setpswd
- call :inputpswd 6 *
- rem 获取密码内容
- set /a pswd_a=1%pswd:~0,3%-900
- set /a pswd_b=1%pswd:~3,3%-900
-
- call :getfile2
-
- for /f "usebackq skip=1 tokens=1,2 delims=_" %%a in ("!file!") do (
- set seed_a=%%a
- set seed_b=%%b
- goto setmove
- )
- :setmove
- rem 通过复数运算得到字符平移参数[ (密码数a + 密码数b * i) * ((密码前三位 + 100) + (密码后三位 + 100) * i) = 字符平移参数]
- call :complex %seed_a% %seed_b% / %pswd_a% %pswd_b% move_a move_b
- call :complex %move_a% %move_b% * %pswd_a% %pswd_b% a b
- rem 检查运算是否正确
- if not "%a%"=="%seed_a%" (echo 密码不正确&goto setpswd)
- if not "%b%"=="%seed_b%" (echo 密码不正确&goto setpswd)
-
- rem 检查字符平移参数是否互质
- set a=%move_a%
- set b=%move_b%
- if %a% lss 0 set /a a=-%a%
- if %b% lss 0 set /a b=-%b%
- :setm1
- if %a% gtr %b% (set /a a=%a% %% %b%) else (set /a b=%b% %% %a%)
- set /a ab=%a%*%b%
- if "%ab%"=="0" (
- set /a a_b=%a%+%b%
- if not "!a_b!"=="1" (echo 密码不正确&goto setpswd)
- ) else (
- goto setm1
- )
-
- set /p =正在解密. . . *****/*****( 0%%)<nul
- copy nul "!file2!" >nul
- call :getchar
- set /p chars=<$tmp$.txt
- del $tmp$.txt
- set _n=0
- set ln_n=0
- for /f "usebackq skip=3 delims= eol=" %%a in ("!file!") do (set /a ln_n=!ln_n!+1)
- set dec=
- set chars=!chars:~%move_a%!!chars:~0,%move_a%!
- for /f "usebackq skip=3 tokens=1,2,3,4,5,6,7,8 delims=_" %%a in ("!file!") do (
- call :setdec %%a
- call :setdec %%b
- call :setdec %%c
- call :setdec %%d
- call :setdec %%e
- call :setdec %%f
- call :setdec %%g
- call :setdec %%h
- set sh1= !_n!
- set sh2= !ln_n!
- set /a sh3=!_n!*100/!ln_n!
- set sh3= !sh3!
- set /p =正在解密. . . !sh1:~-5!/!sh2:~-5!(!sh3:~-2!%%^)<nul
- set /a _n=!_n!+1
- set chars=!chars:~%move_b%!!chars:~0,%move_b%!
- )
- echo;!dec!>>"!file2!"
- echo 解密成功!
- echo 已保存到 !file2! ^^!
- echo ay|choice>nul
- start notepad "!file2!"
- pause
- goto end
-
-
- rem Functions
-
-
- :setdec
- if "%1"=="" goto end
- if "%1"=="-1" goto setd1
- set dec=!dec!!!chars:~%1,1!
- goto end
- :setd1
- echo;!dec!>>"!file2!"
- set dec=
- goto end
-
- :getchar
- rem 禁止延迟变量
- setlocal DISABLEDELAYEDEXPANSION
- for /f "usebackq skip=2 tokens=* delims= eol=" %%t in ("%file%") do (
- echo;%%t>$tmp$.txt
- goto end
- )
- goto end
-
- :complex
- rem complex a实 a虚 符号 b实 b虚 实变量名 虚变量名
- if "%3"=="*" (
- set /a comp_x=%1*%4-%2*%5
- set /a comp_y=%1*%5+%2*%4
- set /a comp_k=1
- )
- if "%3"=="/" (
- set /a comp_x=%2*%5+%1*%4
- set /a comp_y=%2*%4-%1*%5
- set /a comp_k=%4*%4+%5*%5
- )
- set /a %6=%comp_x%/%comp_k%
- set /a %7=%comp_y%/%comp_k%
- goto end
-
- :inputpswd
- set pswd=
- set pswdkey=
- set pswdblank=
- set pswdstar=
- set /a pswdn1=%1-1
- set /p =密码(6位数字):<nul
- for /l %%n in (1,1,%1) do (set pswdblank= !pswdblank!)
- :inp1
- if not "%pswd%"=="" if not "!pswd:~%pswdn1%,1!"=="" (
- echo;
- goto end
- )
- for /f "tokens=*" %%f in ('xcopy /w . . 2^>nul') do (
- set pswdkey=%%f
- goto inp2
- )
- :inp2
- set pswdkey=!pswdkey:~-1!
- if "!pswdkey!"=="" (
- if not "!pswd!"=="" (
- set pswd=!pswd:~0,-1!
- set pswdstar=!pswdstar:~1,-1!
- )
- )
- for /l %%n in (0,1,9) do (
- if "!pswdkey!"=="%%n" (
- set pswd=!pswd!!pswdkey!
- set pswdstar=%2!pswdstar!
- )
- )
- set /p =密码(6位数字):!pswdblank!!pswdstar!<nul
- goto inp1
-
- :getfile2
- setlocal DISABLEDELAYEDEXPANSION
- for %%F in ("%file%") do (set "file2=%%~dpnF_Decript%%~xF")
- set "file2=%file2:!=!exc!%"
- endlocal&set "file2=%file2%"
- goto :end
-
- :end
复制代码
有建议或意见请在下方提出!
作者: CommandBatCmd 时间: 2017-2-1 13:17
回复 1# 0000
输入文件名称:!time!.txt
系统找不到文件 13:12:38.92.txt。
无赖!
作者: 老刘1号 时间: 2017-2-1 13:29
回复 2# CommandBatCmd
确实有这么个坑
作者: 老刘1号 时间: 2017-2-1 13:35
完全用不成。直接输入文件名不可行,输入路径就语法不正确
作者: CommandBatCmd 时间: 2017-2-1 13:40
回复 3# 老刘1号
批处理给我们扔下坑,但希望我们的人生无坑!
新年快乐!
作者: 老刘1号 时间: 2017-2-1 13:42
回复 5# CommandBatCmd
同乐
作者: luckboy45 时间: 2017-2-2 13:25
给你点参考,我朋友9年前的作品
VBS加密解密
Dim WshSHell,FSO
On Error Resume Next
Set WshSHell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Args = WScript.Arguments
Ver="1.1"
CloseTime = 5
FileName = WScript.ScriptName
FileFullName = WScript.ScriptFullName
FilePath = FSO.GetParentFolderName(FileFullName)
InsPath = FSO.GetSpecialFolder(1)
InsFullName = FSO.BuildPath(InsPath ,FileName)
Copyright="baomaboy"
QQ="QQ:25926183"
Email="Email:fty1995@163.com"
InsTitle="加密/解密VBS脚本(简易免杀版)"&Ver
InsAnswer="加密/解密VBS脚本(简易免杀版)"&Ver
RegPath1="HKEY_CLASSES_ROOT\vbsfile\shell\EnCode_VBS\"
RegValue1="加密/解密VBS脚本"&Ver
RegForm1="REG_SZ"
RegPath2="HKEY_CLASSES_ROOT\vbsfile\shell\EnCode_VBS\command\"
RegValue2="wscript.exe " & chr(34) & InsFullName & chr(34) & " " & chr(34) & "%L" & chr(34)
RegPath3="HKEY_CLASSES_ROOT\vbsfile\shell\EnCode_VBS\EnCode_Very"
RegValue3="0"
RegValue4="1"
IF FileFullName <> InsFullName then
intAnswer = MsgBox("【是】将“"+ InsAnswer +"”加入到右键菜单,"&Chr(10)&Chr(10)&"【否】将“"+ InsAnswer +"”从右键菜单删除。 ", vbQuestion + vbYesNoCancel, "安装 - "+ InsTitle +" - "+ Copyright)
If intAnswer = vbYes Then
WshSHell.RegWrite RegPath1,RegValue1,RegForm1
WshSHell.RegWrite RegPath2,RegValue2,RegForm1
WshSHell.RegWrite RegPath3,RegValue4,RegForm1
FSO.GetFile(FileFullName).Copy(InsFullName)
WshSHell.popup _
"添加脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _
"添加注册表项:"+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+ _
chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
, CloseTime, "安装成功 - "+ InsTitle +" - "+ Copyright, 0 + 64
end if
If intAnswer = vbNo Then
WshSHell.RegDelete RegPath3
WshSHell.RegDelete RegPath2
WshSHell.RegDelete RegPath1
FSO.DeleteFile InsFullName
WshSHell.popup _
"删除脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _
"删除注册表项:"+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+ _
chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
, CloseTime, "卸载成功 - "+ InsTitle +" - "+ Copyright, 0 + 64
end if
ELSE
Package = WScript.Arguments.Item(0)
PkgName=FSO.GetBaseName(Package)
PkgPath=FSO.GetParentFolderName(Package)
Set ReadFile = FSO.OpenTextFile(Package, 1)
ReadAllTextFile=ReadFile.ReadAll
if left(ReadAllTextFile,10)<>"Rem EnCode" then
EnCodePanDuan="Rem EnCode-Easy By QQ:25926183"
CodeString=ReadAllTextFile
For i=1 To Len(CodeString)
TempNum = Asc(Mid(CodeString,i,1))
If TempNum = 13 Then
TempNum = 28
ElseIf TempNum = 10 Then
TempNum = 29
elseif TempNum=34 Then
TempNum = 18
elseif TempNum>96 and TempNum<110 then
TempNum=TempNum+13
elseif TempNum>109 and TempNum<123 then
TempNum=TempNum-13
elseif TempNum>47 and TempNum<53 then
TempNum=TempNum+5
elseif TempNum>52 and TempNum<58 then
TempNum=TempNum-5
End If
ThisText = ThisText & chr(TempNum)
Next
Call EnCodeFile
Else
Call UnCodeFile
end if
End if
Set WshSHell = Nothing
Set FSO = Nothing
Set Args = Nothing
WScript.Quit(0)
Sub EnCodeFile()
Set NewFile = FSO.CreateTextFile(FSO.BuildPath(PkgPath ,PkgName&"_Encode.VBS"), True)
NewFile.WriteLine(EnCodePanDuan)
NewFile.WriteLine("ExeString="&chr(34)&ThisText&chr(34))
NewFile.WriteLine("Execute("&chr(34)&"For i=1 To Len(ExeString)"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum = Asc(Mid(ExeString,i,1))"&chr(34)&"&vbCrLf&"&chr(34)&"If TempNum = 28 Then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum = 13"&chr(34)&"&vbCrLf&"&chr(34)&"ElseIf TempNum = 29 Then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum = 10"&chr(34)&"&vbCrLf&"&chr(34)&"elseif TempNum=18 Then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum = 34"&chr(34)&"&vbCrLf&"&chr(34)&"elseif TempNum>96 and TempNum<110 then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum=TempNum+13"&chr(34)&"&vbCrLf&"&chr(34)&"elseif TempNum>109 and TempNum<123 then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum=TempNum-13"&chr(34)&"&vbCrLf&"&chr(34)&"elseif TempNum>47 and TempNum<53 then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum=TempNum+5"&chr(34)&"&vbCrLf&"&chr(34)&"elseif TempNum>52 and TempNum<58 then"&chr(34)&"&vbCrLf&"&chr(34)&"TempNum=TempNum-5"&chr(34)&"&vbCrLf&"&chr(34)&"End If"&chr(34)&"&vbCrLf&"&chr(34)&"ThisText = ThisText & chr(TempNum)"&chr(34)&"&vbCrLf&"&chr(34)&"Next"&chr(34)&")")
NewFile.WriteLine("Execute(ThisText)")
NewFile.Close
WshShell.popup chr(10) &_
"加密成功了!保存为文件:"+ chr(10) &chr(10) & _
FSO.BuildPath(PkgPath ,PkgName&"_Encode.VBS")+chr(10)+chr(10)+ _
chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
, CloseTime, EnCodePanDuan +" - "+ Copyright, 0 + 64
End Sub
Sub UnCodeFile()
Set ReadFile = FSO.OpenTextFile(Package, 1)
ReadLineTextFile1=ReadFile.ReadLine
ReadLineTextFile2=ReadFile.ReadLine
ReadLineTextFile3=ReadFile.ReadLine
ReadFile.Close
Set NewFile = FSO.CreateTextFile(FSO.BuildPath(PkgPath ,PkgName&"_Uncode.VBS"), True)
NewFile.WriteLine(ReadLineTextFile2)
NewFile.WriteLine(ReadLineTextFile3)
NewFile.WriteLine("EnCodePanDuan="&chr(34)&ReadLineTextFile1&chr(34)&vbCrLf&"EnCodePD="&chr(34)&"Rem EnCode-Very By QQ:25926183"&chr(34)&vbCrLf&"For i=1 To Len(ThisText)"&vbCrLf&"TempNum = Asc(Mid(ThisText,i,1))"&vbCrLf&"TempChar = Chr(TempNum)"&vbCrLf&"if EnCodePanDuan=EnCodePD then"&vbCrLf&"If TempChar = Chr(58) Then"&vbCrLf&"TempChar = Chr(13)"&vbCrLf&"End If"&vbCrLf&"End If"&vbCrLf&"ThisTextTem = ThisTextTem & TempChar"&vbCrLf&"Next")
NewFile.WriteLine("strCode = (ThisTextTem)"&vbCrLf&"Set WshSHell = WScript.CreateObject("&chr(34)&"WScript.Shell"&chr(34)&")"&vbCrLf&"Set FSO = CreateObject("&chr(34)&"Scripting.filesystemobject"&chr(34)&")"&vbCrLf&"FileName = WScript.ScriptName"&vbCrLf&"Set fC = FSO.OpenTextFile(FileName, 2, true)"&vbCrLf&"fC.Write strCode"&vbCrLf&"fC.Close"&vbCrLf&"Set WshSHell = Nothing"&vbCrLf&"Set FSO = Nothing"&vbCrLf&"WScript.Quit(0)")
NewFile.Close
WScript.Sleep 1500
WshSHell.Run (chr(34)&FSO.BuildPath(PkgPath ,PkgName&"_Uncode.VBS")&chr(34)), vbHide
WshShell.popup chr(10) &_
"解密成功了!保存为文件:"+ chr(10) &chr(10) & _
FSO.BuildPath(PkgPath ,PkgName&"_Uncode.VBS")+chr(10)+chr(10)+ _
chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _
, CloseTime, "解密成功 - "+ InsTitle +" - "+ Copyright, 0 + 64
End Sub
作者: luckboy45 时间: 2017-2-2 13:28
以上是VBS,BAOMABOY编写的
这里是木森林的BAT版本
@echo off
:: Code by pengfei CMD@XP
:: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=22254
color 27
:start
cls
echo *******************************************************************************
echo * *
echo * BAT 加 密 最 终 版 *
echo * *
echo *******************************************************************************
echo.
echo.
echo BAT加密最终版为"BAT加密工具"的更新版本, 较上一版加密工具而言有诸多优势:
echo.
echo ★ 可以一次性成功加密任何批处理文件, 更省事.
echo.
echo ★ 可以由您输入任意需要加密的批处理, 加密灵活性更大.
echo.
echo ★ 能够自动判断错误输入, 更加人性化.
echo.
echo 说明: 在下面输入需要加密的批处理文件, 直接输入批处理文件名为加密当前目录下的BAT,也可以带路径指定任意BAT. 当前目录下生成的encrypt.bat文件即为加密的批处理.
echo.
echo 作者:木林森 QQ:573381312 BYE
echo.
echo.
echo.
set /p file=请输入需要加密的批处理后按回车键(q=退出):
if "%file%"=="q" goto quit
echo %file%|findstr /i "\.bat$">nul && goto go
echo %file%|findstr /i "\.cmd$">nul && goto go
cls
echo ==============
echo 请正确输入!
echo ==============
echo.
echo.
echo 按任意键重新输入......
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 恭喜你, 批处理加密成功^^!
echo ==========================
echo.
echo.
echo 按任意键退出......
pause>nul
goto quit
dd
echo. >>"%tmp%\encrypt.tmp"
copy "%tmp%\encrypt.tmp" encrypt.bat
del "%tmp%\encrypt.tmp"
cls
echo ==========================
echo 恭喜你, 批处理加密成功^^!
echo ==========================
echo.
echo.
echo 按任意键退出......
pause>nul
goto quit
:newly
cls
echo ================================
echo 找不到批处理文件, 请重新输入!
echo ================================
echo.
echo.
echo 按任意键开始......
pause>nul
goto start
:quit
exit
作者: CommandBatCmd 时间: 2017-2-2 16:40
回复 1# 0000
在复制代码
这行的上面输入以下- echo,变量file2的值为:"%file2%"&pause
复制代码
然后输入文件名:【!time!.txt 】测试,
看变量【file2】的值是否还是【!time!.txt 】。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |