pypush

repository·main·Indexed 25 days ago

https://github.com/jjtech0130/pypush

A platform-independent library designed to interface with Apple's internal API surfaces, specifically focusing on the Apple Push Notification service (APNs). It allows clients to act as Apple devices to receive push notifications and includes CLI tools for proxying APNs traffic and listening for app notifications.

Tokens
843
Snippets
2
Records
12
Agent score
87%

What's inside pypush

  1. Overview of pypush capabilities

    main

    pypush is a platform-independent library designed to interface with Apple's internal APIs.

    Current Capabilities:

    • Supports the client side of Apple's internal APNs (Apple Push Notification service) API.
    • Allows a client to act as an Apple device to receive push notifications.

    Future Roadmap:

    • Re-introduction of the iMessage API and other Apple internal surfaces.
  2. Install pypush in editable mode for development

    main

    If you are developing on pypush, clone the repository and install it in editable mode using pip install -e ..

    git clone https://github.com/JJTech0130/pypush
    cd pypush
    pip install -e .
  3. Install pypush

    main

    You can install pypush using pip. To include the CLI functionality, use the [cli] extra.

    Note: The current version (v2.x) is undergoing a major rewrite and is considered unstable. Stability is expected with version 3.0.0.

    pip install pypush[cli]
  4. Redirect courier traffic using redirect_courier

    main
    The redirect_courier function uses Frida to intercept getaddrinfo calls within an active session. It checks if the requested hostname matches the courier parameter and, if so, redirects the request to the to address by overwriting the memory of the first argument.
  5. Bypass certificate validation with trust_all_hosts

    main
    The trust_all_hosts function hooks the Objective-C method -[APSTCPStream isTrust:validWithPolicy:forPeer:] to force it to always return true (1). This is used to bypass TLS/SSL trust validation for APSD connections.
  6. Run the Courier Proxy with APNS interception

    main

    The pypush.cli.proxy module provides functionality to run a local proxy that intercepts APNS (Apple Push Notification service) traffic. It can act as a transparent proxy between a client and Apple's courier servers, or it can actively attach to the apsd (Apple Push Notification service daemon) process using Frida to redirect traffic to the local proxy.

    To use the proxy, call the main function. If attach is set to True, the proxy will attempt to use Frida to attach to apsd, redirect its courier connections to localhost, and trust all hosts.

  7. Configure the Courier Proxy listener

    main

    The courier_proxy function starts a TLS listener on a specified host and the default transport.COURIER_PORT. It configures the SSL context to support the apns-security-v3 ALPN protocol and uses automatically generated self-signed certificates.

    Key behaviors:

    • Listens on transport.COURIER_PORT.
    • Uses apns-security-v3 ALPN protocol.
    • Automatically generates temporary self-signed certificates via temp_certs().
    • Uses an SNI callback to identify if the connection is intended for the sandbox environment based on the server name.
  8. Listen for app notifications with the `notifications` command

    main
    The notifications command connects to the APNs courier and listens for app notifications on a specific topic. You can toggle between the sandbox and production environments using the --sandbox or --production flags.