diff --git a/appleauth/auth.cpp b/appleauth/auth.cpp index 999e3a6..cf8f2ae 100644 --- a/appleauth/auth.cpp +++ b/appleauth/auth.cpp @@ -11,7 +11,7 @@ IHTTPClientManager *g_pHttpClientMgr = NULL; #define APPLE_LOCAL_USER "e2e70285da39596ef06153b9c4e1e5dc8d2f983bc5cd63f5b1e292207060d931" #define APPLE_HTTP_HEADER \ { \ - {"X-Apple-I-Client-Time", "2026-1-1T12:00:00"}, \ + {"X-Apple-I-Client-Time", "2026-1-9T12:00:00"}, \ {"X-Apple-Locale", "en_US"}, \ {"X-Apple-I-TimeZone", "Europe/Kyiv"}, \ {"X-Mme-Client-Info", " "}, \ @@ -24,12 +24,15 @@ IHTTPClientManager *g_pHttpClientMgr = NULL; {"Accept", "*/*"}, \ }; - +#define N2048 "AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73" +#define G2048 "2" class CAppleAuth: public IAppleAuth { public: virtual void Init() override; virtual void Shutdown() override; + virtual void LaunchLoginDaemon() override; + virtual EAppleAuthDaemonStatus GetStatus() override; virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) override; virtual EAppleAuthStatus Submit2FA( const char *szCode ) override; @@ -59,7 +62,6 @@ CUtlString CAppleAuth::FetchADIPB() CUtlString szAdiPb = NULL; m_pANIClient = g_pHttpClientMgr->Connect("ani.sidestore.io", true, NULL); - m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL); { HTTPHeaderParam_t params[] = APPLE_HTTP_HEADER; @@ -72,7 +74,6 @@ CUtlString CAppleAuth::FetchADIPB() if ( r.m_uCode != 200 ) { g_pHttpClientMgr->Disconnect(m_pANIClient); - g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); return NULL; } } @@ -116,7 +117,6 @@ CUtlString CAppleAuth::FetchADIPB() if ( r.m_uCode != 200 ) { g_pHttpClientMgr->Disconnect(m_pANIClient); - g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); return NULL; } IJSONObject *pObject = PropertyListManager()->ReadString(r.m_message); @@ -155,7 +155,6 @@ CUtlString CAppleAuth::FetchADIPB() if ( r.m_uCode != 200 ) { g_pHttpClientMgr->Disconnect(m_pANIClient); - g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); return NULL; } IJSONObject *pObject = PropertyListManager()->ReadString(r.m_message); @@ -178,11 +177,9 @@ CUtlString CAppleAuth::FetchADIPB() break; } g_pHttpClientMgr->Disconnect(m_pANIClient); - g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); return NULL; } g_pHttpClientMgr->Disconnect(m_pANIClient); - g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); return szAdiPb; } void CAppleAuth::FetchHeaders( CUtlString szAdiPb ) @@ -218,12 +215,14 @@ void CAppleAuth::Init() CreateInterfaceFn fnHttpFactory = Sys_GetFactory("funnyhttp"); g_pHttpClientMgr = (IHTTPClientManager*)fnHttpFactory(HTTP_CLIENT_INTERFACE_VERSION, NULL); - + m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL); + CUtlString szAdiPb = FetchADIPB(); FetchHeaders(szAdiPb); + } void CAppleAuth::Shutdown() @@ -231,41 +230,52 @@ void CAppleAuth::Shutdown() } +void CAppleAuth::LaunchLoginDaemon() +{ + + +} + +EAppleAuthDaemonStatus CAppleAuth::GetStatus() +{ + return APPLE_AUTH_DAEMON_NOT_LOGGED_IN; +} + + EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *szPassword ) { - const char *pszUser = "your_username"; - const char *pszPass = ""; + const char *pszUser = szEmail; + const char *pszPass = szPassword; - SRP_gN *pstGN = SRP_get_default_gN("2048"); - if (!pstGN) return APPLE_AUTH_FAILURE; + BIGNUM* pN = BN_new(); + BIGNUM* pG = BN_new(); + BIGNUM* pa = BN_new(); + BIGNUM* pA = BN_new(); + BN_CTX *pbnCtx = BN_CTX_new(); - const BIGNUM *pN = pstGN->N; - const BIGNUM *pG = pstGN->g; - - unsigned char aucSalt[16]; - Plat_URandom(sizeof(aucSalt), aucSalt); - - unsigned char aucHash[SHA256_DIGEST_LENGTH]; - SHA256_CTX stCtx; - SHA256_Init(&stCtx); - SHA256_Update(&stCtx, aucSalt, sizeof(aucSalt)); - SHA256_Update(&stCtx, pszUser, strlen(pszUser)); - SHA256_Update(&stCtx, ":", 1); - SHA256_Update(&stCtx, pszPass, strlen(pszPass)); - SHA256_Final(aucHash, &stCtx); - BIGNUM *pX = BN_bin2bn(aucHash, SHA256_DIGEST_LENGTH, NULL); - BIGNUM *pV = BN_new(); - BN_CTX *pstCtx = BN_CTX_new(); - if (!BN_mod_exp(pV, pG, pX, pN, pstCtx)) return APPLE_AUTH_FAILURE; - BN_free(pX); - - BIGNUM *pA = BN_new(); - BIGNUM *pApriv = BN_new(); - if (!BN_rand(pApriv, 256, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) return APPLE_AUTH_FAILURE; - if (!BN_mod_exp(pA, pG, pApriv, pN, pstCtx)) return APPLE_AUTH_FAILURE; + /* + CUtlBuffer bN; + CUtlBuffer bG; + */ + SHA256_CTX pSha; + unsigned char szHash[SHA256_DIGEST_LENGTH]; + BN_hex2bn(&pN, N2048); + BN_hex2bn(&pG, G2048); + /* + bN = CUtlBuffer(BN_num_bytes(pN)); + bG = CUtlBuffer(BN_num_bytes(pG)); + BN_bn2bin(pN, bN.GetMemory()); + SHA256_Init(&pSha); + SHA256_Update(&pSha, bN.GetMemory(), bN.GetSize()); + SHA256_Update(&pSha, bG.GetMemory(), bG.GetSize()); + SHA256_Final(szHash, &pSha); + */ + BN_rand(pa, 256, 0, 0); + BN_set_flags(pa, BN_FLG_CONSTTIME); + BN_mod_exp(pA, pG, pa, pN, pbnCtx); char *pszA = BN_bn2hex(pA); - V_printf("A: %s\n",pszA); + CUtlString plist = CUtlString( "\n" "\n" "\n" "\tHeader\n" - "\t\n" + "\t\n" + "\tVersion\n" + "\t1.0.1\n" + "\t\n" "\tRequest\n" "\t\n" + "\tA2k\n" "\t%s\n" + "\tps\n" "\ts2ks2k_fo\n" + + "\tu\n" "\t%s\n" + "\to\n" - "\tcomplete\n" + "\tinit\n" "\tcpd\n" "\t\n" - "\tbootstrap\n" - "\t\n" - "\tcapp\n" - "\tAppStore\n" - "\tckgen\n" - "\t\n" - "\tdc\n" - "\t#d4c5b3\n" - "\tdec\n" - "\t#e1e4e3\n" - "\tloc\n" - "\ten_US\n" - "\tpbe\n" - "\t\n" - "\tprtn\n" - "\tME349\n" - "\tsvct\n" - "\tiTunes\n" + "\tX-Apple-I-Client-Time\n" + "\t2026-1-9T12:00:00Z\n" "\tX-Apple-I-MD\n" "\t%s\n" - + "\tX-Apple-I-MD_LU\n" + "\t" APPLE_LOCAL_USER "\n" "\tX-Apple-I-MD-M\n" "\t%s\n" - "\tX-Apple-I-MD-RINFO\n" "\t%s\n" + "\tX-Mme-Client-Info\n" + "\t<MacBookPro13,2> <macOS;13.1;22C65> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)>\n" + "\tX-Apple-I-SRL-NO\n" + "\t0\n" + + + "\tbootstrap\n" + "\t\n" + + "\tcapp\n" + "\tXcode\n" + + "\tdc\n" + "\t#9d9da0\n" + + "\ticscrec\n" + "\t\n" + + "\tloc\n" + "\ten_US\n" + + "\tpbe\n" + "\t\n" + + "\tprkgen\n" + "\t\n" + + "\tsvct\n" + "\tiCloud\n" + "\t\n" "\t\n" "\n" "\n", pszA, szEmail, m_szAppleIMD.GetString(), m_szAppleIMDM.GetString(), m_szAppleIMDRINFO.GetString()); - m_pGrandSlamClient = g_pHttpClientMgr->Connect("gsa.apple.com", true, NULL); HTTPHeaderParam_t params[] = { {"Content-Type", "text/x-xml-plist"}, {"Accept", "*/*"}, + {"User-Agent", "akd/1.0 CFNetwork/808.1.4"}, \ + {"X-Mme-Client-Info", " "}, \ }; HTTPHeader_t header = { sizeof(params)/sizeof(HTTPHeaderParam_t), @@ -331,7 +364,7 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s V_printf("%s\n",plist.GetString()); m_pGrandSlamClient->Post("/grandslam/GsService2", &header, plist.GetLenght(), plist); HTTPResponse_t stResponse = m_pGrandSlamClient->GetResponse(); - V_printf("%i\n", stResponse.m_uCode); + V_printf("%i %i\n", stResponse.m_uCode, stResponse.m_bIsComplete); if (stResponse.m_uCode == 200) { V_printf("%s\n",stResponse.m_message.GetMemory()); @@ -340,10 +373,6 @@ EAppleAuthStatus CAppleAuth::SubmitLoginData( const char *szEmail, const char *s g_pHttpClientMgr->Disconnect(m_pGrandSlamClient); OPENSSL_free(pszA); - BN_free(pApriv); - BN_free(pA); - BN_free(pV); - BN_CTX_free(pstCtx); return APPLE_AUTH_SUCCESS; } @@ -355,3 +384,4 @@ EAppleAuthStatus CAppleAuth::Submit2FA( const char *szCode ) static CAppleAuth s_appleAuth; EXPOSE_INTERFACE_GLOBALVAR(CAppleAuth, IAppleAuth, APPLE_AUTH_INTERFACE_VERSION, s_appleAuth); + diff --git a/engine/build.cpp b/engine/build.cpp new file mode 100644 index 0000000..686fe2b --- /dev/null +++ b/engine/build.cpp @@ -0,0 +1,47 @@ +#include "helper.h" +#include "c.h" +#include "ld.h" +#include "tier1/utlstring.h" +#include "tier1/commandline.h" + +ADD_DEPENDENCY_BUILD_FILE(MaterialSystem, "../materialsystem/") +ADD_DEPENDENCY_BUILD_FILE(tier0, "../tier0/"); +ADD_DEPENDENCY_BUILD_FILE(tier1, "../tier1/"); +ADD_DEPENDENCY_BUILD_FILE(tier2, "../tier2/"); + +DECLARE_BUILD_STAGE(engine) +{ + CProject_t compileProject = {}; + LinkProject_t ldProject = {}; + + compileProject.m_szName = "engine"; + compileProject.files = { + "engine.cpp", + "cvar.cpp", + + "gamewindow_sdl.cpp", + + "sv_dll.cpp", + "cl_dll.cpp", + }; + compileProject.includeDirectories = { + "../public", + "../external/SDL/include", + }; + compileProject.bFPIC = true; + ldProject = ccompiler->Compile(&compileProject); + + ldProject.linkType = ELINK_DYNAMIC_LIBRARY; + + ldProject.libraryObjects = { + GET_PROJECT_LIBRARY("tier1", "tier1"), + GET_PROJECT_LIBRARY("tier2", "tier2"), + }; + ldProject.libraries = { + "SDL3" + }; + CUtlString outputProject = linker->Link(&ldProject); + + ADD_OUTPUT_OBJECT("engine", outputProject) + return 0; +}; diff --git a/fpc/library/apple/appletool.cpp b/fpc/library/apple/appletool.cpp index 5cad9cf..ba16694 100644 --- a/fpc/library/apple/appletool.cpp +++ b/fpc/library/apple/appletool.cpp @@ -67,6 +67,7 @@ public: virtual CUtlString BuildPackage( AppleManifest_t manifest, CUtlString szManifestDir ) override; virtual CUtlString SignPackage( const char *szIpa, const char *szPassword ) override; }; + CUtlString CAppleTool::BuildPackage( AppleManifest_t manifest, CUtlString szManifestDir ) { CUtlVector args = {}; @@ -86,9 +87,13 @@ CUtlString CAppleTool::SignPackage( const char *szIpa, const char *szPassword ) CreateInterfaceFn fnFactory = Sys_GetFactory("appleauth"); if (fnFactory == NULL) Plat_FatalErrorFunc("Couldn't get xtool\n"); + g_pAppleAuth = (IAppleAuth*)fnFactory(APPLE_AUTH_INTERFACE_VERSION, NULL); g_pAppleAuth->Init(); - g_pAppleAuth->SubmitLoginData("bratelllo@icloud.com", ""); + char *szGSAEmail = CommandLine()->ParamValue("-apple-login"); + char *szGSAPassword = CommandLine()->ParamValue("-apple-password"); + if (szGSAEmail && szGSAPassword) + g_pAppleAuth->SubmitLoginData(szGSAEmail, szGSAPassword); return szIpa; } diff --git a/http/build.cpp b/http/build.cpp index 3b6f62b..0613b0b 100644 --- a/http/build.cpp +++ b/http/build.cpp @@ -2,7 +2,7 @@ #include "c.h" #include "ld.h" #include "tier1/utlstring.h" -#include "tier1/commandline.h" +#include "tier0/commandline.h" ADD_DEPENDENCY_BUILD_FILE(tier0, "../tier0/build.cpp") ADD_DEPENDENCY_BUILD_FILE(tier1, "../tier1/build.cpp") diff --git a/http/client.cpp b/http/client.cpp index f299d32..ac6cbac 100644 --- a/http/client.cpp +++ b/http/client.cpp @@ -116,6 +116,7 @@ HTTPResponse_t CHTTPClient::GetResponse() readSocket: n = Read(response, sizeof(response)); + V_printf("%s\n",response); if (n == -1) goto responseDone; diff --git a/materialsystem/build.cpp b/materialsystem/build.cpp new file mode 100644 index 0000000..b54150a --- /dev/null +++ b/materialsystem/build.cpp @@ -0,0 +1,69 @@ +#include "helper.h" +#include "c.h" +#include "ld.h" +#include "tier1/utlstring.h" +#include "tier1/commandline.h" + +CUtlVector MaterialSystem_CompiledFiles = { + "materialsystem.cpp", + "compiledshader.cpp", +}; +CUtlVector RenderContextVulkan_CompiledFiles = { + "vulkan/shaderparser.cpp", + "vulkan/rendercontext.cpp", + "vulkan/commandbuffer.cpp", + "vulkan/rendercommandlist.cpp", + "vulkan/material.cpp", + "vulkan/shader.cpp", + "vulkan/utils.cpp", + "vulkan/vma.cpp", + "vulkan/commands/draw.cpp", + "vulkan/commands/transfer.cpp", + "vulkan/commands/base.cpp", + "vulkan/libraries/raster.cpp", + "../external/volk/volk.c", +}; +CUtlString material_lib; + +DECLARE_BUILD_STAGE(MaterialSystem) +{ + CProject_t compileProject = {}; + LinkProject_t ldProject = {}; + + compileProject.m_szName = "MaterialSystem"; + compileProject.files = MaterialSystem_CompiledFiles; + compileProject.includeDirectories = { "../public" }; + compileProject.bFPIC = true; + ldProject = ccompiler->Compile(&compileProject); + ldProject.linkType = ELINK_DYNAMIC_LIBRARY; + + CUtlString outputProject = linker->Link(&ldProject); + material_lib = outputProject; + + return 0; +} + +DECLARE_BUILD_STAGE(RenderSystemVulkan) +{ + CProject_t compileProject = {}; + LinkProject_t ldProject = {}; + + compileProject.m_szName = "RenderSystemVulkan"; + compileProject.files = RenderContextVulkan_CompiledFiles; + compileProject.includeDirectories = { + "../public", + "../external/Vulkan-Headers/include", + "../external/Vulkan-Utility-Libraries/include", + "../external/VulkanMemoryAllocator/include", + "../external/volk" + }; + compileProject.bFPIC = true; + ldProject = ccompiler->Compile(&compileProject); + ldProject.linkType = ELINK_DYNAMIC_LIBRARY; + ldProject.libraries = { "vulkan" }; + + CUtlString outputProject = linker->Link(&ldProject); + material_lib = outputProject; + + return 0; +} diff --git a/public/appleauth/iauth.h b/public/appleauth/iauth.h index 1d8c068..d12c9e5 100644 --- a/public/appleauth/iauth.h +++ b/public/appleauth/iauth.h @@ -4,6 +4,11 @@ #include "tier0/platform.h" #include "tier2/iappsystem.h" +enum EAppleAuthDaemonStatus +{ + APPLE_AUTH_DAEMON_NOT_LOGGED_IN, + APPLE_AUTH_DAEMON_LOGGED_IN, +}; enum EAppleAuthStatus { @@ -16,6 +21,8 @@ enum EAppleAuthStatus abstract_class IAppleAuth: public IAppSystem { public: + virtual void LaunchLoginDaemon() = 0; + virtual EAppleAuthDaemonStatus GetStatus() = 0; virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) = 0; virtual EAppleAuthStatus Submit2FA( const char *szCode ) = 0; };