Skip to content

Commit 268a29b

Browse files
author
Dadoum
committed
Add few features to Anisette Server
1 parent 2dd8499 commit 268a29b

File tree

9 files changed

+51
-19
lines changed

9 files changed

+51
-19
lines changed

.github/workflows/cmake.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v3
1818
with:
1919
submodules: recursive
20-
20+
2121
- name: D Compiler Installation
2222
uses: dlang-community/[email protected]
2323
with:

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if(build_sideloadipa)
3737
find_package(PkgConfig REQUIRED)
3838
pkg_check_modules(imobiledevice REQUIRED IMPORTED_TARGET libimobiledevice-1.0)
3939

40-
target_link_libraries(sideload_ipa provision gtk-d gmp-d PkgConfig::imobiledevice)
40+
target_link_libraries(sideload_ipa provision gtk-d PkgConfig::imobiledevice secured)
4141
endif()
4242

4343
if(build_anisetteserver)

LISEZMOI.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
Provision est un jeu d'outils intéragissant avec les serveurs d'Apple sur Linux.
88

99
Cela inclut :
10-
- *libprovision*, utilisé pour enregistrer l'appareil auprès des serveurs d'Apple
10+
- *libprovision*, utilisé pour enregistrer l'appareil auprès des serveurs d'Apple.
11+
- *anisette_server*, un serveur d'approvisionnement Anisette pour des logiciels tiers comme
12+
[AltServer-Linux](https://github.com/NyaMisty/AltServer-Linux).
1113
- *retrieve_headers*, qui permet d'enregistrer l'appareil avec libprovision et de retourner
1214
les en-têtes HTTP à utiliser pour identifier l'appareil.
1315
- *sideload_ipa*, un exemple d'utilisation de libprovision pour installer une application sur
@@ -26,7 +28,7 @@ Pour compiler n'importe lequel des projets, vous devez avoir CMake et le kit de
2628
pour le D (le compilateur + dub).
2729

2830
Pour compiler *sideload_ipa*, il est nécessaire en plus d'avoir ce qu'il faut pour développer avec
29-
GTK+, GMP et libimobiledevice.
31+
GTK+ et libimobiledevice.
3032

3133
## Compilation
3234

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Provision is a set of tools interracting with Apple servers on Linux.
88

99
It includes:
1010
- *libprovision*, a library used to register device on Apple servers.
11+
- *anisette_server*, an Anisette provisioning server for other software such as
12+
[AltServer-Linux](https://github.com/NyaMisty/AltServer-Linux).
1113
- *retrieve_headers*, which registers the device with libprovision and returns in the terminal in
1214
JSON the headers to use to identify the device on future requests.
1315
- *sideload_ipa*, an example on how to use libprovision and continue requests to install application
@@ -22,6 +24,11 @@ the lib/ folder next to the executables. If you want to reduce further the size,
2224
folder all the libraries except libstoreservicescore.so and libCoreADI.so, since they are the only one
2325
needed to run the app.
2426

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.
29+
30+
To build *sideload_ipa*, you also need GTK+ and libimobiledevice development packages.
31+
2532
## Compilation
2633

2734
Clone the project and compile it with CMake:

anisette_server/app.d

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,31 @@ import provision;
99
void main(string[] args) {
1010
auto app = new Archttp;
1111
ADI* adi = new ADI(expandTilde("~/.adi"));
12-
adi.serialNo = "DNPX89219";
13-
adi.customHeaders["X-Apple-Locale"] = "en_US";
1412

1513
ulong rinfo;
16-
adi.provisionDevice(rinfo);
14+
if (!adi.isMachineProvisioned()) {
15+
stderr.write("Machine requires provisioning... ");
16+
adi.provisionDevice(rinfo);
17+
stderr.writeln("done !");
18+
} else {
19+
adi.getRoutingInformation(rinfo);
20+
}
21+
22+
app.get("/reprovision", (req, res) {
23+
writefln!"[%s >>] GET /reprovision"(req.ip);
24+
adi.provisionDevice(rinfo);
25+
writefln!"[>> %s] 200 OK"(req.ip);
26+
res.code(HttpStatusCode.OK);
27+
});
1728

1829
app.get("/", (req, res) {
1930
try {
2031
import std.datetime.systime;
2132
import std.datetime.timezone;
2233
import core.time;
23-
auto time = Clock.currTime(cast(TimeZone) new SimpleTimeZone(dur!"msecs"(0), "GMT+0"));
34+
auto time = Clock.currTime();
2435

25-
writeln("Received request !");
36+
writefln!"[%s >>] GET /"(req.ip);
2637

2738
ubyte[] mid;
2839
ubyte[] otp;
@@ -39,11 +50,13 @@ void main(string[] args) {
3950
"X-Apple-I-MD-LU": adi.localUserUUID,
4051
"X-Apple-I-SRL-NO": adi.serialNo,
4152
"X-MMe-Client-Info": adi.clientInfo,
42-
"X-Apple-I-TimeZone": "GMT+0",
53+
"X-Apple-I-TimeZone": time.timezone.dstName,
4354
"X-Apple-Locale": "en_US",
4455
"X-Mme-Device-Id": adi.deviceId,
4556
];
4657

58+
writefln!"[>> %s] 200 OK %s"(req.ip, response);
59+
4760
res.code(HttpStatusCode.OK);
4861
res.send(response);
4962
} catch(Throwable t) {

cmake/dependencies.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ FetchContent_MakeAvailable(plist_proj)
2222

2323
if(build_sideloadipa)
2424
DubProject_Add(gtk-d ~3.10.0)
25-
DubProject_Add(gmp-d ~0.2.11)
2625
# DubProject_Add(mofile ~0.2.1)
26+
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)
2733
endif()
2834

2935
if(build_anisetteserver)

lib/provision/adi.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ alias ADIGetIDMSRouting_t = extern(C) int function(ulong*, ulong);
358358

359359
void getRoutingInformation(out ulong routingInfo) {
360360
auto ret = pADIGetIDMSRouting(
361-
/+(out) routingInfo+/ cast(ulong*) 17,
361+
/+(out) routingInfo+/ &routingInfo,
362362
/+accountID+/ dsId,
363363
);
364364

lib/provision/androidlibrary.d

+9-5
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ private static __gshared PosixLibrary* libc;
5555
extern(C) int __system_property_getHook(const char* n, char *value) {
5656
auto name = n.fromStringz;
5757

58-
enum str = "DNPX89219";
58+
enum str = "no s/n number";
5959

60-
strcpy(value, str.ptr);
60+
strncpy(value, str.ptr, str.length);
6161
return cast(int) str.length;
6262
}
6363

64+
extern(C) uint arc4randomHook() {
65+
// import std.random;
66+
return 0; // Random(unpredictableSeed()).front;
67+
}
68+
6469
extern(C) int emptyStub() {
65-
import std.random;
66-
return unpredictableSeed();
70+
return 0;
6771
}
6872

6973
struct ADIMessage {
@@ -116,7 +120,7 @@ extern(C) private static void* hookFinder(immutable(char)* s, immutable(char)* l
116120
return &__system_property_getHook;
117121

118122
if (strcmp(s, "arc4random".ptr) == 0)
119-
return &emptyStub;
123+
return &arc4randomHook;
120124

121125
// Hooks to load libandroidappmusic
122126
// if (strcmp(s, "powf".ptr) == 0 ||

sideload_ipa/sideloadipa/identity.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module sideloadipa.identity;
22

3-
enum APPLICATION_NAME = "Sideloader";
3+
enum APPLICATION_NAME = "Sideloader (wip)";
44
enum AUTHORS = ["Dadoum"];
5-
enum VERSION = "0.0.1-dev";
5+
enum VERSION = "WIP build 2";

0 commit comments

Comments
 (0)