Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to obfuscate c#/silverlight source code

I'm looking for ways to obfuscate the following c#/silverlight source code:

    if (searchBox.Text.Equals("string literal")){
        MessageBox.Show("another string literal");
    }

So far all I can come up with to hide it is encoding the strings as arrays of ascii...

All I want is for the source code to be unreadable, this is for an easter egg. Security is not a priority for me.

I don't want the presence of an easter egg to be known. I'm trying to obfuscate the program flow so it doesn't appear like there is a line of code like

if (specialcase)
    doEasterEgg();

I've seen stuff on like the obfuscated c contest where hello world turns into globbidy gook. Anything similar that people know of for c#?

like image 227
NickHalden Avatar asked Jul 13 '10 15:07

NickHalden


1 Answers

What exactly do you want to protect against?

  • The transmission of the text value of the control to your server? In that case, any "obfuscation" by any non-encryption technique will easily be overcome by a motivated attacker. You should look into encrypting your strings, rather than obfuscating them.

  • If you're looking to obfuscate your source code itself, you really should let a third party tool handle it. Anything you might invent on your own is likely to be easily reverse-invented.

  • EDIT: If you just want to hide an Easter Egg, how about using ROT13?

  • EDIT 2: How about assigning them misleading constants and referencing them in a different static class that is misleadingly named?

.

// in other source file ValidateInput.cs
public const VALID_STRING = "secret";

public class ValidateInput {
    public static bool Validate(string srcText)
    {
         return srcText == VALID_STRING;
    }
    public static void LogicValidSearch()
    {
         return;
    } 
}

//In your main application
if (ValidateInput.Validate(searchBox.Text)) {
    ValidateInput.LogValidSearch();
}
like image 153
Mike Atlas Avatar answered Sep 26 '22 15:09

Mike Atlas