private void btnGetSteamGuardData_Click(object sender, EventArgs e)
        {
            var iosBackups = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                          "Apple Computer", "MobileSync", "Backup");

            if (!Directory.Exists(iosBackups))
            {
                txtResults.Text = @"No ios backups found";
                return;
            }
            foreach (var d in Directory.GetDirectories(iosBackups))
            {
                var name = new DirectoryInfo(d).Name;
                if (!File.Exists(Path.Combine(d, "Manifest.mbdb")))
                {
                    txtResults.AppendText($"Directory {name} is not a valid ios backup, skipping" + Environment.NewLine + Environment.NewLine);
                    continue;
                }
                txtResults.AppendText($"Processing Directory {name}" + Environment.NewLine);
                var data       = File.ReadAllBytes(Path.Combine(d, "Manifest.mbdb"));
                var steamfiles = Encoding.UTF8.GetBytes("AppDomain-com.valvesoftware.Steam");
                for (var index = 0; ; index += steamfiles.Length)
                {
                    index = SearchBytes(data, steamfiles, index);
                    if (index == -1)
                    {
                        break;
                    }
                    var index2  = index + steamfiles.Length;
                    var filelen = data[index2] << 8 | data[index2 + 1];
                    var temp    = new byte[filelen];
                    Array.Copy(data, index2 + 2, temp, 0, filelen);
                    var steamfilename = Encoding.UTF8.GetString(temp);
                    if (!steamfilename.StartsWith("Documents/Steamguard-"))
                    {
                        continue;
                    }
                    var hash =
                        new SHA1Managed().ComputeHash(
                            Encoding.UTF8.GetBytes("AppDomain-com.valvesoftware.Steam-" + steamfilename));
                    var hashstr = BitConverter.ToString(hash).Replace("-", "");
                    if (File.Exists(Path.Combine(d, hashstr)))
                    {
                        txtResults.AppendText($"Processing {steamfilename}" + Environment.NewLine);
                        try
                        {
                            var sgdata = BinaryPropertyListParser.Parse(File.ReadAllBytes(Path.Combine(d, hashstr)));
                            var sglist = ((NSArray)((NSDictionary)sgdata)["$objects"]).GetArray();
                            var auth   = new SteamAuthenticator()
                            {
                                SharedSecret     = sglist[14].ToString(),
                                Uri              = sglist[15].ToString(),
                                Steamid          = sglist[16].ToString(),
                                RevocationCode   = sglist[17].ToString(),
                                SerialNumber     = sglist[18].ToString(),
                                TokenGid         = sglist[19].ToString(),
                                IdentitySecret   = sglist[20].ToString(),
                                Secret           = sglist[21].ToString(),
                                ServerTime       = sglist[22].ToString(),
                                AccountName      = sglist[23].ToString(),
                                SteamguardScheme = sglist[24].ToString(),
                                Status           = sglist[25].ToString()
                            };
                            txtResults.AppendText(Environment.NewLine);

                            txtResults.AppendText("In WinAuth, Add Steam Authenticator. Select the Import Android Tab" +
                                                  Environment.NewLine + Environment.NewLine);

                            txtResults.AppendText("Paste this into the steam_uuid.xml text box" + Environment.NewLine);
                            txtResults.AppendText($"android:{name}" + Environment.NewLine + Environment.NewLine);

                            txtResults.AppendText(
                                "Paste the following data, including the {} into the SteamGuare-NNNNNNNNN... text box" +
                                Environment.NewLine);

                            txtResults.AppendText(JsonConvert.SerializeObject(auth, Formatting.Indented) +
                                                  Environment.NewLine + Environment.NewLine);
                        }
                        catch (PropertyListFormatException) //The only way this should happen is if we opened an encrypted backup.
                        {
                            txtResults.AppendText("Error: Encrypted backups are not supported. You need to create a decrypted backup to proceed." + Environment.NewLine);
                            break;
                        }
                        catch (Exception ex)
                        {
                            txtResults.AppendText($"An Exception occurred while processing: {ex.Message}");
                        }
                    }
                    else
                    {
                        txtResults.AppendText($"Error: {steamfilename} is missing from ios backup, aborting" + Environment.NewLine);
                        break;
                    }
                }

                txtResults.AppendText("Done" + Environment.NewLine + Environment.NewLine);
            }
        }
Example #2
0
        private bool ProcessSteamGuardFile(string filename, string filepath, string deviceID)
        {
            txtResults.AppendText($"Processing {filename}" + Environment.NewLine);
            try
            {
                var sgdata = BinaryPropertyListParser.Parse(File.ReadAllBytes(filepath));
                var sglist = ((NSArray)((NSDictionary)sgdata)["$objects"]).GetArray();
                var auth   = new SteamAuthenticator()
                {
                    DeviceID = $"android:{deviceID}"
                };

                for (var i = 2; i < 14; i++)
                {
                    switch (sglist[i].ToString())
                    {
                    case "shared_secret":
                        auth.SharedSecret = sglist[i + 12].ToString();
                        break;

                    case "uri":
                        auth.Uri = sglist[i + 12].ToString();
                        break;

                    case "steamid":
                        auth.Steamid = sglist[i + 12].ToString();
                        break;

                    case "revocation_code":
                        auth.RevocationCode = sglist[i + 12].ToString();
                        break;

                    case "serial_number":
                        auth.SerialNumber = sglist[i + 12].ToString();
                        break;

                    case "token_gid":
                        auth.TokenGid = sglist[i + 12].ToString();
                        break;

                    case "identity_secret":
                        auth.IdentitySecret = sglist[i + 12].ToString();
                        break;

                    case "secret_1":
                        auth.Secret = sglist[i + 12].ToString();
                        break;

                    case "server_time":
                        auth.ServerTime = sglist[i + 12].ToString();
                        break;

                    case "account_name":
                        auth.AccountName = sglist[i + 12].ToString();
                        break;

                    case "steamguard_scheme":
                        auth.SteamguardScheme = sglist[i + 12].ToString();
                        break;

                    case "status":
                        auth.Status = sglist[i + 12].ToString();
                        break;
                    }
                }

                txtResults.AppendText(Environment.NewLine);

                txtResults.AppendText("In WinAuth, Add Steam Authenticator. Select the Import Android Tab" +
                                      Environment.NewLine + Environment.NewLine);

                txtResults.AppendText("Paste this into the steam_uuid.xml text box" + Environment.NewLine);
                txtResults.AppendText($"android:{deviceID}" + Environment.NewLine + Environment.NewLine);

                txtResults.AppendText(
                    "Paste the following data, including the {} into the SteamGuare-NNNNNNNNN... text box" +
                    Environment.NewLine);

                txtResults.AppendText(JsonConvert.SerializeObject(auth, Formatting.Indented) +
                                      Environment.NewLine + Environment.NewLine);

                txtResults.AppendText(
                    "Alternatively, you can paste the above json text into {botname}.maFile in your ASF config directory, if you use ASF"
                    + Environment.NewLine + Environment.NewLine);
            }
            catch (PropertyListFormatException) //The only way this should happen is if we opened an encrypted backup.
            {
                txtResults.AppendText("Error: Encrypted backups are not supported. You need to create a decrypted backup to proceed." + Environment.NewLine);
                return(false);
            }
            catch (Exception ex)
            {
                txtResults.AppendText($"An Exception occurred while processing: {ex.Message}");
                return(false);
            }
            return(true);
        }