Skip to content

Commit 6867fb4

Browse files
author
Dadoum
committed
Add Apple authentication to Sideloader.
Rajoute l'authentification à Sideloader - on avance, bientôt Sideloader fonctionnera !
1 parent a9f080d commit 6867fb4

File tree

14 files changed

+837
-230
lines changed

14 files changed

+837
-230
lines changed

.github/workflows/cmake.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
compiler: ldc-latest
2525

2626
- name: Install dependencies
27-
run: sudo apt-get install -y build-essential gcc g++ ninja-build libgtk-3-dev libimobiledevice-dev
27+
run: sudo apt-get install -y build-essential gcc g++ ninja-build libgtk-3-dev libplist-dev libimobiledevice-dev
2828

2929
- name: Configure CMake
3030
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2
@@ -55,7 +55,7 @@ jobs:
5555
compiler: ldc-latest
5656

5757
- name: Install dependencies
58-
run: sudo apt-get install -y build-essential gcc g++ ninja-build
58+
run: sudo apt-get install -y build-essential gcc g++ ninja-build libplist-dev
5959

6060
- name: Configure CMake
6161
run: cmake -G Ninja -Dbuild_sideloadipa=OFF -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_D_COMPILER=ldc2

CMakeLists.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ include(cmake/dependencies.cmake)
1010
set(PROVISION_SOURCE_DIR "lib/")
1111
file(GLOB_RECURSE PROVISION_D_SOURCES "${PROVISION_SOURCE_DIR}*.d")
1212

13+
find_package(PkgConfig REQUIRED)
14+
pkg_check_modules(plist REQUIRED IMPORTED_TARGET libplist-2.0)
15+
1316
add_library(provision STATIC ${PROVISION_D_SOURCES})
1417
target_include_directories(provision PUBLIC ${PROVISION_SOURCE_DIR})
1518

@@ -18,7 +21,7 @@ target_include_directories(provision PUBLIC ${PROVISION_SOURCE_DIR})
1821
# set_source_files_properties(lib/provision/c.d PROPERTIES COMPILE_FLAGS "-HC -HCf=${CMAKE_BINARY_DIR}/include-provision/provision.h")
1922
# target_include_directories(provision PUBLIC ${CMAKE_BINARY_DIR}/include-provision)
2023

21-
target_link_libraries(provision PUBLIC plist hybris stdc++)
24+
target_link_libraries(provision PUBLIC PkgConfig::plist hybris stdc++)
2225

2326
set(RETRIEVE_HEADERS_SOURCE_DIR "retrieve_headers/")
2427
file(GLOB_RECURSE RETRIEVE_HEADERS_D_SOURCES "${RETRIEVE_HEADERS_SOURCE_DIR}*.d")
@@ -34,10 +37,9 @@ if(build_sideloadipa)
3437
add_executable(sideload_ipa ${SIDELOAD_IPA_D_SOURCES})
3538
target_include_directories(sideload_ipa PUBLIC ${SIDELOAD_IPA_SOURCE_DIR})
3639

37-
find_package(PkgConfig REQUIRED)
3840
pkg_check_modules(imobiledevice REQUIRED IMPORTED_TARGET libimobiledevice-1.0)
3941

40-
target_link_libraries(sideload_ipa provision gtk-d PkgConfig::imobiledevice secured)
42+
target_link_libraries(sideload_ipa provision gtk-d gmp-d PkgConfig::imobiledevice PkgConfig::plist pbkdf2 crypto)
4143
endif()
4244

4345
if(build_anisetteserver)

LISEZMOI.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Music. Vous pouvez ne télécharger que la tranche de votre architecture. Placez
2424
à côté des exécutables. Dans le dossier avec toutes les bibliothèques (fichiers en .so), vous pouvez
2525
ne garder que libstoreservicescore.so et libCoreADI.so. Ce sont les seuls nécessaire.
2626

27-
Pour compiler n'importe lequel des projets, vous devez avoir CMake et le kit de développement
28-
pour le D (le compilateur + dub).
27+
Pour compiler n'importe lequel des projets, vous devez avoir CMake, le kit de développement
28+
pour le D (le compilateur + dub), un compilateur C et C++, et le paquet de dev de libplist.
2929

3030
Pour compiler *sideload_ipa*, il est nécessaire en plus d'avoir ce qu'il faut pour développer avec
3131
GTK+ et libimobiledevice.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ the lib/ folder next to the executables. If you want to reduce further the size,
2424
folder all the libraries except libstoreservicescore.so and libCoreADI.so, since they are the only one
2525
needed to run the app.
2626

27-
To build any of these projects, you need CMake, a C and C++ compiler, and the D SDK, with the compiler
28-
and dub.
27+
To build any of these projects, you need CMake, a C and C++ compiler, the D SDK, with the compiler
28+
and dub and libplist development packages.
2929

3030
To build *sideload_ipa*, you also need GTK+ and libimobiledevice development packages.
3131

cmake/dependencies.cmake

+13-21
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,19 @@ FetchContent_Declare(
1111
FetchContent_MakeAvailable(libhybris)
1212
target_compile_definitions(hybris PUBLIC BROKEN_MODE)
1313

14-
include(UseDub)
14+
if(build_sideloadipa OR build_anisetteserver)
15+
include(UseDub)
1516

16-
FetchContent_Declare(
17-
plist_proj
18-
GIT_REPOSITORY https://github.com/hatf0/plist
19-
PATCH_COMMAND ${DUB_DIRECTORY}/CMakeTmp/DubToCMake -s plist
20-
)
21-
FetchContent_MakeAvailable(plist_proj)
22-
23-
if(build_sideloadipa)
24-
DubProject_Add(gtk-d ~3.10.0)
25-
# DubProject_Add(mofile ~0.2.1)
17+
if(build_sideloadipa)
18+
DubProject_Add(gtk-d ~3.10.0)
19+
DubProject_Add(gmp-d ~0.2.11)
20+
# DubProject_Add(mofile ~0.2.1)
2621

27-
FetchContent_Declare(
28-
secured_proj
29-
GIT_REPOSITORY https://github.com/LightBender/SecureD
30-
PATCH_COMMAND ${DUB_DIRECTORY}/CMakeTmp/DubToCMake -s secured
31-
)
32-
FetchContent_MakeAvailable(secured_proj)
33-
endif()
22+
DubProject_Add(pbkdf2 ~0.1.3)
23+
DubProject_Add(crypto ~0.2.17)
24+
endif()
3425

35-
if(build_anisetteserver)
36-
DubProject_Add(archttp ~1.1.0)
37-
endif()
26+
if(build_anisetteserver)
27+
DubProject_Add(archttp ~1.1.0)
28+
endif()
29+
endif()

lib/provision/adi.d

+19-20
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module provision.adi;
22

33
import provision.android.id;
44
import provision.androidlibrary;
5-
import plist;
6-
import plist.types;
75
import std.base64;
86
import std.conv;
97
import std.digest.sha;
@@ -13,6 +11,8 @@ import std.net.curl;
1311
import std.stdio;
1412
import std.string;
1513

14+
import provision.plist;
15+
1616
@nogc:
1717

1818
alias ADILoadLibraryWithPath_t = extern(C) int function(immutable char*);
@@ -178,14 +178,15 @@ alias ADIGetIDMSRouting_t = extern(C) int function(ulong*, ulong);
178178
}
179179

180180
private void populateUrlBag(HTTP client) {
181-
auto content = std.net.curl.get("https://gsa.apple.com/grandslam/GsService2/lookup", client);
182-
183-
Plist plist = new Plist();
184-
plist.read(cast(string) content);
185-
auto response = (cast(PlistElementDict) (cast(PlistElementDict) (plist[0]))["urls"]);
186-
187-
foreach (key; response.keys()) {
188-
urlBag[key] = (cast(PlistElementString) response[key]).value;
181+
auto content = cast(string) std.net.curl.get("https://gsa.apple.com/grandslam/GsService2/lookup", client);
182+
183+
PlistDict plist = cast(PlistDict) Plist.fromXml(content);
184+
auto response = cast(PlistDict) plist["urls"];
185+
auto responseIter = response.iter();
186+
Plist val;
187+
string key;
188+
while (responseIter.next(val, key)) {
189+
urlBag[key] = cast(string) cast(PlistString) val;
189190
}
190191
}
191192

@@ -209,10 +210,9 @@ alias ADIGetIDMSRouting_t = extern(C) int function(ulong*, ulong);
209210
</plist>
210211
", client);
211212

212-
Plist spimPlist = new Plist();
213-
spimPlist.read(content);
214-
PlistElementDict spimResponse = cast(PlistElementDict) (cast(PlistElementDict) (spimPlist[0]))["Response"];
215-
string spimStr = (cast(PlistElementString) spimResponse["spim"]).value;
213+
auto spimPlist = cast(PlistDict) Plist.fromXml(content);
214+
auto spimResponse = cast(PlistDict) spimPlist["Response"];
215+
string spimStr = cast(string) cast(PlistString) spimResponse["spim"];
216216

217217
return Base64.decode(spimStr);
218218
}
@@ -242,9 +242,8 @@ alias ADIGetIDMSRouting_t = extern(C) int function(ulong*, ulong);
242242
string content = cast(string) post(urlBag["midFinishProvisioning"],
243243
body_, client);
244244

245-
Plist plist = new Plist();
246-
plist.read(content);
247-
PlistElementDict spimResponse = cast(PlistElementDict) (cast(PlistElementDict) (plist[0]))["Response"];
245+
PlistDict plist = cast(PlistDict) Plist.fromXml(content);
246+
PlistDict spimResponse = cast(PlistDict) plist["Response"];
248247

249248
struct SecondStepAnswers {
250249
string rinfo;
@@ -253,9 +252,9 @@ alias ADIGetIDMSRouting_t = extern(C) int function(ulong*, ulong);
253252
}
254253

255254
SecondStepAnswers secondStepAnswers = SecondStepAnswers();
256-
secondStepAnswers.rinfo = (cast(PlistElementString) spimResponse["X-Apple-I-MD-RINFO"]).value;
257-
secondStepAnswers.tk = Base64.decode((cast(PlistElementString) spimResponse["tk"]).value);
258-
secondStepAnswers.ptm = Base64.decode((cast(PlistElementString) spimResponse["ptm"]).value);
255+
secondStepAnswers.rinfo = cast(string) cast(PlistString) spimResponse["X-Apple-I-MD-RINFO"];
256+
secondStepAnswers.tk = Base64.decode(cast(string) cast(PlistString) spimResponse["tk"]);
257+
secondStepAnswers.ptm = Base64.decode(cast(string) cast(PlistString) spimResponse["ptm"]);
259258

260259
return secondStepAnswers;
261260
}

sideload_ipa/sideloadipa/plist/c.d lib/provision/plist/c.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module sideloadipa.plist.c;
1+
module provision.plist.c;
22

33
/**
44
* @file plist/plist.h

0 commit comments

Comments
 (0)