Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void http::steam_login(const QString &uname, const QString &pwd)
- {
- QNetworkProxy fiddler(QNetworkProxy::HttpProxy, "localhost", 8887);
- QNetworkProxy::setApplicationProxy(fiddler);
- this->login_state = 0; //log out
- delete this->cookieJar();
- this->setCookieJar(new QNetworkCookieJar());
- QString SG, emailsteamid, encrypted_password, pkey_mod, pkey_exp, timestamp;
- QByteArray buffer;
- QJsonDocument json_buffer;
- QNetworkCookie steam_timezone;
- steam_timezone.setDomain(".steampowered.com");
- steam_timezone.setPath("/");
- steam_timezone.setName("timezoneOffset");
- steam_timezone.setValue((QString::number(app::getTimeZoneOffset().toInt() * 3600) + ",0").toUtf8());
- this->cookieJar()->insertCookie(steam_timezone);
- QNetworkRequest request;
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded; charset=utf-8");
- request.setUrl(steam_getrsa);
- this->sync_post(request, QString("l=english").toUtf8());
- this->sync_post(request, QString("l=english").toUtf8());
- app::Application->log("Started Steam login process for \""+uname+"\"",1);
- QNetworkReply *reply = this->sync_post(request, QString("username=" + uname + "&l=english").toUtf8());
- buffer = reply->readAll();
- json_buffer = QJsonDocument::fromJson(buffer);
- delete reply;
- QStringList temp = json_buffer.object().keys();
- QString tee = json_buffer.object().empty();
- if (!json_buffer.object().value("success").toBool())
- {
- app::Application->log("Login failure at stage for user"+uname, 2);
- return;
- }
- pkey_mod = json_buffer.object().value("publickey_mod").toString();
- pkey_exp = json_buffer.object().value("publickey_exp").toString();
- timestamp = json_buffer.object().value("timestamp").toString();
- encrypted_password = get_encrypted_password(pwd, pkey_mod, pkey_exp);
- request.setUrl(steam_dologin);
- reply = this->sync_post(request, QString("username=" + uname + "&password=" + percent_encode(encrypted_password) + "&rsatimestamp=" + timestamp).toUtf8());
- buffer = reply->readAll();
- json_buffer = QJsonDocument::fromJson(buffer);
- delete reply;
- if (json_buffer.object().value("message").toString() != "SteamGuard")
- {
- app::Application->log("Login failure at stage 2 for user"+uname, 2);
- return;
- }
- emailsteamid = json_buffer.object().value("emailsteamid").toString();
- SG = app::Application->query("Enter Steam Guard code for \"" + uname+"\": ");
- SG = SG.toUpper();
- encrypted_password = get_encrypted_password(pwd, pkey_mod, pkey_exp);
- reply = this->sync_post(request, QString("username=" + uname + "&password=" + percent_encode(encrypted_password) + "&emailauth=" + SG + "&emailsteamid=" + emailsteamid + "&rsatimestamp=" + timestamp + "&remember_login=true").toUtf8());
- buffer = reply->readAll();
- json_buffer = QJsonDocument::fromJson(buffer);
- if (!json_buffer.object().value("login_complete").toBool())
- {
- app::Application->log("Login failure at stage 3 for user"+uname, 2);
- return;
- }
- pkey_mod = json_buffer.object().value("transfer_parameters").toObject().value("steamid").toString();
- pkey_exp = json_buffer.object().value("transfer_parameters").toObject().value("token").toString();
- timestamp = json_buffer.object().value("transfer_parameters").toObject().value("webcookie").toString();
- request.setUrl(steam_transfer);
- this->sync_post(request,QString("steamid="+pkey_mod+"&token="+pkey_exp+"&remember_login=true&webcookie="+timestamp).toUtf8());
- this->cookieJar()->setCookiesFromUrl(this->cookieJar()->cookiesForUrl(QUrl("https://store.steampowered.com/")),QUrl("http://steamcommunity.com/"));
- QNetworkCookie temp_cookie;
- QList<QNetworkCookie> cookies = this->cookieJar()->cookiesForUrl(steam_getrsa);
- for (int i=0;i<cookies.size();i++){
- temp_cookie=cookies[i];
- temp_cookie.setDomain(".steamcommunity.com");
- this->cookieJar()->insertCookie(temp_cookie);
- }
- app::Application->log("Successfully logged in as \""+uname+"\"",1);
- }
Advertisement
Add Comment
Please, Sign In to add comment