混淆 C#/silverlight 源代码的方法

发布于 2024-09-10 04:59:33 字数 449 浏览 4 评论 0 原文

我正在寻找混淆以下 c#/silverlight 源代码的方法:

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

到目前为止,我所能想到的隐藏它的方法是将字符串编码为 ascii 数组...

我想要的只是源代码不可读,这是复活节彩蛋。安全对我来说不是首要任务。

我不想让人们知道复活节彩蛋的存在。我试图混淆程序流程,这样就不会出现像我在混淆的 c 竞赛中看到的那样的一行代码,

if (specialcase)
    doEasterEgg();

其中 hello world 变成了globbidy gook。人们知道 c# 有什么类似的东西吗?

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#?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦行七里 2024-09-17 04:59:33

您到底想防止什么?

// 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();
}

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();
}
亢潮 2024-09-17 04:59:33

这里没有足够的代码来有效地进行混淆。您唯一的选择是对“字符串文字”的值进行哈希处理并加密“另一个字符串文字”的值。这种技术也不安全,因为您必须公开您的加密方法。

There's not enough code here to obfuscate effectively. Your only option is hashing the value of "string literal" and encrypting the value of "another string literal". This technique is not safe either because you would have to expose your encryption method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文