1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP script to Spoof referrer fooling Google !

Discussion in 'BlackHat Lounge' started by THEELITE, Aug 2, 2008.

  1. THEELITE

    THEELITE Newbie

    Joined:
    Feb 24, 2008
    Messages:
    18
    Likes Received:
    15
    Hi,

    I am not a PHP pro and needs to spoof referrer headers to make this PHP script work with Google Translate, Google seems to have changed their system and does not allow auto-translate.

    Code:
    http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_23046861.html
    PHP:
    <?php
    include("transoptions.php");

    $domain $_SERVER["HTTP_HOST"];

    if(!isset(
    $_GET["u"])){
      
    $_GET["u"] = "";
    }

    if(
    substr($_GET["u"], 07) != "http://"){
      
    $_GET["u"] = "http://" str_replace("//""/""$domain/$_GET[u]");
    }

    $files = array("english.php""spanish.php""german.php""french.php""italian.php""portuguese.php""japanese.php""korean.php""chinese.php""arabic.php");

    $md5 "tcache/" md5("http://" $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"] . "?" $_SERVER["QUERY_STRING"]);
    if(
    file_exists($md5)){
      if(
    time() < filemtime($md5) + 86400*$trans_cache_days $trans_cache_days == 0){
        
    $html file_get_contents($md5);
        echo 
    $html;
        exit;
      }
    }
    if(!isset(
    $_GET["u"])){
      
    $tgurl "http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=$lang&u=" urlencode("http://$domain$trans_folder") . "&prev=/language_tools";
      
    $html file_get_contents($tgurl);
      if(!
    $html){
        
    $html file_get_contents($tgurl);
      }
    }
    else{
      
    $parse parse_url($_GET["u"]);
      if(
    strtolower(str_replace("www."""$parse["host"]))==strtolower(str_replace("www."""$domain))){
        
    $langfile false;
        foreach(
    $files as $file){
          if(
    strpos($_GET["u"], $file)){
            
    $langfile true;
            
    header("Location: $_GET[u]");
            exit;
          }
        }
        
    $_GET["u"] = str_replace("http:/""http://"str_replace("//""/"$_GET["u"]));
        
    $html file_get_contents("http://64.233.179.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=$lang&u=" urlencode($_GET["u"]) . "&prev=/language_tools");
      }
      else{
        
    $ref $_SERVER["HTTP_REFERER"];
        
    $refparts parse_url($ref);
        if(
    $refparts["host"]==$domain){
          
    header("Location: $_GET[u]");
        }
        exit;
      }
    }

    $lparts explode("|"$lang);
    $html str_replace(array("<html>""<HTML>"), "<html lang=$lparts[1]>"$html);
    $html str_replace("<base href=""<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\"><meta http-equiv=\"content-language\" content=\"$lparts[1]\"><base href="$html);
    $ips = array("66.249.93.104""64.233.179.104""64.233.179.104");
    foreach(
    $ips as $ip){
      
    $html str_replace(array("http://$ip/translate_c?hl=en&ie=UTF-8&oe=UTF-8&",
                              
    "http://$ip/translate_c?hl=en&ie=UTF-8&oe=UTF-8&"), "$_SERVER[PHP_SELF]?"$html);
    }
    $html str_replace(array("&prev=/language_tools","&prev=/language_tools"), ""$html);
    $html str_replace(array("langpair=$lang""langpair=" urlencode($lang), "langpair=" str_replace("|""%7C"$lang)), ""$html);
    $html str_replace(array("?&u=""?&u="), "?u="$html);
    $parsed parse_url($_GET["u"]);
    $html str_replace("?u=http://$domain""?u="$html);
    echo 
    $html;
    if(
    $html){
      
    $fh fopen($md5"w+");
      
    fwrite($fh$html);
      
    fclose($fh);
    }
    ?>
     
  2. aftershock2020

    aftershock2020 Senior Member

    Joined:
    Oct 19, 2007
    Messages:
    981
    Likes Received:
    477
    Check this out. It helped me to construct the same thing you are trying to do for my site. You'd think that the auto-translate features would be so much better due to it being Goo*gle but obviously, it isn't.

    This will point you in the right direction.

    Hope it helps.

    Link didn't post...here it is.

    Here: hxxp://www.ka*ptainkra*yola.com/p*hp-auto-tran*slate-text-via-go*ogle-trans*late/

    Change " x " to " t " and only remove " * " , not the hyphens.
     
  3. THEELITE

    THEELITE Newbie

    Joined:
    Feb 24, 2008
    Messages:
    18
    Likes Received:
    15
    Thanks, will look at this and update.

    Update:
    As I said I am not a PHP pro so dont know how to get this work on my site, can you pls. share your script or code.
     
    Last edited: Aug 3, 2008
  4. karkar

    karkar Newbie

    Joined:
    Oct 1, 2008
    Messages:
    13
    Likes Received:
    0
    Could you let me know how to use this script on your site to translate on fly aftershock2020
    thanks
    :beach2:
     
  5. goawayplease

    goawayplease Regular Member

    Joined:
    Apr 10, 2008
    Messages:
    299
    Likes Received:
    67
    Doesn't Google Translate have an API?
     
  6. businessminder

    businessminder BANNED BANNED

    Joined:
    Oct 22, 2009
    Messages:
    243
    Likes Received:
    369
    Google translate does have an API so I don't see why the above script is needed.
    Whats with the IPs?

    $ips = array("66.249.93.104", "64.233.179.104", "64.233.179.104");

    Are those your servers? If they are I'd be a little careful with that.
     
  7. karkar

    karkar Newbie

    Joined:
    Oct 1, 2008
    Messages:
    13
    Likes Received:
    0
    But that's not the whole script .where is the transoptions.php in the first line:hmmmm2:
     
  8. aftershock2020

    aftershock2020 Senior Member

    Joined:
    Oct 19, 2007
    Messages:
    981
    Likes Received:
    477
  9. demoniox

    demoniox Registered Member

    Joined:
    Mar 5, 2007
    Messages:
    98
    Likes Received:
    83