强制编译器接受未使用的字符串?
Force compiler to accept an unused string?
我正在做一个要求用户反编译二进制文件的 crackme 挑战。
我尝试包含以下内容以阻止试图使用字符串反转二进制文件的用户:
const string pointless = "Strings would be too easy";
不幸的是,我的代码中没有引用它,冗余代码在编译时被删除了。有没有办法告诉编译器无论如何都要包含它?
使用变量是在编译代码中保留变量的唯一方法。现在接下来不要在编译代码中获取此 using 语句。
所以最后我们有两个任务。
Use variable
- 然后是
not to get this using code in compiled code
,
你知道如果你使用过你肯定会在编译代码中得到它。我们将使用带有 Debug
class 的变量,因此只有当您将其编译为 debug
模式时,您才会得到,如果您将相同的代码编译为 release
模式,您将不会得到这个 using your variable
代码。如下 -
const string pointless = "Strings would be too easy";
Debug.WriteLine(pointless);
现在因为您已经使用了变量,所以它不会从编译格式中删除。现在,如果您将代码编译为 debug
,您将得到此 Debug.WriteLine(pointless);
但现在将您的代码编译为 release
模式,您将获得您的变量而不是这个 Debug.WriteLine(pointless);
希望对您有所帮助!
我正在做一个要求用户反编译二进制文件的 crackme 挑战。
我尝试包含以下内容以阻止试图使用字符串反转二进制文件的用户:
const string pointless = "Strings would be too easy";
不幸的是,我的代码中没有引用它,冗余代码在编译时被删除了。有没有办法告诉编译器无论如何都要包含它?
使用变量是在编译代码中保留变量的唯一方法。现在接下来不要在编译代码中获取此 using 语句。
所以最后我们有两个任务。
Use variable
- 然后是
not to get this using code in compiled code
,
你知道如果你使用过你肯定会在编译代码中得到它。我们将使用带有 Debug
class 的变量,因此只有当您将其编译为 debug
模式时,您才会得到,如果您将相同的代码编译为 release
模式,您将不会得到这个 using your variable
代码。如下 -
const string pointless = "Strings would be too easy";
Debug.WriteLine(pointless);
现在因为您已经使用了变量,所以它不会从编译格式中删除。现在,如果您将代码编译为 debug
,您将得到此 Debug.WriteLine(pointless);
但现在将您的代码编译为 release
模式,您将获得您的变量而不是这个 Debug.WriteLine(pointless);
希望对您有所帮助!