Skip to content

Instantly share code, notes, and snippets.

@pich4ya
Created March 6, 2023 03:25
Show Gist options
  • Select an option

  • Save pich4ya/f4ae0b04f30653b2bcc2f2246bb564af to your computer and use it in GitHub Desktop.

Select an option

Save pich4ya/f4ae0b04f30653b2bcc2f2246bb564af to your computer and use it in GitHub Desktop.
Install proxychains-ng on macOS m1/m2 arm64e natively without Rosetta 2 (2023)
# @author Pichaya Morimoto ([email protected])
Problem:
```bash
brew install proxychains-ng
proxychains4 ncat 1.2.3.4 # not working
```
There are public workarounds like https://benobi.one/posts/running_brew_on_m1_for_x86/
which suggests to use brew's x86_64 version or run the proxychains4 binary with `arch -x86_64`.
This seems to be working, but it hurts performance (with Rosetta 2 emulator).
Here we can find the proxychains4 binary, in which, it runs natively on our beloved M1/M2 chips <3
Solution:
# M1/M2 supports arm64e, but we need to enable it.
# https://developer.apple.com/documentation/driverkit/debugging_and_testing_system_extensions#3626024
# Tested on macOS 13.2.1 (2023)
# shutdown & long press Power button to recovery mode -> Terminal
csrutil disable
# reboot to normal mode
# enable arm64e support
sudo nvram boot-args=-arm64e_preview_abi
# reboot
Then,
```bash
git clone https://github.com/rofl0r/proxychains-ng
cd proxychains-ng
CFLAGS="-arch arm64e" LDFLAGS="-arch arm64e" ./configure --prefix=/usr/local --bindir=/usr/local/bin --libdir=/usr/local/lib --fat-binary-m1
make
$ file ./proxychains4
./proxychains4: Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64] [arm64e:Mach-O 64-bit executable arm64e]
./proxychains4 (for architecture x86_64): Mach-O 64-bit executable x86_64
./proxychains4 (for architecture arm64): Mach-O 64-bit executable arm64
./proxychains4 (for architecture arm64e): Mach-O 64-bit executable arm64e
$ ./proxychains4 -f /opt/homebrew/etc/proxychains.conf ncat 127.0.0.1 22 -v
[proxychains] config file found: /opt/homebrew/etc/proxychains.conf
[proxychains] preloading /xxx/proxychains-ng/libproxychains4.dylib
[proxychains] DLL init: proxychains-ng 4.16-git-10-g199d03d
Ncat: Version 7.93 ( https://nmap.org/ncat )
[proxychains] Strict chain ... 127.0.0.1:1080 ... 127.0.0.1:22 ... OK
Ncat: Connected to 127.0.0.1:22.
SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
```
@cornradio
Copy link

can any one compile a m1 version for every one to download that?

@troman29
Copy link

troman29 commented Oct 2, 2025

@sorryyyy Your process is being killed because SIP (csrutil) is enabled, and there is no way to bypass this. A binary built under arm64e will work ONLY with SIP disabled.

In your instructions, you replace the proxychain4 built for arm64e with one for arm64, which makes all the effort pointless (the same arm64 binary can simply be installed via brew).

As for me, I just decided not to proxy binaries provided by the system (for example, ssh) but to install them through brew. This way, they are properly proxied through proxychains from brew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment