From b6e253c9c2123a229cb6de9df7e0c6af716d5698 Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Tue, 26 Sep 2023 22:31:17 -0500 Subject: [PATCH 1/7] Update README.md --- README.md | 71 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index a95f6aa..802d85f 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,53 @@ -# pypush -`pypush` is a POC demo of my recent iMessage reverse-engineering. -It can currently register as a new device on an Apple ID, set up encryption keys, and ***send and receive iMessages***! +# Overview +This is the Pypush sms-registration branch. This branch allows you to register your phone number to your Apple account as an iMessage alias. -`pypush` is completely platform-independent, and does not require a Mac or other Apple device to use! +### Info +sms-registration is not fully developed yet, and still contains bugs! If you encounter any sort of bug, please join [our Discord](https://discord.gg/BtSbcExKJ9), however please note we cannot get to everyone, so try to figure out any errors yourself before asking. -## Installation -It's pretty self explanatory: -1. `git clone https://github.com/JJTech0130/pypush` -2. `pip3 install -r requirements.txt` -3. `python3 ./demo.py` +# Installation +You will first install Pypush onto your machine. *Please keep in mind that you will have to have a script running on a home server or PC 24/7 to keep your number active!* -## Troubleshooting -If you have any issues, please join [the Discord](https://discord.gg/BVvNukmfTC) and ask for help. +### PNRgateway +In order for Apple to verify your number, a specialized message has to be sent from your phone to Apple's "gateway number" and have the response captured. This number is different for each carrier, however the newest app version should automatically find your gateway number. -## Operation -`pypush` will generate a `config.json` in the repository when you run demo.py. DO NOT SHARE THIS FILE. -It contains all the encryption keys necessary to log into you Apple ID and send iMessages as you. +1. Enable USB debugging/ADB on your phone. There are multiple online guides that guide you through this based on your phone. +2. Install the APK. The message link containing the APK is located [here](https://discord.com/channels/1130633272595066880/1145177252015915080/1153070972090470481), and the GitHub repository is [here](https://github.com/JJTech0130/PNRGatewayClientV2). +3. Connect your phone to the same WiFi network as your host PC, and open the app. -Once it loads, it should prompt you with `>>`. Type `help` and press enter for a list of supported commands. +### Pypush +Make sure you have git and Python installed. -## Special Notes -### Unicorn dependency -`pypush` currently uses the Unicorn CPU emulator and a custom MachO loader to load a framework from an old version of macOS, -in order to call some obfuscated functions. +1. `git clone -b sms-registration https://github.com/beeper/pypush` +2. `cd pypush` && `python3 -m pip install -r requirements.txt` -This is only necessary during initial registration, so theoretically you can register on one device, and then copy the `config.json` -to another device that doesn't support the Unicorn emulator. Or you could switch out the emulator for another x86 emulator if you really wanted to. +# Number Registration -### Public key caching -iMessage will cache public keys. If you get decryption errors in pypush or can only send and not receive messages from another device, -try logging out and back into iMessage on that device, forcing it to refresh it's key cache. Alternatively, you can wait and the cache should -expire eventually. +3. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. +4. If the previous ran successfully, you can now run `python3 demo.py --reregister` -## Licensing -This project is licensed under the terms of the [SSPL](https://www.mongodb.com/licensing/server-side-public-license). Portions of this project are based on [macholibre by Aaron Stephens](https://github.com/aaronst/macholibre/blob/master/LICENSE) under the Apache 2.0 license. +***Please note:*** This last script is the script you will be running continuously. We recommend every 30 minutes. There should also be a file called `reregister.py`, if you run this it should reregister you every 30 minutes. -If you would like to use all or portions of this project in a commercial produce (without releasing source code), we are open to contacts about possible dual-licensing terms. \ No newline at end of file +### Good to Know + +You will have to reregister your number every so often. This can last anywhere between 10 minutes to 48 hours, and *usually* the longer you run the script, the longer it takes to deregister. We may implement a feature to automatically detect deregistration in the future. + +If you ever have any type of error, delete the config.json file and run steps 3-4 again. *This is really important.* + +# Issues +This is still in the development stage, so expect issues and bugs. Here is a list of possible errors: + +### Timeout waiting for response from gateway +This means it took too long for Apple to respond from the gateway number, PNRgateway is not sending the message to the correct gateway, or the response is in an incorrect encoding. This is common, please reach out for help. + +### Connection Closed +This means the app crashed or could not parse the response data from the gateway. This is also common, and a recent bug has caused this error to happen excessively with non-Verizon carriers. + +### Failed to resolve host +This error occurs when you are not connected to the same network, the all is closed, or you are not using the correct IP. + +If you encounter any other errors, please try to find answers online for help. + +# Resources +- [IDS and APNs error codes](https://discord.com/channels/1130633272595066880/1130990221920575618/1153062573533577246) +- [Rustpush](https://github.com/TaeHagen/rustpush) +- [PNRgateway repo](https://github.com/JJTech0130/PNRGatewayClientV2) \ No newline at end of file From d9eb25990abd4e908194bb05535db5f4680dbc78 Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:10:12 -0500 Subject: [PATCH 2/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 802d85f..d5c9597 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ In order for Apple to verify your number, a specialized message has to be sent f 3. Connect your phone to the same WiFi network as your host PC, and open the app. ### Pypush -Make sure you have git and Python installed. +Make sure you have Git and Python installed. 1. `git clone -b sms-registration https://github.com/beeper/pypush` 2. `cd pypush` && `python3 -m pip install -r requirements.txt` # Number Registration -3. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. -4. If the previous ran successfully, you can now run `python3 demo.py --reregister` +1. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. +2. If the previous ran successfully, you can now run `python3 demo.py --reregister` ***Please note:*** This last script is the script you will be running continuously. We recommend every 30 minutes. There should also be a file called `reregister.py`, if you run this it should reregister you every 30 minutes. From 04d689907adf2bad1a3b85088e173463c0fac710 Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:08:53 -0500 Subject: [PATCH 3/7] Update README.md --- README.md | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d5c9597..359710b 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,36 @@ # Overview This is the Pypush sms-registration branch. This branch allows you to register your phone number to your Apple account as an iMessage alias. -### Info sms-registration is not fully developed yet, and still contains bugs! If you encounter any sort of bug, please join [our Discord](https://discord.gg/BtSbcExKJ9), however please note we cannot get to everyone, so try to figure out any errors yourself before asking. +***Please note:*** You will have to use a client to send messages from your phone. We recommend [Beeper](https://www.beeper.com/), which is the best solution to keep all your chat apps inside one place, including iMessage! You can also use [BlueBubbles](https://www.beeper.com/) (which requires you to have a server Mac running 24/7) or [Sunbird](https://www.sunbirdapp.com/) (which is closed source and requires you to be a beta tester). Beeper is completely free and easy to use, and comes packed with multiple features that reivals native apps. Beeper is currently in the process of removing the waitlist, so you will have to use an invite link shared to you in order to skip the waitlist until this change is made. + # Installation -You will first install Pypush onto your machine. *Please keep in mind that you will have to have a script running on a home server or PC 24/7 to keep your number active!* +You will first install Pypush onto your machine. *Please keep in mind that you will have to have a script running on a home server or PC 24/7 to keep your number active! See below for instructions.* ### PNRgateway -In order for Apple to verify your number, a specialized message has to be sent from your phone to Apple's "gateway number" and have the response captured. This number is different for each carrier, however the newest app version should automatically find your gateway number. +In order for Apple to verify your number, a specialized message has to be sent from your phone to Apple's "gateway number" and have the response captured. This number is different for each carrier, however the newest app version should automatically find your gateway number. If PNRgateway cannot find your gateway number, see below for help. 1. Enable USB debugging/ADB on your phone. There are multiple online guides that guide you through this based on your phone. 2. Install the APK. The message link containing the APK is located [here](https://discord.com/channels/1130633272595066880/1145177252015915080/1153070972090470481), and the GitHub repository is [here](https://github.com/JJTech0130/PNRGatewayClientV2). -3. Connect your phone to the same WiFi network as your host PC, and open the app. +3. Grant SMS permissions. This will be in the app info page, and on the newer version, there should be a button in the app that does this for you. +4. Connect your phone to the same WiFi network as your host PC, and open the app. ### Pypush -Make sure you have Git and Python installed. +Make sure you have git and Python installed. 1. `git clone -b sms-registration https://github.com/beeper/pypush` -2. `cd pypush` && `python3 -m pip install -r requirements.txt` +2. `cd pypush` , `python3 -m pip install -r requirements.txt` # Number Registration -1. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. +1. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. *(Usually this starts with `192.168.x.x`, however it can also start with `172` or `10`.)* 2. If the previous ran successfully, you can now run `python3 demo.py --reregister` -***Please note:*** This last script is the script you will be running continuously. We recommend every 30 minutes. There should also be a file called `reregister.py`, if you run this it should reregister you every 30 minutes. +***Please note:*** This last script is the script you will be running continuously. We recommend every 30 minutes. + +### Automatic registration +There should also be a file called `reregister.py`, if you run this it should reregister you every 30 minutes. You can edit this file to rerun at any other interval. You can also use a cronjob to do this task for you in a more streamlined way if you are more familiar with IT. ### Good to Know @@ -45,9 +50,21 @@ This means the app crashed or could not parse the response data from the gateway ### Failed to resolve host This error occurs when you are not connected to the same network, the all is closed, or you are not using the correct IP. -If you encounter any other errors, please try to find answers online for help. +### Automatic gateway detection failed +This is because PNRgateway could not detect the correct gateway corresponding to your carrier. Please report this issue if you find it. To fix this issue, when you are on step 1 of number registration, append `--gateway [number]` after the `--ip` argument, and replace `number` with the gateway number. *(You can find your gateway number [here](https://discord.com/channels/1130633272595066880/1130990221920575618/1154069380699791470))* + +### Failed to load the dynamic library +This is a Unicorn error. We do not yet know exactly what causes this error, but on MacOS try to run `sudo brew install unicorn`. This error usually occurs in MacOS VMs. + +### Failed to register +Delete `config.json` and retry. + +**If you encounter any other errors, please try to find answers online for help.** # Resources - [IDS and APNs error codes](https://discord.com/channels/1130633272595066880/1130990221920575618/1153062573533577246) - [Rustpush](https://github.com/TaeHagen/rustpush) -- [PNRgateway repo](https://github.com/JJTech0130/PNRGatewayClientV2) \ No newline at end of file +- [PNRgateway repo](https://github.com/JJTech0130/PNRGatewayClientV2) +- [Carrier gateway list](https://discord.com/channels/1130633272595066880/1130990221920575618/1154069380699791470) +- [Beeper install](https://www.beeper.com/download) +- [Beeper signup](https://airtable.com/appSlLTU0QBt8EBZ2/shrYWTCBhNCUKU9iv) From 088e98dcb974546de4eade8a95c5d5a663f245ea Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:10:53 -0500 Subject: [PATCH 4/7] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 359710b..73e557a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is the Pypush sms-registration branch. This branch allows you to register y sms-registration is not fully developed yet, and still contains bugs! If you encounter any sort of bug, please join [our Discord](https://discord.gg/BtSbcExKJ9), however please note we cannot get to everyone, so try to figure out any errors yourself before asking. -***Please note:*** You will have to use a client to send messages from your phone. We recommend [Beeper](https://www.beeper.com/), which is the best solution to keep all your chat apps inside one place, including iMessage! You can also use [BlueBubbles](https://www.beeper.com/) (which requires you to have a server Mac running 24/7) or [Sunbird](https://www.sunbirdapp.com/) (which is closed source and requires you to be a beta tester). Beeper is completely free and easy to use, and comes packed with multiple features that reivals native apps. Beeper is currently in the process of removing the waitlist, so you will have to use an invite link shared to you in order to skip the waitlist until this change is made. +***Please note:*** You will have to use a client to send messages from your phone. We recommend [Beeper](https://www.beeper.com/), which is the best solution to keep all your chat apps inside one place, including iMessage! You can also use [BlueBubbles](https://www.beeper.com/) (which requires you to have a server Mac running 24/7) or [Sunbird](https://www.sunbirdapp.com/) (which is closed source and requires you to be a beta tester). Beeper is completely free and easy to use, and comes packed with multiple features that rivals native apps. Beeper is currently in the process of removing the waitlist, so you will have to use an invite link shared to you in order to skip the waitlist until this change is made. # Installation You will first install Pypush onto your machine. *Please keep in mind that you will have to have a script running on a home server or PC 24/7 to keep your number active! See below for instructions.* From eb9f364e728deb67b783c028311d762f8ac2683f Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:11:58 -0500 Subject: [PATCH 5/7] Grammar check --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73e557a..219f53d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Make sure you have git and Python installed. # Number Registration 1. `python3 demo.py --phone [ip]`. Replace `ip` with your phone's local IP. *(Usually this starts with `192.168.x.x`, however it can also start with `172` or `10`.)* -2. If the previous ran successfully, you can now run `python3 demo.py --reregister` +2. If the previous command ran successfully, you can now run `python3 demo.py --reregister` ***Please note:*** This last script is the script you will be running continuously. We recommend every 30 minutes. From 2c075e0ee2cd23050df0d56acd5685e3a392c4c8 Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:15:25 -0500 Subject: [PATCH 6/7] Reference BlueBubbles Rustpush branch --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 219f53d..20dbe7a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ This is the Pypush sms-registration branch. This branch allows you to register y sms-registration is not fully developed yet, and still contains bugs! If you encounter any sort of bug, please join [our Discord](https://discord.gg/BtSbcExKJ9), however please note we cannot get to everyone, so try to figure out any errors yourself before asking. -***Please note:*** You will have to use a client to send messages from your phone. We recommend [Beeper](https://www.beeper.com/), which is the best solution to keep all your chat apps inside one place, including iMessage! You can also use [BlueBubbles](https://www.beeper.com/) (which requires you to have a server Mac running 24/7) or [Sunbird](https://www.sunbirdapp.com/) (which is closed source and requires you to be a beta tester). Beeper is completely free and easy to use, and comes packed with multiple features that rivals native apps. Beeper is currently in the process of removing the waitlist, so you will have to use an invite link shared to you in order to skip the waitlist until this change is made. +***Please note:*** You will have to use a client to send messages from your phone. We recommend [Beeper](https://www.beeper.com/), which is the best solution to keep all your chat apps inside one place, including iMessage! You can also use [BlueBubbles](https://www.beeper.com/) (which requires you to have a server Mac running 24/7) or [Sunbird](https://www.sunbirdapp.com/) (which is closed source and requires you to be a beta tester). One of our community members is also currently working on a BlueBubbles fork that implements a version of Pypush within it, so no server is needed and number reregistration is automatically ran. + +However, Beeper is completely free and easy to use, and comes packed with multiple features that rivals native apps. Beeper is currently in the process of removing the waitlist, so you will have to use an invite link shared to you in order to skip the waitlist until this change is made. This app is what most testing is done on, and is by far the most popular in the Android and iMessage community. # Installation You will first install Pypush onto your machine. *Please keep in mind that you will have to have a script running on a home server or PC 24/7 to keep your number active! See below for instructions.* From 2daa402ad60726bb11b368883b7ddefa02dceee9 Mon Sep 17 00:00:00 2001 From: Kasherpete <119694008+Kasherpete@users.noreply.github.com> Date: Tue, 3 Oct 2023 21:34:13 -0500 Subject: [PATCH 7/7] Increase timeout to 30s --- sms_registration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sms_registration.py b/sms_registration.py index 8e7208a..a8d3e6b 100644 --- a/sms_registration.py +++ b/sms_registration.py @@ -16,7 +16,7 @@ def register(push_token: bytes, no_parse = False, gateway = None) -> tuple[str, """Forwards a registration request to the phone and returns the phone number, signature for the provided push token""" if gateway is None: print("Requesting device MCC+MNC for gateway detection...") - mccmnc = requests.get(f"http://{PHONE_IP}:{API_PORT}/info").text + mccmnc = requests.get(f"http://{PHONE_IP}:{API_PORT}/info", timeout=30).text print("MCC+MNC received! " + mccmnc) print("Determining gateway...") gateway = gateway_fetch.getGatewayMCCMNC(mccmnc) @@ -30,7 +30,7 @@ def register(push_token: bytes, no_parse = False, gateway = None) -> tuple[str, req_id = random.randint(0, 2**32) sms = f"REG-REQ?v=3;t={token};r={req_id};" print("Sending message and waiting for response...") - r = requests.get(f"http://{PHONE_IP}:{API_PORT}/register", params={"sms": sms, "gateway": gateway}, timeout=16) + r = requests.get(f"http://{PHONE_IP}:{API_PORT}/register", params={"sms": sms, "gateway": gateway}, timeout=30) print("Received response from device!") if no_parse: print("Now do the next part and rerun with --pdu")