2012-04-11 104 views
3

我在http://www.cise.ufl.edu/~manuel/obfuscate/obfuscate.html(http://www.cise.ufl.edu/~manuel/obfuscate/savastio)网站上看到了这段代码。但是这段代码非常非常疯狂。当它发生时,我无法理解正在发生的事情。 请帮帮我。让我知道每行执行时发生了什么。 例如printf函数在那里,如果我们将看到没有声明称为“Enter the number”。但仍然在执行时询问“Enter the number”。从哪里来。 为什么代码是这样写的。它看起来像“n!”(尽管它意味着阶乘)。 请帮帮我。无法理解混淆的C代码

#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); } 
+14

对不起,但是说你不理解混淆的代码意味着作者做了他/她的工作。你不应该明白这一点。 – 2012-04-11 05:05:49

+7

尝试'gcc -E'选项,看看你是否可以。 – shinkou 2012-04-11 05:06:44

+3

@Chris:And ???所以试图剔除东西完全不值得知道该怎么做?有些人为了谋生而做这种事。我们不要关闭它。 – 2012-04-11 05:09:45

回答

10

作为开始,你可以得到代码缩进正确,并删除所造成的#define S中的间接。缩进可以通过GNU indent完成,gcc -E将完成预处理。假定该代码是在factorial.c(这需要使用命令行):

> gcc -E factorial.c | indent > clean_factorial.c 

要注意的是预处理步骤将所有的stdio.h转储到clean_factorial.c甲事情;但这是不相关的信息,所以我们应该在运行gcc -E之前注释/删除#include<stdio.h>。这基本上给出了:

struct llll1 
{ 
    struct llll1 *lll1l, *ll1l1; 
    unsigned short lll[1000]; 
}; 
main() 
{ 
    struct llll1 *ll11, *l1l, *l1, *ll1l, *malloc(); 
    unsigned long l1ll; 
    long l11, ll, l; 
    unsigned short *lll1, *lllll; 
    for (l = 1 - 1; l < 14; putchar ("\t\"8)>l\"9!.)>vl"[l]^'L'), ++l); 
    scanf ("%d", &l); 
    l1l = malloc (sizeof (struct llll1)); 
    l1l->lll1l = 1 - 1; 
    l1l->ll1l1 = 1 - 1; 
    ll11 = malloc (sizeof (struct llll1)); 
    ll11->lll1l = 1 - 1; 
    ll11->ll1l1 = 1 - 1; 
    (l1 = l1l)->lll[l1l->lll[1 - 1] = 1] = 0xFFFF; 
    for (l11 = 1 + 1; l11 <= l; ++l11) 
    { 
     l1 = ll11; 
     lll1 = (ll1l = (ll11 = l1l))->lll; 
     lllll = (l1l = l1)->lll; 
     ll = (l1ll = 1 - 1); 
     for (; ll1l->lll1l || 0xFFFF != *lll1;) 
     { 
      l1ll += l11 ** lll1++; 
      *lllll++ = l1ll % 10000; 
      l1ll /= 10000; 
      if (++ll > 1000) 
      { 
       if (!l1->lll1l) 
       { 
        l1->lll1l = malloc (sizeof (struct llll1)); 
        l1->lll1l->lll1l = 1 - 1; 
        l1->lll1l->ll1l1 = 1 - 1;; 
        l1->lll1l->ll1l1 = l1; 
       } 
       lllll = (l1 = l1->lll1l)->lll; 
       ll = 1 - 1; 
       lll1 = (ll1l = ll1l->lll1l)->lll; 
      } 
     } 
     for (; l1ll;) 
     { 
      *lllll++ = l1ll % 10000; 
      l1ll /= 10000; 
      if (++ll >= 1000) 
      { 
       if (!l1->lll1l) 
       { 
        l1->lll1l = malloc (sizeof (struct llll1)); 
        l1->lll1l->lll1l = 1 - 1; 
        l1->lll1l->ll1l1 = 1 - 1;; 
        l1->lll1l->ll1l1 = l1; 
       } 
       lllll = (l1 = l1->lll1l)->lll; 
       ll = 1 - 1; 
      } 
     } 
     *lllll = 0xFFFF; 
    } 
    for (l = (ll = 1 - 1); (l < 1000) && (l1->lll[l] != 0xFFFF); ++l); 
    for (; l1; l1 = l1->ll1l1, l = 1000) 
    { 
     for (--l; l >= 1 - 1; --l, ++ll) 
     printf ((ll) ? ((ll % 19) ? "%04d" : (ll = 
               19, "\n%04d")) : "%4d", 
       l1->lll[l]); 
    } 
    putchar (10); 
} 

这是略有可读性,我们可以做一些事情,如重命名变量,这样我们就可以很容易分开告诉他们,即使我们不知道他们在做什么呢。例如。这将在结构重命名为structure,并调用它leftright里面的指针(您可以在编辑器中找到替换工具这样做太):

> sed -i 's/llll1/structure/g; s/lll1l/left/g; s/ll1l1/right/g;' clean_factorial.c 

(你必须要注意顺序,或者例如lll的替换可能与lllll冲突)。

还有其他一些容易的事情要做:

  • 1 - 1发生了很多:有0取代它(和1 + 1太,除了与2而不是0取代)。
  • "\t\"8)>l\"9!.)>vl"[l]^'L'一致的行只是沿着打印每个字符后的字符串打印后与'L'(解决原因!它可能有助于将putchar放在for循环的主体中,而不是在逗号语句中) 。
  • putchar(10)只是打印一个新行。
  • 了解comma operator

除此之外,这只是很多辛苦的工作。你可以也应该使用像调试器这样的工具来跟踪执行流程并找出发生在哪里的事情。

+0

+1为“略读” – JeremyP 2012-04-11 08:22:23

2

这是我在展开它的企图,被卡了一下就提示逻辑,所以我只是初始化longC为零,并打印出一些手动请求:清理:

#include <stdio.h> 

struct StructName 
{ 
    struct StructName *structA, *structB; 

    unsigned short unsignedShortArrayA[1000]; 
}; 

main() 
{ 
    struct StructName *structC, *structD, *structE, *structF, *malloc(); 

    unsigned long unsignedLongA; 

    long longA, longB, longC = 0; 

    unsigned short *unsignedShortA, *unsignedShortB; 

    //for(longC=0; longC< 14; putchar("\t\"8)>longC\"9!.)>vl" [longC]^'longC'),++longC) 
    //; 

    printf("%s", "Enter a number: "); 

    scanf("%d", &longC); 

    structD = malloc(sizeof(struct StructName)); 
    structD->structA=0; 
    structD->structB=0; 

    structC=malloc(sizeof(struct StructName)); 
    structC->structA=0; 
    structC->structB=0; 

    (structE=structD)->unsignedShortArrayA[structD->unsignedShortArrayA[0] =1] = 0xFFFF; 

    for(longA=1+1;longA<=longC;++longA) 
    { 
     structE=structC; 
     unsignedShortA = (structF=(structC=structD))->unsignedShortArrayA; 
     unsignedShortB =(structD=structE)->unsignedShortArrayA; 
     longB=(unsignedLongA=0); 

     for(; structF->structA || 0xFFFF != *unsignedShortA;) 
     { 
      unsignedLongA+=longA**unsignedShortA++; 
      *unsignedShortB++=unsignedLongA%10000; 
      unsignedLongA/=10000; 

      if(++longB>1000) 
      { 
       if(!structE->structA) 
       { 
        structE->structA=malloc(sizeof(struct StructName)); 
        structE->structA->structA=0; 
        structE->structA->structB=0; 

        structE->structA->structB=structE; 
       } 

       unsignedShortB=(structE=structE->structA)->unsignedShortArrayA; 
       longB=0; 
       unsignedShortA=(structF =structF-> structA)->unsignedShortArrayA; 
      } 
     } 

     for(; unsignedLongA;) 
     { 
      *unsignedShortB++=unsignedLongA%10000; 
      unsignedLongA/=10000; 

      if(++longB>=1000) 
      { 
       if(!structE->structA) 
       { 
        structE->structA=malloc(sizeof(struct StructName)); 
        structE->structA->structA=0; 
        structE->structA->structB=0; 

        structE->structA->structB=structE; 
       } 

       unsignedShortB=(structE=structE->structA)->unsignedShortArrayA; 
       longB=0; 
      } 
     } 

     * unsignedShortB=0xFFFF; 
    } 

    for(longC=(longB=1- 1); (longC<1000) && (structE->unsignedShortArrayA[ longC] !=0xFFFF); ++longC) 
    { 
     ; 
    } 

    for(; structE; structE=structE->structB, longC=1000) 
    { 
     for(--longC; longC>=0; --longC, ++longB) 
     { 
      printf((longB)?((longB%19) ? "%04d" : (longB=19,"\n%04d")):"%4d",structE-> unsignedShortArrayA[longC]); 
     } 
    } 

    putchar(10); 
} 

编辑提高一点。