Skip to content

Conversation

@0x0a0d
Copy link

@0x0a0d 0x0a0d commented Dec 5, 2025

  • add env PROXYCHAINS_CONFIG_FD= to proxychains4 that will be used to get content and parse before using file parsing (default behavior)
  • add proxychains-cli that take and parse inline config to fd(3) then pipe to proxychains4
  • add cli test in /tests/cli/test-cli.sh
  • add uninstall to Makefile
  • add _proxychains-cli to complications/zsh
  • more details read more on README-CLI.md

Options

Option Default Description
-h, --help Print help and exit
-v, --version Print version and exit
-c, --chain MODE strict Chain mode: strict/dynamic/random/round_robin
-l, --chain-len N Chain length (for random/round_robin)
-q, --quiet Quiet mode
-d, --dns MODE proxy DNS: proxy/old/off/IP:PORT
-S, --dns-subnet N 224 Remote DNS subnet (0-255)
-R, --read-timeout MS 15000 TCP read timeout (ms)
-T, --connect-timeout MS 8000 TCP connect timeout (ms)
-n, --localnet CIDR Bypass proxy for CIDR (repeatable)
--dnat "SRC DST" DNAT mapping (repeatable)
-P, --proxy "IP PORT [ USER PASS ]" Add proxy (repeatable)
--config Print config and exit
--proxychains-path PATH proxychains4 Path to proxychains4 binary

@0x0a0d 0x0a0d closed this Dec 5, 2025
@0x0a0d 0x0a0d reopened this Dec 6, 2025
README-CLI.md Outdated
proxychains-cli -P "socks5 127.0.0.1 1080" curl example.com
```

**Config passed to proxychains4 (fd 3):**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which fd it's using is irrelevant to a user, it's an implementation detail

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to update this README, when using fd, I can not pass content to child process in this case:

1. main.c exec node (nodejs) with PROXYCHAINS_CONFIG_FD=3
   ↓
2. dyld loads libproxychains4.dylib (DYLD_INSERT_LIBRARIES)
   ↓
3. gcc_init() constructor run BEFORE main()
   ↓
4. do_init() → get_chain_data() → setenv("PROXYCHAINS_CONFIG_FD", "5", 1) (nodejs used fd 3, 4 => we use 5)
   ↓
5. [proxychains] DLL init: proxychains-ng...  ← log printed
   ↓
6. node main() started
   ↓  
7. Debugger listening...  ← node start debugger
   ↓
8. [proxychains] failed to read... ← debugger subprocess still see PROXYCHAINS_CONFIG_FD is 3

it happened because

┌─────────────────────────────────────────────────────────────┐
│ Library loading (before main)                               │
├─────────────────────────────────────────────────────────────┤
│ 1. libc.dylib loads                                         │
│ 2. libnode.dylib loads ──► Node's C++ static init           │
│    └── NodeJS snapshot environment HERE!                    │
│ 3. libproxychains4.dylib loads                              │
│    └── run, clone fd, write new value to env but late       │
└─────────────────────────────────────────────────────────────┘
                    ↓
              main() starts

ofcourse I can use a larger fd() but not sure that program dont use that fd
=> I decided to use env PROXYCHAINS_CONFIG_DATA_ENV_VAR to handle config data
will update README

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the issue is the quiet mode ? just pass the right env var just like main.c does then

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to quiet mode.
proxychains4 uses env var to pass data to libproxychains, which is injected and runs before the program's main().
Everything works when the program doesn't spawn child processes, example: I'm using fd3 with PROXYCHAINS_DATA_FD=3.
But when the main program creates child processes, it may forward fd3/fd4 to them. In that case, I must switch libproxychains to use fd5 to avoid conflict with the child process behavior, and update the env to PROXYCHAINS_DATA_FD=5.
The issue when use proxychains to run Node.js (node) in debug mode:
node takes a snapshot of all env at startup and uses that snapshot for all child processes. As a result, child processes still receive PROXYCHAINS_DATA_FD=3 instead of 5, causing parsing errors.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see. will think about the best solution for that.

README-CLI.md Outdated
### Example 1: Basic SOCKS5 proxy

```bash
proxychains-cli -P "socks5 127.0.0.1 1080" curl example.com
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo we should only advertise protocol://[user:pass@]ip:port syntax in the cli tool

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok lets implement this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rofl0r should cli resolve hostname if URL using hostname:port instead of ip:port?

@rofl0r
Copy link
Owner

rofl0r commented Dec 6, 2025

ok, as usual all your AI generated content again makes this a huge PR, which takes every reload take half a minute. for now, exclude all your README and zsh etc additions until we got the proxychains4-cli, Makefile, and libproxychains.c right so i dont have to waste my time with secondary stuff until the primary stuff is right.

- remove zsh completions
- remove test
- remove README-CLI.md
- minimal changes to Makefile
- rename cli to proxychains4-cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants