国产毛片午夜福利,国产黄网,国产亚洲天堂,97国产精品

  •  
    對ikonboard v2.1.9物理路徑泄露的分析
    發(fā)布時(shí)間:2005-03-28   瀏覽次數(shù):1185970
    出處:顛峰網(wǎng)絡(luò)
    作者:未知
    ikonboard是當(dāng)前比較流行的論壇,目前提供下載的版本是ikonboard v2.1.9,可以從http://www.ikonboard.com/downloads/ib219.zip下載。
    舊版本的ikonboard 存在一個(gè)泄露系統(tǒng)文件的漏洞,主要是沒有過濾掉“..”和“/”,再結(jié)合“poison null-byte”,我們可以通過類似下面的形式訪問“/etc/passwd”文件:
    http://www..notfound.org/cgi-bin/ikonboard/help.cgi?helpon=../../../../../etc/passwd%00
    ikonboard v2.1.9已經(jīng)修正了這個(gè)問題,把用戶輸入的“..”和“/”都過濾掉了,但是我發(fā)現(xiàn)它存在著物理路徑泄露的問題。問題還是出在help.cgi上,相關(guān)程序代碼如下:

    #過濾“..”和“/”
    $inhelpon =~ s/\///g;
    $inhelpon =~ s/\.\.//g;

    #讀取指定的文件
    $filetoopen = "$ikondir" . "help/$inhelpon.dat";
    $filetoopen = &stripMETA($filetoopen);
    open (FILE, "$filetoopen") or die "Cannot locate the required files";
    @helpdata = <FILE>;
    close (FILE);

    乍一看,似乎沒有什么問題。如果文件存在;一切OK。如果文件不存在,會(huì)顯示錯(cuò)誤信息“Cannot locate the required files”。
    我們看看實(shí)際情況:
    輸入地址:http://www.notfound.org/ib219/cgi-bin/help.cgi?helpon=12345678
    返回信息:
        
    Content-type: text/html
    Software error:
    Cannot locate the required files at c:\apache\htdocs\ib219\cgi-bin\help.cgi line 100.
    For help, please send mail to the webmaster (webmaster@notfound.org), giving this error message and the time and date of the error. 

    好象結(jié)果和我們想象的不一樣哦,現(xiàn)實(shí)與夢想總是有距離的。海
    通過分析,我們知道問題出在第99行,即:
    open (FILE, "$filetoopen") or die "Cannot locate the required files";
    open函數(shù)應(yīng)該沒有什么問題,看來是die函數(shù)的問題了。用過perl的人應(yīng)該知道,die函數(shù)的作用是顯示錯(cuò)誤信息,然后退出。但是,die函數(shù)還有一個(gè)作用,它還會(huì)在錯(cuò)誤信息的后面附加一些調(diào)試信息,這主要是為了調(diào)試的方便。
    那么,是不是有什么參數(shù)可以去掉這些調(diào)試信息呢?畢竟很多時(shí)候這些調(diào)試信息會(huì)給我們帶來麻煩。我在http://www.perl.com/沒有找到答案,但是我卻在那里找到了一個(gè)抑制錯(cuò)誤信息的方法。
    我們來看:
    test1.pl
    #!/usr/bin/perl
    open(“c:/123”) || die “file open error!”;
        
    C:\>perl test1.pl
    file open error! at C:\test1.pl line 3.
        
    C:\>
    我們再看:
    test2.pl
    #!/usr/bin/perl
    open(“c:/123”) || die “file open error!\n”;
        
    C:\>perl test2.pl
    file open error!
        
    C:\>
    Good!顯然滿足了我們的要求,我們再來看看修改了help.cgi的結(jié)果:
    輸入地址:http://www.notfound.org/ib219/cgi-bin/help.cgi?helpon=12345678
    返回信息:
        
    Content-type: text/html
    Software error:
    Cannot locate the required files.
    For help, please send mail to the webmaster (webmaster@notfound.org), giving this error message and the time and date of the error. 

    Perfect,We Got it!

    發(fā)現(xiàn)了問題,解決了問題,我們再來看看是不是還有其它的地方也是同樣的問題。經(jīng)過查找,研究,排除,確認(rèn),又發(fā)現(xiàn)了以下具有相同問題的CGI程序:

    /ib219/cgi-bin/checklog.cgi
    /ib219/cgi-bin/forums.cgi
    /ib219/cgi-bin/topic.cgi

    好了,到此為止,希望用Perl開發(fā)CGI的程序員能夠從中得到一些啟示,如果您對本文的觀點(diǎn)有什么疑問,請直接給我發(fā)信!

    聲明:
    本文測試環(huán)境是Windows 00+Apache 1.3.+Active Perl 5.6.1
        
    參考資料:
    1.    http://www.perl.com/pub/doc/manual/html/pod/perlfunc/die.html
    2.    http://www.securityfocus.com/vdb/bottom.html?vid=2471
    立即預(yù)約