PHP: Google translate token


<?php

/*
Copyright: www.tutorialspots.com
*/

//Unsigned right shift
function uRShift($a, $b)
{
    $z = hexdec(80000000);
    if ($z & $a)
    {
        $a = ($a >> 1);
        $a &= ( ~ $z);
        $a |= 0x40000000;
        $a = ($a >> ($b - 1));
    } else
    {
        $a = ($a >> $b);
    }
    return $a;
}
function hk($a, $b)
{
    for ($c = 0; $c < strlen($b) - 2; $c += 3)
    {
        $d = $b{$c + 2};
        $d = "a" <= $d ? ord($d) - 87 : intval($d);
        $d = "+" == $b{$c + 1} ? uRShift($a, $d) : ($a << $d);
        $a = "+" == $b{$c} ? $a + $d & 4294967295 : $a ^ $d;
    }
    return $a;
}
function ggtoken($a)
{
    $b = '406398.2087938574';

    $d = explode(".", $b);
    $b = ($d[0]);
    for ($e = array(), $f = 0, $g = 0; $g < strlen($a); $g++)
    {
        $l = (ord($a{$g}));
        $e[$f++] = $l;
    }
     
    $a = $b;
    for ($f = 0; $f < count($e); $f++)
    {
        $a += $e[$f];
        $a = hk($a, "+-a^+6");
    }

    $a = hk($a, "+-3^+b+-f");
    $a ^= (float)($d[1]);
    0 > $a && ($a = ($a & 2147483647) + 2147483648);

    $a = intval(substr($a, -6));
    $tk = ($a . "." . ($a ^ $b));
 
    return $tk;
}

PHP Google translate token

Example:

<?php

$a = 'РФ И СТРАНЫ В КОТОРЫХ ДОСТУП К НАШЕЙ ОСНОВНОЙ ГРУППЕ ЗАКРЫТ ИСПОЛЬЗУЙТЕ VPN РАСШИРЕНИЯ ДЛЯ БРАУЗЕРОВ НАПРИМЕР BROWSEC, ДЛЯ СМАРТФОНОВ НАПРИМЕР CLOUD VPN!!!';

echo ggtoken($a);
?>

Result:

974309.585371

Explain 1:

$b = '406398.2087938574';

view-source:https://translate.google.com/ you will see:

TKK=eval('((function(){var a\x3d2790548428;var b\x3d675265230;return 412094+\x27.\x27+(a+b)})())');

The value of TKK is change, but i can be a fixed value like ‘406398.2087938574’
Explain 2:

function hk($a, $b)

In the file: https://translate.google.com/translate/releases/twsfe_20161212_RC00/r/js/desktop_module_main.js you see:

hk=function(a,b){for(var c=0;c<b.length-2;c+=3){var d=b.charAt(c+2),d="a"<=d?d.charCodeAt(0)-87:Number(d),d="+"==b.charAt(c+1)?a>>>d:a<<d;a="+"==b.charAt(c)?a+d&4294967295:a^d}return a}

Explain 3:

function ggtoken($a)

In the file: https://translate.google.com/translate/releases/twsfe_20161212_RC00/r/js/desktop_module_main.js you see:

jk=function(a){var b;if(null!==ik)b=ik;else{b=gk(String.fromCharCode(84));var c=gk(String.fromCharCode(75));b=[b(),b()];b[1]=c();b=(ik=window[b.join(c())]||"")||""}var d=gk(String.fromCharCode(116)),c=gk(String.fromCharCode(107)),d=[d(),d()];d[1]=c();c="&"+d.join("")+
"=";d=b.split(".");b=Number(d[0])||0;for(var e=[],f=0,g=0;g<a.length;g++){var l=a.charCodeAt(g);128>l?e[f++]=l:(2048>l?e[f++]=l>>6|192:(55296==(l&64512)&&g+1<a.length&&56320==(a.charCodeAt(g+1)&64512)?(l=65536+((l&1023)<<10)+(a.charCodeAt(++g)&1023),e[f++]=l>>18|240,e[f++]=l>>12&63|128):e[f++]=l>>12|224,e[f++]=l>>6&63|128),e[f++]=l&63|128)}a=b;for(f=0;f<e.length;f++)a+=e[f],a=hk(a,"+-a^+6");a=hk(a,"+-3^+b+-f");a^=Number(d[1])||0;0>a&&(a=(a&2147483647)+2147483648);a%=1E6;return c+(a.toString()+"."+
(a^b))};

Leave a Reply