2012-01-18 76 views
1

我無法閱讀正則表達式爲我的生活。
任何人都得到了一秒鐘幫助我找出爲什麼mod_security突然與我的主機上次更新觸發?這個正則表達式的mod_security規則是幹什麼的?

我得到這個錯誤的mod_security:

Message: Access denied with code 406 (phase 2). Pattern match " \b(\d+) ?= ?\1\b|[\'"](\w+)[\'"] ?= ?[\'"]\2\b " at REQUEST_HEADERS:Cookie. [file "/usr/local/apache/conf/modsec2.user.conf"] [line "94"] [id "959901"] [msg "SQL Injection Attack"] [data "1=1"] [severity "CRITICAL"] [tag "WEB_ATTACK/SQL_INJECTION"]

下面是產生這個錯誤記錄的餅乾之一:

Cookie: pmr=9d800ab159baf3962d1c777225b4b632; pmr_referrer=http%3A%2F%2Frateyourmusic.com%2Fadmin%2Fcoraq%2F%3F1%3D1%26status%3Dw%26show%3D10%26start%3D7020; __utma=229707933.920390620.1326769663.1326769663.1326769663.1; __utmb=229707933.1.10.1326769663; __utmc=229707933; __utmz=229707933.1326769663.1.1.utmcsr=rateyourmusic.com|utmccn=(referral)|utmcmd=referral|utmcct=/admin/corq/

這是因爲觸發「管理員」是在餅乾嗎? ??

這裏的另一個...

Cookie: ui-tabs-1=1; superBAGUS=af14474b9bcc7ec3ae436e58ba172520; superBAGUS_referrer=...; superBAGUS_admin=2%3A747167a9cd89703dbfafe3c7a5c523b4; acco=acco_1; superBAGUS_adviews=.2576.2580.; __utma=10910262.1479346800.1326871079.1326871079.1326873539.2; __utmb=10910262.10.8.1326873800604; __utmc=10910262; __utmz=10910262.1326871079.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

這是因爲觸發 「UI-標籤-1 = 1」 看起來像一個1 = 1注???

這個模式匹配到底是什麼?

+0

這就是爲什麼一般的Web應用防火牆是完全沒有用處的一個很好的例子。 – Gumbo 2012-01-18 16:31:28

回答

2

正則表達式不匹配第一個模式,所以我不能說出什麼可能是錯的。

但它與第二個模式的1=1部分匹配,所以您的假設是正確的。

正則表達式的說明:

\b    # Assert position at the start of an alphanumeric "word" 
(\d+)   # Match a number 
?= ?   # Match =, optionally surrounded by spaces 
\1    # Match the same number as before 
\b    # Assert position at the end of an alphanumeric "word" 
|    # or 
['"](\w+)['"] # Match a quoted "word" 
?= ?   # Match =, optionally surrounded by spaces 
['"]\2\b  # Match a quote and the same word as before. 
+0

感謝您的詳細解釋! – neokio 2012-01-18 17:23:24