473,698 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disable reflection thru .NET reflector

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 ReflectionPermi ssionAttribute but don't know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks
Jun 8 '07 #1
12 12400
On Jun 8, 5:09 pm, m_gell <m_g...@discuss ions.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 ReflectionPermi ssionAttribute 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

Jun 8 '07 #2
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 ReflectionPermi ssionAttribute but don't know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks
Jun 8 '07 #3
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 ReflectionPermi ssionAttribute but don't know if this will
do what I want.

Any advice/answer greatly appreciated.

Thanks
Jun 8 '07 #4
When using CE of dotfuscator when I reference the obfuscated dll I can not
build my project as it does not recognize the former classes in the
namespace. Anyone know what I'm missing?

"Jon Skeet [C# MVP]" wrote:
On Jun 8, 5:09 pm, m_gell <m_g...@discuss ions.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 ReflectionPermi ssionAttribute 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

Jun 8 '07 #5
m_gell <mg***@discussi ons.microsoft.c omwrote:
When using CE of dotfuscator when I reference the obfuscated dll I can not
build my project as it does not recognize the former classes in the
namespace. Anyone know what I'm missing?
Have you got it set to obfuscate public classes? Or are you referencing
internal classes with InternalsVisibl eTo?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 8 '07 #6
I have the disable renaming property set to No which then I cannot reference
the classes in the namespace. When set to yes I can. I'm not referencing
any classes w/ InternalsVisibl eTo and I'm not sure if I have it set to
obfuscate public classes. ??? Thoughts

"Jon Skeet [C# MVP]" wrote:
m_gell <mg***@discussi ons.microsoft.c omwrote:
When using CE of dotfuscator when I reference the obfuscated dll I can not
build my project as it does not recognize the former classes in the
namespace. Anyone know what I'm missing?

Have you got it set to obfuscate public classes? Or are you referencing
internal classes with InternalsVisibl eTo?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 8 '07 #7
m_gell <mg***@discussi ons.microsoft.c omwrote:
I have the disable renaming property set to No which then I cannot reference
the classes in the namespace. When set to yes I can. I'm not referencing
any classes w/ InternalsVisibl eTo and I'm not sure if I have it set to
obfuscate public classes. ??? Thoughts
Well, there are a few double negatives in there so I'm not sure what
you're doing, but if you've got something that works, why not just use
that?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 8 '07 #8
It does not fulfill what I want.

I can reference classes in the obfuscated dll with disable renaming=Yes
(which means enable renaming=no)but then the method names are not obfuscated
and the hardcoded key is visible in the constructor method when viewed thru
reflector.

As disable renaming = no (which means enable renaming=yes), then finding the
keyword is near impossible...do esn't show up w/ reflector, but then I cannot
reference any classes from the obfuscated dll in another assembly which is
what I need.

Bottomline, if I enable renaming to obfuscate the dll w/ the keyword, I
cannot use the dll. So do you know how to obfuscate w/ renaming yet still
reference the dll, or certain classes within the dll.

"Jon Skeet [C# MVP]" wrote:
m_gell <mg***@discussi ons.microsoft.c omwrote:
I have the disable renaming property set to No which then I cannot reference
the classes in the namespace. When set to yes I can. I'm not referencing
any classes w/ InternalsVisibl eTo and I'm not sure if I have it set to
obfuscate public classes. ??? Thoughts

Well, there are a few double negatives in there so I'm not sure what
you're doing, but if you've got something that works, why not just use
that?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 8 '07 #9
m_gell <mg***@discussi ons.microsoft.c omwrote:
It does not fulfill what I want.

I can reference classes in the obfuscated dll with disable renaming=Yes
(which means enable renaming=no)but then the method names are not obfuscated
and the hardcoded key is visible in the constructor method when viewed thru
reflector.

As disable renaming = no (which means enable renaming=yes), then finding the
keyword is near impossible...do esn't show up w/ reflector, but then I cannot
reference any classes from the obfuscated dll in another assembly which is
what I need.

Bottomline, if I enable renaming to obfuscate the dll w/ the keyword, I
cannot use the dll. So do you know how to obfuscate w/ renaming yet still
reference the dll, or certain classes within the dll.
The bottom line is going to be that however you rename methods and
types, that hardcoded string is still going to be in there. The
solution is not to have the hard coded string in there in the first
place.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 8 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2842
by: Laser Lu | last post by:
HI, all, I just want to invoke an internal method named 'ResolveClientUrl', which is defined in class System.Web.UI.Control, using an instance object of a type that derives from Control. Let's see the following code snippet (class MyControl is a sub class that derives directly from System.Web.UI.Control): //... MyControl instance = new MyControl(); Type type = instance.GetType();
3
2013
by: Jozsef Bekes | last post by:
Hi All, I am trying to use reflection for getting all the classes from the dlls of a software written by my company. I am using this line: Assembly.LoadFile(s).GetTypes() Gettypes fails, I guess because when one dll refers to another one of mine, Reflection does not find that dll. This is what the exception contains anyway. So I realized that I'd need to copy the dlls, or register them to
7
371
by: John | last post by:
I have a class the reads in a file and sets the values of the file into its properties. This class is used to populate the data onto a form. This form has controls created at runtime based on user input (file values when file is opened). I was hoping to put the name of the property in the tag of each control and fire an event if the a file is open when the control is created and use the tag to get the correct property from the class. ...
7
9964
by: Mark Miller | last post by:
I am using Reflection.Emit to dynamically build a class. A method of the class to be built requires a Parameter of type "Type". But I don't know how to use Emit to pass a call of "typeof()" to the method. The method could look like this: public void myDynamicMethod(Type type){ //.....do something with the Type passed in....... }
2
2200
by: Test1000 | last post by:
Hello, I want to know how I can access the IL code using System.Reflection. I don't want to use any tools like reflector etc because I want to programmatically access the IL code. Thanks,
2
1408
by: forvino | last post by:
Hi Geeks, Ihave a doubt in dotNet reflection. I m developing a tool which will returns set of public(access specifier) methods of the selected assembly. this works completely fine, when the selected components are
1
1854
by: nate | last post by:
hi :) i am having a strange problem. i have a plug-in system that i use to add support for various CAD file formats. i have a Maya plug-in that i have been running successfully for quite some time (i.e. months). a couple of days ago, however, i started getting a BadImageFormatException when i tried loading my managed mayaplug.dll. The DLL does in fact load up some unmanaged DLLs for support, but this has never been a problem in the...
9
4165
by: Michael Sander | last post by:
Hello ng, anyone knowns how to add a reference to an assembly to System.Reflection.AssemblyBuilder? In System.Web.Compilation.AssemblyBuilder is a function like AddAssemblyReference, but not in System.Reflection. Regards, Michael
6
1514
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am slightly familiar with reflection but have never done the following I know how to find a class and call but I haven't done the following The Method return a List of Another Class And I need to pass in an Enumeration which is in the class that contains the method below 1)How do I create a List of this Class thru Reflection and once i populate it
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.