<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    原文地址:http://drops.wooyun.org/tips/2730

    游戲地址:http://fun.coolshell.cn/

    一個很有意思的小游戲,也很費腦子的說TAT

    0-Fuck your brain

    本關地址:http://fun.coolshell.cn/first.html

    進去以后,發現一些亂七八糟的東西,下面一行提示:My brain has been fucked,通過BaiDu得知這是一種編程語言,稱之為Brain Fuck(我不會說當我看到這個著實汗了一把),然后在網上找到編譯器

    編譯器代碼

    #!cpp
    #include <stdio.h>
    int  p, r, q;
    char a[5000], f[5000], b, o, *s=f;
    void interpret(char *c)
    {
        char *d;
        r++;
        while( *c ) {
            switch(o=1,*c++) {
                case '<': p--;        break;             case '>': p++;        break;
                case '+': a[p]++;     break;
                case '-': a[p]--;     break;
                case '.': putchar(a[p]); fflush(stdout); break;
                case ',': a[p]=getchar();fflush(stdout); break;
                case '[':
                    for( b=1,d=c; b && *c; c++ )
                    b+=*c=='[', b-=*c==']';
                    if(!b) {
                        c[-1]=0;
                        while( a[p] )
                        interpret(d);
                        c[-1]=']';
                        break;
                    }
                case ']':
                    puts("UNBALANCED BRACKETS"), exit(0);
                case '#':
      if(q>2)
                    printf("- - - - - - - - - -/n%*s/n",*a,a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],3*p+2,"^");
                    break;
                default: o=0;
            }
     if( p100)
                puts("RANGE ERROR"), exit(0);
        }
        r--;
    }
    main(int argc,char *argv[])
    {
        FILE *z;
        q=argc;
        if(z=fopen(argv[1],"r")) {
     while( (b=getc(z)) > 0 )
                *s++=b;
            *s=0;
            interpret(f);
        }
    }
    

    把該編譯器代碼存為test.c

    然后編譯

    gcc test.c -o test
    

    得到的test即為該語言編譯器,編譯的時候有倆Warning,很抱歉我無視了這個Warning…

    然后將Brain Fuck的代碼存為test.bf

    在shell下執行即可得到答案

    ./test test.bf
    

    1.png

    如圖,得到第一關地址

    1-Multiply

    本關地址:http://fun.coolshell.cn/welcome.html

    首先進去看到一個序列

    2,3,6,18,108,? 
    

    然后上面給出了算法X * Y,觀察序列可得知后一個數字是前兩個數的積,于是得出?地方為18*108=1944

    打開http://fun.coolshell.cn/1944.html可以看到X已經成了紅色,同時得到另一個提示“其中一個答案為1944”,即X=1944

    然后找尋另一個數字,看到另一個提示

    What is the meaning of life, the universe and everything?

    扔到Google中,找到Wiki中的一個提示

    根據道格拉斯·亞當斯的小說《銀河系漫游指南》,42是“生命、宇宙以及任何事情的終極答案”。因此,42也經常被用來向這一作品致敬,例如:

    您若在Google輸入the answer to life, the universe, and everything,Google會直接回答42——而且還是用Google計算器算出來的。

    可以得到Y=42

    輸入http://fun.coolshell.cn/42.html也可以驗證這一點,然后X\*Y=1944\*42=81648

    得到下一關地址81648.html

    2-Keyboard

    本關地址:http://fun.coolshell.cn/81648.html

    首先進去,一個碩大的鍵盤,不過這個鍵盤貌似有些問題,鍵盤上一些鍵和現在用的qwerty鍵盤有些出入,該圖上有個超鏈,得知該種鍵盤被稱之為Dvorak鍵盤,是為了更快的提高打字速度而設計出來了,通常是程序猿和打字猿使用率較高(隱隱感覺這兩個職業沒差別….)

    先把Dvorak鍵盤的布局換成QWERTY的布局,如圖

    黑色為Dvorak布局,紅色為QWERTY布局

    2.png

    把給出的提示用QWERTY布局表示出來即可

    This Code

    //這是給出的代碼
    macb() ? lpcbyu(&gbcq/_\021%ocq\012\0_=w(gbcq)/_dak._=}_ugb_[0q60)s+
    

    This Code

    //這是QWERTY布局下代碼
    main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}
    

    把該代碼編譯之后得到一個程序,運行返回結果unix,過關,如圖

    3.png

    3-QR Code

    本關地址:http://fun.coolshell.cn/unix.html

    首先映入眼簾的是一個二維碼,使用二維碼識別工具可得到下面提示的碼表,如圖

    4.png

    得到字符轉換碼表為

    [abcdefghijklmnopqrstuvwxyz] <=> [pvwdgazxubqfsnrhocitlkeymj]
    

    然后轉換字符,使用python語言,源代碼為

    #Thanks For Code by Mutalisk
    content_de = '''Wxgcg txgcg ui p ixgff, txgcg ui p epm. I gyhgwt mrl lig txg ixgff wrsspnd tr irfkg txui \
    hcrvfgs, nre, hfgpig tcm liunz txg crt13 ra "ixgff" tr gntgc ngyt fgkgf.'''.lower()
    
    content = ''
    
    keychr_de = 'pvwdgazxubqfsnrhocitlkeymj'
    keychr = 'abcdefghijklmnopqrstuvwxyz'
    
    for s_chr in content_de:
        if s_chr in keychr_de:
            content = content + keychr[keychr_de.index(s_chr)]
        else:
            content = content + s_chr
    
    print content
    

    轉換后截圖如下

    5.png

    轉換出結果為:Where there is a shell, there is a way. I expect you use the shell command to solve this problem, now, please try using the rot13 of “shell” to enter next level.

    翻譯出來意思為:只要有shell就會有辦法咩我希望你捏,能使用shell命令去解決這個問題咩,那么現在捏,請使用rot13來過關咩

    然后打開url:http://fun.coolshell.cn/shell.html

    得到新的提示:You really are close, but the “shell” is not the final answer.

    翻譯過來為:你已經很接近正確答案了咩,但可惜shell不是最終的答案咩.

    然后使用rot13來加密shell得到字符串,furyy,過關

    echo 'shell'|tr '[A-Za-z]' '[N-ZA-Mn-za-m]'
    

    4-cat

    本關地址:http://fun.coolshell.cn/furyy.html

    8.png

    首先看提示,提示說答案在源代碼的底部,拉到底下,驚呆了TAT

    9.png

    這一坨TM是什么…

    然后仔細看了一下標題Palindrome還有左邊的一些,可以看到這關是以回文為主體的,找正則大牛幫我寫了一個正則.

    (\[A-Z])([0-9])[a-z\](\2)(\1)|(\[0-9])([A-Z])[a-z\](\6)(\5) 
    

    然后把html中注釋掉的東西拉到http://tool.oschina.net/regex匹配一下,得出結果如圖

    10.png

    得出這些回文

    共找到 9 處匹配:

    E1v1E
    4FaF4
    9XrX9
    O3i3O
    0MaM0
    4GbG4
    M5l5M
    0WeW0
    Y0s0Y
    

    然后觀察網頁主體的回文,可以看到cat來自于回文中央的那個字符串的拼接,把剛才得出的匹配中間字符拼接出來即為key:variables

    5-variables

    本關地址:http://fun.coolshell.cn/variables.html

    本頁提示:繼續跑,你會找到你要的結果

    點擊圖片,進入一個url,http://fun.coolshell.cn/n/2014,頁面返回一個數字,既然提示是繼續跑,里面唯一可控的只有url后面的數字,那么就去跑這個數字,這個頁面顯示的數字放到url進行下次循環。

    用Seraph寫了個小程序跑了一下,秒出

    dim a
    function main
        start = "2014"
        a = GetHTTP("http://fun.coolshell.cn/n/"&start)
        Print(a)
        for ForCount = 1 to 999999
            CStr(a)
            a = GetHTTP("http://fun.coolshell.cn/n/"& a )
            Print(a)
        next
    end function
    

    如圖,得出key為tree

    11.png

    6-tree

    本關地址:http://fun.coolshell.cn/tree.html

    看圖就可以知道,這特么是二叉樹….

    花了3個小時,對這個樹進行了復原,復原圖如下

    12.png

    吐槽一下,這么復雜的樹這是要死人的節奏啊

    有了樹結構圖之后就可以得出前序(Pre-order):

    z, W, b, T, g, h, H, V, 3, o, P, p, 8, L, F, G, u, A, f, n, 0, 1, r, m, w, x, J, 7, e, i, Q, Y, Z, 2, 5, v, K, q, k, 9, y, C, B, N, D, U, 4, l, c, M, I, E, a, j, 6, S, R, o, X, s, d

    同時由圖得知該二叉樹最深路徑為:z, W, p, 8, L, G, n, 0, 1, w, x, J, 7

    然后把最深路徑作為pass帶入openssl中解密那個base64的字符串即可得到明文

    echo U2FsdGVkX1+gxunKbemS2193vhGGQ1Y8pc5gPegMAcg=|openssl enc -aes-128-cbc -a -d -pass pass:zWp8LGn01wxJ7 
    

    13.png

    得到明文為nqueens 過關

    7-N Queen

    本關地址:http://fun.coolshell.cn/nqueens.html

    歷史上著名的N皇后問題,給出的范例為8皇后,求9皇后,code為從右往左,皇后依次在縱坐標上的順序

    在網上找了一份N皇后算法代碼,可得到9皇后問題有352個解,然后修改了一下代碼,可以直接生成出題目所要求的code,得到352個code

    /**
    * n皇后問題
    * date       : 2010-3-12
    * author     : lee
    * change     :LinE
    * change date:2014-8-4
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    #define QUEEN 9    // the number of the queen
    #define INITIAL -10000  //defines the initial value of  the board 
    
    //container
    int a[QUEEN];
    
    //check if the queen can be placed on the position
    int valid(int row, int col);
    //initialize the board
    void clear();
    //print the result
    void print();
    //run the n-queen program 
    void queen();
    
    int main(void)
    {
        clear();
        queen();
        return 0;
    }
    
    void clear()
    {
        int *p;
        for (p = a; p < a + QUEEN; ++p) {
            *p = INITIAL;
        }
    }
    
    void print()
    {
        int i, j,l;
        for (i = 0; i < QUEEN; ++i) {
            for (j = 0; j < QUEEN; ++j) {
                if (a[i] != j) {
                   //printf("%c ", '.');
                 }
                else
                {
                     l=j+1;
                    printf("%d",l);
                    //printf("%c ", '#');
                }
            }
        }
        printf("\n");
        //printf("--------------------------------------------\n");
    }
    
    
    int valid(int row, int col)
    {
        int i;
        for (i = 0; i < QUEEN; ++i) {
            if (a[i] == col || abs(i - row) == abs(a[i] - col)) 
                return 0;
        }
    
        return 1;
    }
    
    void queen()
    {
        int n = 0;
        int i = 0, j = 0;
        while (i < QUEEN) {
    
            while (j < QUEEN) {
                if (valid(i, j)) { //test if the queen can be placed on the position
                    a[i] = j;     //place the queen on the next line
                    j = 0;
                    break;
                } else {         // if not, check the next position
                    ++j;
                }
            }
    
            if (a[i] == INITIAL) {   //if the current queen can't find its place
                if (i == 0)        // and this is the first line ,then program end
                    break;
                else  {           //else   backtrack
                    --i;
                    j = a[i] + 1;
                    a[i] = INITIAL;
                    continue;
                }
            }
    
            if (i == QUEEN - 1) {  //already got a solution, print the result
                //printf("answer %d : \n", ++n);
                print();
            //  _sleep(600);
                j = a[i] + 1;
                a[i] = INITIAL;
                continue;
    
            } 
    
            ++i;      // go on to place the queen on the next line if has any more 
        }
    }
    

    把該程序編譯后,執行的結果重定向到code.txt做下一步的使用

    gcc queen.c -o queen
    ./queen>code.txt
    

    然后編寫一個php腳本,來對所得的解法爆破

    <?php
    $f = fopen("/root/Desktop/test/code.txt","r");
    $passwd="zWp8LGn01wxJ7";
    $hash="e48d316ed573d3273931e19f9ac9f9e6039a4242";
    while (!feof($f))
    {
        $code = fgets($f);
        if (sha1($passwd.$code)===$hash) {
            //因為fgets自帶了一個換行符,故這里不需要再添加"\n"了
            echo $code;
         } 
    }
    fclose($f)
    ?>
    

    15.png

    8-Excel Column

    本關地址:http://fun.coolshell.cn/953172864.html

    感覺這題和Excel關系不大,主要還是一個冪運算,這個類似于16進制轉10進制運算,可以把它看成26進制轉10進制,首先求出來式子當中各個字母在字母表中的位置

    C—-3  
    O—-15  
    L—-12  
    S—-19  
    H—-8  
    E—-5  
    

    然后列出算法,計算出COOLSHELL和SHELL在10進制下的數字

    算法可以參考http://www.cnblogs.com/lavezhang/archive/2012/05/14/2499000.html這里來查看

    COOLSHELL = 3*26^8+15*26^7+15*26^6+12*26^5+19*26^4+8*26^3+5*26^2+12*26^1+12*26^0 = 751743486376
        SHELL = 19*26^4+8*26^3+5*26^2+12*26^1+12*26^0 = 8826856
    

    寫了一個C語言小程序,發現數值太大溢出了,換成長整之后還是溢出了TAT,后來朋友讓我把公式丟谷歌,果然萬能的Google幫我計算出了答案

    16.png

    17.png

    直接結算結果

    COOLSHELL / SHELL = 85165  
    

    然后對這個數字循環計算除數余數,每一步都只取整數部分,答案立馬就出來了

    //個位計算
    85165 / 26 = 3275
    85165 % 26 = 15   //O
    //十位計算
     3275 / 26 = 125
     3275 % 26 = 25   //Y
    //百位計算
      125 / 26 = 4
      125 % 26 = 21   //U
    //千位計算
        4 / 26 = 0
        4 % 26 = 4    //D
    

    最終結果為DUYO,后來自己寫了個python的小程序也實現了這個過程

    import math
    
    COOLSHELL = 3*26**8+15*26**7+15*26**6+12*26**5+19*26**4+8*26**3+5*26**2+12*26**1+12*26**0
    SHELL = 19*26**4+8*26**3+5*26**2+15*26**1+15*26**0
    print 'COOLSHELL=',COOLSHELL
    print 'SHELL=',SHELL
    NUM = int(COOLSHELL / SHELL) + 1
    print 'COOLSHELL / SHELL=',NUM
    temp = NUM
    a = temp / 26
    b = temp % 26
    c4 = chr( b + 64)
    print 'a=',a
    print 'b=',b
    print c4
    temp = a
    a = temp / 26
    b = temp % 26
    c3 = chr( b + 64)
    print 'a=',a
    print 'b=',b
    print c3
    temp = a
    a = temp / 26
    b = temp % 26
    c2 = chr( b + 64)
    print 'a=',a
    print 'b=',b
    print c2
    temp = a
    a = temp / 26
    b = temp % 26
    c1 = chr( b + 64)
    print 'a=',a
    print 'b=',b
    print c1
    print 'Pass is :',c1+c2+c3+c4
    

    9-Fraternal Organisation

    本關地址:http://fun.coolshell.cn/DUYO.html

    首先看提示,提示意思為,如果你能找到上述圖片關系,那么這關將會很容易

    然后把圖片DOWN下來,左邊是豬圈(pigpens),右邊是共濟會的標志(Freemasonry)

    然后以這二者為關鍵詞去搜索,得到一個關聯的詞語,豬圈密碼,然后按照豬圈密碼的翻譯圖對照下面的密文譯成明文即可

    該圖為共濟會的豬圈密碼密文對照表

    18.png

    對照上題目,很快就可以翻譯出密碼明文為helloworld

    然后,木有然后了,游戲到此結束,通關了

    通關證明

    19.png

    97av