Created
March 6, 2023 03:25
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # @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 | |
| ``` | |
can any one compile a m1 version for every one to download that?
@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
Proxychains-ng MacOS M1 -
killedIssue FixNOTE: All credit to pich4ya for the above solution and crypt0nX's comment. I wrote this to save someone else out there from a trial-by-fire for 2 days trying to find and combine many solutions. I came up with nothing new, and the below guide is just my combination of several solutions.
I will note that the above guide brought me the closest to anything out there, so thank you very much pich4ya.
I was, however, still having the following
killedissue:No matter how I ran it - with
sudo, with applications, without applications - nothing worked and it was always beingkilled.Fix Instructions:
Before performing ANY of pich4ya's above solution, perform the below steps. Pich4ya's steps are integrated into the below solution.
Step 0) Prerequisite - Remove/Uninstall/Delete Previous
proxychainsFiles.proxychains/proxychains-ngfiles, especially if installed withbrewor if you installed manually and ranmake install.findcommand and deleted any file containing theroxychaisubstring:Step 1)
Step 2)
arm64e, as outlined below:Step 3)
CFLAGS:Step 4) THE FIX
proxychains-ng, renamed the folder toproxychains-ng-tempand left it?proxychains4binary file we just compiled, with the binary we compiled earlier (in theproxychains-ng-tempfolder).IMPORTANT NOTES:
proxychains-ng-testfolder.csrutilin an earlier step, which provides some critical system security.proxychainswork without issues.csrutilis only required to run the command in Step 2) d), so we can re-enable it now.proxychains.confconfiguration file every time you runproxychains.-fswitch.proxychains.conffile is stored in thesrcfolder of theproxychains-ngfolder downloaded withgit: