HTTP-REFERER这个变量已经越来越不可靠了,完全就是可以伪造出来的东东。
以下是伪造方法:
ASP/Visual Basic代码
dim http
set http=server.createobject("MSXML2.XMLHTTP") '//MSXML2.serverXMLHTTP也可以
Http.open "GET",url,false
Http.setRequestHeader "Referer","http://www.dc9.cn/"
Http.send()
PHP(前提是装了curl):
PHP代码
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://www.dc9.cn/xxx.asp");
curl_setopt ($ch, CURLOPT_REFERER, "http://www.dc9.cn/");
curl_exec ($ch);
curl_close ($ch);
PHP(不装curl用sock)
PHP代码
$server = 'www.dc9.cn';
$host = 'www.dc9.cn';
$target = '/xxx.asp';
$referer = 'http://www.dc9.cn/'; // Referer
$port = 80;
$fp = fsockopen($server, $port, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
$out = "GET $target HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Cookie: ASPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n";
$out .= "Referer: $referer\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp))
{
echo fgets($fp, 128);
}
fclose($fp);
}
VB.NET/C#.NET
C#代码
Dim oXMLHttp As MSXML2.XMLHTTP30 = New MSXML2.XMLHTTP30()
或者
MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30();
oXMLHttp.open(....
oXMLHttp.setRequestHeader(...
oXMLHttp.send(..