PHP page jump and Cross station submit forged Referer address source

Source: Internet
Author: User
Tags curl explode

First, the attempted URL jump method

The code is as follows Copy Code

Echo ' <meta http-equiv= ' refresh "content=" 0; Url= '. $url. ' " > ';

Echo ' <scrīpt language= ' javascrīpt ' >window.location.href= '. $url. ' "; </scrīpt> ';

Echo ' <script language= ' javascrīpt ' >window.location.replace= '. $url. ' "; </script> ';

None of the above three methods can deliver the Referer address.

Second, use PHP socket function to forge refer
Here is the section of the PHP forged Referer code, which is tested to implement Referer address delivery, where $url is the input address.

The code is as follows Copy Code

$uinfo = Parse_url ($url);//Resolve URL address, such as http://111cn.net/archives/1.html

if ($uinfo [' path '])//

$data = $uinfo [' path '];//here get/archives/1.html

Else

$data = '/';//default Root

if (! $FSP = @fsockopen ($uinfo [' Host '], (($uinfo [' Port '])? $uinfo [' Port ']: "("), $errno, $errstr, 12)) {

echo "I'm sorry. The other site is temporarily unable to open, please visit later:". $uinfo [' Host ']; Exit

}else{

Fputs ($FSP, "get". $data. " Http/1.0rn ");//If it is a cross station post submission, you can use the Post method

Fputs ($FSP, "host:". $uinfo [' Host ']. " RN ");

Fputs ($FSP, "referer:111cn.netrn")//Forged Referer Address

Fputs ($FSP, "user-agent:mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.1) rnrn ");

$res = ';

while (!feof ($FSP)) {

$res. =fgets ($FSP, 128);

if (Strstr ($res, "OK")) {

Header ("Location: $url"); Exit

}

}

}

If the 301 or 302 status code can continue processing

Return address approximate form: http/1.1 moved permanentlyncontent-length:164ncontent-type:text/htmlnlocation:http://111cn.net/

$arr =explode ("n", $res);

$arr =explode (":", $arr [3]);//location behind is true redirect address

Header ("Location:". $arr [0]);//Jump Destination Address

Exit


Use another method to curl) Forge Http_referer

The code is as follows Copy Code

PHP (provided the curl is installed):
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://www.111cn.net/");
curl_setopt ($ch, Curlopt_referer, "http://www.111cn.net/");
Curl_exec ($ch);
Curl_close ($ch);

PHP (not installed curl with sock)
$server = ' blog.qita.in ';
$host = ' blog.qita.in ';
$target = '/xxx.asp ';
$referer = ' http://www.baidu.com/'; Referer
$port = 80;
$fp = Fsockopen ($server, $port, $errno, $errstr, 30);
if (! $fp)
{
echo "$errstr ($errno) <br/>n";
}
Else
{
$out = "Get $target http/1.1rn";
$out. = "Host: $hostrn";
$out. = "COOKIE:ASPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEGRN";
$out. = "Referer: $refererrn";
$out. = "Connection:closernrn";
Fwrite ($fp, $out);
while (!feof ($FP))
{
Echo fgets ($FP, 128);
}
Fclose ($FP);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.