Nothing too fancy here, but just an illustration of how versatile the netcat tool is/can be. We all know netcat to be a simple backdoor utility that can be used for simple chats and file transfers. Well to add to its long list of possibilities and features, i am going to set up a one page webserver. Useful if you got to set up a notification about your page being down for maintenance. In its basic form, we set up a netcat listener on port 80 then pipe or push a file into the connection when clients connect.
[for netcat] "# while true; do nc -l -p 80 -q 1 < index.html" ; done
[for ncat] "# while true; d0 ncat -l 80 --send-only < index.html ; done"
Note: we set up a while loop to keep the connection open to accept other requests. Using "-k" in ncat would not work in this instance as using the "--send-only" terminates the connection when all data has been sent to the client.
References/Good reading:
http://www.terminally-incoherent.com/blog/2007/08/07/few-useful-netcat-tricks/
http://www.stearns.org/doc/nc-intro.current.html
No comments:
Post a Comment