Friday, April 18, 2008

De-assemble and Re-assemble a .Net assembly

Friday, April 18, 2008 Posted by Andre Broers , 8 comments
A .Net assembly can be de-assembled pretty easy. In this blog I create an assembly and will de-assemble, alter and re-assemble the assembly.

Let's start with the famous Hello.cs:

[sourcecode language="CSharp"]

using System;

public class Hello
    static void Main(string[] args)
            Console.WriteLine("Hello World!");
build it:

csc /target:exe Hello.cs


ildasm / Hello.exe

edit the string "Hello World!" in the file to something like "Hello Andre Broers!"


ilasm /out:Hello2.exe /res:Hello.res

Now we have the altered assembly.

By signing the assembly we can get sure the assembly isn't tampered with. I will explain this in a next blog.