Wednesday, September 17, 2014

Quick webserver w/ netcat

{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c < <(ls))\r\n\r\n"; cat <(ls); } | nc -l 8080
 
You can replace <(ls) with whatever script or file to display or command to 
execute that you like 
 

http://192.168.1.<your ip>:8080  

(Thanks to https://kb.ip-connect.de/index.php?id=422 for the tip)
 
Or.. if you want to execute a command upon visiting the website url
 
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c < <(ls))\r\n\r\n"; cat <(ls); } | nc -l 8080 && <command>

No comments:

Post a Comment