ÔõÑùʹÓÃNginx¾ÙÐÐHTTPÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽ
ÔõÑùʹÓÃnginx¾ÙÐÐhttpÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽ
¸ÅÊö£º
Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬WebÓ¦ÓóÌÐòµÄÇå¾²ÐÔÔ½À´Ô½Êܵ½¹Ø×¢¡£ÆäÖУ¬HTTPÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽÊDZ£»¤WebЧÀÍÆ÷ÃâÊܶñÒâ¹¥»÷µÄÒªº¦²½·¥Ö®Ò»¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃnginx¾ÙÐÐhttpÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽÉèÖã¬ÒÔÌá¸ßWebЧÀÍÆ÷µÄÇå¾²ÐÔ¡£
×°ÖÃNginx
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃNginx¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÔÚLinuxϵͳÉϾÙÐÐ×°Öãº
sudo apt-get install nginx
µÇ¼ºó¸´ÖÆ
ÉèÖÃNginx
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÉèÖÃNginxÒÔʵÏÖHTTPÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽ¹¦Ð§¡£·¿ªNginxµÄÉèÖÃÎļþ¾ÙÐб༣º
sudo nano /etc/nginx/nginx.conf
µÇ¼ºó¸´ÖÆ
ÔÚhttp²¿·ÖÉèÖÃÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º
http { ... server { ... # ÉèÖ÷À»ðǽ¹æÔò location / { deny 192.168.0.1; allow all; } # ÉèÖÃÄÚÈݹýÂ˹æÔò location ~* (eval(|base64_) { return 403; } ... } ... }
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÉèÖÃʵÏÖÁË×èÖ¹IPµØµãΪ192.168.0.1µÄÓû§»á¼ûЧÀÍÆ÷£¬²¢Õ¥È¡°üÀ¨eval(ºÍbase64_µÄÇëÇó¡£
ÖØÆôNginx
ÉúÑIJ¢Í˳öÉèÖÃÎļþºó£¬ÎÒÃÇÐèÒªÖØÆôNginxЧÀÍÒÔʹÉèÖÃÉúЧ£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
ÑéÖ¤ÉèÖÃ
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔÑéÖ¤NginxµÄÄÚÈݹýÂ˺ͷÀ»ðǽÉèÖÃÊÇ·ñÉúЧ¡£ÈÃÎÒÃǼÙÉèWebЧÀÍÆ÷µÄIPµØµãΪ192.168.0.100¡£
Ê×ÏÈ£¬ÊµÑéʹÓÃIPµØµãΪ192.168.0.1µÄ¿Í»§¶Ë»á¼ûЧÀÍÆ÷¡£ÈôÊÇÒ»ÇÐÕý³££¬¿Í»§¶Ë½«ÎÞ·¨ÅþÁ¬µ½Ð§ÀÍÆ÷²¢ÊÕµ½403 ForbiddenµÄ¹ýʧ¡£
È»ºó£¬ÊµÑéʹÓÃÒÔÏÂÇëÇó»á¼ûЧÀÍÆ÷£º
curl -X GET 'http://192.168.0.100/index.php?test=eval(base64_encode("hello world"))'
µÇ¼ºó¸´ÖÆ
ÈôÊÇÒ»ÇÐÕý³££¬¿Í»§¶Ë½«ÊÕµ½403 ForbiddenµÄ¹ýʧ¡£
ͨ¹ýÑéÖ¤£¬ÎÒÃÇ¿ÉÒÔÈ·¶¨NginxµÄÄÚÈݹýÂ˺ͷÀ»ðǽÉèÖÃÒѾÉúЧ¡£
½áÂÛ£º
±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃnginx¾ÙÐÐhttpÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽÉèÖá£Í¨¹ýÉèÖÃNginx£¬ÎÒÃÇ¿ÉÒÔÓÐÓõر£»¤WebЧÀÍÆ÷ÃâÊܶñÒâ¹¥»÷¡£Òª×¢ÖصÄÊÇ£¬ÎÒÃÇ¿ÉÒÔƾ֤ÏÖʵÐèÇóÐÞ¸ÄÉèÖÃÎļþÒÔ˳Ӧ²î±ðµÄÇå¾²ÒªÇó¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx¾ÙÐÐHTTPÇëÇóµÄÄÚÈݹýÂ˺ͷÀ»ðǽµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡