Atma
Atma

Reputation: 29767

how to netcat url with parameters?

I am trying to do a get via netcat to this address:

printf 'GET / HTTP/1.1\r\nHost: www.iana.org/domains/reserved\r\nConnection: close\r\n\r\n' |   nc www.iana.org/domains/reserved 80

I get the error:

nc: getaddrinfo: nodename nor servname provided, or not known

What am I doing wrong?

Upvotes: 3

Views: 3710

Answers (1)

Mattias Wadman
Mattias Wadman

Reputation: 11425

The path should be in the request line (the first line) after the method name (GET in this case). Currently you tell nc to look up the hostname www.iana.org/domains/reserved which will fail. Also the "Host" header should not include the path, only the hostname.

This should work:

printf 'GET /domains/reserved HTTP/1.1\r\nHost: www.iana.org\r\nConnection: close\r\n\r\n' | nc www.iana.org 80

Upvotes: 4

Related Questions