å¨phpåºç¨ç¨åºå¼åä¸ä¸æ£å½ä½¿ç¨mail()å½æ°å¼åçè¡æ¡_php_web-itnose
é¦é¡µ
asp
php
javascript
iis
apache
html/css
coldfusion
ajax
vbscript
cgi
xml/xsl
è·¨æµè§å¨å¼å
ruby/rails
ç¨åºå
html5
jquery
seo
jboss
json
angularjs
markdown
nginx
thinkphp
yii
pageadmin
extjs
wampserver
kendo ui
coffeescript
gulp
ecmascript
bootstrap
itnoseé¦é¡µ > web > php >
å¨phpåºç¨ç¨åºå¼åä¸ä¸æ£å½ä½¿ç¨mail()å½æ°å¼åçè¡æ¡
2017-05-04 20:14
åè¨
å¨æ们 ææphpåºç¨ç¨åºæ¼æ´ çè¿ç¨ä¸ï¼æ们åèåçwebmailæå¡æä¾å roundcube æ交äºä¸ä¸ªè¿ç¨å½ä»¤æ§è¡æ¼æ´ï¼ cve-2016-9920 ï¼ã该æ¼æ´å 许æ»å»è éè¿å©ç¨roundcubeæ¥å£åéä¸ä¸ªç²¾å¿æé ççµåé®ä»¶ä»èå¨ç®æ ç³»ç»ä¸æ§è¡ä»»æå½ä»¤ãå¨æ们åååæ交æ¼æ´ï¼åå¸äºç¸å ³çæ¼æ´åææç« åï¼ç±äºphpå èå½æ°mail()导è´ç类似å®å ¨é®é¢å¨å ¶ä»çphpåºç¨ç¨åºä¸éç»æåºãå¨è¿ç¯æç« ä¸ï¼æ们å°åæä¸ä¸è¿äºæ¼æ´çå ±åç¹ï¼é£äºå®å ¨è¡¥ä¸ä»ç¶åå¨é®é¢ï¼ä»¥åå¦ä½å®å ¨ç使ç¨mail()å½æ°ã
æµ æphpçmail()å½æ°
phpèªå¸¦äºä¸ä¸ªå èå½æ°mail()ç¨äºå¨phpåºç¨ç¨åºä¸åéçµåé®ä»¶ãå¼åè å¯ä»¥éè¿ä½¿ç¨ä»¥ä¸äºä¸ªåæ°æ¥é ç½®é®ä»¶åéã
http://php.net/manual/en/func…
bool mail( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters ]]è¿ä¸ªå½æ°çåä¸ä¸ªåæ°è¿éå°±ä¸ç»è¯´äºï¼å 为è¿äºåæ°ä¸è¬æ åµä¸ä¸ä¼åå°æ³¨å ¥æ»å»çå½±åãä½æ¯ï¼å¼å¾å ³æ³¨çä¸ç¹æ¯ï¼å¦æ$toåæ°ç±ç¨æ·æ§å¶æ§å¶çè¯ï¼é£ä¹å ¶å¯ä»¥åä»»æçµåé®ä»¶å°ååéåå¾é®ä»¶ã
é®ä»¶å¤´æ³¨å ¥
å¨è¿ç¯æç« ä¸æ们éç¹åæå两个åæ°ã第å个åæ°$additional_headersç主è¦åè½æ¯è§å®é¢å¤çµåé®ä»¶æ¥å¤´ãæ¯å¦fromãreply-toãcc以åbccãç±äºé®ä»¶æ¥å¤´ç±crlfæ¢è¡ç¬¦rnåéãå½ç¨æ·è¾å ¥å¯ä»¥æ§å¶ç¬¬å个åæ°ï¼æ»å»è å¯ä»¥ä½¿ç¨è¿äºå符ï¼rnï¼æ¥å¢å å ¶ä»çé®ä»¶æ¥å¤´ãè¿ç§æ»å»æ¹å¼ç§°ä¸ºçµåé®ä»¶å¤´æ³¨å ¥ï¼æççµåé®ä»¶æ³¨å ¥ï¼ãè¿ç§æ»å»å¯ä»¥éè¿åé®ä»¶å¤´æ³¨å ¥cc:æbcc:å段é æåéå¤å°åå¾é®ä»¶ãå¼å¾æ³¨æçæ¯ï¼æäºé®ä»¶ç¨åºä¼èªå¨å°næ¿æ¢ä¸ºrnã
为ä»ä¹æ²¡ææ£ç¡®å¤çmail()å½æ°ç第5个åæ°ä¼å¼åå®å ¨é®é¢
为äºå¨phpä¸ä½¿ç¨mail()å½æ°ï¼å¿ é¡»é ç½®ä¸ä¸ªçµåé®ä»¶ç¨åºææå¡å¨ãå¨php.inié ç½®æ件ä¸å¯ä»¥ä½¿ç¨ä»¥ä¸ä¸¤ä¸ªé项ï¼
1.é ç½®phpè¿æ¥çsmtpæå¡å¨ç主æºåå端å£
2.é ç½®phpç¨ä½é®ä»¶ä¼ è¾ä»£çï¼mtaï¼çé®ä»¶ç¨åºæ件路å¾
å½phpé ç½®äºç¬¬äºä¸ªé项æ¶ï¼è°ç¨mail()å½æ°çå°å¯¼è´æ§è¡é ç½®çmta(é®ä»¶ä¼ è¾ä»£ç)ç¨åºã尽管phpå é¨å¯ä»¥è°ç¨escapeshellcmd()å½æ°é²æ¢æ¶æç¨æ·æ³¨å ¥å ¶ä»çshellå½ä»¤ï¼mail()å½æ°ç第5个åæ°$additional_parameterså 许åmta(é®ä»¶ä¼ è¾ä»£ç)ä¸æ·»å æ°çç¨åºåæ°ãå æ¤ï¼æ»å»è å¯ä»¥å¨ä¸äºmtaä¸éå ç¨åºæ å¿ï¼å¯ç¨å建ä¸ä¸ªç¨æ·å¯æ§å 容çæ件ã
æ¼æ´æ¼ç¤ºä»£ç
mail(“myfriend@example.com”, “subject”, “message”, “”, “-f” . $_get[‘from’]);å¨ä¸è¿°ä»£ç ä¸åå¨ä¸ä¸ªè¿ç¨å½ä»¤æ§è¡æ¼æ´ï¼è¿ä¸ªé®é¢å®¹æ被没æå®å ¨æè¯çå¼å人å忽ç¥ãgetåæ°å®å ¨ç±ç¨æ·æ§å¶ï¼æ»å»è å¯ä»¥å©ç¨è¯¥å¤è¾å ¥åé®ä»¶ç¨åºä¼ éå ¶ä»é¢å¤çåæ°ã举ä¾æ¥è¯´ï¼å¨åéé®ä»¶çè¿ç¨ä¸å¯ä»¥ä½¿ç¨-oåæ°æ¥é ç½®åéé®ä»¶çé项ï¼ä½¿ç¨-xåæ°å¯ä»¥æå®æ¥å¿æ件çä½ç½®ã
æ¦å¿µæ§éªè¯ï¼pocï¼
example@example.com -oqueuedirectory=/tmp -x/var/www/html/rce.phpè¿ä¸ªpocçåè½æ¯å¨webç®å½ä¸çæä¸ä¸ªphp webshellã该æ件ï¼rce.phpï¼å å«åå°php代ç 污æçæ¥å¿ä¿¡æ¯ãå æ¤ï¼å½è®¿é®rce.phpæ件æ¶ï¼æ»å»è è½å¤å¨webæå¡å¨ä¸æ§è¡ä»»æphp代ç ã读è å¯ä»¥å¨ æ们çåå¸çæç« å è¿é æ¾å°æ´å¤å ³äºå¦ä½å©ç¨è¿ä¸ªæ¼æ´çç¸å ³ä¿¡æ¯ã
ææ°ç¸å ³çå®å ¨æ¼æ´
å¨è®¸å¤ç°å®ä¸ççåºç¨ç¨åºä¸ï¼æå¾å¤ç±äºmail()å½æ°ç第äºä¸ªåæ°ä½¿ç¨ä¸å½å¼åçå®å ¨é®é¢ãæè¿åç°ä»¥ä¸å¹¿åå ³æ³¨çphpåºç¨ç¨åºåå°æ¤ç±»æ¼æ´çå½±åï¼å¤æ°æ¼æ´ç±dawid golunskiåç°ï¼ã
ç±äºä¸äºå¹¿æ³ä½¿ç¨çwebåºç¨ç¨åºï¼å¦ wordpressï¼ joomlaå drupalï¼é¨å模ååºäºä»¥ä¸åºå¼åï¼æ以ä¹ä¼åå°è¯¥ç±»æ¼æ´çå½±åã
为ä»ä¹escapeshellarg()å½æ°æ²¡æé£ä¹å®å ¨ï¼
phpæä¾äº escapeshellcmd() å escapeshellarg() å½æ°ç¨æ¥è¿æ»¤ç¨æ·çè¾å ¥ï¼é²æ¢æ¶ææ»å»è æ§è¡å ¶ä»çç³»ç»å½ä»¤æåæ°ãç´è§æ¥è®²ï¼ä¸é¢çphpè¯å¥çèµ·æ¥å¾å®å ¨ï¼å¹¶ä¸é²æ¢äº-param1åæ°çä¸æï¼
system(escapeshellcmd(“./program -param1 “. escapeshellarg( $_get[‘arg’] )));ç¶èï¼å½æ¤ç¨åºæå ¶ä»å¯å©ç¨åæ°æ¶ï¼é£ä¹è¿è¡ä»£ç å°±æ¯ä¸å®å ¨çãæ»å»è å¯ä»¥éè¿æ³¨å ¥”foobar’ -param2 payload “æ¥çªç ´-param1åæ°çéå¶ãå½ç¨æ·çè¾å ¥ç»è¿ä¸¤ä¸ªescapeshell*å½æ°çå¤çï¼ä»¥ä¸å符串å°å°è¾¾system()å½æ°ã
./program -param1 ‘foobar’\” -param2 payload ‘ä»æç»ç³»ç»æ§è¡çå½ä»¤å¯ä»¥çåºï¼ä¸¤ä¸ªåµå¥ç转ä¹å½æ°æ··æ·äºå¼ç¨å¹¶å 许éå å¦ä¸ä¸ªåæ°param2ã
phpçmail()å½æ°å¨å é¨ä½¿ç¨escapeshellcmd()å½æ°è¿æ»¤ä¼ å ¥çåæ°ï¼ä»¥é²æ¢å½ä»¤æ³¨å ¥æ»å»ãè¿æ£æ¯ä¸ºä»ä¹escapeshellarg()å½æ°ä¸ä¼é»æ¢mail()å½æ°ç第5个åæ°çæ»å»ã roundcubeå phpmailerçå¼å人åçå åå¸äºé对该æ¼æ´çè¡¥ä¸ã
为ä»ä¹filter_validate_emailæ¯ä¸å®å ¨çï¼
å¦ä¸ç§ç´æ¥çæ¹æ³æ¯ä½¿ç¨phpççµåé®ä»¶è¿æ»¤å¨ï¼email filterï¼ï¼ä»¥ç¡®ä¿å¨mail()å½æ°ç第5个åæ°ä¸åªä½¿ç¨ææççµåé®ä»¶å°åã
filter_var($email, filter_validate_email)ä½æ¯ï¼å¹¶ä¸æ¯ææå¯è½åå¨å®å ¨é®é¢çå符串é½ä¼è¢«è¯¥è¿æ»¤å¨è¿æ»¤ãå®å 许使ç¨åµå ¥åå¼å·ç转ä¹çç©ºæ ¼ã
ç±äºå½æ°åºå±å®ç°æ£å表达å¼çåå ï¼filter_var()没æ对è¾å ¥æ£ç¡®çè¿æ»¤ï¼å¯¼è´æé çpayloadè¢«å¸¦å ¥æ§è¡ã
‘a.”‘ -oqueuedirectory=%0d -x/var/www/html/”@a.php对äºä¸æç»åºçurlç¼ç è¾å ¥ï¼filter_var()å½æ°è¿åtrueï¼å°è¯¥payloadè¯å«ä¸ºææçé®ä»¶æ ¼å¼ã
å½å¼å人å使ç¨è¯¥å½æ°éªè¯çµåé®ä»¶æ ¼å¼ä½ä¸ºå¯ä¸çå®å ¨éªè¯æªæ½ï¼æ¤æ¶ä»ç¶æ¯å¯ä»¥è¢«æ»å»è å©ç¨çï¼ä¸æ们ä¹åçæ»å»æ¹å¼ç±»ä¼¼ï¼å¨phpç¨åºåéé®ä»¶æ¶ï¼æ们精å¿æé çæ¶æâçµåé®ä»¶å°åâä¼å°å°php webshellçæå¨webæå¡æ ¹ç®å½ä¸ã
/): no such file or directoryåè®°ï¼filter_var()ä¸éåç¨äºå¯¹ç¨æ·è¾å ¥å 容çè¿æ»¤ï¼å 为å®å¯¹é¨åå符串çéªè¯æ¯ä¸ä¸¥æ ¼çã
å¦ä½å®å ¨ç使ç¨mail()å½æ°
ä»ç»åæåºç¨ç¨åºä¸ä¼ å ¥mail()å½æ°çåæ°ï¼æ»¡è¶³ä»¥ä¸æ¡ä»¶ï¼
$to é¤éå¯ä»¥é¢æç¨æ·çè¾å ¥å 容ï¼å¦åä¸ç´æ¥ä½¿ç¨ç¨æ·è¾å ¥
$subject å¯ä»¥å®å ¨ç使ç¨
$message å¯ä»¥å®å ¨ç使ç¨
$additional_headers è¿æ»¤rãnå符
$additional_parameters ç¦æ¢ç¨æ·è¾å ¥
äºå®ä¸ï¼å½æç¨æ·çè¾å ¥ä½ä¸ºshellæ令æ§è¡æ¶ï¼æ²¡æä»ä¹åæ³å¯ä»¥ä¿è¯ç³»ç»çå®å ¨æ§ï¼åä¸ä¸è¦å»èéªä½ çè¿æ°ã
å¦æå¨å¼åæ¨çåºç¨ç¨åºè¿ç¨ä¸ç¬¬5个åæ°ä¸å®è¦ç±ç¨æ·æ§å¶ï¼ä½ å¯ä»¥ä½¿ç¨çµåé®ä»¶è¿æ»¤å¨ï¼email filterï¼å°ç¨æ·è¾å ¥çåæ³æ°æ®éå¶ä¸ºæå°å符éï¼å³ä½¿å®è¿åäºrfcåè§æ§ãæ们建议ä¸è¦ä¿¡ä»»ä»»ä½è½¬ä¹æå¼ç¨ç¨åºï¼å 为æ®åå²èµæ表示 è¿äºåè½æ¯åå¨å®å ¨é®é¢çï¼ç¹å«æ¯å¨ä¸åç¯å¢ä¸ä½¿ç¨æ¶ï¼å¯è½è¿ä¼æ´é²åºå ¶ä»å®å ¨éæ£ãpaul buonopaneç 究åºäºå¦ä¸ç§æ¹æ³å»è§£å³è¿ä¸ªé®é¢ï¼å¯ä»¥å¨ è¿éæ¾å°ã
æ»ç»
许å¤phpåºç¨ç¨åºé½æåå ¶ç¨æ·åéçµåé®ä»¶çåè½ï¼ä¾å¦æéåéç¥ã è½ç¶çµåé®ä»¶å¤´æ³¨å ¥æ¯ä¼æå¨ç¥çå®å ¨é®é¢ï¼ä½æ¯å½å¼å人å使ç¨mail()å½æ°æ¶ï¼å¾å¾ä¼å¿½è§ä¸æ£å½ç使ç¨æå¯è½å¯¼è´è¿ç¨å½ä»¤æ§è¡æ¼æ´ã å¨è¿ç¯æç« ä¸ï¼æ们主è¦åæäºmail()å½æ°ç第5个åæ°ä½¿ç¨ä¸å½å¯è½åå¨çå®å ¨é£é©ï¼ä»¥åå¦ä½é²èè¿ç§é®é¢ï¼é²æ¢æå¡å¨åå°æ»å»ãæ¬æç±ç²çªcpaèçï¼www.jiazhua.comï¼æ´çç¼è¾ï¼
ç¸å
³æç´¢ï¼
javaç¨åºåå¨å京çå·¥èµ
jspä¸ç注é
c++ä¸ç~
å¦ä½å©ç¨å¾è¡¨å¨è¡å¸ä¸è·å©
cè¯è¨çåºç¨
ç¸å ³æç«
2017-01-01 01:25 å¤ä¸ªphp mailå½æ°å¼åçå½ä»¤æ§è¡æ¼æ´åæ
2017-03-11 21:52 phpå¨appå¼åä¸çåºç¨
2017-02-15 14:51 ç¡®ä¿ php åºç¨ç¨åºçå®å
¨
2014-02-09 11:13 jsonå¨phpä¸çåºç¨
2016-07-26 20:13 phpä¸çåºæ¬å½æ°ä½¿ç¨ãååã
æ´å¤ç¸å ³æç« >>
ææ°æç«
2017-06-20 01:35 èé们ï¼æ没æå¯è½è®©phpæ件åæ¶åªè½ä¸ä¸ªäººè®¿é®
2017-06-20 01:35 æä¹ç¦æ¢å¾çç´æ¥éè¿url访é®
2017-06-20 01:35 æ±æ!å¯å¨wampåªè½ç¨æ¬æºè®¿é®,åå±åç½çå
¶å®è®¾å¤è®¿é®ä¸å°!æäºå¤§å天t-t
2017-06-19 15:35 nginxä¸çthinkphpé®é¢
2017-06-19 15:35 php form æ件ä¸ä¼
æ´å¤ææ°æç« >>
çé¨æç´¢
c++çåºç¨
人工æºè½ä¸çå¾è¡¨æ¨ç
jspåºç¨å¼å详解
phpç¨åºå
php æ°æ®åºå¼å
æ°æ®åºåºç¨ä¸å¼å
html5 移å¨åºç¨å¼å
html5å¼å移å¨åºç¨
æ°æ®åºçå¼å
phpç¨åºååjavaç¨åºå
spring 3.xä¼ä¸åºç¨å¼åå®æ
j2meææ¯å¼åä¸åºç¨
html5å¼åææºåºç¨
ç¯ççç¨åºå
ç¨åºåçç±æ
京icpå¤14022385å·-2
©2014 itnose软件ç¼ç¨æç¨ | èç³»æ们ï¼emailï¼twobrushes@126.com qq:35155868