Skip to content

rust-proxy/proxychains-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

proxychains-rs

A Rust rewrite of proxychains-windows - A proxifier for Win32 programs that forces TCP connections through SOCKS5 proxies.

Overview

This is a work-in-progress Rust implementation of proxychains for Windows, using modern Rust async/await, safe memory management, and strong type safety guarantees.

Architecture

┌─────────────────┐     启动      ┌─────────────────┐
│  proxychains.exe │ ───────────► │  目标程序.exe    │
│   (主控程序)     │   挂起+注入   │  (被注入DLL)    │
└────────┬────────┘              └────────┬────────┘
         │                                │
         │        Named Pipe (命名管道)    │
         │◄──────────────────────────────►│
         │    交换: DNS查询/FakeIP/日志    │
         │                                │
    维护 FakeIP 映射表              Hook 网络 API
    监控子进程生命周期              转发到 SOCKS5 代理

Project Structure

proxychains-rs/
├── Cargo.toml              # Workspace root
├── src/
│   ├── main.rs            # Main controller entry point
│   ├── injector.rs        # DLL injection logic
│   ├── ipc_server.rs      # Named pipe IPC server
│   ├── fakeip.rs          # FakeIP allocation/management
│   └── config.rs          # Configuration parser
├── proxychains-hook/      # Hook DLL crate
│   └── src/
│       ├── lib.rs         # DLL entry point
│       ├── ipc.rs         # IPC client
│       └── hooks.rs       # API hooks (connect, GetAddrInfoW, etc.)
└── proxychains-common/    # Shared types and protocols
    └── src/
        └── lib.rs         # IPC messages, config types

How It Works

  1. Process Creation: Main program creates target process in suspended state using CreateProcessW with CREATE_SUSPENDED flag
  2. DLL Injection: Injects proxychains_hook.dll into target process using CreateRemoteThread + LoadLibraryW
  3. API Hooking: Hooked DLL intercepts Winsock functions:
    • connect / WSAConnect - Hijacks TCP connections
    • GetAddrInfoW - Implements FakeIP DNS resolution
    • CreateProcessW - Propagates hooks to child processes
  4. FakeIP Mechanism: Returns fake IPs (198.18.x.x) for DNS queries, maps them to real hostnames internally
  5. SOCKS5 Proxying: Redirects all connections through configured SOCKS5 proxy

Building

Prerequisites

  • Rust 1.75+ (2024 edition)
  • Windows SDK
  • Visual Studio Build Tools (for Windows API)

Build Commands

# Build everything
cargo build --release

# Build specific targets
cargo build --release --bin proxychains
cargo build --release --manifest-path proxychains-hook/Cargo.toml

Usage

# Basic usage
proxychains.exe curl https://example.com

# With config file
proxychains.exe -c proxychains.conf firefox.exe

# Verbose mode
proxychains.exe -v ssh user@server

Configuration

Create proxychains.conf in one of these locations:

  • %USERPROFILE%\.proxychains\proxychains.conf
  • %APPDATA%\Proxychains\proxychains.conf
  • %PROGRAMDATA%\Proxychains\proxychains.conf

Example:

# SOCKS5 proxy
socks5 127.0.0.1:1080

# Enable remote DNS resolution
proxy_dns

# Quiet mode
quiet_mode

Status

⚠️ Work in Progress - This is an early implementation. Core features implemented:

  • Project structure and IPC protocol
  • FakeIP allocation logic
  • DLL injection framework
  • API hook skeleton
  • SOCKS5 client implementation
  • Full DNS resolution handling
  • Child process propagation
  • Configuration file parsing
  • Error handling and logging

License

GPL-2.0+ (same as original proxychains)

Credits

Based on proxychains-windows by shunf4.

About

Rust rewrite of proxychains-windows - A proxifier for Win32 programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages