NyaMisty / AltServer-Linux

AltServer for AltStore, but on-device
GNU Affero General Public License v3.0
988 stars 74 forks source link

Lighter Anisette server #64

Open Dadoum opened 2 years ago

Dadoum commented 2 years ago

I was myself making an AltServer for Linux when I saw yours. Mine was incomplete but I managed to generate Anisette on Linux in a lighter and more efficient way than the way this AltServer does. It uses Apple Music libraries from the Android APK and generates in few seconds this output:

{
    "X-Apple-I-MD-M":"<80 bytes long base64 string>",
    "X-Apple-I-MD":"<40 bytes long base64 string>",
    "X-Apple-I-MD-RINFO":"8 digits integer",
    "X-Apple-I-MD-LU":"<64 bytes long hex string>",
    "X-Mme-Device-Id":"<40 bytes long hex string>",
}

Is it sufficient ? And how should work a server ?

link to my repo

NyaMisty commented 2 years ago

You can see the needed headers with this:

curl https://sideloadly.io/anisette/irGb3Quww8zrhgqnzmrx | jq

typically it has these:

{
  "X-Apple-I-Client-Time": "2022-06-22T12:48:11Z",
  "X-Apple-I-MD": "AAAABQAAABDnCI2aAjo8uE47dzNBsOfRAAAAAQ==",
  "X-Apple-I-MD-LU": "CE99147F8610526892ED1AC53931EF38552A2CB64C2DC433D242FDAE789A7F80",
  "X-Apple-I-MD-M": "wbxShQ1m2WmGT+Sf496k3tYfwQhrzQ+79dQKNUVBzpz/rO+4faO/k3ZjePXDCXk1jMefsXn7NllulZOH",
  "X-Apple-I-MD-RINFO": "17106176",
  "X-Apple-I-SRL-NO": "0",
  "X-Apple-I-TimeZone": "GMT+0",
  "X-Apple-Locale": "en_GB",
  "X-MMe-Client-Info": "<iMac11,3> <Mac OS X;10.15.6;19G2021> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)>",
  "X-Mme-Device-Id": "F6C158F4-BD50-4EDD-B897-9BE4349EEED5"
}
NyaMisty commented 2 years ago

As for your provision header, I believe X-Apple-I-Client-Time X-Apple-I-TimeZone X-Apple-Locale can be simply filled. But X-MMe-Client-Info needs more consideration

Dadoum commented 2 years ago

I added X-Mme-Client-Info, and I changed it to the one provided by the server you're using now. Since provisioning just needs to put the Client Info as a header (and actually does not use it to make the actual content of provisioning) it can be easily customized.

NyaMisty commented 2 years ago

We don't know if Apple actually uses it. Long time ago apple uses this to distinguish Xcode and Cydia Impactor. By the way, for all those other simple fields (Time & Locale headers) I still suggest you to provide it altogether, as AltServer currently still rely on them.

Dadoum commented 2 years ago

X-Mme-Client-Info still needs to be present with a very specific format since Apple Provisioning server refuses anything which is not Windows or macOS, not using an official Apple app etc…

Anyway it now generates everything !

Dadoum commented 2 years ago

I added an Anisette Server !

Dadoum commented 2 years ago

Also, if you want you can modify the server to regenerate each time a new Anisette machine. But it can't be used for an Anisette server since there is a cooldown of few seconds each time you want to generate an ID. But maybe by trying regenerating every time Anisette, (and if it doesn't work just output the one we have) + randomizing the only things that matters for Anisette (Serial number + arc4random output), maybe we could make a better general Anisette server.

Dadoum commented 2 years ago

I added GitHub Actions in my repo, you can now download anisette_server easily.

I can't get AltServer-Linux working on my computer, but I don't think it's related to this server. Can you please try it out?

Dadoum commented 2 years ago

Ok it was related to the server, I made a dumb mistake, now it works !

NyaMisty commented 2 years ago

That's brilliant. Would you mind make a small README for me so that I can add it into this repo?

Dadoum commented 2 years ago

Something like this ?

## Troubleshooting

> I get `Unable to sign you in to your Apple ID. Try again later. (-36607)` when I try to install an app

This is related to the public Anisette server. To fix this error, download [the latest version of anisette-server from this link](https://github.com/Dadoum/Provision/actions), and setup it accordingly to the README there (get the Apple Music APK, and extract from it the lib/ folder and place it next to anisette_server executable).

Then launch AltServer-Linux with `ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969` environment variable (write this in the beginning of the command line before writing ./AltServer-x86_64).

Preview:

Troubleshooting

I get Unable to sign you in to your Apple ID. Try again later. (-36607) when I try to install an app

This is related to the public Anisette server. To fix this error, download the latest version of anisette-server from this link, and setup it accordingly to the README there (get the Apple Music APK, and extract from it the lib/ folder and place it next to anisette_server executable).

Then launch AltServer-Linux with ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969 environment variable (write this in the beginning of the command line before writing ./AltServer-x86_64).

Dadoum commented 2 years ago

Should I change anything in this readme ?

j5155 commented 2 years ago

@Dadoum Any way you could make the steps more convenient? Finding a specific APK online and extracting it is a bit weird, especially when you could do it automatically since Apple distributes the apk themselves at https://www.apple.com/lae/apple-music/android-download/ (with Android user agent goes to this direct link) https://apps.mzstatic.com/content/android-apple-music-apk/applemusic.apk Especially if this was a single line solution someone could copy paste, or even integrated into AltServer-Linux, it would be a lot more user-friendly.

Dadoum commented 2 years ago

@Dadoum Any way you could make the steps more convenient? Finding a specific APK online and extracting it is a bit weird, especially when you could do it automatically since Apple distributes the apk themselves at https://www.apple.com/lae/apple-music/android-download/ (with Android user agent goes to this direct link) https://apps.mzstatic.com/content/android-apple-music-apk/applemusic.apk Especially if this was a single line solution someone could copy paste, or even integrated into AltServer-Linux, it would be a lot more user-friendly.

The only issue of automatic APK download is that I don't want to download a big file without user consent. I could make a CLI prompt for it, but to address the whole user-friendlyness problem, I am currently remaking a full AltServer implementation on Linux (with headless and GUI) but I don't have much time these days to finish it soon. [^1]

Hence why I opened this issue. I wanted the APK downloading and everything else to be implemented in AltServer (also because currently, anisette_server is not compatible with 32 bits machines because of one of the dependencies I use, and that if it was integrated deeper in AltServer it could have called directly the right executables).

[^1]: EDIT: I made it, https://github.com/Dadoum/Sideloader