Advertisement
Eugene_Krayzie

STEAM AUTH

Oct 26th, 2017
2,639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1.     function get_acces_token($username, $password, $mobile = true){
  2.         global $UTIL;
  3.         require_once("./phpseclib/Crypt/RSA.php");
  4.        
  5.         $cookies = array(
  6.             "mobileClientVersion"   => "0 (2.1.3)",
  7.             "mobileClient"          => "android",
  8.             "Steam_Language"        => "english"
  9.             );
  10.         $headers = $UTIL->createCookie($cookies);
  11.         $headers[] = "X-Requested-With: com.valvesoftware.android.steam.community";
  12.         $headers[] = "Referer: https://steamcommunity.com/login?oauth_client_id=DE45CD61&oauth_scope=read_profile%20write_profile%20read_client%20write_client";
  13.  
  14.         $response = $UTIL->curl("https://store.steampowered.com/login/getrsakey", "username=".$username, $headers);
  15.         $auth = json_decode($response, true);
  16.         $rsa = new Crypt_RSA();
  17.         $modulus = new Math_BigInteger($auth["publickey_mod"], 16);
  18.         $exponent = new Math_BigInteger($auth["publickey_exp"], 16);
  19.  
  20.         $key = array('modulus' => $modulus, 'publicExponent' => $exponent);
  21.         $rsa->setPublicKey($key);
  22.         $rsa->loadKey($key, CRYPT_RSA_PUBLIC_FORMAT_RAW);
  23.         $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
  24.         $enc_password = base64_encode($rsa->encrypt($password));
  25.        
  26.         $parameter = array(
  27.             "username"          => $username,
  28.             "password"          => $enc_password,
  29.             "twofactorcode"     => $this->generateSteamGuardCode(),
  30.             "rsatimestamp"      => $auth["timestamp"],
  31.             "donotcache"        => time()."777"
  32.             );
  33.         if($mobile){
  34.             $parameter['oauth_client_id']   = 'DE45CD61';
  35.             $parameter['oauth_scope']       = 'read_profile write_profile read_client write_client';
  36.             $parameter['loginfriendlyname'] = '#login_emailauth_friendlyname_mobile';
  37.         }
  38.  
  39.         $response = $UTIL->curl("https://steamcommunity.com/login/dologin/", http_build_query($parameter), $headers);
  40.         $json = json_decode($response, true);
  41.        
  42.         if($mobile){
  43.             $json = json_decode($json["oauth"], true);
  44.             $access_token = $json["oauth_token"];
  45.             if($access_token != null){
  46.                 $UTIL->log("новый access_token=".$access_token);
  47.                 return $access_token;
  48.             }
  49.             else{
  50.                 $UTIL->log("ошибка получения access_token");
  51.             }
  52.         }
  53.         else{
  54.             //добавить не мобилу
  55.         }
  56.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement