[英].htaccess password protection broken
不久前,我建立了一個網站,其中包含一個公共區域和一個私人區域。 在包含敏感信息的相關目錄上,.htaccess密碼保護了私有區域的安全。
一切都經過了全面的測試,並且運行良好,直到最近一段時間才引起我的注意,該數據可以在沒有任何用戶名和密碼的情況下免費提供給全世界。 該數據不是核導彈的發射代碼,但我仍然希望將其保密信息僅限於授權用戶。
我與網絡托管公司聯系,並獲得了兩個假定的密碼保護為什么不起作用的原因。 考慮到以前的工作原理,我很難接受他們的理由。
他們首先聲稱我的.htaccess文件無效。 因此,他們創建了一個新的訪問者,但同樣也沒有阻止訪問。 我的原始.htaccess文件在下面。
他們接下來聲稱這是因為我的index.html文件包含javascript。 它調用了兩個javascript文件。 第一個(下面)只是簡單地對CSS文件的調用進行了document.write。 第二個(下面)做了document.writes搜索表單和下拉菜單。 每個包含index.html的html文件都稱為這兩個腳本。
他們證明了最初的診斷是錯誤的,因為他們的.htaccess版本沒有幫助。 (這只是我代碼的最后4行)。 因此問題是,僅通過添加一些在屏幕上寫入菜單的簡單javascript,就可以打破.htaccess密碼保護的功能,如果是的話,該文件在網絡上的位置如何?
可以想象javascript可能會影響下拉菜單中項目的安全性,但是建議位於受保護目錄中的index.html本身應該突然無須密碼訪問,這完全是不合邏輯的,僅僅是因為它包含可寫的javascript菜單。
這是我原始的.htaccess文件:
Options -Indexes
AddHandler x-httpd-php .html .htm
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>
<Files index.html>
AuthUserFile "/home/xxxxxxxx/.htpasswds/public_html/private/passwd"
AuthName "private"
</Files>
這是我的index.html的開始:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>xxxxxxxx Private Area</title>
<script type="text/javascript" src="header1.js"></script>
</head>
<body onload="document.searchbox.query.focus()">
<div class="page">
<script type="text/javascript" src="header2.js"></script>
這是header1.js:
document.write('<link href="../menus.css" rel="stylesheet" type="text/css" />');
document.write('<!--[if lt IE 7]>');
document.write('<style type="text/css" media="screen">');
document.write('body{behavior:url(csshover.htc);}');
document.write('</style>');
document.write('<![endif]-->');
這是header2.js的開始(模糊了一些行以保護無辜者):
document.write(' <form action="sphider29/search.php" method="get" name="searchbox" target="_blank">');
document.write(' <table align="right">');
document.write(' <tr>');
document.write(' <td align="center">');
document.write(' <input type="text" name="query" id="query" size="25" value="" />');
document.write(' </td>');
document.write(' <td align="center">');
document.write(' <input type="hidden" name="search" value="1" />');
document.write(' <input type="submit" class="sbmt" value="Site Search" />');
document.write(' </tr>');
document.write(' </table>');
document.write(' <div align="center">');
document.write(' <input type="hidden" name="media_only" value="0" />');
document.write(' <input type="hidden" name="db" value="0" />');
document.write(' <input type="hidden" name="prefix" value="0" /> <br />');
document.write(' </div>');
document.write(' </form>');
document.write('<div style="position: absolute; left: 10px; top: 70px; width: 960px; height: 40px;">');
document.write('<ul class="menuH decor1">');
document.write(' <li style="margin-left:70px;"><a href="../">Home</a>');
document.write(' <li> <a class="parent">xxxxx</a>');
document.write(' <ul>');
document.write(' <li><a class="parent">xxxxxxxxx</a>');
document.write(' <ul>');
document.write(' <li><a href="xxxxxxxxxxxx.pdf" target="_blank">yyyy</a></li>');
document.write(' <li><a href="xxxxxxxxxxxxx.pdf" target="_blank">yyyy</a></li>');
document.write(' <li><a href="xxxxxxxxxx.pdf" target="_blank">yyyy</a></li>');
document.write(' <li><a href="xxxxxxxxxxx.pdf" target="_blank">yyyy</a></li>');
document.write(' <li><a href="xxxxxxxxxxxx.pdf" target="_blank">yyyy</a></li>');
如果問題是Javascript,那么如果我擺脫了它,並且全部在PHP中使用菜單代碼包含PHP,那可以解決此問題嗎?
根據托管公司的說法,我的代碼很好。 他們沒有完全解釋引起問題的其他地方的其他文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.