Best way to obfuscate a Batch File?
Moderator: DosItHelp
-
- Posts: 118
- Joined: 02 Apr 2017 06:11
Re: Best way to obfuscate a Batch File?
@penpen I've followed ShadowThief's method and salted and hashed the password. So I guess the most popular topic of mine finishes here!
PaperTronics
PaperTronics
Re: Best way to obfuscate a Batch File?
PaperTronics wrote:@dbenham - I like your obfuscating batch file so much, that I may even use it on my new game! Do you mind if I post about it on my website?
Not at all. Just be sure to preserve my documentation and credits if you repost the ObfuscateBatch.bat code.
Also, it would be nice if any released game gave credit for the obfuscation technique (including my name, as well as the DosTips site) in a human readable comment within the code.
Dave Benham
-
- Posts: 118
- Joined: 02 Apr 2017 06:11
Re: Best way to obfuscate a Batch File?
@dbenham - Of Course! I will give full credits to you in the header of the game and even in the readme documentation.
PaperTronics
PaperTronics
Re: Best way to obfuscate a Batch File?
Sorry to bother You all. But, As PaperTronic has posted on TheBATeam Blog - about Dave's great plugin - A User has faced a problem of JS Error in the console. (See Here)http://www.thebateam.org/2017/08/properly-encode-obfuscate-your-code.html?showComment=1504078324080#c722512734334501697
Can You Please Sort out the issue. As, I don't know about the working method and kind of out of time understanding it first. Thanks for your time.
Re: Best way to obfuscate a Batch File?
Hey, Dave And PaperTronics - pardon me for bothering you here. But, I really don't know to use this system of the forum (trying hard to learn though). I think I've replied before - but, couldn't see my comment in the topic. So, trying again.
As promised - PaperTronics and I've posted the great plugin on the OurBatchblog (TheBATeam). And, a user recently commented about the JS Error they are facing while using the plugin. I don't know about the working of the plugin - so, I will be better if either of you can reply with a proper solution. http://www.thebateam.org/2017/08/properly-encode-obfuscate-your-code.html?showComment=1504195437642#c5951254323612374791
Thanks for your time.
"The strength of the team is each individual member. The strength of each member is the team." --Phil Jackson
Re: Best way to obfuscate a Batch File?
Ask the user what exactly the error message is. JScript always outputs a nice message including line number and position in the line where the error occurred.
Steffen
Steffen
Re: Best way to obfuscate a Batch File?
I've downloaded the example, executed "test.bat" to create "Hello_obfuscated.bat", which gives this output:
On a fast check i guess, that the error is in daves "ObfuscateBatch.bat" is located in line 123:
I think the for/f-loop is missing the dot character ('.') as a delimiter, so correct line should be:
Although it might be, that the resulting "chcp 708>nul" also may lead to an error, so i would prefer ">nul chcp 708".
penpen
Code: Select all
Hello World!
Parameterformat falsch - 708.
On a fast check i guess, that the error is in daves "ObfuscateBatch.bat" is located in line 123:
Code: Select all
echo @echo off^&(if defined @lo@ goto !hi:~0,1!)^&setlocal disableDelayedExpansion^&for /f "delims=: tokens=2" %%%%A in ('chcp') do set "@chcp@=chcp %%%%A>nul"^&chcp 708^>nul^&set ^^^^"@args@=%%*"
I think the for/f-loop is missing the dot character ('.') as a delimiter, so correct line should be:
Code: Select all
echo @echo off^&(if defined @lo@ goto !hi:~0,1!)^&setlocal disableDelayedExpansion^&for /f "delims=:. tokens=2" %%%%A in ('chcp') do set "@chcp@=chcp %%%%A>nul"^&chcp 708^>nul^&set ^^^^"@args@=%%*"
Although it might be, that the resulting "chcp 708>nul" also may lead to an error, so i would prefer ">nul chcp 708".
penpen
Re: Best way to obfuscate a Batch File?
One important limitation of JREPL that I have not documented - based on a private message I received, it appears JREPL does not support Asian languages that use multi-byte characters within cmd.exe. I wonder if Staszek Michal is running into that limitation The opening lines of his posted hello_obfuscated.bat are certainly corrupted in a major way.
So the format of CHCP output must not be consistent across all languages. I was aware that the words would change, but I thought the punctuation would be consistent. On my US machine I get
But your output must have a period at the end. Adding the dot to delims should indeed fix that problem, assuming there are no other variations with other languages.
Dave Benham
Wowpenpen wrote:I've downloaded the example, executed "test.bat" to create "Hello_obfuscated.bat", which gives this output:Code: Select all
Hello World!
Parameterformat falsch - 708.
On a fast check i guess, that the error is in daves "ObfuscateBatch.bat" is located in line 123:Code: Select all
echo @echo off^&(if defined @lo@ goto !hi:~0,1!)^&setlocal disableDelayedExpansion^&for /f "delims=: tokens=2" %%%%A in ('chcp') do set "@chcp@=chcp %%%%A>nul"^&chcp 708^>nul^&set ^^^^"@args@=%%*"
I think the for/f-loop is missing the dot character ('.') as a delimiter, so correct line should be:Code: Select all
echo @echo off^&(if defined @lo@ goto !hi:~0,1!)^&setlocal disableDelayedExpansion^&for /f "delims=:. tokens=2" %%%%A in ('chcp') do set "@chcp@=chcp %%%%A>nul"^&chcp 708^>nul^&set ^^^^"@args@=%%*"
So the format of CHCP output must not be consistent across all languages. I was aware that the words would change, but I thought the punctuation would be consistent. On my US machine I get
Code: Select all
C:\test>chcp
Active code page: 437
Putting the redirection in front certainly can't hurt, but it should not be necessary. CMD.EXE redirection only recognizes single digit file streams. The 8 would only be a problem if it were a complete token, but it is part of the larger 708 token. So CMD.EXE knows it does not represent a file stream.penpen wrote:Although it might be, that the resulting "chcp 708>nul" also may lead to an error, so i would prefer ">nul chcp 708".
Dave Benham
-
- Posts: 118
- Joined: 02 Apr 2017 06:11
Re: Best way to obfuscate a Batch File?
@dbenham - Perhaps posting the solution directly to the website may help. Can you please reply to Michal directly on the website since none of us, Kvc or me, understand JS.
Re: Best way to obfuscate a Batch File?
I don't want to speak for Dave. So the following is just my opinion.
You asked Dave if you can use/post his code on your website. You copied the code and uploaded it externally. This is the first point where you failed. Nobody but you can update this upload. Don't expect you get informed whenever Dave updates his code here at DosTips. So from my point of view it would have been much better to post a link to this thread instead. Also even that you told the people who developed the code you didn't tell them where to get help. Of course they will ask you if they get problems now. And of course you have to answer. Are you really trying to force Dave being responsible to answer in any forum or on any website his code might be copied or linked?
Just my 2 cents ...
Steffen
You asked Dave if you can use/post his code on your website. You copied the code and uploaded it externally. This is the first point where you failed. Nobody but you can update this upload. Don't expect you get informed whenever Dave updates his code here at DosTips. So from my point of view it would have been much better to post a link to this thread instead. Also even that you told the people who developed the code you didn't tell them where to get help. Of course they will ask you if they get problems now. And of course you have to answer. Are you really trying to force Dave being responsible to answer in any forum or on any website his code might be copied or linked?
Just my 2 cents ...
Steffen
Re: Best way to obfuscate a Batch File?
Perfect response Steffen, thanks.
@PaperTronics - I'm almost positive the dot will not solve Staszek Michal's problem.
I suspect he is using a machine configured for a multi-byte character set, which JREPL does not support (unfortunately). I'll leave it up to you to follow up with him. Ask him what active code page he is using (execute CHCP from command line and report the result). Then look up that code value to determine if it is multi-byte.
Dave Benham
@PaperTronics - I'm almost positive the dot will not solve Staszek Michal's problem.
I suspect he is using a machine configured for a multi-byte character set, which JREPL does not support (unfortunately). I'll leave it up to you to follow up with him. Ask him what active code page he is using (execute CHCP from command line and report the result). Then look up that code value to determine if it is multi-byte.
Dave Benham
Re: Best way to obfuscate a Batch File?
dbenham wrote: Wow
So the format of CHCP output must not be consistent across all languages. I was aware that the words would change, but I thought the punctuation would be consistent.
Code: Select all
Aktive Codepage: 850.
So it's just the point at the end of the sentence. That's how I usually work around it:
Code: Select all
for /f "tokens=2 delims=:" %%i in ('chcp') do set /a "oemcp=%%~ni"
Steffen
Re: Best way to obfuscate a Batch File?
aGerman wrote:I don't want to speak for Dave. So the following is just my opinion.
You asked Dave if you can use/post his code on your website. You copied the code and uploaded it externally. This is the first point where you failed. Nobody but you can update this upload. Don't expect you get informed whenever Dave updates his code here at DosTips. So from my point of view it would have been much better to post a link to this thread instead. Also even that you told the people who developed the code you didn't tell them where to get help. Of course they will ask you if they get problems now. And of course, you have to answer. Are you really trying to force Dave being responsible to answer in any forum or on any website his code might be copied or linked?
Just my 2 cents ...
Steffen
Pardon me for forgetting about - posting the related link of the forum in the article (My Bad). Handling lot of things together leads me to forget important things. I'll quickly update the article.
And, We are not forcing Dave - Just trying to get their help in understanding the working & solution for their complex work. We always change the source Link of the code with our own Media-fire link because of two reasons...
1. The BatchStore Project (http://www.thebateam.org/2017/06/batch-app-batch-store-v10-by-kvc.html)
And, BatchStore detects only Mediafire links as project download links...
2. If Someone removes the Code from the source - We'll need to update all those related articles again & again. (And, we'll know about the problem - only if someone complains... SO, didn't want to depend on such conditions - independent solution. Already faced some problems in this case - so,...)
3. Newbie programmers don't even know 'how to use these plugins?' so, Needed to provide a simple help file in the download link - such as 'Test.bat' in this case. So, they can get the result quickly. And, when the curiosity takes over their lazy brain... they'll try to know how it worked. And, then self-motivation will motivate them to know more about the plugin, its creator, and the method - how it works?
Can't do all 3 when we'll only provide the link to the source of the code. But, we can provide the link alongside with our download link. Thanks for the reminder - From next time We'll keep that in mind.
Re: Best way to obfuscate a Batch File?
dbenham wrote:I suspect he is using a machine configured for a multi-byte character set, which JREPL does not support (unfortunately). I'll leave it up to you to follow up with him. Ask him what active code page he is using (execute CHCP from the command line and report the result). Then look up that code value to determine if it is multi-byte.
Dave Benham
Perfect. And, I'll also ask Michal to update the code from v.1.0 to v.1.1 (your recent update). But, Are you sure - it is not the problem of having java installed in the PC? (just curious)
If you can't stop thinking about it, never stop working for it.