Skip to content

Instantly share code, notes, and snippets.

@pich4ya
Created March 6, 2023 03:25
Show Gist options
  • Save pich4ya/f4ae0b04f30653b2bcc2f2246bb564af to your computer and use it in GitHub Desktop.
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?

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