绕过 Steam 网站上的年龄检查(使用 PHP curl)

Bypass age check on Steam website (with PHP curl)

我知道,已经有关于此的讨论帖了……请参阅 ……但我是新用户,无法在现有讨论帖中发表评论,也无法在其中将答案标记为解决方案不再工作了。

我有自己的代码,在过去(2017 年左右)运行良好,但现在也不起作用了。

这是我过去有效的代码:

function curl_redirect_exec2($ch, &$redirects, $curlopt_header = false) {
    $ckfile = tempnam(sys_get_temp_dir(), "CURLCOOKIE");
    curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'snr=1_agecheck _agecheck__age-gate&ageDay=1&ageMonth=May&ageYear=1990');
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
    //new start
    curl_setopt($ch, CURLOPT_COOKIE, 'mature_content=1; path=/app/'.$gameid.';');
    //new end
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if($http_code == 301 || $http_code == 302) {
        list($header) = explode("\r\n\r\n", $data, 2);
        $matches = array();
        preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
        $url = trim(array_pop($matches));
        $url_parsed = parse_url($url);
        if(isset($url_parsed)) {
            curl_setopt($ch, CURLOPT_URL, $url);
            $redirects++;
            return curl_redirect_exec2($ch, $redirects);
        }
    }
    if($curlopt_header) {
        return $data;
    } else {
        list(,$body) = explode("\r\n\r\n", $data, 2);
        return $body;
    }
}

这是上面链接的线程中的代码示例,它在过去似乎也有效(但现在无效):

<?php
$url = "http://store.steampowered.com/app/312660/";
// $file = __DIR__ . DIRECTORY_SEPARATOR . "cookie.txt";
// $postData = array(
// 'ageDay' => '31',
// 'ageMonth' => 'July',
// 'ageYear' => '1993'
// );
$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
curl_setopt($ch,CURLOPT_POSTFIELDS,$postData);
// curl_setopt($ch,CURLOPT_COOKIESESSION, true);
// curl_setopt($ch,CURLOPT_COOKIEJAR,$file); 
// curl_setopt($ch,CURLOPT_COOKIEFILE,$file);
$strCookie = 'mature_content=' . 1 . '; path=/';
curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );

curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);

curl_close($ch);
echo $data;
?>

到目前为止我测试了什么:

您可以以游戏“RUST”为例:https://store.steampowered.com/app/252490/

页面重定向到年龄检查:https://store.steampowered.com/agecheck/app/252490/

我看到 cookie 集现在使用其他名称(“wants_mature_content”而不是 JavaScript 中的“mature_content”),但即使在更改 PHP 要用新名字,不行。

JavaScript 来自 Steam 页面的代码:

function HideAgeGate( )
{
  var bHideAll = false;
  console.log(bHideAll);
  var strCookiePath = bHideAll ? '/' : "\/app\/252490";
  V_SetCookie( 'wants_mature_content', 1, 365, strCookiePath );

  document.location = "https:\/\/store.steampowered.com\/app\/252490\/Rust\/?snr=";
}

编辑:我还在 https://store.akamai.steamstatic.com/public/shared/javascript/shared_global.js 中找到了函数“V_SetCookie” ... 由上面的代码调用:

function V_SetCookie( strCookieName, strValue, expiryInDays, path )
{
    if ( !path )
        path = '/';

    var strDate = '';

    if( typeof expiryInDays != 'undefined' && expiryInDays )
    {
        var dateExpires = new Date();
        dateExpires.setTime( dateExpires.getTime() + 1000 * 60 * 60 * 24 * expiryInDays );
        strDate = '; expires=' + dateExpires.toGMTString();
    }

    document.cookie = strCookieName + '=' + strValue + strDate + ';path=' + path;
}

有人可以帮忙吗? :-) 谢谢!

好的,成功了。

实际上有 3 个 cookie:“wants_mature_content”、“lastagecheckage”和“birthtime”

打开一个包含年龄检查的页面,例如Chrome,单击“查看页面”,然后在 chrome 中查找 3 个 cookie(及其内容)。使用 PHP 的 curl 设置所有 3 个 cookie,它正在工作 ;-)

这对我有用

<?php 

$url = 'https://store.steampowered.com/bundle/5699/Grand_Theft_Auto_V_Premium_Edition/';

$ch = curl_init();
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Cookie: birthtime=470682001;lastagecheckage=1-0-1985;']);
$html = curl_exec($ch);
curl_close($ch);

var_dump($html);