After having my Paypal account compromised I got a bit paranoid and wanted to secure everything in my sites. One of them includes renaming the admin/ page to something else, then I will put something like a honeypot to see which IP’s they are coming from:
<?
// 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>
My only concern right now is, can this form be attacked to gain access to the site? I don’t think sql injection can work here since we never used sql, nor injecting js to the output since it only outputs some fake text. After that I can’t think of anything else an attacker might get wise on…
What do you think? could there be a better way to track them down?
Now that you’ve posted the code here, you’ve spoiled the surprise. If you are going to use this code in production, change the code so it won’t be that easy to google.
Notes:
sleep(10)– this makes your server vulnerable to a denial of service attackI would avoid using a honey pot like this. Besides that not all form submissions are cracking attempts (I’ve seen bots submitting my forms which were “protected” with a simple text question), it may be challenging visitors with bad intentions. Do proper logging of requests and actions and let someone review your code.