October 25, 2014 · linux netcat

Quick and simple http server using netcat



  .       .       
  \`-"'"-'/       
   } 6 6 {        
  ==. Y ,==       
    /^^^\  .      
   /     \  )     
  (  )-(  )/     _
  -""---""---   / 
 /   Ncat    \_/  
(     ____        
 \_.=|____E       


Netcat - it's a great tool for probably most things we can do with data.
And sometimes we may need a web-based server for getting some info (logs, for example).
Get a web server with netcat is very easy:

while :; do cat /var/log/rc.log  | nc -l -p 8080 -q1;done

To run netcat an all interfaces on port 8080, and get contents of /var/log/rc.log file.
Also the are several versions of netcat (GNU netcat, openbsd netcat and "classic" netcat) including patched versions with encryption in Gentoo and cryptcat - netcat with encryption capabilities. And not all options from OpenBSD-netcat have all other versions and vice versa.

Besides, it possible to get almost same functionality with just bash and named pipes using it pseudo-interface /dev/tcp, in reverse mode.

Thanks to http://razvantudorica.com/08/web-server-in-one-line-of-bash/

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus