> For the complete documentation index, see [llms.txt](https://johnermac.gitbook.io/johnermac/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://johnermac.gitbook.io/johnermac/post-exploitation/data-exfiltration/udp/netcat.md).

# Netcat

Netcat, also known as "nc," is a versatile networking utility that allows for easy creation of TCP/IP connections, port scanning, and network troubleshooting.

### Basic Usage

```css
nc [options] [hostname/IP] [port]
```

```
nc example.com 80
```

Send and receive files

```css
nc -l [port] < file_to_send
nc [server_IP] [port] > received_file
```

Port scanning

<pre class="language-css"><code class="lang-css">nc -zv [hostname/IP]<a data-footnote-ref href="#user-content-fn-1"> </a>[start_port]-[end_port]
</code></pre>

## How to extract files using netcat

<figure><img src="https://3593245608-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkPEBr0Ohu5Y49JHmv4La%2Fuploads%2F7qXK1UZls3ZgmfoAf4mJ%2Fimage.png?alt=media&amp;token=496482c5-f379-46ad-bd9d-fc28f8a53a3f" alt=""><figcaption><p>Set a UDP Listener</p></figcaption></figure>

<figure><img src="https://3593245608-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkPEBr0Ohu5Y49JHmv4La%2Fuploads%2FKwuEezg4eoPlb8uqkdPA%2Fimage.png?alt=media&amp;token=b62d7e6e-4386-4410-a3a0-47166e159712" alt=""><figcaption><p>Send the files</p></figcaption></figure>

<figure><img src="https://3593245608-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkPEBr0Ohu5Y49JHmv4La%2Fuploads%2F90WcyM7u700ACh3SSx0H%2Fimage.png?alt=media&amp;token=ee1167f0-d862-4570-9bf9-f533d6ff1da5" alt=""><figcaption><p>Wireshark Results</p></figcaption></figure>

[^1]:
