<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            原文地址:http://drops.wooyun.org/papers/4505

            0x00 背景


            enter image description here

            前幾天有個人在某大會上講了一個在perl中存在了20年的問題。作為一個只會perl不會python的人,真的很心痛。看完視頻后感覺被黑的吃不下東西。

            這儼然就是一場對perl的吐槽批斗大會,整個演講充滿了sucks、fuck等和諧詞匯,也能看出演講者是多么的義憤填膺,場下一次次的鼓掌和附,嗯,讓我想起了郭德綱。

            0x01 問題


            enter image description here

            言歸正傳,這個在perl中存在了20年的問題到底是啥呢?拋去perl的語法的槽點,真正的問題在data types上,對的,就是數據類型。

            Perl對數據類型的處理真是有點匪夷所思了。

            我們先了解一下perl中的變量有哪幾種。

            perl中的變量

            perl的數據類型分為三類:標量$,數組@,哈希%。

            具體定義在這里不多說,我們來看幾個例子:

            enter image description here

            不管是標量、數組還是哈希(字典),定義跟其他語言沒什么區別。

            enter image description here

            我們來看看幾個特殊的情況,下面每個預期值為正常人類理解應該得到的結果。

            #!perl
            @array =(1, 2, 'a', 'b', 'c');
            print $array[0];
            

            預期值 1

            enter image description here

            實際值 1

            #!perl
            $scalar = (1, 2, 'a', 'b', 'c'); 
            print $scalar;
            

            預期值 1

            enter image description here

            實際值 c 我擦淚,為毛會是c!太不科學了,繼續往下看。

            #!perl
            @list = (1, 2, 'a', 'b', 'c'); 
            print scalar @list;
            

            預期值 1

            enter image description here

            實際值 5 呵呵,他把數組的長度輸出了。

            再看看這個哈希的例子

            #!perl
            %hash = (1, 2, 'a', 'b', 'c'); 
            print $hash{'a'};
            

            預期值 木有

            enter image description here

            實際值 b 為毛把b給輸出了,誰能告訴我這頭草泥馬是怎么處理的。

            0x02 漏洞


            這些問題會產生什么漏洞呢?

            一起看看在web中php跟perl處理的對比。

            enter image description here

            enter image description here

            這么看來是木有任何問題的,那么使用復參的時候呢?

            enter image description here

            php很好的處理了傳入的數據,而perl的做法就是草泥馬在奔騰%>_<%他是直接可以傳入數組的。

            再深入一下,看看當數組和哈希結合的時候的情況。

            #!perl
            @list = ('f', 'lol', 'wat');
            $hash = {'a' => 'b',
                     'c' => 'd', 
                     'e' => @list
            };
            print $hash;
            

            預期值

            #!perl
            {
            'a' => 'b',?    
            'c' => 'd',?    
            'e' => ['f','lol','wat'] 
            } 
            

            enter image description here

            神馬情況,數組中的“,”變成了“=>”又給賦值了?e=>f、lol=>wat,what the f*cuk!

            enter image description here

            這是多大的一個坑啊!看Bugzilla是怎么掉進去的。

            http://zone.wooyun.org/content/15628

            關于數據類型的這些問題我不想再說了,有些惡心。

            0x03 GPC的問題


            enter image description here

            enter image description here

            屌屌的棒棒的,對吧,可是……

            enter image description here

            我了個*,一個都不給轉義了,就這么罷工了,可以順順暢暢的注入了好么。

            enter image description here

            我想靜靜。

            0x04 來源


            Pdf:

            http://events.ccc.de/congress/2014/Fahrplan/system/attachments/2542/original/the-perl-jam-netanel-rubin-31c3.pdf

            視頻地址:

            http://media.ccc.de/browse/congress/2014/31c3_-6243-en-saal_1-201412292200-the_perl_jam_exploiting_a_20_year-old_vulnerability-_netanel_rubin.html#video

            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线