Forum Moderators: open
83.23.202.99 - - [22/Jan/2013:12:30:44 -0800] "GET / HTTP/1.1" 200 2526 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:30:39"
83.23.202.99 - - [22/Jan/2013:12:30:44 -0800] "GET /wp-login.php?action=register HTTP/1.1" 403 928 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:30:40"
83.23.202.99 - - [22/Jan/2013:12:30:45 -0800] "GET /register.php HTTP/1.1" 403 928 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:30:41"
83.23.202.99 - - [22/Jan/2013:12:30:45 -0800] "GET /admin.php HTTP/1.1" 403 928 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:30:41"
<snip, snip for a total of 15 requests>
83.23.202.99 - - [22/Jan/2013:12:47:57 -0800] "GET /add HTTP/1.1" 404 912 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:47:52"
83.23.202.99 - - [22/Jan/2013:12:47:57 -0800] "GET /otwarty_admin/ HTTP/1.1" 404 912 "-" "Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 2013-01-22 21:47:53" Just tack your current server time onto the end of your UA string and nobody will ever be able to block you.
/^Mozilla\/(?P<mozversion>(?P<mozmajor>\d{1,2})\.(?P<mozminor>\d{1,2})) \((?P<platform>X11|Maemo|Macintosh|Windows NT \d{1,2}\.\d{1,2}|Android);(?:.*)\) Gecko\/\d{1,10}(\.\d{1,2}){0,3} Firefox\/(?P<foxversion>\d{1,2}(\.\d{1,2}){0,3})$/ /^Mozilla\/(?P<mozversion>(?P<mozmajor>\d{1,2})\.(?P<mozminor>\d{1,2})) \(compatible; MSIE (?P<version>(?P<major>\d{1,2})\.(?P<minor>\d{1,2})); Windows (?P<windows>(XP|CE|95|98; Win 9x 4\.90|98|NT (?P<winversion>(?P<winmajor>\d{1,2})\.(?P<winminor>\d{1,2}))))(?:;|\))(?P<fragment1>.*?)(?:\)|$)(?P<fragment2>.*$)/ FWIW, the regex for Safari/Chrome/Firefox are almost all identical which makes MSIE the odd browser out in this process.
?P<mozversion> Did you collect those?
?P<mozversion>
Shared hosting, remember.
<?php
$ip = get_server('REMOTE_ADDR');
$fh = fopen("headers-". date('Ymd') . ".log","a");
fwrite($fh, "IP: $ip\n");
foreach (getallheaders() as $name => $value) {
fwrite($fh, "$name: $value\n");
}
fwrite($fh, "----\n\n");
fclose($fh);
?>
# Now log all headers for static web pages
php_value auto_prepend_file "/var/www/vhosts/example.com/logheaders.php"
# Map all static pages to a PHP handler, add more if needed
AddType application/x-httpd-php .htm .html
# Now log all headers for static web pages
php_value auto_prepend_file "/var/www/vhosts/example.com/logheaders.php"
/var/www/vhosts/can be altered to the actual path to where we put the logheaders.php file, right? - or will this be prepended to files in subdomains as well? Guess testing will tell, these hosting accounts are not all set up the same way.
To test it just run logheaders.php directly and then look at the contents of the headers-YYYYMMDD.log file it created.
Fatal error: Call to undefined function get_server()
Fatal error: Call to undefined function getallheaders()
<?php
function get_server($var) {
return isset($_SERVER[$var]) ? $_SERVER[$var] : false;
}
$ip = get_server('REMOTE_ADDR');
$fh = fopen("headers-". date('Ymd') . ".log","a");
fwrite($fh, "IP: $ip\n");
foreach (getallheaders() as $name => $value) {
fwrite($fh, "$name: $value\n");
}
fwrite($fh, "----\n\n");
fclose($fh);
?>
<?php
function get_server($var) {
return isset($_SERVER[$var]) ? $_SERVER[$var] : false;
}
if (!function_exists('getallheaders'))
{
function getallheaders()
{
$headers = '';
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$ip = get_server('REMOTE_ADDR');
$fh = fopen("headers-". date('Ymd') . ".log","a");
fwrite($fh, date('Y-m-d:') . date("H:i:s\n"));
fwrite($fh, "IP: $ip\n");
foreach (getallheaders() as $name => $value) {
fwrite($fh, "$name: $value\n");
echo "$name: $value<br>";
}
fwrite($fh, "----\n\n");
fclose($fh);
?>
give me a little time
I think almost all my pages now have a php include.
<?php
function get_server($var) {
return isset($_SERVER[$var]) ? $_SERVER[$var] : false;
}
if (!function_exists('getallheaders'))
{
function getallheaders()
{
$headers = '';
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$ip = get_server('REMOTE_ADDR');
$fh = fopen("headers-". date('Ymd') . ".log","a");
fwrite($fh, date('Y-m-d:') . date("H:i:s\n"));
fwrite($fh, "IP: $ip\n");
foreach (getallheaders() as $name => $value) {
fwrite($fh, "$name: $value\n");
}
fwrite($fh, "----\n\n");
fclose($fh);
?>
<cfsilent>
<cfscript>
function rdnsLookUp(address) {
var iaclass="";
var addr="";
iaclass=CreateObject("java", "java.net.InetAddress");
addr=iaclass.getByName(address);
return addr.getCanonicalHostName();
}
</cfscript>
<cfset x = GetHttpRequestData()>
<cfset rdnsTimeStart = now()>
<cfsavecontent variable="headers"><cfoutput>
#chr(13)##chr(13)#-----------------------------
ip: #cgi.REMOTE_ADDR#
remote host: #rdnsLookUp(cgi.REMOTE_ADDR)# (#DateDiff('s', now(), rdnsTimeStart)#)
time: #now()#
http_content: #x.content#
method: #x.method#
protocol: #x.protocol#
<cfloop collection = "#x.headers#" item = "http_item">
#chr(13)##http_item#: #StructFind(x.headers, http_item)#</cfloop>
</cfoutput></cfsavecontent>
<cffile action="append" addnewline="yes"
output="#headers#"
file="#GetDirectoryFromPath(GetCurrentTemplatePath())#headers.txt">
</cfsilent>
OOPS!
I left in a debugging ECHO statement while testing it on FastCGI
fopen("headers-". date('Ymd') . ".log","a"); if the host that allows php includes (running PHP 5.2 or earlier) goes to cloud based file serving, in all probability they will upgrade to PHP 5.3 or greater and your php includes will likely break (no matter what type handler you use in htaccess.)
<!--#include virtual="/directory/filename.xtn" --> include ($_SERVER['DOCUMENT_ROOT'] . "/directory/filename.php"); AddType text/html .html [edited by: lucy24 at 1:08 am (utc) on Jan 24, 2013]
php includes will likely break
<?php
include("parts/menu.php");
?> but the cloud based schema that drops PHP globals and includes
Is the Apache environment getting set correctly?
Sounds like they'll need to fix this as it would break a lot of software.
All this shared hosting / cloud hosting issues is exactly why I have my own dedicated servers.
Yah, but this is your day job, right?
It also makes it much easier to do bot blocking when you deploy server-wide solutions vs. going account to account.
any thing in particular you'd recommend to check for within the server headers, and do/have you ban based on something within the headers?