MS Excel VBA 的混淆工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16765277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Obfuscation Tool for MS Excel VBA
提问by Chronix3
What are some recommendations of tools that can obfuscate VBA code across forms, modules and class modules?
有哪些工具可以跨表单、模块和类模块混淆 VBA 代码?
I've done a bit of research and read up here in the archives but there hasn't been anything mentioned in a while so I thought those recommendations could be outdated.
我做了一些研究并在档案中阅读了这里,但有一段时间没有提到任何内容,所以我认为这些建议可能已经过时了。
A couple of picked up from reading on other places are:
从其他地方阅读的一些内容是:
- CrunchCode
- Obfu-VBA
- 紧缩代码
- 模糊VBA
Also, please correct me if I'm wrong but from my understanding the simplified logic of a obfuscator is:
另外,如果我错了,请纠正我,但根据我的理解,混淆器的简化逻辑是:
- Scramble the VBA code by using a defined logic (change X to Y)
- The tool creates a new workbook where the VBA code is all scrambled, but everything else remains the same.
- The tool can use the defined logic to revert back to the original VBA code (change Y to X)
- 使用定义的逻辑打乱 VBA 代码(将 X 更改为 Y)
- 该工具创建了一个新的工作簿,其中 VBA 代码全部被打乱,但其他一切都保持不变。
- 该工具可以使用定义的逻辑恢复到原始 VBA 代码(将 Y 更改为 X)
Is that correct? What do I need to be looking into when selecting the 'defined logic'? I played around with CrunchCode before and there was a plethora of options but they were all foreign to me.
那是对的吗?选择“定义的逻辑”时我需要考虑什么?我之前玩过 CrunchCode,有很多选择,但它们对我来说都很陌生。
Thanks for any help :)
谢谢你的帮助 :)
回答by andrewkoay
I have bought CrunchCode and beware that it doesn't support 64-bit systems. Support is really bad (no email replies whatsoever over a few weeks). The string encryption feature will screw up all your string comparisons and MsgBoxes, as decrypted strings are not the same as the originals. Recommend to avoid this product!
我购买了 CrunchCode 并注意它不支持 64 位系统。支持真的很糟糕(几周内没有任何电子邮件回复)。字符串加密功能会搞砸所有的字符串比较和 MsgBoxes,因为解密的字符串与原始字符串不同。建议避免使用该产品!
回答by csharpforevermore
My previous answer was poorly researched and as nobody else has replied I thought you deserved a better answer. Having tested CrunchCode, it appears that it obfuscates through the following techniques:
我之前的答案研究不足,因为没有其他人回答过,我认为您应该得到更好的答案。测试 CrunchCode 后,它似乎通过以下技术进行混淆:
- Renaming
- 重命名
The number one obfuscation technique is to strip out all semantics and reduce the likelihood that any context will be inferred. This was commonly a problem in the days of assembly code when it was very hard to tell what the code was going to do unless you were familiar with it.
首要的混淆技术是去除所有语义并降低推断任何上下文的可能性。在汇编代码时代,这通常是一个问题,除非您熟悉它,否则很难判断代码将要做什么。
Upper and lower case letters, with poor spacing make it very tough to read.
大写和小写字母,间距差,阅读起来非常困难。
- Removal of Comments
- 删除评论
As above, this removes the chance of an understanding of the code being inferred.
如上所述,这消除了理解推断代码的机会。
- Substitution
- 代换
Overloading of operators (through the use of User Defined Functions) is a useful technique. You can do this in VBA and I always remember this being a question I was given during an interview:
运算符重载(通过使用用户定义函数)是一种有用的技术。你可以在 VBA 中做到这一点,我一直记得这是我在面试中被问到的一个问题:
Sub 1: x = z + y
Sub 2: x = y + z
子 1:x = z + y
子 2:x = y + z
Sub 2 is proven to take longer than sub 1. Why is this?
事实证明,Sub 2 比 sub 1 花费的时间更长。这是为什么呢?
Out of 10 interviewees, I was the only one who guessed operator overloading, so this has always stuck with me. You can make code behave very differently to how it is supposed to. The addition symbol can be made to subtract, divide or any other number of combinations. When something this fundamental is changed in code, it is much harder to understand the source code.
在 10 位受访者中,我是唯一一个猜到运算符超载的人,所以这一直困扰着我。您可以使代码的行为与其预期的行为大不相同。加法符号可以用于减法、除法或任何其他数量的组合。当代码中的这一基本原理发生变化时,理解源代码就会困难得多。
- Extras
- 附加功能
As an additional step, I would probably be tempted to add many redundant methods to the source code. Essentially pieces of code that perform pointless code based on a condition being true. This condition is never true, but because the code is difficult to read, this is hard to understand.
作为一个额外的步骤,我可能会想在源代码中添加许多冗余方法。本质上是基于条件为真执行无意义代码的代码段。这种情况永远不会成立,但由于代码难以阅读,因此难以理解。
Essentially, it works like the very opposite of all the coding standards I've read over the last few years. Everything you are supposed to do as a developer to make you code more readable (after all we should all be writing our code for other developers not just for the machine - who cares that you can reduce that method to a single line if nobody can understand it?).
从本质上讲,它的工作方式与我过去几年阅读的所有编码标准完全相反。作为一名开发人员,你应该做的一切都是为了让你的代码更具可读性(毕竟我们都应该为其他开发人员编写我们的代码,而不仅仅是为机器编写代码——如果没有人能理解,谁会在乎你能把那个方法减少到一行它?)。
Caveat: There is no sure fire way to stop someone stealing your source code. I know of people who stopped their open source projects because people were selling compiled versions of it as their own. It's just one of those things for developers. Obfuscation will go some of the way but is not 100% guaranteed to stop a determined developer from stealing it but it is a case of making it more trouble than it is worth so they have diminishing returns (e.g. they could write the same functionality in the time it takes to reverse engineer the code).
警告:没有可靠的方法可以阻止有人窃取您的源代码。我知道有些人停止了他们的开源项目,因为人们将它的编译版本作为自己的版本出售。对于开发人员来说,这只是其中之一。混淆会起到一定的作用,但并不能 100% 保证阻止有决心的开发人员窃取它,但这是一种让它带来的麻烦超过其价值的情况,因此他们的收益递减(例如,他们可以在对代码进行逆向工程所需的时间)。
Hope this helps - for more information check out the YouTube video here(with very ominous sounding music!)
希望这会有所帮助 - 有关更多信息,请查看此处的 YouTube 视频(带有非常不祥的音乐!)
回答by Harry
If you dont mind some copy and pasting and double checking the product vbobfuscator seems to be nice. Does both vba and vbscript. Changes var and function names. www.vbobfuscator.net . Obfuscation is way more complex than a simple find and replace... that will deliver non working code ;)
如果您不介意进行一些复制和粘贴并仔细检查产品 vbobfuscator 似乎不错。vba 和 vbscript 都可以。更改 var 和函数名称。www.vbobfuscator.net。混淆比简单的查找和替换复杂得多......这将提供非工作代码;)
回答by doctorlai
Online VBScript Obfuscator (Encrypt/Protect VBS)
在线 VBScript 混淆器(加密/保护 VBS)
Using this handy VBS tool, you can convert your VBScript into an obfuscated VBS source code, without compromising/altering the scripting functionalities and the VBScript keywords. This Free VBScript Obfuscator works by converting each character in your VBS source code into a much obfuscated format. Then these obfuscated letters are combined at runtime and be executed via the Execute function.
使用这个方便的 VBS 工具,您可以将 VBScript 转换为混淆的 VBS 源代码,而不会影响/改变脚本功能和 VBScript 关键字。这个免费的 VBScript Obfuscator 的工作原理是将 VBS 源代码中的每个字符转换成一种非常模糊的格式。然后这些混淆的字母在运行时被组合并通过 Execute 函数执行。
回答by YeP
Just want to add that a tool called "VBASH" (www.ayedeal.com/vbash) can do the job. I have been using it for a while and am happy with it so far.
只想补充一个名为“VBASH”(www.ayedeal.com/vbash)的工具可以完成这项工作。我已经使用它一段时间了,到目前为止我对它很满意。