Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement BAT encryption tool

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to achieve BAT encryption tool, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Bat files are easy to use, but their security is too fragile

Anyone can open it and view it, or even modify it.

Is there any way not to convert .bat to .exe or .com, which is still .bat file?

But others cannot view and modify the contents.

Is there any self-encryption or something?

Master, give me a way to solve the problem.

The options currently under discussion are as follows:

1. The scheme of inserting Unicode feature string into batch code.

It is valid for programs such as notepad that use IsTextUnicode functions to identify coding types.

Invalid for programs that do not use IsTextUnicode functions such as type/edit/EditPlus/UltraEdit

2. The scheme of adding Unicode byte order mark (BOM) to the header of batch code

EncryBat.rar (zxcv)

Valid for notepad, Word, UltraEdit, type and other programs that support Unicode coding

Invalid for programs that do not support Unicode encoding, such as edit/WinRAR internal viewers

3. The scheme of replacing the carriage return newline character of the batch code with the carriage return character

It is valid for editors such as edit to identify carriage return newline characters respectively.

4. the scheme of lexicographic conversion of batch code.

The code is generated dynamically when plaintext is run, so the scheme is independent of the editor.

BAT file encryption (better than Bat2Com software)

The method is:

Open notepad and write the following statement at the beginning of the file

The code is as follows:

For / l% an in (1penny 1 10) do ren * .jpg% a% a% a% A% a% a% A% a% a% A% a% a% A% a% a% A% a% a% A% a% a% A% a% a%

When saving a newly created document, the notepad program uses the default ANSI type (for the Chinese version, the corresponding GB code) if the encoding type is not specified.

When opening a created document, it will analyze the encoding type of the document, it first determines whether the document header has BOM (Byte Order Mark, byte order mark, the length is 2x3 bytes), and if so, it determines the encoding type according to its content, FF, FE (Unicode), FE, FF (Unicode big endian), EF, BB, BF (UTF-8) [1].

Because of the fact that many non-ANSI-encoded documents are "plain text" without any BOM, these documents cannot be simply judged to be ANSI-encoded. Instead, a series of statistical algorithms are used to guess the document encoding according to the content of the document. Notepad uses the IsTextUnicode function to determine whether it is Unicode/Unicode big endian-encoded and IsTextUTF8 to determine whether it is UTF8-encoded.

However, since it is a statistical algorithm, there will inevitably be misjudgment, especially when the content of the document is too short, because the size of the sample is too small, the probability of misjudgment will be significantly increased. For example, the famous joke that Microsoft has a feud with Unicom is that when notepad opened an ANSI coding document with only the word "Unicom", the IsTextUTF8 function misjudged it as UTF8 coding [2]; the same misjudgment also occurred on IsTextUnicode functions, such as documents with 4335 structure such as "this app can break", which would be misjudged as Unicode coding [3] [4].

It should be noted that the possibility of misjudgment is based on the premise that the text is short and its byte features are not disturbed. If the above text is slightly modified (even if only a carriage return is added), it will be very difficult for misjudgment to happen again.

The particularity of the yuanyong630 scheme is that its byte string not only has Unicode characteristics, but also reaches 1288 bytes in length, that is to say, its Unicode characteristic is very strong, so it can resist some short interference without Unicode characteristic strings, which is determined by the law of statistics. However, when the interference string is slightly longer, the characteristics of Unicode will be significantly interfered until it is recognized as non-Unicode by the IsTextUnicode function. Therefore, some friends always fail to test successfully, which should be related to the length and content of the additional batch code. You can test the code in [5].

Because other editors (such as Word / Wordpad / EditPlus / UltraEdit) use newer coding type judgment algorithms, the Unicode judgment has been improved a lot, while the UTF8 judgment is still not satisfactory. But because a completely accurate algorithm doesn't exist in theory, we can only rely on avoiding non-ANSI documents without BOM, or manually specifying the encoding type when the document is opened.

In addition, if you use notepad to save these files that misjudge the encoding type, it will be difficult to recover. If you save with an erroneous code, the original document will be marked with a BOM, and the original document will no longer be visible using other editors. If you save using ANSI encoding, the original document will be converted as an Unicode document, and the possibility of restore is close to zero.

[1] introduction to Unicode

Http://my.opera.com/neutronstar/blog/index.dml/tag/ coding

[2] Why does Microsoft have a feud with Unicom?

Http://blog.vckbase.com/localvar/archive/2005/07/12/9510.aspx

[3] Notepad bug? Encoding issue?

Http://weblogs.asp.net/cumpsd/archive/2004/02/27/81098.aspx

[4] Bush Hid The Facts

Http://www.shoutwire.com/comments/16341/Bush_Hid_The_Facts

[5] cry.cmd

For the method of changing 0d 0a to 0a, it is better to change it to 0d. If you are about to enter the newline instead of only entering the carriage return and not wrapping, the text of the current line will be overwritten by the non-newline text line, and the overlay will be repeated. If you add a comment text that is longer than all the above lines on the last line of the batch, only such comments will eventually be displayed.

This method is effective for EDIT and TYPE, so it was once popular in the era of DOS. However, this scheme is similar to that of brother yuanyong630, except that a specific text processing mechanism for a specific text processor cannot be applied to all platform environments.

The above is all the content of this article "how to implement BAT encryption tool". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report