|
| 1 | +@if (@X)==(@Y) @end /* Res2Batch Encoder by AveYo ver 1.0 |
| 2 | +@echo off &setlocal &set "app=%APPDATA%\AveYo" |
| 3 | +md "%app%" >nul 2>&1 &if exist "%~1" (set "fchoice=%~1") else call :filechoice |
| 4 | +cscript.exe //e:javascript //nologo "%~f0" %fchoicejs% |
| 5 | +del /f /q "%fpath%\%fname%%cfext%" &popd &pause &endlocal &exit /b |
| 6 | + |
| 7 | +goto :eof |
| 8 | +:filechoice |
| 9 | +set "appjs=%app:\=\\%" &set "openpath=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32" |
| 10 | +reg copy "%openpath%" "%openpath%_bak" /s /f >nul 2>&1 ® delete "%openpath%" /f >nul 2>&1 |
| 11 | +mshta.exe "about:<input type=file style="display:none" id=FILE><script>resizeTo(0,0);FILE.click();var out=new ActiveXObject('Scripting.FileSystemObject').CreateTextFile('%appjs%\\fchoice.bat',true);out.write('@set fchoice='+FILE.value);out.close();close();</script>" |
| 12 | +reg copy "%openpath%_bak" "%openpath%" /s /f >nul 2>&1 ® delete "%openpath%_bak" /f >nul 2>&1 |
| 13 | +call "%app%\fchoice.bat" &del /f /q "%app%\fchoice.bat" |
| 14 | +rem needs compression? |
| 15 | +for %%A in ("%fchoice%") do set "fpath=%%~dpA" &set "fname=%%~nA" &set "fext=%%~xA" &set "fsize=%%~zA" |
| 16 | +if %fsize% GTR 10485760 echo ERROR! Chosen file is larger than 10MB, what are you trying to do?! &pause &exit |
| 17 | +rem commend above line to remove 10MB file limit |
| 18 | +set "cfext=%fext:~0,-1%_" |
| 19 | +pushd "%fpath%" &makecab.exe "%fchoice%" "%fname%%cfext%" >nul 2>&1 |
| 20 | +for %%A in ("%fname%%cfext%") do set "cfsize=%%~zA" |
| 21 | +if %cfsize% LSS %fsize% set "fchoice="%fpath%\%fname%%cfext%" |
| 22 | +set fchoicejs=%fchoice: =_RSPACE_% |
| 23 | +goto :eof |
| 24 | +:xbase85_batjs_encoder */ |
| 25 | +//read |
| 26 | +var arg0=WScript.Arguments(0);var fn=arg0.replace(/_RSPACE_/g,' '),name=fn.split('\\').pop().split('/').pop(),exp=fn.slice(-1); |
| 27 | +var W=WScript,O='CreateObject',AS='ADODB.Stream',rs=ws=W[O](AS),xe=W[O]('Microsoft.XMLDOM').createElement('bh'); |
| 28 | +rs.Mode=3;rs.Type=1;rs.Open();rs.LoadFromFile(fn);len=rs.Size;xe.dataType='bin.hex';xe.nodeTypedValue = rs.Read();rs.Close(); |
| 29 | +//encode |
| 30 | +WScript.Echo('Res2Batch Encoder by AveYo: encoding '+fn); |
| 31 | +var x85='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$()*+,-./:;=?@[]_`{}~'.split(''); |
| 32 | +var d85={};for(var i=85;i--;)d85[x85[i]]=i;var p85=[];for(var i=5;i--;)p85[i]=Math.pow(85,i); |
| 33 | +var shex=xe.text;var pad=(shex.length%8)||8;shex+='00000000'.slice(pad);pad=4-pad/2;var a=shex.match(/.{1,8}/g); |
| 34 | +for(var l=a.length;l--;){var n=parseInt(a[l],16);a[l]='';for(j=5;j--;){a[l]=x85[parseInt(n%85,10)]+a[l];n/=85}} |
| 35 | +var xbase85enc = pad>0? a.join('').slice(0,-pad):a.join(''); |
| 36 | +//sfx generator |
| 37 | +ws.Mode=3;ws.Type=2;ws.Charset='Windows-1252';ws.Open(); |
| 38 | +ws.WriteText('@if (@X)==(@Y) @end /* made with Res2Batch Encoder by AveYo ver 1.0\n@echo off &setlocal &pushd %~dp0\n'); |
| 39 | +ws.WriteText('cscript.exe //e:javascript //nologo "%~f0"\n'); |
| 40 | +if (exp==='_') ws.WriteText('set "res='+name+'"\nexpand -R "%res%" >nul 2>&1 &del /f /q "%res%"\n'); |
| 41 | +ws.WriteText('pause &endlocal &exit /b\n:xbase85_batjs_decoder */\nvar fn="'+name+'", res=[\n'); |
| 42 | +var o=xbase85enc.match(/.{1,126}/g);for(i=0,l=o.length-1;i<l;i++) ws.WriteText("'"+o[i]+"',\n");ws.WriteText("'"+o[o.length-1]+"'];\n"); |
| 43 | +ws.WriteText("var x85='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$()*+,-./:;=?@[]_`{}~'.split('');\n"); |
| 44 | +ws.WriteText("var d85={};for(var i=85;i--;)d85[x85[i]]=i;var p85=[];for(var i=5;i--;)p85[i]=Math.pow(85,i);dec=res.join('');\n"); |
| 45 | +ws.WriteText("var pad=(dec.length%5)||5;dec+='~~~~~'.slice(pad);pad=10-2*pad;var a=dec.match(/.{1,5}/g);for(var l=a.length;l--;){var n=0;\n"); |
| 46 | +ws.WriteText("for(j=5;j--;)n+=d85[a[l].charAt(j)]*p85[4-j];a[l]='00000000'.slice(n.toString(16).length)+n.toString(16)};\n"); |
| 47 | +ws.WriteText("var xbase85dec= pad>0? a.join('').slice(0,-pad):a.join('');WScript.Echo('Res2Batch Encoder by AveYo: extracting '+fn);\n"); |
| 48 | +ws.WriteText("var W=WScript,O='CreateObject',AS='ADODB.Stream',ws=W[O](AS),xe=W[O]('Microsoft.XMLDOM').createElement('bh');\n"); |
| 49 | +ws.WriteText("ws.Mode=3;ws.Type=1;ws.Open();xe.dataType='bin.hex';xe.text=xbase85dec;ws.Write(xe.nodeTypedValue);ws.SaveToFile(fn,2);ws.Close();\n"); |
| 50 | +ws.SaveToFile(fn+'.bat',2);ws.Close(); |
0 commit comments