Redirect Script with Referrer Spoofing Required.

Discussion in 'PHP' started by NotFound, Nov 17, 2008.

  1. #1
    Looking for a script doing the following:

    Let's say I have a link on www.container.ext. The link connects to www.link.ext/link.php?ID=123. There is an array in link.php contains a list of URLs that I want the script to redirect to. There should be another array of referrers that I want to spoof the destination site with. When a visitor clicks the link on www.container.ext, s/he will be redirected to www.target.ext with a whatever referrer I want.

    I don't mind paying for it. Please let me know your price.

    Budget: $40.
     
    NotFound, Nov 17, 2008 IP
  2. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think I need to mention that I need it in PHP, do I?

    This is *NOT* what I want:
    <?php header("location: http://www.whatever.ext"); ?>

    nor meta refresh.
     
    NotFound, Nov 17, 2008 IP
  3. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #3
    Then theres only a way to read the script from the domain.

    For example an user comes on your domain. (domain.com) but yuo want the user to see yourdomain.com then you need to readfile/fopen/curl the content of yourdomain.com and display it to the user on domain.com but you will miss alot of images/scripts/stylesheets and other things.

    It's just best to use header/javascript/meta refresh
     
    EricBruggema, Nov 19, 2008 IP
  4. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have done readfile/fopen/curl. It was haunted by the problems with relative paths.ß
     
    NotFound, Nov 19, 2008 IP
  5. xcrox

    xcrox Banned

    Messages:
    232
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    <?
    $url="any url";
    header("Location: $url");
    ?>
     
    xcrox, Nov 20, 2008 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    It's possible to work around the relative path problems with a single preg_replace call.

    If you want to spoof referers, your ONLY option is cURL/etc.
     
    joebert, Nov 20, 2008 IP
  7. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It won't work. it always gives an error like "header already sent".
     
    NotFound, Nov 20, 2008 IP
  8. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Mind share some tips? Appreciated.
     
    NotFound, Nov 20, 2008 IP
  9. !Unreal

    !Unreal Well-Known Member

    Messages:
    1,671
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    165
    #9
    I tried this but cURL can only control the server. It has nothing over the client which is the important thing here unfortunatly.

    Unless there is a way to do this with something like Javascript I dont think its possible.
     
    !Unreal, Nov 20, 2008 IP
  10. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #10
    Try adding ob_start(); before the <?php and ob_end_flush(); before the end of your code e.g.
    
    <?php
    ob_start();
    $locationurl = "http://google.com";
    header("location: $locationurl");
    ob_end_flush(); 
    ?>
    
    PHP:
     
    dannywwww, Nov 20, 2008 IP
  11. Shoro

    Shoro Peon

    Messages:
    143
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #11
    It's impossible to redirect a user to a site and have the referrer spoofed, because the referrer header is sent by the user, not the server that they're being redirected from.
     
    Shoro, Nov 20, 2008 IP
  12. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    That's the point. It's being sent by the user, so as a user, I should be able to send an incorrect referer.
     
    NotFound, Nov 20, 2008 IP
  13. NotFound

    NotFound Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    No errors, and redirect was successful, but correct referers will still show up with and without header("Referer: $referer");
     
    NotFound, Nov 20, 2008 IP
  14. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #14
    cURL is the only option for spoofing a referer for a page request because the server acts as the visitor and can tell the destination server whatever it wants, if the visitors browser gets ahold of the URL all bets are off.

    The following will apply a <base> url to the page using the address the page is comming from to force inpage resources to go to the server they're on.

    For instance if the requested URL is "http://domain.com/folder/page.html" then $url will be "http://domain.com/folder/".

    $base_url = "<base href='{$url}'>";
    $html_returned_from_curl = preg_replace('#(<base[^>]+>|</head>#i', $base_url, $html_returned_from_curl);
    Code (markup):
    If the host matches resource requests up to page requests to detect spoofing this will fail however, since the images/css/etc will return the referer as the page you're showing the visitor on your domain.
     
    joebert, Nov 21, 2008 IP
  15. eric90

    eric90 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    The header function only works if no output has been displayed in the browser window. Once something is printed to screen it no longer works. To get around that problem, i just use javascript form autosubmit that submits to a page that only contains the header function.

    But to answer your main question, cURL is the best way for what you wanna do, since you can manually set the referrer.
     
    eric90, Nov 21, 2008 IP