php伪造来路跳转,用PHP伪造来路信息

function getUrl($address, $myip) {

ob_start();

$mtime = explode(' ', microtime());

$starttime = $mtime[1] + $mtime[0];

$onoff = (function_exists('ini_get')) ? ini_get('register_globals') : get_cfg_var('register_globals');

if($onoff != 1) {

@extract($_POST, EXTR_SKIP);

@extract($_GET, EXTR_SKIP);

}

$self = $_SERVER['PHP_SELF'];

$myaddress = 'http://'.$_SERVER['HTTP_HOST'].$self;

$comm = '';

if(isset($url) && $url) {

$url = str_replace($address, '', $url);

}

/*

foreach($_POST as $key => $val) {

if($comm == '') {

$comm = $key.'='.rawurlencode($val);

} else {

$comm = $comm.'&'.$key.'='.rawurlencode($val);

}

}

*/

$pcomm = '';

foreach($_POST as $key => $val) {

if($pcomm == '') {

$pcomm .= $key.''.urlencode($val);

} else {

$pcomm .= $pcomm.'&'.$key.'='.urlencode($val);

}

}

foreach($_GET as $key => $val) {

if($key != 'url') {

if($comm == '') {

$comm = $key.'='.rawurlencode($val);

} else {

$comm = $comm.'&'.$key.'='.rawurlencode($val);

}

}

}

if(!$url) {

$url = $address;

} else {

$url = $address.$url;

if($comm) {

if(strstr($url,'?')) {

$url = $url.'&'.$comm;

} else {

$url = $url.'?'.$comm;

}

}

}

if($url) {

$cookies= '';

if(count($_COOKIE)) {

foreach($_COOKIE as $cookie_name => $cookie_var) {

$cookies .= $cookies != '' ? '; '.$cookie_name.'='.$cookie_var : $cookie_name.'='.$cookie_var;

}

}

$temp = @parse_url($url);

$temp['port'] = isset($temp['port']) ? $temp['port'] : 80;

$temp['path'] = isset($temp['path']) ? $temp['path'] : '/';

$temp['file'] = substr($temp['path'], strrpos($temp['path'], '/')+1);

$temp['dir'] = substr($temp['path'], 0, strrpos($temp['path'], '/'));

$temp['base'] = $temp['scheme'].'://'.$temp['host'].($temp['port'] != 80 ? ':'.$temp['port'] : '').$temp['dir'];

$temp['prev_dir'] = $temp['path'] != '/' ? substr($temp['base'], 0, strrpos($temp['base'], '/')+1) : $temp['base'].'/';

$fp = @fsockopen($temp['host'], $temp['port'], $errno, $errstr, 30);

if($fp) {

if($_SERVER['REQUEST_METHOD'] != 'POST') {

@fputs($fp, "GET $temp[path]?$temp[query] HTTP/1.1\r\n");

} else {

@fputs($fp, "POST $temp[path]?$temp[query] HTTP/1.1\r\n");

}

@fputs($fp, "Host: $temp[host]\r\n");

@fputs($fp, "Accept: */*\r\n");

@fputs($fp, "Referer: http://$temp[host]/\r\n");

@fputs($fp, "Cookie: $cookies\r\n");

@fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值