本帖最后由 pcl_test 于 2024-5-2 17:58 编辑
以下代码保存为decrypt.bat,跟需解密的其它bat文件放一起运行- /*&cls&echo off&cd /d "%~dp0"
- for /f "delims=" %%a in ('dir /a-d-h/b *.bat *.cmd') do (
- if /i "%%~nxa" neq "%~nx0" (
- echo;"%%a"
- cscript -nologo -e:jscript "%~f0" "%%a" > "[decrypt]%%~na.txt"
- )
- )
- pause
- exit
- */
- var fso=new ActiveXObject('Scripting.FileSystemObject'),key='',result=[];
- var ws=new ActiveXObject('Wscript.Shell');
- var f=fso.OpenTextFile(WSH.Arguments(0), 1);
- while(!f.AtEndOfStream){
- var line=f.ReadLine();
- if(!/cls|>nul|BatchEncryption Build/i.test(line)){
- var tmpline=crack(line, key);
- result.push(tmpline);
- }
- }
- WSH.echo(result.join('\r\n'));
- WSH.Quit();
-
- function crack(s, k){
- var kw=k;
- var m1=s.match(/%[^%:]+?:~-?\d*,1%/g);
- if(m1){
- for(var i=0;i<m1.length;i++){
- var m2=m1[i].match(/%([^%:]+?):/);
- if(m2){
- if(m2[1] != "'"){
- kw=ws.ExpandEnvironmentStrings(m1[i].replace(/:.+$/, '')+'%');
- }else{
- kw=k;
- }
- }
- var n=m1[i].replace(/^%.+?:~(-?\d*).+$/, '$1');
- if(n=='')n=0;
- var s=s.replace(m1[i], n=='-1'?kw.slice(Number(n)):kw.slice(Number(n), Number(n)+1));
- }
- }
- var m3=s.match(/^@set '=\^">nul&.+?&@set '=(.+?)&@set.+?&@echo "$/);
- if(m3){key=m3[1].replace(/\^{3}/g, '^');}
- return s;
- }
复制代码
|