now need to get m2
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "tier2/fileformats/plist.h"
|
||||
#include "http/http.h"
|
||||
#include "openssl/srp.h"
|
||||
#include "openssl/evp.h"
|
||||
#include "openssl/sha.h"
|
||||
#include "tier0/rand.h"
|
||||
|
||||
@@ -26,6 +27,12 @@ IHTTPClientManager *g_pHttpClientMgr = NULL;
|
||||
|
||||
#define N2048 "AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73"
|
||||
#define G2048 "2"
|
||||
enum EPasswordType
|
||||
{
|
||||
PASSWORD_TYPE_S2K,
|
||||
PASSWORD_TYPE_S2K_FO,
|
||||
};
|
||||
|
||||
class CAppleAuth: public IAppleAuth
|
||||
{
|
||||
public:
|
||||
@@ -35,6 +42,7 @@ public:
|
||||
virtual EAppleAuthDaemonStatus GetStatus() override;
|
||||
virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) override;
|
||||
virtual EAppleAuthStatus Submit2FA( const char *szCode ) override;
|
||||
virtual CUtlString EncryptPassword( const char *szPassword, CUtlString szSalt, uint32_t uIters, EPasswordType eType );
|
||||
|
||||
CUtlString FetchADIPB();
|
||||
void FetchHeaders( CUtlString szAdiPb );
|
||||
@@ -292,7 +300,7 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s
|
||||
"\t<dict>\n"
|
||||
|
||||
"\t<key>A2k</key>\n"
|
||||
"\t<string>%s</string>\n"
|
||||
"\t<data>%s</data>\n"
|
||||
|
||||
"\t<key>ps</key>\n"
|
||||
"\t<array><string>s2k</string><string>s2k_fo</string></array>\n"
|
||||
@@ -310,7 +318,7 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s
|
||||
"\t<string>2026-1-9T12:00:00Z</string>\n"
|
||||
"\t<key>X-Apple-I-MD</key>\n"
|
||||
"\t<string>%s</string>\n"
|
||||
"\t<key>X-Apple-I-MD_LU</key>\n"
|
||||
"\t<key>X-Apple-I-MD-LU</key>\n"
|
||||
"\t<string>" APPLE_LOCAL_USER "</string>\n"
|
||||
"\t<key>X-Apple-I-MD-M</key>\n"
|
||||
"\t<string>%s</string>\n"
|
||||
@@ -323,19 +331,11 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s
|
||||
|
||||
|
||||
"\t<key>bootstrap</key>\n"
|
||||
"\t<false/>\n"
|
||||
|
||||
"\t<key>capp</key>\n"
|
||||
"\t<string>Xcode</string>\n"
|
||||
|
||||
"\t<key>dc</key>\n"
|
||||
"\t<string>#9d9da0</string>\n"
|
||||
"\t<trur/>\n"
|
||||
|
||||
"\t<key>icscrec</key>\n"
|
||||
"\t<true/>\n"
|
||||
|
||||
"\t<key>loc</key>\n"
|
||||
"\t<string>en_US</string>\n"
|
||||
|
||||
"\t<key>pbe</key>\n"
|
||||
"\t<false/>\n"
|
||||
@@ -346,6 +346,9 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s
|
||||
"\t<key>svct</key>\n"
|
||||
"\t<string>iCloud</string>\n"
|
||||
|
||||
"\t<key>loc</key>\n"
|
||||
"\t<string>en_US</string>\n"
|
||||
|
||||
"\t</dict>\n"
|
||||
|
||||
"\t</dict>\n"
|
||||
@@ -368,7 +371,9 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s
|
||||
if (stResponse.m_uCode == 200)
|
||||
{
|
||||
V_printf("%s\n",stResponse.m_message.GetMemory());
|
||||
|
||||
IJSONObject *pObject = PropertyListManager()->ReadString(stResponse.m_message);
|
||||
IJSONObject *pResponse = pObject->GetValue("Response")->GetObject();
|
||||
EncryptPassword(szPassword, pResponse->GetValue("s")->GetStringValue(), pResponse->GetValue("i")->GetNumberValue(), PASSWORD_TYPE_S2K);
|
||||
}
|
||||
g_pHttpClientMgr->Disconnect(m_pGrandSlamClient);
|
||||
|
||||
@@ -381,6 +386,48 @@ EAppleAuthStatus CAppleAuth::Submit2FA( const char *szCode )
|
||||
|
||||
}
|
||||
|
||||
int base64_decode(const char *b64, unsigned char *out) {
|
||||
int len = strlen(b64);
|
||||
int out_len = EVP_DecodeBlock(out,
|
||||
(const unsigned char *)b64,
|
||||
len);
|
||||
if (out_len < 0)
|
||||
return -1;
|
||||
|
||||
while (len > 0 && b64[len - 1] == '=') {
|
||||
out_len--;
|
||||
len--;
|
||||
}
|
||||
|
||||
return out_len;
|
||||
}
|
||||
CUtlString CAppleAuth::EncryptPassword( const char *szPassword, CUtlString szSalt, uint32_t uIters, EPasswordType eType )
|
||||
{
|
||||
|
||||
unsigned char hashedPassword[SHA256_DIGEST_LENGTH];
|
||||
CUtlString szHashedPasswordHex = "";
|
||||
unsigned char encryptedPassword[32];
|
||||
CUtlString szEncryptedPasswordHex = "";
|
||||
unsigned char salt[32];
|
||||
int iSaltLen = base64_decode(szSalt, salt);
|
||||
|
||||
if ( eType == PASSWORD_TYPE_S2K )
|
||||
{
|
||||
for ( int i = 0; i < SHA256_DIGEST_LENGTH; i++ )
|
||||
{
|
||||
szHashedPasswordHex.AppendTail(CUtlString("%02x", hashedPassword[i]));
|
||||
}
|
||||
PKCS5_PBKDF2_HMAC(szHashedPasswordHex, szHashedPasswordHex.GetLenght(), salt, iSaltLen, uIters, EVP_sha256(), 32, encryptedPassword);
|
||||
};
|
||||
for ( int i = 0; i < SHA256_DIGEST_LENGTH; i++ )
|
||||
{
|
||||
szEncryptedPasswordHex.AppendTail(CUtlString("%02x", encryptedPassword[i]));
|
||||
}
|
||||
V_printf("%s\n",szEncryptedPasswordHex.GetString());
|
||||
return szEncryptedPasswordHex;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static CAppleAuth s_appleAuth;
|
||||
EXPOSE_INTERFACE_GLOBALVAR(CAppleAuth, IAppleAuth, APPLE_AUTH_INTERFACE_VERSION, s_appleAuth);
|
||||
|
||||
Reference in New Issue
Block a user