Hi all... I'm eric, CyberNac's cousin. I'm down in Bogota Colombia for the week bustin' ass on another biz so haven't hardly had time for my own cousin much less this forum. My eyes are bugging out from doing QuickBooks all friggin' day, so I'd thought I'd take a little break and put out some comments.
First, I'm really taken aback that my crappy little PHP hack has garnered some interest. Major props to MoneyMafia for extending the code and supporting the community.
Second, I wanted to point out a few things regarding the script. As MoneyMafia said, it's barely been tested so anybody trying this is a guina pig. FWIW, the site we deployed it on has seen an increase of signifigant size while her organic traffic hasn't increased much, if at all. Thus, its reasonable to suggest that there *might* be something here. However, Alexa doesn't appear to update their stats servers (by my math there are about 8-10 different nodes) all that often... perhaps weekly. So, it could take time for the ballot stuffing to take effect.
Third, the script kinda assumes that you have traffic to begin with. IMHO, the reason WHY Alexa, Compete and the whole lot of them that rely on client submission of data SUCK EGGS that it's pretty easy to duplicate... thus the ballot stuffing.
Assume for a minute that the alexa client is installed on 5 in 100 computers. To estimate your traffic, alexa assumes that your real traffic must be 20 times whatever value they got. Anybody who stayed awake even one day in statistics would realize how stupid this is. (A website dedicated to PHD-Level supercomuting discussions probably *isn't* frequented by people silly enough to install a piece of crap toolbar like Alexa.)
The way this script works is by duplicating the trigger that Alexa uses for EVERY visitor... not just those with the toolbar installed. So, using the example above, (and assuming the code actually works) you'd be inflating your traffic rate by a factor of 20.
Heres the kicker though: If you don't have traffic to begin with, this script is essentially worthless. It's important to understand that the trigger activates when a client "loads" an image that has this code as it's source. This is what causes the source IP to be the client rather than the server, or your own desktop. But if nobody is visiting your site to begin with, then the trigger won't happen, get it?
Anyway, I just thought i'd throw that out. Sorry i haven't been around to help out. If it helps make up for it, heres my experiment with Compete.com:
PHP:
<?php
// This information was gleened from the windows registry and is used in the UserAgent string
$CfgVer = "1809"; //
$DCAVer = "1809"; //
$UserID = rand(500000,2500000); // Hopeing it's okay to make this random...
$RulesVer = "0008"; //
ini_set('user_agent', 'mayflower/'.$CfgVer.'/'.$DCAVer.'/'.$UserID.'/'.$RulesVer); // This is the useragent used by the compete.com toolbar
// set some more variables
$domain = "http://66.151.182.194/fast-cgi/ClickServer"; // The URL that receives the ClickData
$ts = time(); // Local Timestamp based on seconds from epoch
$bua = "N/A"; // No clue
$meth = "get"; // No clue
$eid = "300"; // No clue
$fid = "NULL"; // No clue
$bin = "5178486"; // No clue
$url = "http://www.yourwebsitehere.com/"; // The site being clicked on
$md5 = "00000000000000000000000000000000"; // A MD5 hash of the above information (the specifics on how the secret is constructed is unknown.
// We stuff the variable with junk initially. This will be used to get correct value later.
// $data is the payload for the HTTP POST method
$data = "md5=".$md5."&ts=".$ts."&bua=".$bua."&meth=".$meth."&eid=".$eid."&fid=".$fid."&bin=".$bin."&url=".$url;
// We submit a first (and probably invalid) request to obtain short XML-like markup reply. within this reply is the real MD5 hash.
// we then extract that hash for use later.
$result = request($domain, $data);
$hash = substr($result,strpos($result,"<md5>")+5,32);
// So, we take the hash and generate a new payload with the correct MD5 hash
$md5 = $hash;
$data = "md5=".$md5."&ts=".$ts."&bua=".$bua."&meth=".$meth."&eid=".$eid."&fid=".$fid."&bin=".$bin."&url=".$url;
// Resend the request, this time with the correct hash value.
echo request($domain, $data);
// This function sends the HTTP POST data.
function request($url, $data)
{
$fp = @fopen($url, 'rb', false, stream_context_create(array('http'=>array('method'=>'POST','content'=>$data))));
$response = @stream_get_contents($fp);
return $response;
}
?>
Now, before anybody gets all crazy here, the above does NOT work like the alexa code. I'll elaborate:
This was was a little bit tougher. See, the folks at compete actually make an attempt to filter out ballot stuffing... Fortunately, their attempt is totally half assed. What they do is include in the POST DATA a MD5 hash of the information being reported back ***and*** some secret code which I couldn't figure out.
But thats really okay, because if you send them a invalid POST, they respond anyway, and part of the response includes the *correct* MD5 hash. So, you just take that value and activate the trigger again. Stupid, huh? Hopefully they weren't intending to use MD5 as a security method.
The only other important thing is that they use a custom user agent string that must be duplicated otherwise their server rejects it. And this is what makes it worth not too much more that an experiment. You see, there is no way to change the user agent string on a client... at least not that i am aware of. (My first thought was JavaScript, but the window.agent string is read-only, so... no joy.)
Anyway, consider the above an experiment for those inclined to explore.
If anybody can figure out a way to do the following, i'd be excited to hear about it:
- TASK A -
Figure out how submit a HTTP POST request from a client merely by having the client load the page. (I do not think this is possible)
- TASK B -
Figure out how to change the useragent on the client for one transaction only. Only client side scripting is allowed. (I do not think this is possible either)
Saludos,
Eric