Obfuscated version (using Justin's HTML trick):
#include <stdio.h>
main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_
,main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&
t==2?_<13?main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')#\
}'+}##(!!/"):t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,
_,a+1):0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
Deobfuscated version:
#include <stdio.h>
int main(int Step, int Pnt, char *Str)
/*+------------------------------------------------------------+*/
/*| |*/
/*| Deobfuscated Source Code for "Twelve Days of Christmas" |*/
/*| |*/
/*| Program decrypts internal text using a direct substitution |*/
/*| key. The decrypted text is displayed to screen as the |*/
/*| lyrics of "Twelve Days of Christmas". The program |*/
/*| exploits the repetitive form of "Twelve Days of Christmas" |*/
/*| in it's logic to make the program more compact. The |*/
/*| decryption key is disguised to look like live code. The |*/
/*| program's logic is self calling (re-entrant). Program |*/
/*| maintains state through it's argument list. Commented |*/
/*| numbers in square brackets, i.e. [2], show initial |*/
/*| calling sequence. |*/
/*| |*/
/*| Public domain code with no copyright claimed. |*/
/*| |*/
/*| Version: 1.0, 10 August 2001 |*/
/*| |*/
/*+------------------------------------------------------------+*/
{
int Ret ;
char *new_Str ;
/* Decryption Key */
char Key[] =
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry" ;
/* Encrypted Text of "Twelve Days of Christmas" */
char Text[] =
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{"
"n+,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'"
"+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d"
"}rw' i;# ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w"
"#q#n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/"
"*de}'c ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/"
" ') }+}{rl#'{n' ')# }'+}##(!!/" ;
/* Initial reset (called only once at program start) [0] */
if (Step == 1) {
Ret = main(2, 2, " ") ;
return(Ret) ;
}
/* Begin new stanza, i.e. "On the first day of ..." [1] */
if (Step == 2) {
new_Str = Str + main(-86, 0, Str + 1) ;
new_Str = Str + main(-87, 1-Pnt, new_Str);
main(-79, -13, new_Str) ;
if (Step < Pnt) main(Step + 1, Pnt, Str) ;
Ret = main(-94, Step - 27, Str) ;
if (Ret) {
if (Pnt < 13) {
Ret = main(2, Pnt + 1, " ") ;
}
else {
Ret = 9 ;
}
}
else Ret = 16 ;
return(Ret) ;
}
/* Load Text to initialize phrase [2] */
if (Step < -72) {
Ret = main(Pnt, Step, Text) ;
return(Ret) ;
}
/* Single letter of Txt now in Str, point to decryption Key [3] */
if (Step == 0) {
Ret = (*Str == '/') || main(-61, *Str, Key) ;
Ret = (*Str == '/') || main(0, Ret, Str + 1) ;
return(Ret) ;
}
/* Scan decryption key then print character when match found [4] */
if ((-72 <= Step)&&(Step < -50)) {
/* Character from Txt found in Key so print it */
if (Pnt == *Str) {
Ret = putchar(*(Str + 31)) ;
}
/* Character not found so check next character in Key */
else {
Ret = main(-65, Pnt, Str + 1) ;
}
return(Ret) ;
}
/* Advance sequence to next step */
if ((-50 <= Step)&&(Step < 0)) {
if (*Str == '/') {
Ret = main(Step + 1, Pnt, Str + 1) ;
}
else {
Ret = main(Step, Pnt, Str + 1) ;
}
return(Ret) ;
}
/* Stanza type selector, i.e. called 4 times for "five gold rings" */
if (2 < Step) {
if (Step < Pnt) main(Step + 1, Pnt, Str) ;
main(-94, Step - 27, Str) ;
Ret = 16 ;
return(Ret) ;
}
/* program never gets here */
} /* --- end of the "Main" routine --- */
Off Topic » in reply to LOL, nevermind, it compiled no prob
Obfuscated and Deobfuscated Versions
