I saw this code in http://www.cise.ufl.edu/~manuel/obfuscate/obfuscate.html (http://www.cise.ufl.edu/~manuel/obfuscate/savastio) website.But this code is very very crazy. I could not able to understand what is happening when it is happening.
Please help me. Let me know what is happening when each line is getting executed.
e.g. printf function is there, if we will see there is no statement called as “Enter the number“. But still while executing it is asking “Enter the number“. From where it is comming.
And why the code is written like this. It looks like “n!“(Though it means factorial).
Please help me.
#include <stdio.h>
#define l11l 0xFFFF
#define ll1 for
#define ll111 if
#define l1l1 unsigned
#define l111 struct
#define lll11 short
#define ll11l long
#define ll1ll putchar
#define l1l1l(l) l=malloc(sizeof(l111 llll1));l->lll1l=1-1;l->ll1l1=1-1;
#define l1ll1 *lllll++=l1ll%10000;l1ll/=10000;
#define l1lll ll111(!l1->lll1l){l1l1l(l1->lll1l);l1->lll1l->ll1l1=l1;}\
lllll=(l1=l1->lll1l)->lll;ll=1-1;
#define llll 1000
l111 llll1 {
l111 llll1 *
lll1l,*ll1l1 ;l1l1 lll11 lll [
llll];};main (){l111 llll1 *ll11,*l1l,*
l1, *ll1l, * malloc ( ) ; l1l1 ll11l l1ll ;
ll11l l11,ll ,l;l1l1 lll11 *lll1,* lllll; ll1(l
=1-1 ;l< 14; ll1ll("\t\"8)>l\"9!.)>vl" [l]^'L'),++l
);scanf("%d",&l);l1l1l(l1l) l1l1l(ll11 ) (l1=l1l)->
lll[l1l->lll[1-1] =1]=l11l;ll1(l11 =1+1;l11<=l;
++l11){l1=ll11; lll1 = (ll1l=( ll11=l1l))->
lll; lllll =( l1l=l1)->lll; ll=(l1ll=1-1
);ll1(;ll1l-> lll1l||l11l!= *lll1;){l1ll
+=l11**lll1++ ;l1ll1 ll111 (++ll>llll){
l1lll lll1=( ll1l =ll1l-> lll1l)->lll;
}}ll1(;l1ll; ){l1ll1 ll111 (++ll>=llll)
{ l1lll} } * lllll=l11l;}
ll1(l=(ll=1- 1);(l<llll)&&
(l1->lll[ l] !=l11l);++l); ll1 (;l1;l1=
l1->ll1l1,l= llll){ll1(--l ;l>=1-1;--l,
++ll)printf( (ll)?((ll%19) ?"%04d":(ll=
19,"\n%04d") ):"%4d",l1-> lll[l] ) ; }
ll1ll(10); }
As a start, you can get the code indented properly and remove the indirection caused by the
#defines. The indentation can be done by GNUindentandgcc -Ewill do the preprocessing. Assuming the code is infactorial.c(this requires using the command line):A thing to note is the preprocessing step will dump all of
stdio.hintoclean_factorial.c; but that is irrelevant information, so we should comment out/delete#include<stdio.h>before runninggcc -E. This basically gives:This is slightly readable, and we can do things like rename variables so that we can tell them apart easily, even if we don’t know what they do yet. E.g. this will rename the struct to
structure, and call the pointers inside itleftandright(you can do this with the find-replace tool in your editor too):(you have to be careful of the order, or the replacement for
lllmight conflict withlllll, for example).There are some other easy things to do:
1 - 1occurs a lot: replace it with0(and1 + 1too, except replace that with2instead of0)."\t\"8)>l\"9!.)>vl"[l] ^ 'L'just goes along the string printing each character after xor’ing it with'L'(work out why! It might help to put theputcharin the body of the for loop, rather than in the comma-statement).putchar(10)just prints a new line.Other than that, it’s just a lot of hard work. You can and should use tools like a debugger to trace the flow of execution and work out what is happening where.