SpriteHand
Module Border
  Obfuscating Silverlight (for free)
Module Border
Location: BlogsAndy's Blog    
Posted by: host 4/15/2010 5:39 PM

You might be aware that when you publish a Silverlight XAP on the web, your source code is very vulnerable to prying eyes. A XAP file is in a ZIP compressed format, and the contents are .NET Assemblies and resources which can be disassembled easily using a tool like .NET Reflector . Although there is no sure-fire way to stop someone from copying your Silverlight application logic, obfuscation can at least make it a bit more difficult to hack through.

Babel Obfuscator for .NET

There are a few obfuscators out there that support Silverlight, but they can be pricey. However, Babel Obfuscator started out as a community project and still maintains a freeware edition. Additionally, it appears that the new version of Babel has corrected some issues with obfuscating Silverlight assemblies.

Here is how you can use the free edition of Babel Obfuscator to encrypt your Silverlight assemblies: (I should mention, if you do have $149 laying about, I recommend buying the Pro version of Babel which has XAP support)

1.       Download the Free edition of Babel Obfuscator.

2.       Download the Free 7-zip compression utility. We’ll need this to update the obfuscated assemblies in our Silverlight XAP file. If you are happier with a different ZIP utility, go ahead and use it instead.

3.       Inside your Silverlight solution, right-click the Silverlight project and select Properties.

4.       Go to the “Build Events” tab and add the following inside the Post-build event command line:

"C:\Program Files\Babel\babel.exe" $(TargetPath) --noildasm --nomsil --noinvalidopcodes

"C:\Program Files\7-Zip\7z.exe" a $(TargetDir)$(ProjectName).xap $(TargetDir)BabelOut\$(TargetFileName) -y -tZIP

This post-build event will run the Babel Obfuscator against your assembly, which places it into a “BabelOut” subdirectory. Then we use 7-zip to bring that updated, obfuscated assembly back into our XAP file.

Examining the Obfuscation

We can use a tool like .NET Reflector to see what the obfuscator does for us. Here is some example before-and-after code showing an example of the obfuscation.

BEFORE OBFUSCATION

    private bool IsRagDollPart(string part);
    private void LayoutRoot_KeyDown(object sender, KeyEventArgs e);
    private void LayoutRoot_KeyUp(object sender, KeyEventArgs e);
    private void MainPage_Loaded(object sender, RoutedEventArgs e);
    private void newObstacleExplode_Exploded(ucObstacle source);
    private void newObstacleExplode_Exploding(ucObstacle source);
    private void PositionBalloon(ucObstacle obstacle);
    private void PositionEnemy(FlyingEnemyBase enemy);
    private void PositionPowerUp(PowerupBase powerUp);
    public static double RadiansToDecimalDegrees(double radians);
    private void ResetLevel();
    private void ShieldActive(bool isActive);
    private void ucExplosion1_Exploded(ucExplosion source);
    private void ucMainGame_KeyDown(object sender, KeyEventArgs e);
    private void ucMainGame_KeyUp(object sender, KeyEventArgs e); 

AFTER OBFUSCATION

    private void (bool );
    private bool (string );
    private void (object );
    private void ();   
private
void (PowerupBase );
private void (bool );
    private void (ucObstacle );
    private void (ucExplosion );
    private void ();
    private void (ucObstacle );
    private void (ucObstacle );
    private void (PowerupBase );
    private void (FlyingEnemyBase );
    private void (object , KeyEventArgs );
    private void (object , KeyEventArgs );

 

Permalink |  Trackback

Comments (5)   Add Comment
Re: Obfuscating Silverlight (for free)    By Anonymous on 4/15/2010 7:55 PM
Thank you very much for another Wise Tip Andy.

Regards

KRK

Re: Obfuscating Silverlight (for free)    By Anonymous on 4/16/2010 2:28 AM
There's also Eazfuscator.Net which is free, and very easy to use. Just drag and drop either your assembly or project(see link below).

http://www.foss.kharkov.ua/g1/projects/eazfuscator/dotnet/Default.aspx

Re: Obfuscating Silverlight (for free)    By Anonymous on 4/16/2010 9:35 AM
Deep Sea Obfuscator is a little more pricey but includes physical corruption of the manifest so you need to do a bit more work to get it to work in Reflector.

Re: Obfuscating Silverlight (for free)    By Anonymous on 4/20/2010 12:47 PM
Thanks Andy,

Small change I made was to bable the release code:

IF $(ConfigurationName) == Release "C:\Program Files\Babel\babel.exe" "$(TargetPath)" --noildasm --nomsil --noinvalidopcodes

IF $(ConfigurationName) == Release "C:\Program Files\7-Zip\7z.exe" a "$(TargetDir)$(ProjectName).xap" "$(TargetDir)BabelOut\$(TargetFileName)" -y -tZIP

Marti

Re: Obfuscating Silverlight (for free)    By Anonymous on 5/23/2010 2:34 PM
Hi folks.
CodeFort Free Edition automatically parses your XAML code and excludes exactly those types and members that are referenced. No hassle - and it's perfectly free.
If you want to also obfuscate the types and members that are referenced in the XAML code, you can opt to the Xaml Renaming feature of CodeFort Professional, which is available for $199.
Check it out if you haven't yet done so!
www.codefort.org


Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border

RSS

Module Border Module Border
Module Border
  Diversions
Module Border

BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2010 andy.beaulieu.com - Login