Created
March 26, 2014 16:38
-
-
Save gerjantd/9787569 to your computer and use it in GitHub Desktop.
Bash/nc: netcat as a simple http/smtp client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TALKING TO SERVERS | |
It is sometimes useful to talk to servers “by hand” rather than through a user interface. It can aid in troubleshooting, when it might be necessary to verify what data a server is sending in response to commands issued by the client. For example, to | |
retrieve the home page of a web site: | |
$ printf "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80 | |
Note that this also displays the headers sent by the web server. They can be filtered, using a tool such as sed(1), if necessary. | |
More complicated examples can be built up when the user knows the format of requests required by the server. As another example, an email may be submitted to an SMTP server using: | |
$ nc [-C] localhost 25 << EOF | |
HELO host.example.com | |
MAIL FROM:<[email protected]> | |
RCPT TO:<[email protected]> | |
DATA | |
Body of email. | |
. | |
QUIT | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment