# Simple TCP Relaying with NetCat

This is a simple lab that looks at how to setup a traffic relay using netcat.

We are amining to create a relay between ports 4444 and 22 - any traffic coming to 4444 will be redirected to port 22.

```bash
# setup listener on port 22
nc -lvvp 22

# setup listener on port 4444 and direct stdout to port 22 using netcat
nc -lvvp 4444 | nc localhost 22

# send a string "test" to port 4444 using netcat
echo test | nc localhost 4444
```

Below is an animated demo of how this all works in action:

![](/files/-LVw_rNzgDjkrHZ_0-rw)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ired.team/offensive-security/lateral-movement/simple-tcp-relaying-with-netcat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
