Comment out the VBS line being written like this (that's a single quote just before the randomize keyword)
(etc)
> Randalphabet.vbs echo 'randomize timer
(etc)
Oh okay i see now, thats a really cool trick
. Now i came up with this using some of the code that was provided by you guys and some old code i had laying around. this code is supposed encrypt a text file full of batch commands, then make a decrypter to take the encrypted text file, decrypt each command, and execute it within the same batch file. Now i am having a problem, each line in the text file is supposed placed in a separate variable to encrypt/decrpyt them one at a time, but if i wanted to use variable in the encrypted text file (For example~ %Variable%, %%V, !Variable!), they wont work correctly. It would appear "%Variable%" rather than what the substitution of what the variable should be set to.
for example if i typed something like this in a text file and encrypted it;
color 17
echo hello
pause
everything would work completely fine but if i tried to type something like this;
color 17
set a=hello
echo %a%
pause
When the decrypter.bat file would decrypt then execute the commands it would display as this
"%a%"
instead of
"hello"
Is there a way to fix this? here is my code so far.
@ECHO Off
echo encrypt batch file
echo.
Setlocal EnableDelayedExpansion
Set _RNDLength=8
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop
REM 65 for upper case, 97 for lower case
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs
set /A CREATEKEY=%random% %%200 +2
set /P "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefile") : "
set /P "FILEB= Enter the new name for the text file that you wish to encrypt (Example; "NewFile") : "
Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%
for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (
set "CHECKPASSWORD=!CHECKPASSWORD:%%D=-%%E!"
)
)
)
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
Set X
echo @ECHO Off >> Decrypt.bat
echo. >> Decrypt.bat
echo Setlocal EnableExtensions EnableDelayedExpansion >> Decrypt.bat
echo for /f "delims=" %%%%A in (%FILEB%.!_RndAlphaNum!) do ( >> Decrypt.bat
Setlocal DisableExtensions DisableDelayedExpansion
echo Set /a C+=1 >> Decrypt.bat
echo Set X[!C!]=%%%%A >> Decrypt.bat
echo set CHECKPASSWORD=%%%%A >> Decrypt.bat
echo set CHECKKEY=%%%%B >> Decrypt.bat
echo set CHAR=0123456789%Randalphabet% >> Decrypt.bat
echo. >> Decrypt.bat
echo for /l %%%%C in (10 1 36) do ( >> Decrypt.bat
echo for /f %%%%D in ("!CHAR:~%%%%C,1!") do ( >> Decrypt.bat
echo set /a MATH=%%%%C*%CREATEKEY% >> Decrypt.bat
echo for /f %%%%E in ("!MATH!") do ( >> Decrypt.bat
echo. >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:%%%%E=%%%%D!" >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo for /f %%%%F in ("!CHECKPASSWORD!") do ( >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:-=!" >> Decrypt.bat
echo !CHECKPASSWORD! >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo Set X >> Decrypt.bat
I have a working example of some encrypted commands that do work, they shoud help give example of what
im trying to do, but you have to download it here.
http://www.filedropper.com/batchencrypter_2