在我的Paypal帐户遭到入侵后,我有点偏执,想要保护我网站中的所有内容。其中一个包括将管理员/页面重命名为其他内容,然后我会放一些类似蜜罐的内容来查看它们来自哪个IP:
<?
// honeypot
if($_POST['username']) {
sleep(10);
$filename = "intruders.txt";
$date = date('l jS \of F Y h:i:s A');
$handle = fopen($filename,"a+");
$content = "Username: $_POST[username] , Password: $_POST[password] $date ... from $_SERVER[REMOTE_ADDR] \n";
fwrite($handle,$content);
fclose($handle);
echo "<br/><b>Wrong username or password. Please try again</b><br/><br/>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WHMCS - Admin alt</title>
</head>
<body>
<form id='login' action='index.php' method='post' accept-charset='UTF-8'>
<fieldset>
<legend>WHMCS Secure alt Login</legend>
<label for='username' >Username*:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='Submit' value='Submit' />
</fieldset>
</form>
<div id="footer">Copyright © <a href="http://www.whmcs.com/" target="_blank">WHMCompleteSolution</a>. All Rights Reserved.</div>
</body>
</html>
我现在唯一担心的是,这种形式是否可以被攻击以获取对该网站的访问权限?我不认为sql注入可以在这里工作,因为我们从未使用过sql,也没有将js注入输出,因为它只输出一些假文本。在那之后,我想不出任何其他攻击者可能会明智的......
你怎么看?有没有更好的方法来追踪它们?答案 0 :(得分:2)
现在你已经在这里发布了代码,你已经破坏了惊喜。如果您打算在生产中使用此代码,请更改代码,以便谷歌不那么容易。
注意:
sleep(10)
- 这会使您的服务器容易遭受拒绝服务攻击我会避免使用像这样的蜜罐。除此之外,并非所有形式的提交都是破解尝试(我已经看到机器人提交我的表格,这些表格被一个简单的文本问题“保护”),它可能会挑战那些意图不好的访客。正确记录请求和操作,让别人检查您的代码。