2012-04-11 148 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); 
} 

編輯提高一點。