功能如下:通过ie地址栏直接输入:http://www.xxx.com/a.php在a.php当中直接用js或者php 重新定向到http://baidu.com我想让百度认为我的来源是:http://google.cn前提是我想在a.php当中重新定向到,http://baidu.com这个页面之后让用户看到http://baidu.com这个页面,当然如果不想让用户看到http://baidu.com这个页面的话.可以用curl模拟浏览器头设置来源就可以,部然后用curl问http://baidu.com就可以了。不知道如果想实现上面所述功能应当在a.php当中做些什么,请各位老师指点,谢谢了

解决方案 »

  1.   

    构造http的头就可以满足你的要求了
      

  2.   

    POST /service/sql.aspx HTTP/1.1
    Accept: */*
    Referer: http://www.yto.net.cn/
    Accept-Language: zh-cn
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB5; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    Host: www.yto.net.cn
    Content-Length: 60
    Connection: Keep-Alive
    Cache-Control: no-cache
    Cookie: ASPSESSIONIDCSTTBATQ=PNIDLGMCOLGIFIOCNFCFCOGF; ASPSESSIONIDCQTTDATR=NEJHHHDDCKEFDCOGLJAMNDFGNumberText=2171011262&yanma=6384&loginvip.x=20&loginvip.y=24这是一个http的请求,只要你请求的时候,构造上面的头,就能达到你的要求。
    需要构造的地方主要有这几个 referer,cookie,host这些。当然,最好就是全部构造成ie的样子来伪造。你的问题,要伪造的是Referer。
      

  3.   

    谢谢楼上的朋友,关键是如何在a.php当中伪造Referer。之后通过a.php访问http://baidu.com
    并实际打开http://baidu.com(可以让用户看到百度的首页),并让百度页面的Referer为:http://google.cn呢?
      

  4.   

    第一个问题,比较好解决,就用file打开baidu,然后再做正则表达替换所有没有带http:://那些连接阿,图片阿,替换到baidu那里去。再用echo显示出来就可以了。(这样子做,baidu的referer会认为是浏览器直接输入地址的)第二个问题,就相对复杂点。我没有仔细研究过file等等取得网页的函数,相信也不能用。你需要用fsockopen来构造http请求。你看看手册的fsockopen就知道了PHP Manual 
    后退  前进 
      
     
     fsockopen
    (PHP 3, PHP 4 , PHP 5)fsockopen --  Open Internet or Unix domain socket connection 
    Description
    resource fsockopen ( string target, int port [, int errno [, string errstr [, float timeout]]])
    Initiates a socket connection to the resource specified by target. PHP supports targets in the Internet and Unix domains as described in 附录 N. A list of supported transports can also be retrieved using stream_get_transports(). 注: If you need to set a timeout for reading/writing data over the socket, use stream_set_timeout(), as the timeout parameter to fsockopen() only applies while connecting the socket. As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host. fsockopen() returns a file pointer which may be used together with the other file functions (such as fgets(), fgetss(), fwrite(), fclose(), and feof()). If the call fails, it will return FALSE and if the optional errno and errstr arguments are present they will be set to indicate the actual system level error that occurred in the system-level connect() call. If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket. Note that the errno and errstr arguments will always be passed by reference. Depending on the environment, the Unix domain or the optional connect timeout may not be available. The socket will by default be opened in blocking mode. You can switch it to non-blocking mode by using stream_set_blocking(). 例子 1. fsockopen() Example<?php
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    } else {
        $out = "GET / HTTP/1.1\r\n";
        $out .= "Host: www.example.com\r\n";
        $out .= "Connection: Close\r\n\r\n";    fwrite($fp, $out);
        while (!feof($fp)) {
            echo fgets($fp, 128);
        }
        fclose($fp);
    }
    ?>  
     
    The example below shows how to retrieve the day and time from the UDP service "daytime" (port 13) in your own machine. 例子 2. Using UDP connection<?php
    $fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
    if (!$fp) {
        echo "ERROR: $errno - $errstr<br />\n";
    } else {
        fwrite($fp, "\n");
        echo fread($fp, 26);
        fclose($fp);
    }
    ?>  
     警告 
    UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data. 
     注: 当指定数字的 IPv6 地址(例如 fe80::1)时必须将 IP 地址放在方括号内。例如 tcp://[fe80::1]:80。注: The timeout parameter was introduced in PHP 3.0.9 and UDP support was added in PHP 4. See also pfsockopen(), stream_set_blocking(), stream_set_timeout(), fgets(), fgetss(), fwrite(), fclose(), feof(), and the Curl extension.    
    后退 起点 前进 
    dns_get_record 上一级 gethostbyaddr 
     
     
      

  5.   

    学着他这样做就可以的了<?php
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    } else {
        $out = "GET / HTTP/1.1\r\n";
        $out .= "Host: www.example.com\r\n";
        $out .= "Connection: Close\r\n\r\n";    fwrite($fp, $out);
        while (!feof($fp)) {
            echo fgets($fp, 128);
        }
        fclose($fp);
    }
    ?> 
      

  6.   

    你们都看清楚点吧。他要的是重定向。header('http://www.baidu.com');
    不是让你模拟一个连接。他要在百度看到的ip是客户的而不是你服务器的。
    这是根本做不到的。除非你黑了客户的IE。或是让客户使用你写的游览器。
      

  7.   

    那就更简单了,直接a到google的一个跳转连接,让google帮你跳不就成了嘛我以为你要的是地址栏看不到baidu的地址。
      

  8.   

    http://www.google.com/url?q=http://www.baidu.com/&sa=X&oi=unauthorizedredirect&ct=targetlink&ust=1247197894880215&usg=AFQjCNFpikFChFrvb0QUwPw__KezX3LF8w
      

  9.   


    用vc或者delphi写一个activex,让ax来做
      

  10.   

    正式签名的activex认证麻烦,每年还要交钱给微软。
    写无签名activex就相当于黑客户端了,一般有点安全意识的人都不会装的。
      

  11.   

    而且我想这种修改客户来源的activex也通不过微软认证。
      

  12.   

    这个方法确实不错,可是我想让来源为:http://google.cn多一个也不要,有办法没?
      

  13.   

    其实我提出的问题,还有另外一种解决方案。如果能实现js跨域访问iframe当中的节点也可以实现,不知道
    js跨域目前能实现吗?不用插件。
      

  14.   

    js能实现跨域。前提是你让google在他的页里面远程嵌入你的js。实现此功能的办法只有2种:
    1.正规的办法,不犯法的。联系google公司让他们帮你跳转。
    2.写黑客软件控制客户机器(找到微软未被发现的bug加以利用)。
      

  15.   

    http://www.cnblogs.com/interdrp/archive/2009/05/03/1448382.htmlax的免费签名
      

  16.   


    再次请教:Gdj
    请问一下如果实现js跨域访问a.php当中框架(test)<iframe name="test" id="test" src="http://126.com"></iframe>
    的元素的话,必须在http://126.com当中嵌入我的js代码才能实现吗?有其它办法没有?
    我在想别人网站的页面也不充许放入我的js代码啊?如果我有在别人页面加入js代码的权限,也就不需要这样麻烦了。
    呵呵,个人想法,还请gdj指教
      

  17.   

    在别人页面加入js代码?这个属于xss攻击范畴。