mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Misc corrections
This commit is contained in:
@@ -31,14 +31,14 @@ namespace ArchiSteamFarm {
|
||||
public static class ArchiCryptoHelper {
|
||||
private static byte[] EncryptionKey = Encoding.UTF8.GetBytes(nameof(ArchiSteamFarm));
|
||||
|
||||
internal static string BruteforceSteamParentalCode(byte[] passwordHash, byte[] salt, bool derivedKey = true) {
|
||||
internal static string BruteforceSteamParentalCode(byte[] passwordHash, byte[] salt, bool scrypt = true) {
|
||||
if ((passwordHash == null) || (salt == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(passwordHash) + " || " + nameof(salt));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return derivedKey ? BruteforceSteamParentalCodeDerived(passwordHash, salt) : BruteforceSteamParentalCodePbkdf2(passwordHash, salt);
|
||||
return scrypt ? BruteforceSteamParentalCodeScrypt(passwordHash, salt) : BruteforceSteamParentalCodePbkdf2(passwordHash, salt);
|
||||
}
|
||||
|
||||
internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) {
|
||||
@@ -93,40 +93,6 @@ namespace ArchiSteamFarm {
|
||||
EncryptionKey = Encoding.UTF8.GetBytes(key);
|
||||
}
|
||||
|
||||
private static string BruteforceSteamParentalCodeDerived(byte[] passwordHash, byte[] salt) {
|
||||
if ((passwordHash == null) || (salt == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(passwordHash) + " || " + nameof(salt));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] password = new byte[4];
|
||||
|
||||
for (char a = '0'; a <= '9'; a++) {
|
||||
password[0] = (byte) a;
|
||||
|
||||
for (char b = '0'; b <= '9'; b++) {
|
||||
password[1] = (byte) b;
|
||||
|
||||
for (char c = '0'; c <= '9'; c++) {
|
||||
password[2] = (byte) c;
|
||||
|
||||
for (char d = '0'; d <= '9'; d++) {
|
||||
password[3] = (byte) d;
|
||||
|
||||
byte[] passwordHashTry = SCrypt.ComputeDerivedKey(password, salt, 8192, 8, 1, null, passwordHash.Length);
|
||||
|
||||
if (passwordHashTry.SequenceEqual(passwordHash)) {
|
||||
return Encoding.UTF8.GetString(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string BruteforceSteamParentalCodePbkdf2(byte[] passwordHash, byte[] salt) {
|
||||
if ((passwordHash == null) || (salt == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(passwordHash) + " || " + nameof(salt));
|
||||
@@ -163,6 +129,40 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string BruteforceSteamParentalCodeScrypt(byte[] passwordHash, byte[] salt) {
|
||||
if ((passwordHash == null) || (salt == null)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(passwordHash) + " || " + nameof(salt));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] password = new byte[4];
|
||||
|
||||
for (char a = '0'; a <= '9'; a++) {
|
||||
password[0] = (byte) a;
|
||||
|
||||
for (char b = '0'; b <= '9'; b++) {
|
||||
password[1] = (byte) b;
|
||||
|
||||
for (char c = '0'; c <= '9'; c++) {
|
||||
password[2] = (byte) c;
|
||||
|
||||
for (char d = '0'; d <= '9'; d++) {
|
||||
password[3] = (byte) d;
|
||||
|
||||
byte[] passwordHashTry = SCrypt.ComputeDerivedKey(password, salt, 8192, 8, 1, null, passwordHash.Length);
|
||||
|
||||
if (passwordHashTry.SequenceEqual(passwordHash)) {
|
||||
return Encoding.UTF8.GetString(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string DecryptAES(string encrypted) {
|
||||
if (string.IsNullOrEmpty(encrypted)) {
|
||||
ASF.ArchiLogger.LogNullError(nameof(encrypted));
|
||||
|
||||
@@ -25,6 +25,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
using ArchiSteamFarm.CMsgs;
|
||||
using ArchiSteamFarm.Localization;
|
||||
@@ -665,15 +666,15 @@ namespace ArchiSteamFarm {
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
bool derivedKey;
|
||||
bool scrypt;
|
||||
|
||||
switch (body.settings.passwordhashtype) {
|
||||
case 4:
|
||||
derivedKey = false;
|
||||
scrypt = false;
|
||||
|
||||
break;
|
||||
case 6:
|
||||
derivedKey = true;
|
||||
scrypt = true;
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -695,7 +696,15 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
if (i >= steamParentalCode.Length) {
|
||||
byte[] passwordHash = derivedKey ? SCrypt.ComputeDerivedKey(password, body.settings.salt, 8192, 8, 1, null, body.settings.passwordhash.Length) : SCrypt.GetEffectivePbkdf2Salt(password, body.settings.salt, 8192, 8, 1, null);
|
||||
byte[] passwordHash;
|
||||
|
||||
if (scrypt) {
|
||||
passwordHash = SCrypt.ComputeDerivedKey(password, body.settings.salt, 8192, 8, 1, null, body.settings.passwordhash.Length);
|
||||
} else {
|
||||
using (KeyedHashAlgorithm hmacAlgorithm = KeyedHashAlgorithm.Create()) {
|
||||
passwordHash = Pbkdf2.ComputeDerivedKey(hmacAlgorithm, body.settings.salt, 10000, body.settings.passwordhash.Length);
|
||||
}
|
||||
}
|
||||
|
||||
if (passwordHash.SequenceEqual(body.settings.passwordhash)) {
|
||||
return (true, steamParentalCode);
|
||||
@@ -705,7 +714,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.PleaseWait);
|
||||
|
||||
steamParentalCode = ArchiCryptoHelper.BruteforceSteamParentalCode(body.settings.passwordhash, body.settings.salt, derivedKey);
|
||||
steamParentalCode = ArchiCryptoHelper.BruteforceSteamParentalCode(body.settings.passwordhash, body.settings.salt, scrypt);
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.Done);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user