Read Mode
Default

Batch File Obfuscation | By Param

Secure Your Source Code | Obfuscation Method

Let us first understand what obfuscation is. According to Wikipedia, "Obfuscation is the obscuring of intended meaning in communication, making the message confusing, wilfully ambiguous, or harder to understand."

So, let me try to give you an example of how we may obfuscate batch files. Here is a pretty intelligent obfuscation of batch files. I have separated all the examples in 3 Cases, as below. Note that you cannot directly copy the codes from the website, 'cuz #TheBATeam has disabled the Text selection from the Website. So, I have provided the Download link instead.

You can Download the code directly from the link given below the article. 😎 Even though the 3 codes seem very different from each-other, they all do exactly the same thing.

Batch File Obfuscation | Explained | By Param
Output on the Console
The only difference is that the obfuscated codes don't easily explain from their codes what they actually do, and they also protect your code from being edited easily by someone else. so it is a kind of extra layer of security to your Source code.

In the first obfuscated code, the characters used in the batch file are put into separate variables, which are later organised appropriately to make-up the code properly. In the second obfuscated code, many characters are put into a single variable, and parts of the variable are used to make-up the code. 

To be more clear, let me first explain to you the first obfuscated code, Here, we have put the character 'e' in the variable 'a', 'c' in the variable 'b', 'h' in the variable 'c', and so on. Later we combine the configured variables in various forms to recreate the commands.
i.e. We use '%a%%b%%c%%d%' for the command 'echo', and so on. Similarly, we complete the code. However, this type of code would be harder to edit, so it will be safer to keep the original code saved somewhere else.

Now, let me explain to you how the second obfuscated code works. In the second obfuscated code, we have put all the required characters i. e. 'echo Zh pause' in a single variable 'a', use different parts of that variable to recreate the commands i.e. For the command 'echo', we will use '%a:~0,1%%a:~1,1%%a:~2,2%', and so on. Or you can also make it in single GO. Like... '%a:~0,4%' for printing 'echo'. Notice how we used the variable (We could have also used '%a:~0,1%%a:~1,1%%a:~2,1%%a:~3,1', but we tried to make it simpler).

Although Batch is not meant to be a hidden code, you may use obfuscation to protect your code from being copied and modified easily by any other person. This may also help you make it hard for the other person to understand how your code functions.


However, this may not be the best way to obfuscate batch files, as special characters (%, *, ^, &, >, <, etc) cannot be included in the variable.The preparation of such an obfuscated batch file is also very hard, but I have found out an easy way to do this, which I may tell you later. 

You may also get your own code obfuscated by me, but make sure that the code follows certain standards for that. Try to include a reason if possible. Send the code as an e-mail here: email@psiddharth.tk
Visit My Facebook page: NIU.
Visit Our Facebook page: TheBATeam

Keep Learning, Keep Sharing...
Be Happy, Spread Happiness...

Download Link:

#TheBATeam

5 comments:

  1. Might it be possible to hire you to Obfuscate a program for me? Its built up of 4 scripts each under 300 lines...

    ReplyDelete
    Replies
    1. :) Please Read the Link before Any of the official bussiness.

      And, You can hire me officially at: Karanveer Chouhan.

      Thanks for your time and faith.

      Delete
    2. Please, refer to this article... http://www.thebateam.org/2017/08/properly-encode-obfuscate-your-code.html

      You can do it all along by your own. :)

      Delete
  2. Might it be possible to hire you to Obfuscate a program for me? Its built up of 4 scripts each under 300 lines...

    ReplyDelete
  3. We can create a tool to automatic it!

    So we using "for" command:
    for /f "tokens=*" %%a in (%filename%) do (
    set text=%%a
    set text=!text:e=^%a^%!
    set text=!text:c=^%b^%!
    set text=!text:h=^%c^%!
    set text=!text:o=^%d^%!
    rem and so on... (^% mean when output it will return as %)

    echo !text!>>!filename!_OUT.txt
    )

    The code above is not finished yet, still need to edit more.

    ReplyDelete

Powered by Blogger.