can request trade confirmations, don't know if parsing works

This commit is contained in:
Carson McManus 2021-04-04 17:48:44 -04:00
parent 36c4b7c819
commit d64bf5cade
2 changed files with 46 additions and 19 deletions

0
src/accountlinker.rs Normal file
View file

View file

@ -1,8 +1,11 @@
use std::{collections::HashMap, convert::TryInto, thread, time}; use std::{collections::HashMap, convert::TryInto, thread, time};
use hmacsha1::hmac_sha1; use hmacsha1::hmac_sha1;
use regex::Regex;
use reqwest::{Url, cookie::CookieStore, header::{COOKIE, USER_AGENT}}; use reqwest::{Url, cookie::CookieStore, header::{COOKIE, USER_AGENT}};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use log::*; use log::*;
#[macro_use]
extern crate lazy_static;
pub mod steamapi; pub mod steamapi;
@ -13,6 +16,11 @@ pub mod steamapi;
// const TWO_FACTOR_BASE: String = STEAMAPI_BASE + "/ITwoFactorService/%s/v0001"; // const TWO_FACTOR_BASE: String = STEAMAPI_BASE + "/ITwoFactorService/%s/v0001";
// static TWO_FACTOR_TIME_QUERY: String = TWO_FACTOR_BASE.Replace("%s", "QueryTime"); // static TWO_FACTOR_TIME_QUERY: String = TWO_FACTOR_BASE.Replace("%s", "QueryTime");
lazy_static! {
static ref CONFIRMATION_REGEX: Regex = Regex::new("<div class=\"mobileconf_list_entry\" id=\"conf[0-9]+\" data-confid=\"(\\d+)\" data-key=\"(\\d+)\" data-type=\"(\\d+)\" data-creator=\"(\\d+)\"").unwrap();
static ref CONFIRMATION_DESCRIPTION_REGEX: Regex = Regex::new("<div>((Confirm|Trade|Account recovery|Sell -) .+)</div>").unwrap();
}
extern crate hmacsha1; extern crate hmacsha1;
extern crate base64; extern crate base64;
extern crate cookie; extern crate cookie;
@ -129,14 +137,21 @@ impl SteamGuardAccount {
// confirmation details: // confirmation details:
let url = "https://steamcommunity.com".parse::<Url>().unwrap(); let url = "https://steamcommunity.com".parse::<Url>().unwrap();
let cookies = reqwest::cookie::Jar::default(); let cookies = reqwest::cookie::Jar::default();
let session_id = self.session.clone().unwrap().session_id; let session = self.session.clone().unwrap();
let cookie_val = format!("sessionid={}", session_id); let session_id = session.session_id;
cookies.add_cookie_str(cookie_val.as_str(), &url); cookies.add_cookie_str("mobileClientVersion=0 (2.1.3)", &url);
cookies.add_cookie_str("mobileClient=android", &url);
cookies.add_cookie_str("Steam_Language=english", &url);
cookies.add_cookie_str("dob=", &url);
cookies.add_cookie_str(format!("sessionid={}", session_id).as_str(), &url);
cookies.add_cookie_str(format!("steamid={}", session.steam_id).as_str(), &url);
cookies.add_cookie_str(format!("steamLogin={}", session.steam_login).as_str(), &url);
cookies.add_cookie_str(format!("steamLoginSecure={}", session.steam_login_secure).as_str(), &url);
let client = reqwest::blocking::ClientBuilder::new() let client = reqwest::blocking::ClientBuilder::new()
.cookie_store(true)
.build() .build()
.unwrap(); .unwrap();
loop {
match client match client
.get("https://steamcommunity.com/mobileconf/conf".parse::<Url>().unwrap()) .get("https://steamcommunity.com/mobileconf/conf".parse::<Url>().unwrap())
.header("X-Requested-With", "com.valvesoftware.android.steam.community") .header("X-Requested-With", "com.valvesoftware.android.steam.community")
@ -145,13 +160,25 @@ impl SteamGuardAccount {
.query(&self.get_confirmation_query_params("conf")) .query(&self.get_confirmation_query_params("conf"))
.send() { .send() {
Ok(resp) => { Ok(resp) => {
info!("{:?}", resp); trace!("{:?}", resp);
break; let text = resp.text().unwrap();
trace!("text: {:?}", text);
match CONFIRMATION_REGEX.captures(text.as_str()) {
Some(caps) => {
let conf_id = &caps[1];
let conf_key = &caps[2];
let conf_type = &caps[3];
let conf_creator = &caps[4];
debug!("{} {} {} {}", conf_id, conf_key, conf_type, conf_creator);
}
_ => {
info!("No confirmations");
}
}
} }
Err(e) => { Err(e) => {
error!("error: {:?}", e); error!("error: {:?}", e);
thread::sleep(time::Duration::from_secs(3)); return;
}
} }
} }
} }