Sometimes handy for me: if you have information that you've sent in an HTTP POST, and you need to recover it for whatever reason, there's often no easy way to get at it from the browser interface. The browser will send the data again if you reload the page, so:
1. In a terminal, startup netcat as a listener:
nc -l -p9999
2. In your browser, configure the connection preferences to use manual proxy settings of host "localhost" and port "9999"
3. Hit reload on the browser, and tell it "yup, send the POST data again"
4. Look at the output of netcat
(Don't forget to change your proxy settings back!)
Absolutely. I already wrote in another part of this discussion "Most of the things one wants or needs to do on the net are most easily accomplished with dedicated tools, so places where only netcat will serve are rare." On the other hand, my little trick does just take a few seconds, and is probably easier than getting ethereal (oops, wireshark) set up for someone new to it.
I do think it's still useful to be aware of and play with tools like netcat, even when there are dedicated tools to accomplish most tasks. It's a bit like hacking in assembly... probably not practical in many cases, but you'll learn how stuff works underneath, and that understanding can still be really useful even when working at a higher level of abstraction.
My favorite nc trick of late is using it in combination with
ssh_config(5)'s "ProxyCommand" directive. "ProxyCommand" tells ssh to
use the specified command's stdin and stdout to communicate with the
destination host, rather than establishing a TCP connection itself. For example, if I can connect to the host "bastion", and if "bastion"
can connect to the host "destination", but I cannot connect directly to
"destination", I can stick the following in my ~/.ssh/ssh_config file:
Their link to netcat for windows supposedly from security focus definitely points to my website. I'm not actually affiliated with security focus in any way...
Netcat is an old and venerable Unix hacker tool. If you want to be a better hacker the netcat README is required reading. I would also recommend reading the source code, in particular the comments. Hobbit can be quite funny at times.
Netcat is usually installed on linux systems these days, but it is seldom compiled with -DGAPING_SECURITY_HOLE like it should be. Those really were the good old days...
nc is also great for redirecting *sqldump over the wire and importing directly on another machine. Using "nc -l" (for listen) and pointing a browser to it also let's you know plenty about what headers a browser is sending. (Yes, you can get a tool made especially for that, but when you don't, it's a great two second hack.)
Hm... Neat, but it looks like unencrypted mini-ssh to me, at least that's what I use to quickly send files or tunnel X between machines. What did I miss?
It's tiny, you don't need keys, it can run any any port privileged or not with or without an install. It can take a port and pipe it to a shell, or a program, or the file system. I guess I didn't say anything the article didn't, I've mostly seen it as part of rootkits honestly. Good tools can be used for anything good or bad.
Most of the things one wants or needs to do on the net are most easily accomplished with dedicated tools, so places where only netcat will serve are rare. It comes in handy for odd corner cases, or in restricted environments where dedicated tools might not be present (it was invaluable when I was a consultant).
Us Rubyists are used to using curl for testing our REST apps. What additional help/insight can netcat provide when building REST apps? Or Rails apps in general? Is there any?
curl is higher level. It implements a number of protocols like HTTP. nc is basically raw sockets. You can listen on a port with curl like you can with nc.
1. In a terminal, startup netcat as a listener:
2. In your browser, configure the connection preferences to use manual proxy settings of host "localhost" and port "9999"3. Hit reload on the browser, and tell it "yup, send the POST data again"
4. Look at the output of netcat
(Don't forget to change your proxy settings back!)