简体   繁体   English

发布C#Web项目

[英]publishing a C# web project

I have a web service written in c# and .Net , I have the following questions: 我有一个用c#.Net编写的Web服务,我有以下问题:

  • what happens when I choose to publish the project ? 当我选择发布项目时会发生什么?
  • will the code still be readable ? 代码仍然可读吗?
  • and if not, how easy it is to reverse it ? 如果没有,逆转它有多容易?

what happens when I choose to publish the project ? 当我选择发布项目时会发生什么?

it compiles the project (to .dll files) and export your project to a folder 它编译项目(到.dll文件)并将您的项目导出到文件夹

will the code still be readable ? 代码仍然可读吗?

yes, by using Reflector 是的,通过使用Reflector

and if not, how easy it is to reverse it ? 如果没有,逆转它有多容易?

very easy.. just install Reflector.. 非常容易..只需安装Reflector ..

When you perform publish action in Visual studio or MSBuild it just compiles the code and copies it to some particular target location. 在Visual Studio或MSBuild中执行发布操作时,它只是编译代码并将其复制到某个特定的目标位置。

Compiling changes your readable source code to more machine readable form. 编译会将您可读的源代码更改为更多机器可读的形式。 In C# and other CLR based languages (ie VB.NET) the output is Intermediate Language (IL). 在C#和其他基于CLR的语言(即VB.NET)中,输出为中间语言(IL)。 This language is not as itself human readable, but it can be relative easily reverse engineered back to C# with many different tools. 这种语言本身并不是人类可读的,但是可以使用许多不同的工具相对容易地反向工程回C#。

When compiling happens, code will change to perform some optimations for the code, so the reverse engineered code will most likely not look exactly like the original source. 发生编译时,代码将更改以对代码进行一些优化,因此反向工程代码很可能看起来与原始源代码完全不同。 Comments and other parts of the code that don't affect the execution, are removed. 注释和不影响执行的代码其他部分将被删除。

There are tools to obfuscate code before it is compiled. 有一些工具可以在编译代码之前对其进行混淆处理。 For example dotfuscator will be shipped with the Visual Studio. 例如,dotfuscator将随Visual Studio一起提供。 Unfortunately these obfuscations can be quite easily reversed by those same tools that reverse engineer the compiled C# code. 不幸的是,通过对工程C#代码进行反向工程的相同工具,可以很容易地消除这些混淆。

what happens when I choose to publish the project ? 当我选择发布项目时会发生什么?

在此处输入图片说明

Your C# code is complied to managed DLL file which is red color box in the picture. 您的C#代码已编译为托管DLL文件,该文件为图片中的红色框。

Only C++ can write unmanaged code which is very hard to decompile. 只有C ++可以编写很难反编译的非托管代码

will the code still be readable ? 代码仍然可读吗? and if not, how easy it is to reverse it ? 如果没有,逆转它有多容易?

Yes, it is quite easy. 是的,这很容易。 You can use the following tools to decompilerthe source - 您可以使用以下工具反编译源代码-

Obfuscation does not provide 100% code protection. 混淆不提供100%的代码保护。 The bottom line is do not host your web application if you do not trust the hosting service. 最重要的是,如果您不信任托管服务,则不要托管您的Web应用程序。

Credit: picture is from Illustrated C# 2012 by Daniel Solis 图片提供:图片来自Daniel Solis的Illustrated C#2012

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM