
為什麼包裝-e
中缺少該選項netcat-openbsd
?有一個netcat-traditional
軟體包,但它缺少 OpenBSD 軟體包的許多功能。我正在運行 Linux Mint 16。
有人知道為什麼缺少這個?它刪除了 netcat 的一個很大的功能。
答案1
因為該程式有各種版本。
與 POSIX 中指定的許多其他標準實用程式不同,沒有「標準」來描述netcat
必須支援哪些選項。您有netcat
OpenBSD、FreeBSD、GNU 網路貓等等。
對於 OpenBSD 變體線上幫助頁指出:
There is no -c or -e option in this netcat, but you still can execute a
command after connection being established by redirecting file descriptors.
Be cautious here because opening a port and let anyone connected execute
arbitrary command on your site is DANGEROUS. If you really need to do this,
here is an example:
On ‘server’ side:
$ rm -f /tmp/f; mkfifo /tmp/f
$ cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f
On ‘client’ side:
$ nc host.example.com 1234
$ (shell prompt from host.example.com)
By doing this, you create a fifo at /tmp/f and make nc listen at port 1234
of address 127.0.0.1 on ‘server’ side, when a ‘client’ establishes a
connection successfully to that port, /bin/sh gets executed on ‘server’
side and the shell prompt is given to ‘client’ side.
When connection is terminated, nc quits as well. Use -k if you want it keep
listening, but if the command quits this option won't restart it or keep nc
running. Also don't forget to remove the file descriptor once you don't
need it anymore:
$ rm -f /tmp/f
答案2
在上一個版本中,我在 netcat 的某些來源中找到了定義,也啟用了執行指令。通常出於安全原因它被禁用。
但我找到了一種替代方法來解決