Skip to content

Commit

Permalink
Grab and store Steam auth ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
RubberDuckShobe committed Feb 27, 2024
1 parent 1ef54e7 commit 7459a50
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wavebreaker_client"
version = "0.1.0"
version = "3.0.0"
edition = "2021"

[lib]
Expand Down Expand Up @@ -29,4 +29,4 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
figment = { version = "0.*", features = ["toml", "env"] }
crochet = "0.2.3"
lofty = "0.18.2"
urlencoding = "2.1.3"
url_encoded_data = "0.6.1"
22 changes: 16 additions & 6 deletions src/hooking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use lofty::TaggedFileExt;
use tracing::debug;
use tracing::error;
use tracing::trace;
use url_encoded_data::UrlEncodedData;
use windows::core::PCSTR;
use windows::Win32::Networking::WinInet::INTERNET_FLAG_RELOAD;
use windows::Win32::Networking::WinInet::INTERNET_FLAG_SECURE;
Expand Down Expand Up @@ -108,16 +109,25 @@ unsafe fn send_hook(
CString::from_vec_unchecked(headers.as_bytes().to_vec()),
data
);
let mut data = UrlEncodedData::parse_str(data);

let mut global_data = state::GLOBAL_DATA.lock().unwrap();

// store ticket for our own uses
if data.exists("ticket") {
let ticket = data.get_first("ticket").unwrap();
global_data.ticket = Some(ticket.to_string());
debug!("Ticket found in data: {:?}", ticket);
}

// really crude way to find out if this is a score submission
let global_data = state::GLOBAL_DATA.lock().unwrap();
if data.contains("artist=")
&& data.contains("song=")
&& data.contains("score=")
if data.exists("artist")
&& data.exists("song")
&& data.exists("score")
&& global_data.current_mbid.is_some()
{
let encoded_mbid = urlencoding::encode(global_data.current_mbid.as_ref().unwrap());
let new_data_string = data.to_string() + "&mbid=" + &encoded_mbid;
data.set_one("mbid", global_data.current_mbid.as_ref().unwrap());
let new_data_string = data.to_string_of_original_order();
debug!("New score submission form data: {:?}", new_data_string);

// allocate new string
Expand Down
3 changes: 2 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::sync::Mutex;

pub struct GlobalData {
pub current_mbid: Option<String>,
pub ticket: Option<String>,
}

pub static GLOBAL_DATA: Mutex<GlobalData> = Mutex::new(GlobalData { current_mbid: None });
pub static GLOBAL_DATA: Mutex<GlobalData> = Mutex::new(GlobalData { current_mbid: None, ticket: None });

0 comments on commit 7459a50

Please sign in to comment.