【发布时间】:2013-01-23 18:38:00
【问题描述】:
我通过以下方式使用“file_get_contents”:
(下面的脚本发布在,例如https://siteA.com/checkifvalid.php ...注意URL是httpS)
<?php
//there is a login form on this URL and the entries put in the form are used to set the username & password variables below.
$username = "someusername";
$password = "somepassword";
$secretkey = "slkd89087235";
$yesorno = file_get_contents("httpS://siteB.com/checkdatabase.php?username=$username&password=$password&secretkey=$secretkey");
if ($yesorno == 'yes') {
//details are valid, so something
} else {
//details aren't valid, display they aren't valid
}
?>
“checkdatabase.php”脚本使用 _GET 获取用户名和密码,并从 URL 中获取变量,然后交叉引用这些登录详细信息以查看它们是否有效。如果是,则回显“是”,如果不是,则回显“否”。
checkdatabase.php 脚本设置为仅在用户名、密码和密钥参数均已传递且已传递的密钥值与该 php 脚本中存储的密钥匹配时才运行。
对于在给定的时间范围内可以输入“http://siteA.com/checkifvalid.php”的次数也将有限制,以防止一种类型的“暴力”攻击猜测用户/通行证组合。
我的问题是,上述方法在两个 URL 都使用 httpS 的情况下有多安全?
我应该加密发送的值吗?或者上面的内容已经安全了吗?
【问题讨论】:
-
TCP 和 HTTP 之间的整个连接应该被加密,是否可以使用 cURL 来代替执行 POST 请求?
-
是的,cURL 是可用的……但是我不知道怎么用,哈哈。
-
这里有一个类似的问题线程stackoverflow.com/questions/893959/… 我会避免这种情况,以确保不会生成可能包含查询字符串参数的服务器日志
标签: php security file-get-contents