Git Product home page Git Product logo

ngrok4ios's Introduction

ngrok4ios

Patching ngrok macOS arm64 binary to run on iOS

How does it work?

  • The ngrok binary is taken from a macOS arm64 build.
  • By default, some checks prevent a macOS binary from running on iOS. This repository contains a patcher to fix them.
  • There are a few missing functions. Stubs can be found in stubs.c. ngrok doesn't appear to use these functions. Forcing dyld to the flat namespace mode and insert the stubs can be used as a workaround.

Patching process

This can be done directly on a jailbroken iOS environment. You need to find and install iOS SDK (on Procursus, it is build-essential).

  • Install required tools (clang, Darwin CC Tools, git, ldid, build-essential). One-line command: sudo apt install -y build-essential clang git ldid odcctools.
  • Place ngrok into /usr/bin/ngrok_bin.
# Clone this repository
git clone https://github.com/khanhduytran0/ngrok4ios
cd ngrok4ios

# Set path to the SDK. The path below is an example, but is default in Procursus's build-essential
export SDK=/usr/share/SDKs/iPhoneOS.sdk

# Jump to root, this is required for doing ngrok modifications in /usr
su

# Change frameworks path
install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation -change /System/Library/Frameworks/Security.framework/Versions/A/Security /usr/lib/libngrokhelper.dylib /usr/bin/ngrok_bin

# Build and install the helper library
clang -isysroot $SDK stubs.c -o /usr/lib/libngrokhelper.dylib -dynamiclib -framework Security

# Build and install the patcher to /usr/bin
clang -isysroot $SDK patcher.c -o /usr/bin/ngrokpatcher

# Patch ngrok
ngrokpatcher /usr/bin/ngrok_bin

# Sign ngrok
ldid -Sent.xml /usr/bin/ngrok_bin

# Create a wrapper script
echo "DYLD_FORCE_FLAT_NAMESPACE=1 ngrok_bin \$@" > /usr/bin/ngrok

# Give executable permission
chmod +x /usr/bin/ngrok_bin /usr/bin/ngrok

# Run ngrok
ngrok ...

Note: since macOS's ngrok build is 11.0 (which is compatible with iOS 14.0), this might not work on iOS below 14.0.

ngrok4ios's People

Contributors

khanhduytran0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.