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

做~自己de王妃 提交于 2020-08-06 04:46:04

问题:

How does this C program work? 这个C程序如何工作?

main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);}

It compiles as it is (tested on gcc 4.6.3 ). 它按原样编译(在gcc 4.6.3上测试)。 It prints the time when compiled. 它打印编译时的时间。 On my system: 在我的系统上:

    !!  !!!!!!              !!  !!!!!!              !!  !!!!!! 
    !!  !!  !!              !!      !!              !!  !!  !! 
    !!  !!  !!              !!      !!              !!  !!  !! 
    !!  !!!!!!    !!        !!      !!    !!        !!  !!!!!! 
    !!      !!              !!      !!              !!  !!  !! 
    !!      !!              !!      !!              !!  !!  !! 
    !!  !!!!!!              !!      !!              !!  !!!!!!

Source: sykes2 - A clock in one line , sykes2 author hints 资料来源: sykes2 - 一行中的一个时钟sykes2作者提示

Some hints: No compile warnings per default. 一些提示:默认情况下没有编译警告。 Compiled with -Wall , the following warnings are emitted: 使用-Wall编译,会发出以下警告:

sykes2.c:1:1: warning: return type defaults to ‘int’ [-Wreturn-type]
sykes2.c: In function ‘main’:
sykes2.c:1:14: warning: value computed is not used [-Wunused-value]
sykes2.c:1:1: warning: implicit declaration of function ‘putchar’ [-Wimplicit-function-declaration]
sykes2.c:1:1: warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]
sykes2.c:1:1: warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]
sykes2.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]

解决方案:

参考一: https://stackoom.com/question/12aXJ/混淆的C代码竞赛-请解释sykes-c
参考二: https://oldbug.net/q/12aXJ/Obfuscated-C-Code-Contest-2006-Please-explain-sykes2-c
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!