tisdag 4 december 2012

Creating a Obfuscater using Mono.Cecil [C#]

Short tutorial in two parts how to make a obfuscater for .net, using Mono Cecil and C#. We will use .net 4.0 for the GUI but 3.5 will be fine as well. Mono.Cecil use .net 3.5, the first part will be GUI and second part the 'code'.

 It will have the following feature
 -Drag and Drop, very friendly and easy to use.
 - Some misc feature.
 -Some picture boxes
 -And a menu stripe.

 I am aware that my tutorial about unpacking and packing .net assembly is not done. I lost the sample i had in mind using and will wait until i find a new fresh sample.

 Now back on topic, for the GUI i will use Winform since i know that pretty well compare to WPF. Open Visual Studio express, new project choose Windows Application Form. I will name it MonoObfuscater then a empty Winform should show up. Go to Properties disable the Maximizes Button. Since the Form will be pretty small and not look very good using full screen better off disabling that.

Now we add a Menu Stripe and add one label we change it text to 'About'. If the user click it the idea is that it should popup a second form with some information.

Below that we add two picture box, one for drag and drop and the other will be for user that don't like drag and drop and prefer a open FileDialog. Inside them i  choose a blue icon for drag and drop and a green for filedialog.

The Form should ate this moment look like something like this, next we will add code for the green one double click the green picture box and add the following.



Notice that we don't check extension that user choose .exe, This is think you can add later to improve but as off now we want forward.

Drag and Drop

Now we will focus on the drag and drop part,  We will use Event and that pretty easy and  use full.
Even is some thing that tricked under a special condition. We need to add two event doing that by 
selecting the other picture box and right click properties  click the yellow lighting icon and scroll down to DragDrop and DragEnter, in the empty text field double click.  Now Do that for both DragEnter and DragDrop. Once inside "MainForm" viewing the code scroll to 
public FromName()
{
InitializeComponent();
}
Inside that we add the following, this make the form allow drop and event handler for drag and drop.

Now add the following code, this will handle the drag and drop it self.




Misc notice i most off the time use iconspedia for icon's and below are links to the icon i use.
Make sure you download them as '.png'.
http://www.iconspedia.com/icon/inbox-green-icon-34984.html
http://www.iconspedia.com/icon/inbox-blue-icon-34983.html
 And thanks to doublejdesign.co.uk for the icon's :).


Inga kommentarer:

Skicka en kommentar