CCCPaste

netcat webserver notes

#webservers using netcat, busybox nc, or ncat
#this will work with the full version of ncat, but busybox nc doesn't have '-c' builtin
ncat -l -p 8000 -c 'echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n";echo "

How are you today?

"' #this is more universal { echo -e 'HTTP/1.1 200 OK\r\n'; echo "

How are you today?

"; } | netcat -l -p 8000 #keep it up and running after serving files while [ 1 ];do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "

How are you today?

"; } | busybox -l -p 8000;done #or you can pass it a file { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html; } | busybox nc -l -p 8000 #or the output of a command { echo -e 'HTTP/1.1 200 OK\r\n'; ls /; } |busybox nc -l -p 8000 #or a command with html tags #note the use of '' and use single quotes due to special characters { echo -e 'HTTP/1.1 200 OK\r\n'; echo '';echo "
    ";for i in /*;do echo "
  • $i
  • ";done;echo "
"; } | busybox nc -l -p 8000 { echo -e 'HTTP/1.1 200 OK\r\n'; echo ''; #you can embed images into your document with base64 { echo -e 'HTTP/1.1 200 OK\r\n'; echo '';cat img.html; } | busybox nc -l -p 8000 #display all png images in current folder { echo -e 'HTTP/1.1 200 OK\r\n'; echo '';for i in *.png;do echo "";done; } | busybox nc -l -p 8000 { echo -e 'HTTP/1.1 200 OK\r\n'; echo '';for i in *.ogg;do echo "";done; } | busybox nc -l -p 8000