秘密查询字符串是限制访问和隐藏非安全站点内容的合理方法吗?
所以我要提前说,显然我知道这实际上并不安全,请不要为此责备我。我只是从懒惰的角度对这个问题感兴趣。
我有一个网站,其中包含一些我想向公众“隐藏”的信息。没有什么重要或脆弱的事情;我只是不想让人们找到它并弄乱它。我已经有了一个 robots.txt 文件,禁止所有抓取。该页面上没有链接(或者不会有其他网站到此页面的链接)。
设置
example.com 会将您带到“您无权访问”页面,而 example.com?real=fun 实际上会为您获取内容。除非查询键/值对正确,否则 PHP 不会实际运行该页面。那么,我是否可以合理地假设没有人会偶然找到此页面,并且即使他们偶然找到此页面,他们也将无法进入其中的内容?
是的,我很懒,但我还是想知道。
• 编辑 • 我不是在寻找“如何做到这一点”。我已经做到了。正确的答案将解决人们是否还有其他基本方法可以进入使用此技术的页面。
So I'll say right up front, obviously I know this is not actually secure, don't beat me up over that. I'm just interested in the question from a lazyness standpoint.
I have a website that has some information that I'd like to "hide" from the general public. Nothing important or vulnerable; I just don't really want people to find it and mess with it. I've already got a robots.txt file disallowing all crawling. There are no links on the page (or will be no links from other sites to this one).
The setup
example.com takes you to a "You are not allowed access" page, while example.com?real=fun actually gets you the content. PHP will not actually run the page unless the query key/value pair is correct. So is it reasonable for me to assume that no one will find this page by accident, and on the offchance they do, that they won't be able to get into the content?
Yes, I'm lazy, but I'd still like to know.
• edit •
I'm not looking for "how to do this". I've already done it. The correct answer would address if there are other basic ways for a person to get into the page which uses this technique.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
是的,可以合理地假设他们无法访问内容,因为 Apache 会看到一个 index.php 请求并简单地处理资源。他们不可能简单地猜测您在后端服务器中硬编码的内容,除非它就像某些共享网络托管并且服务器上的其他用户可以看到您目录的内容。
将其添加到 www.example.com 根目录的 index.php 文件顶部
Yes, it's reasonable to assume they won't be able to get into the contents because Apache will see an index.php request and simply deal out the resource. There is no way they can simply just guess what you've hardcoded in the backend server unless it's like some shared web hosting and other users on the server can see the contents of your directory.
Add this at the top of the index.php file for the root of www.example.com
您依靠默默无闻的安全性。它在一定程度上有效,但你不应该指望它。您的问题的答案是“是”,这是合理的,但不要在生产中依赖它。
最好的方法是使用 Basic Http Auth 仅允许具有登录凭据的用户访问页面。
一种稍微懒惰的方法是显示一个没有信息的表单,他们必须输入一些随机字符串并提交它。如果字符串正确,它将在服务器上设置一个会话,允许他们访问该页面。
You're relying on security by obscurity. It works up to a certain extent, but you shouldn't count on it. The answer to your question is "yes" it is reasonable, but don't rely on it in production.
The best way to do this would be to use Basic Http Auth to only permit those with login credentials to access the page(S).
A slightly more lazy way would be to display a form with no information, and they would have to enter some random string and submit it. If the string is correct, it would set a session on the server that would allow them to access the page.
这肯定是比设置密码更好的“隐藏”某些内容的方法。受密码保护的站点显然意味着有东西隐藏在栅栏后面,而秘密查询字符串基本上不会泄露任何内容。
另一方面,如果秘密字符串泄露,那么您的安全系统就会遭到破坏。如果提供了秘密查询,我建议加倍并触发常规登录页面。然后您就可以继续工作,而不必在 URL 中保留查询字符串(并且如果您链接到任何外部内容,则不会显示在其他站点的引用日志中)。
通过这种方式,您可以获得所需登录的安全性,甚至不会出现明显的“这里有安全内容”的额外安全性。
It'd certainly be a better way of "hiding" something than putting on a password. A password protected site obviously implies there's something hiding behind the fence, while the secret query string essentially gives away nothing.
On the other hand, if the secret string leaks, then your security system is torpedoed. I'd suggest doubling-down and triggering a regular login page if the secret query is provided. Then you can work away without having to keep the query string in view in the URL (and wouldn't show up in other sites' referer logs if you link to anything external).
This way you get the security of a required login, with the extra security of not even having obvious in-your-face "there is secured content here".
如果您并不严重担心安全性,而只是想让人们远离某些页面,那么您有几种选择。再次澄清一下,我不会仅仅依靠这些想法来实现银行式安全......
系统是设置cookie或者session
您可以检查 id 是否
用户已在您的每个页面上登录
想要保护。没那么难!只是不要将会话的值设置为您不希望被劫持的值。
文件或文件夹,这是一个快速
以及将人们拒之门外的肮脏方式
的某事。
源认证系统可以是
相对容易地插入。
给你一个完整的身份验证系统,
基本完成并准备出发。
If you're not seriously concerned about security and are just trying to keep people off a few pages, you've got a few options. Again, just to clarify, I wouldn't rely on these ideas solely for banking-style security....
system is to set a cookie or session
id that you can check to see if the
user is logged in on each page you
want to protect. It's not that difficult! Just don't set the value of the session to something that you don't want hijacked.
files or folders, which is a quick
and dirty way of keeping people out
of something.
source auth systems that can be
relatively easily bolted in.
give you an entire auth system,
basically done and ready to go.
“合理”是根据上下文来定义的。新奇的页面背后没有什么真正敏感的东西?当然。请记住,如果您曾经向任何人发送过“隐藏”链接,他们可以轻松地将其发布到某个 IRC 聊天室中,或者当您不在时,某人可以查看您的浏览器历史记录。键盘。请记住,任何了解
example.com/index.php?real=fun
的人都可以到达那里。一旦他们知道了,“没人可能知道”就帮不了你了。现在,如果您确实对安全性感兴趣,您可以在数据库中的某个位置设置一个临时 ID 值,其中包含随机生成的 6 或 8 字符哈希值和到期日期(例如一天)。向朋友发送电子邮件
example.com/index.php?real=8AC02F
,他将可以在一天左右的时间内访问该内容。编写一个密码脚本来生成哈希值和到期日期并将其存储在数据库中。不要忘记删除过期哈希值的 cron 脚本,你不想把事情弄得一团糟。
"Reasonable" is defined by the context. Novelty page with nothing really sensitive behind it? Sure. Just keep in mind that if you've ever sent the "hidden" link to anyone, they can just as easily post it in some IRC chat room somewhere, or someone can take a peek through your browser history while you're away from your keyboard. Remember, anyone that knows of
example.com/index.php?real=fun
can get there. "Nobody could possibly know" won't help you once they know.Now, if you're really interested in security you could set up a temporary ID value in a database somewhere, with a randomly generated 6 or 8 character hash and an expiry date (of, say, one day). Email a friend
example.com/index.php?real=8AC02F
, and he'll have access to that content for a day or so. Write a passworded script to generate a hash and expiry date and store them in database.Don't forget the cron script to remove expired hashes, you don't want to make a mess of things.
您问这个解决方案是否“合理”。由于您显然不是指“安全”,因此不清楚您的意思。我猜你的意思是“可能且易于实施”,在这种情况下,答案是是。但请随意编辑您的问题以使其更加清晰。
You're asking if this solution is "reasonable". Since you obviously don't mean "secure", it's unclear what you do mean. I'm going to guess you mean "possible and easy to implement", in which case the answer is yes. But feel free to edit your question to make it more clear.