Binary hack a .NET executable

I would first like to preface this article in saying: If you’re .net library is being protected by a single boolean function, you deserve to be hacked… :)

It’s actually not that hard to binary hack an assembly. I first learned it by reading these blog entries: Part 1 Part 2

When you change an .net executable by re-signing it after hacking, you have a small problem. Any dlls or executables referencing this executable will break because the public key has changed.

You can fix this by round-tripping to IL code and back.

ildasm.exe File.exe /text /out=File.il

Then edit the public key in the .IL file(s), and run this:

ilasm.exe File.il /exe /output=OutExe /key=PubKey.snk

Voila! All references replaced.

Hacking

To hack a binary, you need a good hex editor. I use UltraEdit. Here’s the code for a IsLicensed() method.

Public Function IsLicensed() As Boolean     Try         Me.License = _          LicenseManager.Validate(MyBase.GetType, Me)         Return True     Catch ex As Exception         Return False     End Try End Function

All you would have to do is change the Return False to Return True. Not a good way to protect your code. In binary, 16 is false, and 17 is true. so editing one byte changing from 16 to 17 and then re-signing makes a control be fully licensed. The license check will always fail, but by returning true, it’s licensed (as far as it knows). Remember to remove the old one from the GAC, and to update all references.



kick it on DotNetKicks.com
5. January 2009 20:07 by Rick | Comments (0) | Permalink

Comments

About Rick

Rick lives in North Las Vegas. He loves his wife, kids, dog, motorcycle, music and programming. There ain't nothing else. Oh yeah, mountain dew!



Programming interests are geared towards multimedia. Platforms are asp.net, windows forms, and WPF.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

RecentComments

Comment RSS