1

Testing a simple HTTP request using nc:

$ printf 'GET / HTTP/1.1\r\nHost: mozilla.org\r\nAccept: */*\r\n\r\n' | nc mozilla.org 80
HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Date: Thu, 10 Mar 2016 23:07:31 GMT
Location: https://www.mozilla.org/
Connection: Keep-Alive
Content-Length: 0

But most hosts result in no output. Using the -v option result is positive:

Connection to stackoverflow.com.com 80 port [tcp/http] succeeded!
Connection to reddit.com 80 port [tcp/http] succeeded!

Using the -D option one line is given:

nc: Permission denied

What is the reason for this?

user367890
  • 1,887
  • 2
  • 16
  • 27

2 Answers2

2

You may want -q 1 (or 2 or 3 or something) as otherwise nc will exit before the remote server has issued its response.

-D probably requires root.

0

You also might be missing some headers.

For example, httpbin.org/get would require Accept: header, and other websites may require other headers to be present to trigger a response.

dz902
  • 403