-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import: add support for importing steam mobile app v2 format, remove …
…`--sda` argument (#307) - add account schema for steam app v2 - make it possible to import steam v2 accounts - import: remove the `--sda` flag, the format should be detected automatically - add unit tests - make it actually work closes #305
- Loading branch information
Showing
5 changed files
with
152 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use secrecy::SecretString; | ||
use serde::{Deserialize, Deserializer}; | ||
use serde_json::Value; | ||
use steamguard::{token::TwoFactorSecret, SteamGuardAccount}; | ||
use uuid::Uuid; | ||
|
||
/// Defines the schema for loading steamguard accounts extracted from backups of the official Steam app (v2). | ||
/// | ||
/// ```json | ||
/// { | ||
/// "steamid": "X", | ||
/// "shared_secret": "X", | ||
/// "serial_number": "X", | ||
/// "revocation_code": "X", | ||
/// "uri": "otpauth:\/\/totp\/Steam:USERNAME?secret=X&issuer=Steam", | ||
/// "server_time": "X", | ||
/// "account_name": "USERNAME", | ||
/// "token_gid": "X", | ||
/// "identity_secret": "X", | ||
/// "secret_1": "X", | ||
/// "status": 1, | ||
/// "steamguard_scheme": "2" | ||
/// } | ||
/// ``` | ||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct SteamMobileV2 { | ||
#[serde(deserialize_with = "de_parse_number")] | ||
pub steamid: u64, | ||
pub shared_secret: TwoFactorSecret, | ||
pub serial_number: String, | ||
#[serde(with = "crate::secret_string")] | ||
pub revocation_code: SecretString, | ||
#[serde(with = "crate::secret_string")] | ||
pub uri: SecretString, | ||
pub server_time: Option<serde_json::Value>, | ||
pub account_name: String, | ||
pub token_gid: String, | ||
#[serde(with = "crate::secret_string")] | ||
pub identity_secret: SecretString, | ||
#[serde(with = "crate::secret_string")] | ||
pub secret_1: SecretString, | ||
pub status: Option<serde_json::Value>, | ||
pub steamguard_scheme: Option<serde_json::Value>, | ||
} | ||
|
||
impl From<SteamMobileV2> for SteamGuardAccount { | ||
fn from(account: SteamMobileV2) -> Self { | ||
Self { | ||
shared_secret: account.shared_secret, | ||
identity_secret: account.identity_secret, | ||
revocation_code: account.revocation_code, | ||
uri: account.uri, | ||
account_name: account.account_name, | ||
token_gid: account.token_gid, | ||
serial_number: account.serial_number, | ||
steam_id: account.steamid, | ||
// device_id is unknown, so we just make one up | ||
device_id: format!("android:{}", Uuid::new_v4()), | ||
secret_1: account.secret_1, | ||
tokens: None, | ||
} | ||
} | ||
} | ||
|
||
fn de_parse_number<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u64, D::Error> { | ||
Ok(match Value::deserialize(deserializer)? { | ||
Value::String(s) => s.parse().map_err(serde::de::Error::custom)?, | ||
Value::Number(num) => num | ||
.as_u64() | ||
.ok_or(serde::de::Error::custom("Invalid number"))?, | ||
_ => return Err(serde::de::Error::custom("wrong type")), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"steamid": "76561199441992970", | ||
"shared_secret": "kSJa7hfbr8IvReG9/1Ax13BhTJA=", | ||
"serial_number": "5182004572898897156", | ||
"revocation_code": "R52260", | ||
"uri": "otpauth://totp/Steam:afarihm?secret=SERFV3QX3OX4EL2F4G676UBR25YGCTEQ&issuer=Steam", | ||
"server_time": "123", | ||
"account_name": "afarihm", | ||
"token_gid": "2d5a1b6cdbbfa9cc", | ||
"identity_secret": "f62XbJcml4r1j3NcFm0GGTtmcXw=", | ||
"secret_1": "BEelQHBr74ahsgiJbGArNV62/Bs=", | ||
"status": 1, | ||
"steamguard_scheme": "2" | ||
} |