隐藏服务器的内部文件结构不在源中列出
Hide Internal File Structure of server from being listed on Sources
当我浏览我的网站并检查 google chrome 中的元素时,通过选择源选项卡,我可以获得我网站所有文件夹的列表。事实上,我得到了他们原来的名字,我可以下载整个网站的代码。
我只想隐藏真正的文件夹名称,因为人们可以使用该文件夹名称浏览内部网站
我该如何防止这种情况发生?我已经在 .htaccess 文件中列出了 Options -Indexes。
我正在使用 Joomla 并使用 Amazon EC2 Ubuntu 服务器,所以我可以完全控制服务器。
编辑:感谢 Pt。 Raman Sharma 和 LaughingQuoll。我真的不想隐藏 css 或 js。我只想隐藏真正的文件夹名称,因为人们可以使用该文件夹名称浏览内部网站
编辑:我的 .htaccess 文件:
IndexIgnore *
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
它应该只显示你的 css html 和 JS。这些是前端平台。您的后端 PHP 和 MYSQL 仍然隐藏。所以不用担心这些前端可见性。
CSS 无法隐藏JS链接。主要是因为它们用于显示页面,任何人都可以直接回到文件来源(这就是 Google chrome 所做的)。所以无论如何也藏不住。此外,如果您使用 CRT + S,则可以保存网页 CSS 和 JS。
我希望我已经正确理解了你的问题,如果是这样,那么你的问题并没有一个简单的答案。在 this question 中,他们解释了如何隐藏开发人员工具,这应该是您实现目标的良好起点:
Just to be clear: trying to block hackers client-side is a bad idea in general;
this is to protect against a specific social engineering attack.
If you ended up in the test group and are annoyed by this, sorry. I tried to
make the opt-out page as simple as
possible while still being scary enough to stop at least some of the
victims.
The actual code is pretty similar to @joeldixon66's link; ours is a little more complicated for no good reason.
Chrome wraps all console code in
with ((console && console._commandLineAPI) || {}) {
<code goes here>
}
... so the site redefines console._commandLineAPI
to throw:
Object.defineProperty(console, '_commandLineAPI',
{ get : function() { throw 'Nooo!' } })
This is not quite enough (try it!), but that's the main trick.
当我浏览我的网站并检查 google chrome 中的元素时,通过选择源选项卡,我可以获得我网站所有文件夹的列表。事实上,我得到了他们原来的名字,我可以下载整个网站的代码。
我只想隐藏真正的文件夹名称,因为人们可以使用该文件夹名称浏览内部网站
我该如何防止这种情况发生?我已经在 .htaccess 文件中列出了 Options -Indexes。
我正在使用 Joomla 并使用 Amazon EC2 Ubuntu 服务器,所以我可以完全控制服务器。
编辑:感谢 Pt。 Raman Sharma 和 LaughingQuoll。我真的不想隐藏 css 或 js。我只想隐藏真正的文件夹名称,因为人们可以使用该文件夹名称浏览内部网站
编辑:我的 .htaccess 文件:
IndexIgnore *
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
它应该只显示你的 css html 和 JS。这些是前端平台。您的后端 PHP 和 MYSQL 仍然隐藏。所以不用担心这些前端可见性。
CSS 无法隐藏JS链接。主要是因为它们用于显示页面,任何人都可以直接回到文件来源(这就是 Google chrome 所做的)。所以无论如何也藏不住。此外,如果您使用 CRT + S,则可以保存网页 CSS 和 JS。
我希望我已经正确理解了你的问题,如果是这样,那么你的问题并没有一个简单的答案。在 this question 中,他们解释了如何隐藏开发人员工具,这应该是您实现目标的良好起点:
Just to be clear: trying to block hackers client-side is a bad idea in general; this is to protect against a specific social engineering attack.
If you ended up in the test group and are annoyed by this, sorry. I tried to make the opt-out page as simple as possible while still being scary enough to stop at least some of the victims.
The actual code is pretty similar to @joeldixon66's link; ours is a little more complicated for no good reason.
Chrome wraps all console code in
with ((console && console._commandLineAPI) || {}) { <code goes here> }
... so the site redefines
console._commandLineAPI
to throw:Object.defineProperty(console, '_commandLineAPI', { get : function() { throw 'Nooo!' } })
This is not quite enough (try it!), but that's the main trick.