Click here to Skip to main content
15,860,859 members
Articles / Programming Languages / MSIL

Building Security Awareness in .NET Assemblies : Part 3 - Learn to break Strong Name .NET Assemblies

Rate me:
Please Sign up or sign in to vote.
4.72/5 (94 votes)
31 Oct 20043 min read 455.7K   1.3K   95   68
Building Security Awareness in .NET Assemblies : Part 3 of 3

Disclaimer

NeCoders shall not be held responsible for any cases of software/files being hacked due to the information provided in this article.

General Overview

Welcome back to part 3 of the Building Security Awareness in .Net Assemblies series. In this article, I will share with you the possibility of breaking Strong Named .Net Assemblies. Make sure you have already read through part 1 and 2 before continuing on.

Questions pertaining to Strong Name

I do believe many others have the same doubts as I do on whether Strong Name keys could really protect the assembly from being tampered. I would like to share my doubts with you in this article.

Questions:

  1. Question : Is Strong Name key secure?
    • Answer : Yes, Strong Name key uses RSA 1024 bit encryption.
  2. Question : Is Strong Name key breakable?
    • Answer : If you have enough computing power, time and knowledge on how to break RSA, the answer is yes.
  3. Question : Can Strong Name key be removed from .NET assemblies?
    • Answer : Yes, it can be removed very easily if you know how.

The Demonstration Test machine specifications :

  • Windows XP Professional Edition SP 1 1

  • Intel Pentium 4 2.6GHz

  • 256MB DDR-RAM

  • Visual Studio .Net 2003 Professional Edition

  • Microsoft .Net Framework 1.1
  1. Download the executable files that come with this article.
  2. Open your Visual Studio .Net 2003 command prompt.
  3. Make sure you are inside the CrackingIL/bin/debug directory.
  4. Type “ildasm CrackingIL.exe /out=CrackingIL.il”.

Image 1

  1. You must be wondering, why we are repeating what we had done in part 1 and part 2 of the series. If you notice, the way to break Strong Name keys is by manipulating the Intermediate Language. But the problem is in part 2, we did modify the Intermediate Language and at the end when we tried to convert it back to an assembly, we will receive an error. I will explain in detail on which part of the Intermediate Language that you should modified to remove the Strong Name key.
  2. Open up the CrackingIL.il with a text editor. I use notepad.

Image 2

  1. Take a look at the red boxes. From what I understand, each assemblies like System.Windows.Forms, System and mscorlib contains their own public key token and version number.
  2. Now, does our assembly contain a public key? The answer is yes. Before showing it to you, I will first show you 2 screenshots; one without Strong Name key and one with Strong Name key attached.

Without Strong Name :

Image 3

With Strong Name :

Image 4

  1. You will notice that the difference on both sides is that the Strong Name key assembly contains a public key. In order to tamper a Strong Named .Net Assembly, just remove that highlighted section. It will look like this.

Image 5

  1. Now do some modifications to the existing Intermediate Language. You have to remove the registry checking so it will not prompt you for serial number or license. Look for this code.

Image 6

  1. Then remove the lines of code from IL_0000 to IL_0075. You should have an output like this.

Image 7

  1. Now just edit some text to prove that you have hijacked that Strong Named key .Net Assembly. Find the code with the phrase “Welcome to NeCoders” and replace it to “You are being hijacked, Strong Names are useless here”.

Image 8

Change above to:

Image 9

  1. Open your Visual Studio .Net 2003 command prompt, and type “ilasm CrackingIL.il”.

Image 10

  1. Try to run CrackingIL.exe. You will see this.

Image 11

  1. Congratulations! You had managed to manipulate .Net assemblies with Strong Name key attached to it.

Conclusion

Again, I hope you find this series of the article to be interesting. There will be more articles under this series, in terms of breaking and securing the .Net assemblies. Do check out article 4 when it is available as it will explaining the many theories in .NET security. This in return should provide you with a better understanding in this topic.

References

None

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Malaysia Malaysia
I am Chua Wen Ching and it is great to be part of CodeProject network Smile | :)

Comments and Discussions

 
QuestionCareful Here Pin
eduardna26-Mar-12 22:15
eduardna26-Mar-12 22:15 
GeneralMy vote of 1 Pin
JanV800017-Nov-09 1:40
JanV800017-Nov-09 1:40 
RantSuperb Pin
SyntaxCheck10-May-08 0:47
SyntaxCheck10-May-08 0:47 
Questionis there other parts than 1,2&3? Pin
ZHM12-Feb-08 16:31
ZHM12-Feb-08 16:31 
GeneralRe: is there other parts than 1,2&3? Pin
Chua Wen Ching4-Mar-08 16:19
Chua Wen Ching4-Mar-08 16:19 
GeneralRe: is there other parts than 1,2&3? Pin
ZHM5-Mar-08 11:48
ZHM5-Mar-08 11:48 
QuestionBreak without removing? Pin
Ariston Darmayuda4-Jul-07 6:53
Ariston Darmayuda4-Jul-07 6:53 
Questionwhat would you suggest to do when you have a strong name assembly that need to call a non strong named assembly? Pin
vvatclor28-Aug-06 11:29
vvatclor28-Aug-06 11:29 
GeneralWaiting for part 4 of this series. Pin
horngsh1687-Jun-06 19:17
horngsh1687-Jun-06 19:17 
QuestionHow can I assign Strong Name to DLL [modified] Pin
Nimit Patel22-May-06 3:13
Nimit Patel22-May-06 3:13 
Generalwaiting 4 part 4 Pin
shystars8-Dec-05 19:35
shystars8-Dec-05 19:35 
GeneralOffline thread Pin
Shaun Wilde25-Nov-04 20:56
Shaun Wilde25-Nov-04 20:56 
GeneralRe: Offline thread Pin
Chua Wen Ching25-Nov-04 21:29
Chua Wen Ching25-Nov-04 21:29 
QuestionPossible to change the public key? Pin
Kelvin Tsang12-Nov-04 21:59
Kelvin Tsang12-Nov-04 21:59 
QuestionSecure or not? Pin
uTILLIty10-Nov-04 21:15
uTILLIty10-Nov-04 21:15 
AnswerRe: Secure or not? Pin
hakervytas29-Nov-05 4:41
hakervytas29-Nov-05 4:41 
GeneralGreat Article Pin
Adam Goossens10-Nov-04 20:30
Adam Goossens10-Nov-04 20:30 
GeneralRe: Great Article Pin
Mashayekh3-Apr-05 23:21
Mashayekh3-Apr-05 23:21 
GeneralExcellent, I am eagerly awaiting future parts Pin
Member 9610-Nov-04 6:12
Member 9610-Nov-04 6:12 
GeneralRe: Excellent, I am eagerly awaiting future parts Pin
Chua Wen Ching10-Nov-04 10:03
Chua Wen Ching10-Nov-04 10:03 
QuestionWhat strong names do Pin
punkrock9-Nov-04 13:55
punkrock9-Nov-04 13:55 
AnswerRe: What strong names do Pin
Chua Wen Ching9-Nov-04 14:31
Chua Wen Ching9-Nov-04 14:31 
GeneralRe: What strong names do Pin
Some Pathetic Slob1-Dec-04 10:24
Some Pathetic Slob1-Dec-04 10:24 
GeneralRe: What strong names do Pin
Chua Wen Ching1-Dec-04 12:38
Chua Wen Ching1-Dec-04 12:38 
GeneralRe: What strong names do Pin
Anonymous5-Jan-05 23:36
Anonymous5-Jan-05 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.