c - 为什么 1987 Korn oneliner 打印的是 unix?

标签 c deobfuscation

<分区>

好,我咬。一个answer到广受欢迎的Why does the C preprocessor interpret the word "linux" as the constant "1"?问题提到

main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}`

prints "unix", but for reasons that have absolutely nothing to do with the spelling of the macro name.

我读了http://www.ioccc.org/1987/korn.hint但我认为更多的细节将有助于消除混淆:)

最佳答案

unix 为 1,因为编译器或运行时环境中的隐式 #define

因此,因为 a[b] == b[a] == *(a + b) 因此 1["xy"] == "xy"[1 ],你得到:

  • &unix["\021%six\012\0"] 指向 "%six\012\0"
  • (unix)["have"] = "have"[1] = 'a',
  • "'a'+"fun"-0x60"= "fun"+ 1 = "un"

这会将您带到 printf("%six\012\0", "un"); 显然会打印 "unix\012", \012 是换行符(与 \n 相同)。

如果 unix 未定义,e. G。在 Windows 系统上,您会收到错误消息。

如果 unix0(在干净的系统上会是这样吗?),你会得到

printf("\012%six\n", 'h'+"fun"-0x60)

第二个参数是 "fun"+8,指向 Nirvana 并导致未定义的行为。

关于c - 为什么 1987 Korn oneliner 打印的是 unix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19298778/

相关文章:

c - 如何生成混淆代码

javascript - 这是深度混淆吗?无法理解其含义

javascript - 这段 JavaScript 代码对 MD5 哈希值做了什么?

c - 在 C 函数中将指针作为参数传递

c - 在C编程中执行该语句时,对数组执行什么操作++arrayname[value[i]/10];

c - 将字符串中的字符串替换为字符

javascript - 去混淆 Javascript 代码以使其再次可读

c - c编译器如何处理无符号和有符号整数?为什么无符号和有符号算术运算的汇编代码相同?

c - 如何确定字符串长度?

c - 混淆的 C 代码竞赛 2006。请解释 sykes2.c