|
Answer» I changed the code again, maybe this one is more better to look at. before i thought it wasn't possible to make the variables work but it is. turns out i have to encrypt everything but the defined variables. this is the encrypter.
title Encrypt Batch File color f0 @ECHO Off mode con:cols=50 lines=2 echo Encrypt Batch File pause cls mode con:cols=160 lines=2 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% %% 3%random:~-1%%random:~-1%
set /P "FILEA= Enter the name of the text file that you WISH to encrypt (Example; "Somefile") This file should have your batch commands in it : " cls set /P "FILEB= Enter the new name for the text file that you wish to encrypt (Example; "NewFile") This is the ecrypted version of yor text file : " cls set /P "FILEC= Enter the name of the decrypter that will be generated (Example; "Decrypter") This will decrypt and execute your encrypted code : " cls
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 > "%FILEC%.bat" echo. >> "%FILEC%.bat" echo Setlocal EnableExtensions EnableDelayedExpansion >> "%FILEC%.bat" echo for /f "delims=" %%%%A in (%FILEB%.!_RndAlphaNum!) do ( >> "%FILEC%.bat" Setlocal DisableExtensions DisableDelayedExpansion echo Set /a C+=1 >> "%FILEC%.bat" echo Set X[!C!]=%%%%A >> "%FILEC%.bat" echo set CHECKPASSWORD=%%%%A >> "%FILEC%.bat" echo set CHECKKEY=%%%%B >> "%FILEC%.bat" echo set CHAR=0123456789%Randalphabet% >> "%FILEC%.bat" echo. >> "%FILEC%.bat" echo for /l %%%%C in (10 1 36) do ( >> "%FILEC%.bat" echo for /f %%%%D in ("!CHAR:~%%%%C,1!") do ( >> "%FILEC%.bat" echo set /a MATH=%%%%C*%CREATEKEY% >> "%FILEC%.bat" echo for /f %%%%E in ("!MATH!") do ( >> "%FILEC%.bat" echo. >> "%FILEC%.bat" echo set "CHECKPASSWORD=!CHECKPASSWORD:%%%%E=%%%%D!" >> "%FILEC%.bat" echo ) >> "%FILEC%.bat" echo ) >> "%FILEC%.bat" echo ) >> "%FILEC%.bat" echo for /f %%%%F in ("!CHECKPASSWORD!") do ( >> "%FILEC%.bat" echo set "CHECKPASSWORD=!CHECKPASSWORD:¼=!" >> "%FILEC%.bat" Setlocal EnableExtensions EnableDelayedExpansion echo ^^!CHECKPASSWORD^^! >> "%FILEC%.bat" echo ) >> "%FILEC%.bat" echo ) >> "%FILEC%.bat" echo Set X >> "%FILEC%.bat"
now that i figured out that variables do work, i know they cant be encrypted or they wont work, how would i encrpyt everything in the text file except the variables. you can encrpyt where you set the variables but as FAR as CALLING them back, it has to be unencrypted to work. for example;
if i use this batch file.
@ECHO Off
Setlocal EnableExtensions EnableDelayedExpansion for /f "delims=" %%A in (2.jhuAwr1t) do ( Set /a C+=1 Set X[!C!]=%%A set CHECKPASSWORD=%%A set CHECKKEY=%%B set CHAR=0123456789porqkbgsnavdxmjihtfcluyzew
for /l %%C in (10 1 36) do ( for /f %%D in ("!CHAR:~%%C,1!") do ( set /a MATH=%%C*356 for /f %%E in ("!MATH!") do (
set "CHECKPASSWORD=!CHECKPASSWORD:%%E=%%D!" ) ) ) for /f %%F in ("!CHECKPASSWORD!") do ( set "CHECKPASSWORD=!CHECKPASSWORD:¼=!" call !CHECKPASSWORD! ) ) Set X
with a text file named "2.jhuAwr1t" with this in it.
¼6052¼12104¼9612 ¼6764=¼9612¼12104¼6052¼9612 ¼12104¼10324¼9256¼3916 %A% ¼3560¼6764¼11036¼6052¼12104
the variables will work completely fine.
notice the VARIABLE %A% i didn't encrypt it and it works!
the set command is encrpyted.
set A=test
now all i need to know is how to avoid encrypting everything between "%PercentageSigns%" and everything 1 letter after 2 percentage signs "%%P" how would i do this? I've been thinking that if i can make it avoid encrpything everything that is capitalized so that i could type the code in the text file all in lower case and define the variables capitalized before actually encrypting it. but i need to know how to avoid the capitalized characters
i tried doing this by changing the above code to this
REM Check for caps echo(%%A|findstr /V "[abcdefghijklmnopqrstuvwxyz]" >nul && ( goto avoid ) || ( REM Encrypt for /f %%D in ("!CHAR:~%%C,1!") do ( set /a MATH=%%C*%CREATEKEY% for /f %%E in ("!MATH!") do ( )
REM Avoid the caps :avoid
REM place a character between commands set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!" ) ) )
REM Send to encrypted text file echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum! ) ) Set X
but im a little confused to place what goes where or if im doing it correctly or not. if i can do this, then this would be a nearly perfect batch encryter. and no im not trying to do a OTP encryption. just a simple batch encrypter.
Zack, I thought you already did this. It is still hard to understand your intention. Quote from: Geek-9pm on May 24, 2016, 03:42:06 PM Zack, I thought you already did this. It is still hard to understand your intention.
okay i will explain, and yes i have but i just got busy and just now had the time to start again. im trying to make a text file. this text file will have commands in the batch language inside of it. i want to make a encrypter to take this text file and encrypt it. after the text file becomes encrypted i want the encrypter to generate another batch file (the decrypter), in this new batch file, it will take all the encrpyted lines of text (commands) and decrypt them within the same batch file and execute them. this way i can actually encrypt my batch files themselves, unlike other batch encrypters that only encrypt messages, i want to make the first actual batch encrpyter (a.k.a encrpyt the commands). I gave up in the past because i couldn't get any commands that involve variables to execute within the decrypt batch file in the correct way. but i found out that as long as the variables aren't enrypted and everything else is, the code will work completely fine. i tested this with the example above. now im wondering if there is a way to avoid encrypting capitalized letters, this way if a make a variable like this %A%, it wont become encrypted. but if i add one like this %a%, it will become encrypted. this way i can ensure that if i capitalized all my variables, they will display correctly rather than incorrectly because they wont become encrypted.
if you would like me to explain exactly what everything in the code is doing then i can, and it's honestly not as complex as it looks. it's actually petty essay to understand once you explain it. the reason is because at this moment, there is no true batch encrypter, and i think it would just be absolutely amazing if someone could make one of these, because it is possible, just no one has put the effort into doing it. if i obfuscated my code, then encrypt my obfuscated code, as well as obfuscate my decrpyter, then compile the decrpyter, then i could more effectively protect my batch file sources, or at least use it for a small part of my programs that i have compiled. is this elaborate enough? The problem is in this section of code.
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%%% echo(%%A|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( goto avoid ) || ( 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 ( :avoid set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!" ) ) ) echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum! ) ) ) Set X Quote from: zask on May 24, 2016, 03:44:17 PMokay i will explain, and yes i have but i just got busy and just now had the time to start again. im trying to make a text file. this text file will have commands in the batch language inside of it. i want to make a encrypter to take this text file and encrypt it. after the text file becomes encrypted i want the encrypter to generate another batch file (the decrypter), in this new batch file, it will take all the encrpyted lines of text (commands) and decrypt them within the same batch file and execute them. this way i can actually encrypt my batch files themselves, unlike other batch encrypters that only encrypt messages, i want to make the first actual batch encrpyter (a.k.a encrpyt the commands). I gave up in the past because i couldn't get any commands that involve variables to execute within the decrypt batch file in the correct way. but i found out that as long as the variables aren't enrypted and everything else is, the code will work completely fine. i tested this with the example above. now im wondering if there is a way to avoid encrypting capitalized letters, this way if a make a variable like this %A%, it wont become encrypted. but if i add one like this %a%, it will become encrypted. this way i can ensure that if i capitalized all my variables, they will display correctly rather than incorrectly because they wont become encrypted.
if you would like me to explain exactly what everything in the code is doing then i can, and it's honestly not as complex as it looks. it's actually petty essay to understand once you explain it. the reason is because at this moment, there is no true batch encrypter, and i think it would just be absolutely amazing if someone could make one of these, because it is possible, just no one has put the effort into doing it. if i obfuscated my code, then encrypt my obfuscated code, as well as obfuscate my decrpyter, then compile the decrpyter, then i could more effectively protect my batch file sources, or at least use it for a small part of my programs that i have compiled. is this elaborate enough? The problem is in this section of code.
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%%% echo(%%A|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( goto avoid ) || ( 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 ( :avoid set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!" ) ) ) echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum! ) ) ) Set X
im basically trying to add this to my code
@echo off setlocal set x=ABC set y=AbC echo(%x%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %x% is Valid pause ) || ( echo %x% is Invalid pause ) echo(%y%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %y% is Valid pause ) || ( echo %y% is Invalid pause )
this is all i can think of so far
Setlocal EnableExtensions for /f "delims=" %%A in (%FILEA%.txt) do ( :reload Set /a C+=1 Set X[!C!]=%%A set CHECKPASSWORD=%%A set CHECKKEY=%%B set CHAR=0123456789%Randalphabet% Setlocal EnableExtensions echo("%%A"|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %%A >> %FILEB%.!_RndAlphaNum! call :reload ) ) || ( 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! ) )There is a button on the editor toolbar in the forum that adds code TAGS around the highlighted section of text. - usually you highlight your code and then select the # button and it will appear correctly when you submit your post.Code: [Select]@echo off setlocal set x=ABC set y=AbC echo(%x%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %x% is Valid pause ) || ( echo %x% is Invalid pause ) echo(%y%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %y% is Valid pause ) || ( echo %y% is Invalid pause )
this is all i can think of so far
Setlocal EnableExtensions for /f "delims=" %%A in (%FILEA%.txt) do ( :reload Set /a C+=1 Set X[!C!]=%%A set CHECKPASSWORD=%%A set CHECKKEY=%%B set CHAR=0123456789%Randalphabet% Setlocal EnableExtensions echo("%%A"|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && ( echo %%A >> %FILEB%.!_RndAlphaNum! call :reload ) ) || ( 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! ) ) Quote from: foxidrive on May 25, 2016, 01:59:45 AMThere is a button on the editor toolbar in the forum that adds code TAGS around the highlighted section of text. - usually you highlight your code and then select the # button and it will appear correctly when you submit your post.
Oh ok i figured it out now. Is this what you mean? I just didn't know how to do it on here.Please quit quoting your code and creating huge posts.
I think i mentioned this previously...if not ...take heed.Quote from: patio on May 25, 2016, 02:33:58 PMPlease quit quoting your code and creating huge posts.
I think i mentioned this previously...if not ...take heed.
Okay ill just be simple, i need a way to detect if a variable contains a capital letter in it, if it does do one thing, if it dont do something else.Zack, just get it to work with lower case letters. Then deal with upper case later. Also, is there any other program language you use?Yes autoit, autohotkey, javascript, vbs, html, css, php, and java. By vbs you mean VBScript https://en.wikipedia.org/wiki/VBScript Or did you mean "Vacation Bible School" (Rather doubtful.)
VBScript is well suited for manipulation of strings and characters. My segues is that a simple encryption program can be done in 25 lines or less. Yo can invoke VBScript from a command line. Quote from: Geek-9pm on May 25, 2016, 08:43:33 PMBy vbs you mean VBScript https://en.wikipedia.org/wiki/VBScript Or did you mean "Vacation Bible School" (Rather doubtful.)
VBScript is well suited for manipulation of strings and characters. My segues is that a simple encryption program can be done in 25 lines or less. Yo can invoke VBScript from a command line.
Vbscript, I was hoping you would wold have understood by "vbs" meaning vbscript, not visual basic, or "Vacation Bible School." And i know you can encrypt in vbscript, im trying to do it in batch. -_- Im not trying to make a encryption program for any other language. im trying to make a batch encrypter. Understood. If it were me, I would create a working model in my best language and then try to get it to work in batch. VBScript might be what I would use. Or maybe VBA. After I verified the algorithm I use is good, then I would try to export the idea into a batch file. But if I wanted to obfuscate, I might just go to machine code at the lowest level.
Obfuscate: verb verb: obfuscate; 3rd person present: obfuscates; past tense: obfuscated; past participle: obfuscated; gerund or present participle: obfuscating
render obscure, unclear, or unintelligible. "the spelling changes will deform some familiar words and obfuscate their etymological origins" synonyms:obscure, confuse, make unclear, blur, muddle, complicate, overcomplicate, muddy, cloud, befog "mere rationalizations to obfuscate rather than clarify the real issue.
As mentioned earlier, encryption is not the same as making something hard to understand. BTW: New hardware is coming soon with encryption built into the motherboard of a PC. Quote from: zask on May 25, 2016, 05:10:38 PMOkay ill just be simple, i need a way to detect if a variable contains a capital letter in it, if it does do one thing, if it dont do something else.
There's a way to do that with FOR but it depends on what other kinds of characters are in the variable.
Alphanumeric characters are handled easily but various special characters will not work.
|