내가 사용하고 있는 netcat의 종류를 어떻게 알 수 있나요?

내가 사용하고 있는 netcat의 종류를 어떻게 알 수 있나요?

두 가지 맛으로 제공됩니다 netcat.netcat-openbsd그리고Netcat-전통적.

내가 사용하고 있는 netcat의 종류를 어떻게 알 수 있나요? 먹어봤지만 man nc맛이 어땠는지에 대한 말은 없었습니다.

답변1

첫째, 컴퓨터에 여러 버전을 설치할 수 있습니다. 따라서 대답은 설치된 버전 수와 입력하는 명령에 따라 달라집니다.

netcat-traditional그리고 Ubuntu의 패키지 관리자를 netcat-openbsd통해 설치할 수 있습니다 . 제 경우에는 apt소스 코드 빌드를 통해 GNU netcat플레이버 도 설치했습니다.이 공식 웹사이트.

"openbsd" 버전의 경우 <package-name>을 사용하여 위치 바이너리 이름을 찾을 수 있습니다 ( 패키지 관리자가 아닌 경우 dpkg -L에 해당하는 항목을 직접 검색하세요 ).dpkg Lapt

$ dpkg -L netcat-openbsd dpkg -L grep /bin |
/쓰레기통
/쓰레기통/nc.openbsd

그런 다음 type -a이진 이름이 nc.openbsd명령 내에서 검색 가능 $PATH하고 명령으로 해석되는지 확인하는 데 사용됩니다.

$ type -a nc.openbsd
nc.openbsd is /bin/nc.openbsd
nc.openbsd is /bin/nc.openbsd

"전통적인" 맛의 경우에도 동일합니다.

$ dpkg -L netcat-traditional | grep /bin
/bin
/bin/nc.traditional
$ type -a nc.traditional
nc.traditional is /bin/nc.traditional
nc.traditional is /bin/nc.traditional

nc.openbsd이는 도구를 실행하기 위한 명령을 실행할 수 있고 도구를 실행하기 위한 netcat-openbsd명령을 실행할 수 있음을 의미합니다 . (명령어에 '.'가 포함되어 있는데 패키지 이름에는 '-'가 포함되어 있어 혼동될 수 있습니다.)nc.traditionalnetcat-traditional

설치할 수 있는 맛은 3가지인 것 같습니다 apt.

$ apt-cache search netcat --names-only
netcat-openbsd - TCP/IP swiss army knife
netcat - TCP/IP swiss army knife -- transitional package
netcat-traditional - TCP/IP swiss army knife

하지만 실제로는 netcat가상 패키지일 뿐입니다.

$ apt-cache show netcat | grep Description-en  -A 2
Description-en: TCP/IP swiss army knife -- transitional package
 This is a "dummy" package that depends on lenny's default version of
 netcat, to ease upgrades. It may be safely removed.

따라서 필요한 경우 다음을 설치 netcat-openbsd하고 netcat-traditional전달할 수 있습니다.apt

sudo apt-get install netcat-openbsd
sudo apt-get install netcat-traditional

nc명령은 어떻습니까 netcat? 검색 가능한 여러 스타일에 바인딩될 수 있으며, 또는 를 입력하면 $PATH경로 중 하나가 실행됩니다. 마찬가지로 우선순위가 첫 번째 줄인 동안을 사용하여 확인할 수 있습니다(예:ncnetcattype -a용감한다음과 같은):

$ 유형-a nc 
nc는 /usr/local/bin/nc입니다.
nc는 /bin/nc입니다.
nc는 /usr/local/bin/nc입니다.
nc는 /bin/nc입니다.
$ 유형 -a netcat
netcat은 /usr/local/bin/netcat입니다.
netcat은 /bin/netcat입니다.
netcat은 /usr/local/bin/netcat입니다.
netcat은 /bin/netcat입니다.

realpath다음을 사용하여 해결 경로를 찾을 수 있습니다 .

$ 실제 경로/usr/local/bin/netcat 
/usr/local/bin/netcat
$ 실제 경로/bin/netcat
/bin/nc.openbsd
$ 실제 경로/usr/local/bin/nc
/usr/local/bin/netcat
$ 실제 경로/bin/nc
/bin/nc.openbsd

4개의 경로 중 2개만 내 시스템에서 고유합니다. 하나는 "GNU"이고 다른 하나는 "openbsd"입니다.

$ /usr/local/bin/netcat --version | head -1
netcat (The GNU Netcat) 0.7.1
$ /bin/nc.openbsd -h |& head -1
OpenBSD netcat (Debian patchlevel 1.130-3)

즉 , ncOR 을 입력하면 "GNU Netcat" netcat이 실행됩니다 /usr/local/bin/netcat.

update-alternatives확인된 심볼릭 링크 경로를 조정해 볼 수 있습니다 .

$ realpath /bin/nc
/bin/nc.openbsd
$ realpath /bin/netcat
/bin/nc.openbsd
$ sudo update-alternatives --config nc
There are 2 choices for the alternative nc (providing /bin/nc).

  Selection    Path                 Priority   Status
------------------------------------------------------------
  0            /bin/nc.openbsd       50        auto mode
* 1            /bin/nc.openbsd       50        manual mode
  2            /bin/nc.traditional   10        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in manual mode
$ realpath /bin/nc
/bin/nc.traditional
$ realpath /bin/netcat
/bin/nc.traditional

/bin/nc심볼릭 링크 와 확인된 심볼릭 링크를 모두 변경 /bin/netcat하지만 OR을 넣어도 /bin/nc.traditional여전히 우선 순위가 높기 때문에 스타일이 변경되지 않습니다.ncnetcat/usr/local/bin//bin$PATH

$ /bin/nc -h |& head -1
[v1.10-41]
$ nc -h |& head -1
GNU netcat 0.7.1, a rewrite of the famous networking tool.
$ type -a nc | head -1
nc is /usr/local/bin/nc

netcat에는 더 많은 종류가 있습니다.국립 고양이,소캇,sbd,넷캣 6,인터넷 고양이, 그리고크립토캣.

1 업데이트된 실제 심볼릭 링크는 /etc/alternatives/nc및 입니다 /etc/alternatives/netcat. 여기서 은 이미 /bin/nc및 각각 에 대한 심볼릭 링크 /bin/netcat입니다 ./etc/alternatives/nc/etc/alternatives/netcat

답변2

내가 실행하면 nc --version다음을 얻습니다.

netcat (The GNU Netcat) 0.7.1
Copyright (C) 2002 - 2003  Giovanni Giacobbi

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of
the GNU General Public License.
For more information about these matters, see the file named COPYING.

Original idea and design by Avian Research <[email protected]>,
Written by Giovanni Giacobbi <[email protected]>.

아마도 BSD 버전도 구체적일 것입니다.

답변3

Mac의 경우(GNU 버전이 표시되지만):

$ nc -h
GNU netcat 0.7.1, a rewrite of the famous networking tool.
[ further output snipped ]

Linux 머신(특히 Ubuntu)의 경우:

$ nc -h
[v1.10-41]
[ further output snipped ]

netcat --version, 다른 답변에서 제안한 것처럼 "잘못된 옵션" 오류가 발생 --version하므로 -h일반적인 테스트인 것 같습니다.

관련 정보