Domain 5Pivoting & MetasploitCORE

Proxychains Configuration

Complete guide to Proxychains4 configuration, chain types, and usage with SOCKS proxies for routing pentesting tools through tunnels in OSCP.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#proxychains#socks-proxy#nmap#configuration#oscp

Proxychains Configuration

Proxychains is a tool that forces any TCP connection through a proxy (SOCKS4, SOCKS5, or HTTP). Combined with a SOCKS proxy (from SSH or Chisel), it lets you route any pentesting tool through your tunnel to reach internal network targets.

What is Proxychains?

Proxychains intercepts TCP connections from supported applications and routes them through your configured proxy chain. This means tools like nmap, curl, firefox, and Impacket scripts can all reach internal hosts through your tunnel.

graph LR
    A[nmap / curl / msfconsole] -->|TCP| B[Proxychains]
    B -->|SOCKS5| C[localhost:1080]
    C -->|SSH/Chisel Tunnel| D[Pivot 10.10.10.5]
    D --> E[Target 10.10.10.10]

Installation

# Kali / Debian
sudo apt install proxychains4

# Verify
proxychains4 curl http://example.com

Configuration File

Location: /etc/proxychains4.conf

# View current config
cat /etc/proxychains4.conf

Key Configuration Sections

# [Strict Chain] - connections go through ALL proxies in order
strict_chain

# [Dynamic Chain] - skip failed proxies, try next
#dynamic_chain

# [Random Chain] - random order
#random_chain

# Maximum number of retries per proxy
chain_len = 2

# Set to 1 to proxy DNS requests through the chain
proxy_dns

# DNS timeout in seconds
proxy_timeout = 4

# Quiet mode
#quiet_mode

# [ProxyList]
# Format: type  host  port  [user  passwd]
# SOCKS5
socks5  127.0.0.1  1080
# SOCKS4
#socks4  127.0.0.1  1080
# HTTP with auth
#http  127.0.0.1  8080  myuser  mypass

Chain Types

Type Behavior Best For
strict_chain Connections go through ALL proxies in order. If any proxy fails, the connection fails. Single reliable proxy (most OSCP scenarios)
dynamic_chain If a proxy fails, skip it and try the next. More resilient. Multiple proxies, unreliable connections
random_chain Randomize proxy order for each connection. Obfuscation, load balancing

Chain Length

# Maximum number of retries per proxy
chain_len = 2

Proxy DNS

# CRITICAL: Set to 1 (uncomment) to proxy DNS requests
proxy_dns

Without proxy_dns, DNS resolution happens on your local machine, which may not resolve internal hostnames. With it enabled, DNS queries go through the tunnel.


ProxyList Syntax

[ProxyList]
# SOCKS5 (most common)
socks5  127.0.0.1  1080

# SOCKS4
socks4  127.0.0.1  1080

# HTTP proxy (with authentication)
http  127.0.0.1  8080  username  password

# Multiple proxies (for chaining)
socks5  127.0.0.1  1080
socks5  127.0.0.1  1081

Usage Examples

Basic Usage

# Prepend any command with proxychains4
proxychains4 <command>

# Examples
proxychains4 nmap -sT -Pn -p 22,80,443 10.10.10.10
proxychains4 curl http://10.10.10.10:8080
proxychains4 wget http://10.10.10.10/file.txt

Nmap Through Proxychains

# TCP connect scan (REQUIRED - SYN scan does NOT work through SOCKS)
proxychains4 nmap -sT -Pn -p 22,80,443,3306,8080 10.10.10.10

# With timing template
proxychains4 nmap -sT -Pn -T4 -p 22,80,443,8080 10.10.10.10

# Service version detection
proxychains4 nmap -sT -Pn -sV -p 80,443 10.10.10.10

Metasploit Through Proxychains

# Launch msfconsole through proxychains
proxychains4 msfconsole

# Or set environment variable
export USE_PROXYchains=1
proxychains4 msfconsole

Firefox Through Proxychains

# Launch browser through proxy
proxychains4 firefox http://10.10.10.10:8080

Impacket Through Proxychains

# SMB enumeration
proxychains4 python3 smbclient.py -port 445 DOMAIN/user:pass@10.10.10.10

# Secret dumping
proxychains4 python3 secretsdump.py DOMAIN/admin:pass@10.10.10.10

# PSEXEC
proxychains4 python3 psexec.py DOMAIN/admin:pass@10.10.10.10

Full Workflow: SSH SOCKS + Proxychains

# Step 1: Create SSH SOCKS tunnel
ssh -f -N -D 1080 user@10.10.10.5

# Step 2: Verify proxychains config
# /etc/proxychains4.conf should have:
# [ProxyList]
# socks5  127.0.0.1  1080

# Step 3: Test the proxy
proxychains4 curl http://10.10.10.10

# Step 4: Scan internal network
proxychains4 nmap -sT -Pn -p 22,80,443,3306,8080 10.10.10.10

# Step 5: Exploit internal services
proxychains4 python3 exploit.py 10.10.10.10 80

Full Workflow: Chisel SOCKS + Proxychains

# Step 1: Start Chisel server (attacker)
chisel server --port 8000 --reverse

# Step 2: Start Chisel client (pivot)
./chisel client 10.10.14.3:8000 R:socks

# Step 3: SOCKS proxy is now on localhost:1080
# Verify proxychains config:
# [ProxyList]
# socks5  127.0.0.1  1080

# Step 4: Use tools through the proxy
proxychains4 nmap -sT -Pn -p 22,80,443 10.10.10.10
proxychains4 curl http://10.10.10.10:8080

Critical: Why -sT and NOT -sS?

Scan Type Flag Works with Proxychains? Why?
TCP Connect -sT YES Completes full TCP handshake, works through SOCKS
SYN (Stealth) -sS NO Uses raw packets, cannot be proxied through SOCKS
# CORRECT
proxychains4 nmap -sT -Pn -p 22,80,443 10.10.10.10

# WRONG - will fail silently or show all ports closed
proxychains4 nmap -sS -Pn -p 22,80,443 10.10.10.10

Limitations

Limitation Impact Workaround
TCP only Cannot proxy UDP traffic Use socat for UDP forwarding
No ICMP Cannot proxy ping/traceroute Use socat or direct tunnel
Tool compatibility Some tools don’t work with proxychains Use environment variable ALL_PROXY=socks5://127.0.0.1:1080
Performance Extra hop adds latency Use -T4 timing in nmap
DNS resolution Internal hostnames may not resolve Enable proxy_dns in config

Troubleshooting

Problem Cause Solution
Proxychains error Config file missing proxy Add proxy to [ProxyList] section
Connection timed out SOCKS proxy not running Verify SSH/Chisel tunnel is active
DNS resolution fails proxy_dns not enabled Uncomment proxy_dns in config
Nmap shows all closed Using -sS instead of -sT Switch to -sT (TCP connect scan)
Tool not supported Tool doesn’t use libc Try proxyresolv or ALL_PROXY env var
Slow scanning Default timing too slow Use -T4 flag with nmap

OSCP Exam Tips

  1. Always use -sT with nmap through proxychains — this is the #1 mistake.
  2. Enable proxy_dns — it helps resolve internal hostnames.
  3. Test with curl first — proxychains4 curl http://target is a quick sanity check.
  4. Keep proxychains config clean — comment out unused proxies to avoid confusion.
  5. Use strict_chain for single proxy (default and most reliable).
  6. Some Python tools may need ALL_PROXY=socks5://127.0.0.1:1080 environment variable.

Further Reading