標籤:style class code c 檔案 使用
CSS(Cascading Style Sheet,可譯為“層疊樣式表”或“階層式樣式表”)是一組格式設定規則,用於控制Web頁面的外觀。通過使用CSS樣式設定頁面的格式,可將頁面的內容與表現形式分離。頁面內容存放在HTML文檔中,而用於定義表現形式的CSS規則則存放在另一個檔案中或HTML文檔的某一部分,通常為檔案頭部分。將內容與表現形式分離,不僅可使維護網站的外觀更加容易,而且還可以使HTML文檔代碼更加簡練,縮短瀏覽器的載入時間。
一般情況下,我們的CSS是無需加密的,也是無法加密的,但是有些時候,應客戶的特殊癖好,抑或是出於防小人不妨君子的目的,我們不得不採取一些措施,將我們的CSS給藏起來。
看下邊這段代碼:
12 |
/*抄襲者死,看什麼看,說的就是你!*//*\0le\0u\0r\0y\[email protected]\0s\0.c\0s\0ss\0s\[email protected]@\0t u\0)r\0y\0le\0s u\0r\0y\0le\0s\0.c\0s\@0sy\0le\ u\0r\0y\0le\0s\0.c\0s\0s0s\0.c u\ u\[email protected]\0y\[email protected]\0s\[email protected]\0s\0s0r\0y\0le\0s\0.c\0s\0 t u\0r\[email protected]\0le\0u\0r\0y\[email protected]\0s\0.c\0s\0ss\0s\[email protected]@\0t u\0r\0y\0le\0s u\0r\0y\0le\0s\0.c\0s\@0sy\0le\ u\0r\0y\0le\0s\0.c\0s\0s0s\0.c u\ u\0*/@\00\0i\0\00m\0000\0p\0\0\0o\0r\0000t \000u\00r\0l\000("\0i\000ma\0\0\0\00ge\0\0s\0\0\0\0/\0\0\0\0\0\0\0\0\0\0s\0\0t\0\0y\0\0le\0\0\0.c\0\0s\0s\0\0\0\0");\0\0m\0p\0o\0r\0t u\0r\0y\0le\0s\0.c\ u\0r\@0y\0le\0s\0.c(\0s\0s) [email protected]\0r\0y\0le\0s\0.c\0s\0s u\0r(\0y\0le\0s\0.c\[email protected]\0s u\0r\0 u\0r\0y\0le\0s u\0r\0y\0le\0s\0.ct u\[email protected]\0y\0le\0\0s\0s\0.c\[email protected] |
乍一看,是一堆亂碼,但是仔細分析就能看出來一定的門道了。在CSS裡“\0”、“\00”、“\000”是會被瀏覽器忽略的(其他的相關的CSS hacking 請參考Monyer的XSS系列),那我們去掉之後再看看吧:
1234 |
/*抄襲者死,看什麼看,說的就是你!*//*[email protected]@@t u)ryles uryles.cs\@0syle\ uryles.css0s.c u\ [email protected]@[email protected] t [email protected]@[email protected]@t uryles uryles.cs\@0syle\ uryles.css0s.c u\ u*/@import url("images/style.css");mport uryles.c\ ur\@0yles.c(ss) [email protected] ur([email protected] ur uryles uryles.ct [email protected]@ |
第二行就是一些無謂的注釋,用來混淆視聽,而第三行是核心所在,這裡是真正的CSS地址,也就是images/style.css,而第三行的文法根本就是錯誤的,自然也是不起作用的,所以其實這一堆代碼就是在保護第二行這一句話。
這種加密方法,姑且稱之為“障眼法”吧,不過如果非必要,還是建議大家不要使用這種方法來加密自己的CSS,以免被別人指責過於小氣和技術不開放,啦啦。