通过.NET反射器禁用反射 [英] disable reflection thru .NET reflector

查看:61
本文介绍了通过.NET反射器禁用反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何禁用对敏感代码的反射吗?


具体是我要做的事情。我在一个集合中有一个方法

我试图阻止使用反射来查看代码。

代码包含我做的硬编码关键字不想以任何

方式看到。


我尝试过使用ReflectionPermissionAttribute但不知道这是否会

做我想做的事。


任何建议/答案都非常感谢。


谢谢

解决方案

6月8日下午5:09,m_gell< m_g ... @ discussion.microsoft.comwrote:


有人知道如何禁用敏感代码的反射吗?


这是我正在努力做的事情。我在一个集合中有一个方法

我试图阻止使用反射来查看代码。

代码包含我做的硬编码关键字不想以任何

方式看到。


我尝试过使用ReflectionPermissionAttribute但不知道这是否会

做我想做的事。



嗯,这里有两件事:

1)代码反思

2)工具中的反编译像Reflector


你不能真的阻止他们中的任何一个。混淆会让它更难以找到东西,但这就是它。


如果你的任何硬编码敏感数据在你的申请,

基本上是安全漏洞。


http://pobox.com/~skeet/csharp/obfuscation.html 了解更多信息。


Jon


即使您的程序集被混淆,任何如此倾向的人都可以在其上运行ILDASM

并获得所有CIL源代码,找到你的东西没有困难。

如果你需要保密密钥,请不要使用密码。

彼得


- -

网站: http://www.eggheadcafe.com

UnBlog: http://petesbloggerama.blogspot.com

短网址&更多: http://ittyurl.net


" m_ge​​ll"写道:


您好,有人知道如何禁用对敏感代码的反射吗?


这是具体的我是什么试图做。我在一个集合中有一个方法

我试图阻止使用反射来查看代码。

代码包含我做的硬编码关键字不想以任何

方式看到。


我尝试过使用ReflectionPermissionAttribute但不知道这是否会

做我想做的事。


非常感谢任何建议/答案。


谢谢


你在哪里建议保留密钥?


" Peter Bromberg [C#MVP]"写道:


即使您的程序集被混淆,任何如此倾向的人都可以在其上运行ILDASM

并获取所有CIL源代码和找到你的东西没有困难。

如果你需要保密密钥,请不要使用密码。

彼得


- -

网站: http://www.eggheadcafe.com

UnBlog: http://petesbloggerama.blogspot.com

短网址&更多: http://ittyurl.net


" m_ge​​ll"写道:


您好,有人知道如何禁用对敏感代码的反射吗?


这是具体的我是什么试图做。我在一个集合中有一个方法

我试图阻止使用反射来查看代码。

代码包含我做的硬编码关键字不想以任何

方式看到。


我尝试过使用ReflectionPermissionAttribute但不知道这是否会

做我想做的事。


非常感谢任何建议/答案。


谢谢


Hi, anyone know how to disable reflection on sensitive code?

Here is specifically what I''m trying to do. I have one method in a class
within an assembly I''m trying to prevent using reflection to see the code.
The code contains a hardcoded key word that I do not want to be seen in any
way.

I''ve tried using ReflectionPermissionAttribute but don''t know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks

解决方案

On Jun 8, 5:09 pm, m_gell <m_g...@discussions.microsoft.comwrote:

Hi, anyone know how to disable reflection on sensitive code?

Here is specifically what I''m trying to do. I have one method in a class
within an assembly I''m trying to prevent using reflection to see the code.
The code contains a hardcoded key word that I do not want to be seen in any
way.

I''ve tried using ReflectionPermissionAttribute but don''t know if this will
do what I want.

Well, there are two things here:
1) Reflection in code
2) Decompilation in tools like Reflector

You can''t really prevent either of them. Obfuscation will make it
harder to find stuff, but that''s about it.

If you''ve got any hard coded sensitive data in your application,
that''s a security flaw, basically.

See http://pobox.com/~skeet/csharp/obfuscation.html for more info.

Jon


Even if your assembly is obfuscated, anyone who is so inclined can run ILDASM
on it and get all the CIL sourcecode and find your "thing" with no difficulty.
If you need to keep a secret key, keep it out of the code.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"m_gell" wrote:

Hi, anyone know how to disable reflection on sensitive code?

Here is specifically what I''m trying to do. I have one method in a class
within an assembly I''m trying to prevent using reflection to see the code.
The code contains a hardcoded key word that I do not want to be seen in any
way.

I''ve tried using ReflectionPermissionAttribute but don''t know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks


Where do you recommend keeping the secret key?

"Peter Bromberg [C# MVP]" wrote:

Even if your assembly is obfuscated, anyone who is so inclined can run ILDASM
on it and get all the CIL sourcecode and find your "thing" with no difficulty.
If you need to keep a secret key, keep it out of the code.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"m_gell" wrote:

Hi, anyone know how to disable reflection on sensitive code?

Here is specifically what I''m trying to do. I have one method in a class
within an assembly I''m trying to prevent using reflection to see the code.
The code contains a hardcoded key word that I do not want to be seen in any
way.

I''ve tried using ReflectionPermissionAttribute but don''t know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks


这篇关于通过.NET反射器禁用反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆