通过 Reflector 反编译 ASP.NET 有多少成功?
我刚刚完成了一个小项目,需要对预编译但不再受支持的 ASP.NET 网站进行更改。 代码很丑陋,但在编译之前就很丑陋,令我印象深刻的是,一切似乎仍然工作正常。
它需要一些编辑,例如删除控件声明,因为它们被放入生成的文件中,并与反编译的基类发生冲突,但几个小时后没有任何问题无法解决。
现在我只是好奇有多少其他人在这方面取得了多大成功。 我实际上想写一篇关于定义逆向工程过程(如果不是自动化的话)的 CodeProject 文章。
I just finished a small project where changes were required to a pre-compiled, but no longer supported, ASP.NET web site. The code was ugly, but it was ugly before it was even compiled, and I'm quite impressed that everything still seems to work fine.
It took some editing, e.g. to remove control declarations, as they get put in a generated file, and conflict with the decompiled base class, but nothing a few hours didn't cure.
Now I'm just curious as to how many others have had how much success doing this. I would actually like to write a CodeProject article on defining, if not automating, the reverse engineering process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于 .NET 平台中存在所有编译器糖,如果没有极其复杂的反编译器,您就无法将二进制文件反编译为原始代码。 例如,编译器在后台创建类来处理封装。 自动化这种事情似乎是一项艰巨的任务。 然而,处理预期的问题只是为了让它编译可能是可以编写脚本的。
Due to all the compiler sugar that exists in the .NET platform, you can't decompile a binary into the original code without extremely sophisticated decompilers. For instance, the compiler creates classes in the background to handle enclosures. Automating this kind of thing seems like it would be a daunting task. However, handling expected issues just to get it to compile might be scriptable.
幸运的是,这个特定的应用程序非常简单,但我不希望反编译为原始代码,只需反编译为像原始代码一样工作的代码,或者甚至可以提供有关如何反编译的见解原来的作品,允许“拼接”新代码。
Fortunately this particular application was incredibly simple, but I don't expect to decompile into the original code, just into code works like the original, or maybe even provides an insight into how the original works, to allow 'splicing' in of new code.
我必须做类似的事情,而且我实际上比拥有代码更高兴。 我可能花费的时间更少,但是编译器优化后的代码质量可能比原始代码更好。 所以,是的,如果它是一个简单的应用程序,那么对其进行逆向工程就相对简单; 另一方面,我想避免将来不得不这样做。
i had to do something similar, and i was actually happier than if i had the code. it might have taken me less time to do it, but the quality of the code after the compiler optimized it was probably better than the original code. So yes, if its a simple application, is relatively simple to do reverse engineer it; on the other hand i would like to avoid having to do that in the future.
如果它是用 .NET 1.1 或 .NET 2.0 编写的,那么您将比使用 VS 2008 编译器编译的任何内容获得更大的成功,主要是因为新语言修订版引入的语法糖(Lambda、匿名类等) 。
只要代码没有被混淆,那么您应该能够使用反射器来获得可行的代码,如果您随后将其放入 VS,您应该立即在反射代码。
请注意以
<>
开头的变量/方法,我经常看到这种情况(特别是在反映 .NET 3.5 时)。最糟糕的情况就是将其全部导出到 VS,点击编译并确定有多少错误,然后从中进行调用。
但如果它是一个足够简单的项目,您应该能够从反射器进行逆向工程,至少使用反射器来了解代码正在做什么的一般要点,然后自己重新编码。
If it was written in .NET 1.1 or .NET 2.0 you'll have a lot more success than anything compiled with the VS 2008 compilers, mainly because of the syntactic suger that the new language revisions brought in (Lambda, anonymous classes, etc).
As long as the code wasn't obfuscated then you should be able to use reflector to get viable code, if you then put it into VS you should immidiately find errors in the reflected code.
Be on the look out for variables/ method starting with
<>
, I see that a lot (particularly when reflecting .NET 3.5).The worst you can do is export it all to VS, hit compile and determine how many errors there are and make a call from that.
But if it's a simple enough project you should be able to reverse engineer from reflector, at least use reflector to get the general gist of what the code is doing, and then recode yourself.