![Forrest logo](/images/logo.png)
nc:tldr:9a1f1
nc: Send a HTTP request.
$ echo -e "GET / HTTP/1.1\nHost: ${hostname}\n\n" | nc ${hostname} 80
try on your machine
This command is used to send an HTTP request to a web server using the echo
and nc
utilities in Linux.
Here is a breakdown of the command:
echo
: This command is used to print or output text. In this case, it is used to generate the HTTP request.-e
: This option allows the interpretation of escape sequences in the text provided toecho
."GET / HTTP/1.1\nHost: ${hostname}\n\n"
: This is the text being echoed. It represents the HTTP request being sent to the web server. The request consists of a GET method for the root directory ("/") using HTTP/1.1, and includes the "Host" header with the value of the${hostname}
variable. The "\n" represents newlines in the request.|
: This is the pipe operator, used to pass the output of theecho
command as input to another command.nc
: This command is short for "netcat" and is used for reading and writing network connections. In this case, it is used to establish a connection to the specified${hostname}
on port 80.${hostname}
: This is a placeholder for the hostname or IP address of the web server you want to send the HTTP request to. This value should be provided when executing the command.
In summary, the command creates an HTTP GET request and sends it to the specified web server using nc
on port 80.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.