Looking to encrypt batch scripts but need to edit in-between
Moderator: DosItHelp
-
- Posts: 184
- Joined: 21 Feb 2013 15:54
Looking to encrypt batch scripts but need to edit in-between
I am looking to encrypt my batch scripts to exe to protect the code I've, and some here, have put together.
I will then be giving my work to others en masse.
But here's the problem. Within the script I have file and directory paths that are specific to my computer. These will have to be changed for each person. (I know how to do this part, as I can ask for user input and they can type the file paths and I can find and replace them within my batch script).
BUT, how do I do that but keeping my files encrypted at the same time. In essence, I'd like people to download my work, protected or encrypted, and then they can launch the install batch that asks for the user input for the file paths, which will then replace the file paths within my script. But how do I do the find and replace if my scripts are encrypted?
Is there a way to unencrypt, then find and replace file paths in the script, then encrypt again?
Or put them in a safe place until the find and replace then encrypt them? What would you suggest?
I will then be giving my work to others en masse.
But here's the problem. Within the script I have file and directory paths that are specific to my computer. These will have to be changed for each person. (I know how to do this part, as I can ask for user input and they can type the file paths and I can find and replace them within my batch script).
BUT, how do I do that but keeping my files encrypted at the same time. In essence, I'd like people to download my work, protected or encrypted, and then they can launch the install batch that asks for the user input for the file paths, which will then replace the file paths within my script. But how do I do the find and replace if my scripts are encrypted?
Is there a way to unencrypt, then find and replace file paths in the script, then encrypt again?
Or put them in a safe place until the find and replace then encrypt them? What would you suggest?
-
- Posts: 184
- Joined: 21 Feb 2013 15:54
Re: Looking to encrypt batch scripts but need to edit in-bet
Could I possible package the scripts in a password protected .rar archive then unrar it to edit the file paths, then encrypt it?
Will a batch unrar an archive that is password protected?
Will a batch unrar an archive that is password protected?
Re: Looking to encrypt batch scripts but need to edit in-bet
You can't protect your code by "encrypting" them with BAT2EXE converters. It's impossible! Forget it.
Re: Looking to encrypt batch scripts but need to edit in-bet
I agree. All those bat2exe programs are just wrappers. When you execute them they unpack them to the current working directory or to the TEMP directory. All you are doing is obscuring your code.
What is wrong with people seeing the code?
What is wrong with people seeing the code?
Re: Looking to encrypt batch scripts but need to edit in-bet
have a look at "Quick Batch File Compiler", it's not free unfortunately but it does what you need.
-
- Posts: 184
- Joined: 21 Feb 2013 15:54
Re: Looking to encrypt batch scripts but need to edit in-bet
How do software companies encrypt their code? Knowing that they aren't writing in batch script.
Re: Looking to encrypt batch scripts but need to edit in-bet
software are written in other language like C/C++ when they compile the source they just convert it from a readable language to machine language that you don't understand.
Re: Looking to encrypt batch scripts but need to edit in-bet
about protect code with compiled batch, is impossible because cmd.exe execute source files ("compilers" encode the code itself and extract the plain code to a temp folder), about this i remember that a batch file can be encoded with Big Endian, when you look the code with notepad it show garbage characters, but you can execute it with cmd /u /c Anyways the file can be reencoded and the source file can be catched. Other tool can be ofuscate the code (this slow the execution).
I think that you can hide the code mounting a telnet server (kpym), configuring and connecting to the telnet server with telnet.exe (In the past I do this with a batch that launch some dos games), then you play remote dos games, and the batch code that launch the games was hidden.
About change the value of a variable.
Remember that children windows of cmd.exe inherits a copy of the variables of father windows. Then you can use this:
launch.bat
other.bat
other.bat will use the content of myvalue setted in launch.bat because launch.bat is launching other.bat and giving a copy of the variables.
I think that you can hide the code mounting a telnet server (kpym), configuring and connecting to the telnet server with telnet.exe (In the past I do this with a batch that launch some dos games), then you play remote dos games, and the batch code that launch the games was hidden.
About change the value of a variable.
Remember that children windows of cmd.exe inherits a copy of the variables of father windows. Then you can use this:
launch.bat
Code: Select all
Set /P "myvalue=Enter value:"
Call other.bat
other.bat
Code: Select all
If Not Defined myvalue Set myvalue=DEFAULT
other.bat will use the content of myvalue setted in launch.bat because launch.bat is launching other.bat and giving a copy of the variables.
-
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
Re: Looking to encrypt batch scripts but need to edit in-bet
Why do you need to encrypt your code do you work for the DoD? , Seriously most of the compilers that I have used extract to the tmp folder during execution so anyone with any basic puter knowledge can still get your code easily..Plus you have to backup all your batch files if you want
to make future revisions..I usually just pack my batch in a sfx .exe file with icon then run it without any user action, still you can upzip it but you can easily revise when needed.
to make future revisions..I usually just pack my batch in a sfx .exe file with icon then run it without any user action, still you can upzip it but you can easily revise when needed.
Re: Looking to encrypt batch scripts but need to edit in-bet
+1 to the suggestion that encryption is stoopid.
But you could include a variable name in all the locations for paths in the batch file, and then use the correct paths that have been typed in by the user.
Example: (It seems obvious to me)
:: "encrypted batch file.exe"
You'll have to include code to test that the locations are valid.
But you could include a variable name in all the locations for paths in the batch file, and then use the correct paths that have been typed in by the user.
Example: (It seems obvious to me)
:: "encrypted batch file.exe"
Code: Select all
@echo off
set /p "path1=enter path to widget A "
set /p "path2=enter path to widget B "
set /p "path3=enter path to widget C "
set /p "path4=enter path to widget D "
copy /b "%path1%\backup folder" "%path2%\working folder"
findstr "Text to find" "%path4\business.file" > "%path3\outputfile.txt"
You'll have to include code to test that the locations are valid.
-
- Posts: 184
- Joined: 21 Feb 2013 15:54
Re: Looking to encrypt batch scripts but need to edit in-bet
carlos wrote:about protect code with compiled batch, is impossible because cmd.exe execute source files ("compilers" encode the code itself and extract the plain code to a temp folder), about this i remember that a batch file can be encoded with Big Endian, when you look the code with notepad it show garbage characters, but you can execute it with cmd /u /c Anyways the file can be reencoded and the source file can be catched. Other tool can be ofuscate the code (this slow the execution).
I think that you can hide the code mounting a telnet server (kpym), configuring and connecting to the telnet server with telnet.exe (In the past I do this with a batch that launch some dos games), then you play remote dos games, and the batch code that launch the games was hidden.
About change the value of a variable.
Remember that children windows of cmd.exe inherits a copy of the variables of father windows. Then you can use this:
launch.batCode: Select all
Set /P "myvalue=Enter value:"
Call other.bat
other.batCode: Select all
If Not Defined myvalue Set myvalue=DEFAULT
other.bat will use the content of myvalue setted in launch.bat because launch.bat is launching other.bat and giving a copy of the variables.
I don't understand this Big Endian thing.
Although your variable tactics I did not realize, I cannot use that method because it would then require everyone to input the filepaths everytime my scripts run, instead of just making the find and replace permanent.
Re: Looking to encrypt batch scripts but need to edit in-bet
pditty8811 wrote:Although your variable tactics I did not realize, I cannot use that method because it would then require everyone to input the filepaths everytime my scripts run, instead of just making the find and replace permanent.
Make your batch file read a text file with the info - and use another batch file to get the info just once from the user.
Re: Looking to encrypt batch scripts but need to edit in-bet
carlos wrote: i remember that a batch file can be encoded with Big Endian, when you look the code with notepad it show garbage characters, but you can execute it with cmd /u /c
I am not aware of any Windows version where cmd/u can execute unicode-encoded batch files, neither big nor little endian nor utf-8. I'd be more than happy to be proven wrong, though if you had a pointer to an actual working case.
Liviu
-
- Posts: 184
- Joined: 21 Feb 2013 15:54
Re: Looking to encrypt batch scripts but need to edit in-bet
So if there is no program that encrypts batch scripts in existance, or there is no way to encrypt batch, then this whole thread is a waste of time?
Re: Looking to encrypt batch scripts but need to edit in-bet
if you still insist on encryption i remembered now carlos made a tool called BHX it is used to put exe files or other files inside a batch, if you look at that batch you will see many numbers and won't understand what is in from the first look.
you can use the same method, create your batch and make sure it delete itself after it's done.
then use the BHX tool to (compile it) and add a line at the end of the resulted batch to run your batch after it's done.
your original batch will be safe inside the batch that was created using the BHX
you can use the same method, create your batch and make sure it delete itself after it's done.
then use the BHX tool to (compile it) and add a line at the end of the resulted batch to run your batch after it's done.
your original batch will be safe inside the batch that was created using the BHX