I've been trying to make simple Steam bot for sending announcements to Steam group by logging in to Steam page and then sending annoucement. I got stuck in logging in. Here is what I have:
include('Math/BigInteger.php');
include('Crypt/RSA.php');
$url = 'http://store.steampowered.com/login/getrsakey/'; // here I get public key
$data = array('username' => 'user'); // I'm sending username by POST method
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$result = json_decode($result)
// And this is part that don't work:
$rsa = new Crypt_RSA();
$key = array(
'n' => new Math_BigInteger($result->publickey_mod,16),
'e' => new Math_BigInteger($result->publickey_exp,2)
);
$rsa->loadKey($key);
$password = $rsa->encrypt("password"); // encrypting password
$data = array(
'username' => 'user',
'password' => $password,
'twofactorcode'=> "",
'emailauth'=> "",
'loginfriendlyname'=> "",
'captchagid'=> "",
'captcha_text'=> "",
'emailsteamid'=> "",
'rsatimestamp'=> $result->timestamp,
'remember_login'=> "false"
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
And result is:
{"success":false}
Problem is that encrypted password does not look same as when I encrypted it with javascript functions which are used by Steam. So I tried encrypting password in javascript and then just paste it in PHP code but that didn't work either.
Any help would be appreciated.