LinuxЧÀÍÆ÷ÍøÂçÇå¾²£ºWeb½Ó¿Ú¹¥»÷µÄʵʱ¼ì²âÓëÏìÓ¦¡£
LinuxЧÀÍÆ÷ÍøÂçÇå¾²£ºWeb½Ó¿Ú¹¥»÷µÄʵʱ¼ì²âÓëÏìÓ¦
ͻ񻣼
Ëæ×ÅWebÓ¦ÓóÌÐòµÄÆÕ¼°ºÍÉú³¤£¬Web½Ó¿Ú¹¥»÷Ò²ÈÕÒæ·Å×Ý¡£ÎªÁ˱£»¤Ð§ÀÍÆ÷µÄÍøÂçÇå¾²£¬±¾ÎÄÏÈÈÝÁËÒ»ÖÖÕë¶ÔLinuxЧÀÍÆ÷µÄWeb½Ó¿Ú¹¥»÷ʵʱ¼ì²âÓëÏìÓ¦ÒªÁ졣̫ͨ¹ýÎöÇëÇóÁ÷Á¿£¬Ê¹ÓûùÓÚ¹æÔòµÄ¼ì²âÒýÇæʵʱ¼ì²âWeb½Ó¿Ú¹¥»÷£¬²¢ÍŽá´úÂëʾÀýÏÈÈÝÁËÒ»ÖÖ»ùÓÚNginxºÍModSecurityµÄʵÏּƻ®¡£
СÐò
Ëæ×Å»¥ÁªÍøµÄ·ÉËÙÉú³¤£¬WebÓ¦ÓóÌÐòÒѾ³ÉΪÈËÃÇ»ñÊØÐÅÏ¢ºÍ¾ÙÐн»Á÷µÄÖ÷Ҫ;¾¶¡£È»¶ø£¬ËæÖ®¶øÀ´µÄÊÇÍøÂçÇ徲Σº¦µÄÒ»Ö±ÔöÌí£¬Web½Ó¿Ú¹¥»÷³ÉΪ»¥ÁªÍøÁìÓòÖеij£¼ûÍþв¡£ÎªÁ˱£»¤Ð§ÀÍÆ÷µÄÍøÂçÇå¾²£¬ÊµÊ±¼ì²âºÍÏìÓ¦Web½Ó¿Ú¹¥»÷ÖÁ¹ØÖ÷Òª¡£
Web½Ó¿Ú¹¥»÷µÄÀàÐÍ
Web½Ó¿Ú¹¥»÷°üÀ¨µ«²»ÏÞÓÚSQL×¢Èë¡¢¿çÕ¾¾ç±¾¹¥»÷£¨XSS£©¡¢¿çÕ¾ÇëÇóαÔ죨CSRF£©ºÍ»á¼û¿ØÖÆȱÏݵȡ£ÕâЩ¹¥»÷ÊÖ·¨¼È¿ÉÒÔÖ±½Óµ¼ÖÂЧÀÍÆ÷µÄÊý¾Ýй¶ºÍÊÜËð£¬Ò²¿ÉÒÔ½øÒ»²½¹¥»÷ÆäËûϵͳ»òÓû§¡£
»ùÓÚ¹æÔòµÄWeb½Ó¿Ú¹¥»÷¼ì²âÒýÇæ
»ùÓÚ¹æÔòµÄ¼ì²âÒýÇæÊÇÒ»ÖÖ³£¼ûµÄWeb½Ó¿Ú¹¥»÷¼ì²âÒªÁì¡£Ëüͨ¹ý½ç˵һϵÁйæÔò£¬¶ÔÇëÇóÁ÷Á¿¾ÙÐÐÆÊÎöºÍÆ¥Å䣬´Ó¶øʵʱ¼ì²â³öÖÖÖÖ¹¥»÷ÐÐΪ¡£ÏÂÃæÊÇÒ»¸ö¼òÆӵĹæÔòʾÀý£º
¹æÔò1£º¼ì²âSQL×¢Èë¹¥»÷
Æ¥Åäģʽ£º’ OR ‘1’=’1
Ðж¯£º×èµ²ÇëÇ󣬲¢¼Í¼IPµØµã
¹æÔò2£º¼ì²âXSS¹¥»÷
Æ¥Åäģʽ£º<script>alert(‘XSS’)</script>
Ðж¯£º×èµ²ÇëÇ󣬲¢¼Í¼IPµØµã
¹æÔò3£º¼ì²âCSRF¹¥»÷
Æ¥Åäģʽ£º
Ðж¯£º×èµ²ÇëÇ󣬲¢¼Í¼IPµØµã
»ùÓÚNginxºÍModSecurityµÄʵÏּƻ®
NginxÊÇÒ»¸ö¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬¶øModSecurityÊÇÒ»¸ö¿ªÔ´µÄWebÓ¦ÓóÌÐò·À»ðǽ£¨WAF£©Ä£¿é¡£ÍŽá¶þÕß¿ÉÒÔʵÏÖWeb½Ó¿Ú¹¥»÷µÄʵʱ¼ì²âÓëÏìÓ¦¡£ÏÂÃæÊÇÒ»¸ö»ùÓÚNginxºÍModSecurityµÄʵÏÖʾÀý£º
ʾÀý´úÂë1£ºNginxÉèÖÃÎļþ
server { listen 80; server_name example.com; location / { ModSecurityEnabled on; ModSecurityConfig modsecurity.conf; proxy_pass http://backend; } }
µÇ¼ºó¸´ÖÆ
ʾÀý´úÂë2£ºModSecurityÉèÖÃÎļþ£¨modsecurity.conf£©
SecRuleEngine On SecRule REQUEST_FILENAME "@rx /login.php" "id:1,rev:1,phase:2,deny,status:403,msg:'SQL Injection attack detected'" SecRule REQUEST_FILENAME "@rx /index.php" "id:2,rev:1,phase:2,deny,status:403,msg:'XSS attack detected'" SecRule REQUEST_FILENAME "@rx /logout.php" "id:3,rev:1,phase:2,deny,status:403,msg:'CSRF attack detected'"
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöʾÀýÖУ¬NginxÉèÖÃÎļþÖÐÆôÓÃÁËModSecurityÄ£¿é£¬²¢Ö¸¶¨ÁËModSecurityµÄÉèÖÃÎļþ¡£ModSecurityÉèÖÃÎļþÖнç˵ÁËÈý¸ö¹æÔò£¬»®·Ö¼ì²âSQL×¢Èë¹¥»÷¡¢XSS¹¥»÷ºÍCSRF¹¥»÷¡£
½áÂÛ
Web½Ó¿Ú¹¥»÷ÒѾ³ÉΪLinuxЧÀÍÆ÷ÍøÂçÇå¾²µÄÖ÷ÒªÍþв֮һ¡£ÎªÁ˱£»¤Ð§ÀÍÆ÷µÄÍøÂçÇå¾²£¬±¾ÎÄÏÈÈÝÁËÒ»ÖÖÕë¶ÔLinuxЧÀÍÆ÷µÄWeb½Ó¿Ú¹¥»÷ʵʱ¼ì²âÓëÏìÓ¦ÒªÁ졣ͨ¹ý»ùÓÚ¹æÔòµÄ¼ì²âÒýÇ棬ÍŽáNginxºÍModSecurityµÄʵÏּƻ®£¬¿ÉÒÔÓÐÓõؼì²âºÍ×èÖ¹ÖÖÖÖWeb½Ó¿Ú¹¥»÷ÐÐΪ¡£ÔÚÏÖʵӦÓÃÖУ¬ÎÒÃÇ¿ÉÒÔƾ֤ÏêϸµÄÐèÇó½ç˵¸ü¶àµÄ¹æÔò£¬²¢Ò»Á¬¸üкÍά»¤¹æÔò¿â£¬ÒÔÓ¦¶Ôһֱת±äµÄÍøÂçÇå¾²Íþв¡£
ÒÔÉϾÍÊÇLinuxЧÀÍÆ÷ÍøÂçÇå¾²£ºWeb½Ó¿Ú¹¥»÷µÄʵʱ¼ì²âÓëÏìÓ¦¡£µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡