
다음 파이프라인을 설정했습니다. 이를 통해 파이프라인을 통과하는 원시 HTTP 요청 및 응답을 볼 수 있습니다.
메모:나는 아래 BSD를 사용하지만 (이것은 macOS 및 AmazonLinux와 함께 제공됩니다) 동일한 인수를 사용할 수 있는 nc
nmap's 도 시도했습니다. 1.7.3.2 동작은 동일합니다. 다른 인수를 사용하지만 파이프라인은 동일합니다. 설명은 동일하므로 한 줄만 추가하겠습니다 .ncat
socat
socat
socat
짧막 한 농담:
mkfifo res; nc -kl 8888 < res | tee /dev/stderr | nc google.com 80 | tee res
또는
mkfifo res; socat tcp-listen:8888,reuseaddr,fork - < res | tee /dev/stderr | socat - tcp:google.com:80 | tee res
설명:
mkfifo res; \ <-- Make a named pipe file with the name 'res'.
nc -kl 8888 < res \ <-- Open a socket listening on all interfaces at TCP port 8888. Use the 'res' pipe as input.
| tee /dev/stderr \ <-- Copy the request to stderr, so it's emitted by the terminal. stdout will be used as input for the next netcat.
| nc google.com 80 \ <-- Resolve google.com, connect to it on TCP port 80, and send what was received on stdin. The response goes to stdout.
| tee res <-- Copy the response to the 'res' pipe.
나는 이 파이프라인을 한 터미널에서 실행합니다(파이프라인 터미널), curl
다른 터미널(컬 터미널):
curl --resolve google.com:8888:127.0.0.1 http://google.com:8888
macOS와 Linux 모두에서:
그만큼컬 터미널응답을 올바르게 수신하고 표시합니다. 그만큼파이프라인 터미널요청과 응답을 표시합니다.
macOS(macOS Mojave 10.14.3):
파이프라인은 계속 실행됩니다. 을(를) 사용하여 다른 요청을 보낼 수 curl
있으며 에서 해당 요청을 볼 수 있습니다.파이프라인 터미널그리고 의 응답둘 다터미널.
Linux(AmazonLinux 4.1.13):
파이프라인은 계속 실행됩니다. curl
다른 요청을 보내면 작동이 중단되고 어디서도 요청이나 응답을 볼 수 없습니다.
버전:
맥 OS
$ uname -a
Darwin ch007837.na.webmd.net 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin
$ curl --version
curl 7.64.1 (x86_64-apple-darwin18.2.0) libcurl/7.64.1 SecureTransport zlib/1.2.11
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile libz NTLM NTLM_WB SSL UnixSockets
$ bash --version | head -1
GNU bash, version 5.0.3(1)-release (x86_64-apple-darwin18.2.0)
$ ncat --version
Ncat: Version 7.70 ( https://nmap.org/ncat )
nc
플래그가 없어서 잘 모르겠지만 --version
OS와 함께 제공되었습니다. 하지만 바이너리에는 다음 문자열이 있습니다.
$ strings "$(which nc)" | tail -1
@(#)PROGRAM:nc PROJECT:netcat-42.200.1
리눅스
$ uname -a
Linux ip-10-200-38-72 4.1.13-19.31.amzn1.x86_64 #1 SMP Wed Jan 20 00:25:47 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ curl --version
curl 7.40.0 (x86_64-redhat-linux-gnu) libcurl/7.40.0 NSS/3.19.1 Basic ECC zlib/1.2.8 libidn/1.18 libssh2/1.4.2
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
$ bash --version | head -1
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)
$ ncat --version
Ncat: Version 5.51 ( http://nmap.org/ncat )
$ yum list nc | tail -1 | sed 's/ \+/ /g'
nc.x86_64 1.84-24.8.amzn1 @amzn-main