> For the complete documentation index, see [llms.txt](https://rosemary-2.gitbook.io/rosemary-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rosemary-2.gitbook.io/rosemary-docs/tutorials/socks5-proxy.md). Agents can also search and read this documentation through its [MCP server](https://rosemary-2.gitbook.io/rosemary-docs/~gitbook/mcp).

# SOCKS5 Proxy

***

*Beginner · 10 minutes*

Route any SOCKS5-compatible tool through a Rosemary agent.

***

### Overview

SOCKS5 proxy allows any application that supports SOCKS5 to tunnel through a specific agent. Unlike transparent routing (which works kernel-level), SOCKS5 is application-level and works instantly with browsers, proxychains, curl, and most security tools.

**In this tutorial:**

* Start a SOCKS5 proxy through an agent
* Use it with curl
* Use it with proxychains
* Add authentication

***

### Scenario

You have an agent connected to an internal network. You want to run tools like `curl`, `nmap`, or a browser through that agent to access internal services.

```
[Your Tool] > SOCKS5 > [Server] > [Agent] > [Internal Network]
```

***

### Step 1: Start SOCKS5 Proxy

```bash
rosemary> socks agent-24 1080
```

**Output:**

```
[+] SOCKS5 started on 127.0.0.1:1080 > agent agent-24 (id: socks-abc12345, no auth)
```

***

### Step 2: Use with curl

```bash
curl --socks5 127.0.0.1:1080 http://192.168.1.104
```

***

### Step 3: Use with proxychains

Edit `/etc/proxychains4.conf`:

```
[ProxyList]
socks5 127.0.0.1 1080
```

Run tools through the agent:

```bash
proxychains nmap -sV 192.168.1.104
proxychains ssh user@192.168.1.50
proxychains firefox
```

***

### Step 4: SOCKS5 with Authentication

```bash
rosemary> socks agent-24 1081 internal_user SecurePass123
```

**Output:**

```
[+] SOCKS5 started on 127.0.0.1:1081 > agent agent-24 (id: socks-def67890, auth: internal_user)
```

***

### Step 5: List Active SOCKS5 Proxies

```bash
rosemary> socks list
```

**Output:**

```
SOCKS5 Servers (Proxy Pivots):
ID              Port  Agent        Conns  Uptime
socks-abc12345  :1080 agent-24     3      5m30s
socks-def67890  :1081 agent-24     0      1m10s
```

***

### Step 6: Stop a SOCKS5 Proxy

```bash
rosemary> socks stop socks-abc12345
```

**Output:**

```
[+] SOCKS5 socks-abc12345 stopped
```

***

***

### API Reference

#### Start SOCKS5

| Field     | Type   | Required | Description           |
| --------- | ------ | -------- | --------------------- |
| agent\_id | string | yes      | Agent ID              |
| port      | int    | yes      | Local port for SOCKS5 |
| username  | string | no       | Auth username         |
| password  | string | no       | Auth password         |

```bash
curl -X POST http://localhost:1024/api/v1/socks \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"agent_id":"agent-24","port":1080}'
```

#### List SOCKS5 Proxies

```bash
curl http://localhost:1024/api/v1/socks \
  -H "Authorization: Bearer $TOKEN"
```

#### Stop SOCKS5

```bash
curl -X DELETE "http://localhost:1024/api/v1/socks?id=socks-abc12345" \
  -H "Authorization: Bearer $TOKEN"
```

***

### SOCKS5 vs Transparent Routing

| Feature             | SOCKS5             | Transparent      |
| ------------------- | ------------------ | ---------------- |
| Requires root       | No                 | Yes              |
| Application support | SOCKS5-aware tools | All applications |
| Setup               | One command        | Automatic        |
| Granularity         | Per application    | System-wide      |

***
