Last active
November 18, 2025 10:47
-
-
Save MoserMichael/32ad3a5cb1e09b9a32f105688da8eccf to your computer and use it in GitHub Desktop.
netcat without lies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| On ubuntu: a date server with netcat, so that you can see something in a web browser | |
| # For a single run; access with http://localhost:12005 | |
| d=$(date);echo -e "HTTP/1.1 200 OK\nConnection: close\nContent-Length: ${#d}\n\n${d}" | nc -l -p 12005 | |
| # For mutltiple runs; access with http://localhost:12005 | |
| while true; do d=$(date);echo -e "HTTP/1.1 200 OK\nConnection: close\nContent-Length: ${#d}\n\n${d}" | nc -l -p 12005; done | |
| # serving a video file | |
| # first downlod the video file to meow.webm | |
| # download yt-dlp (only way that works): python3 -m pip install -U "yt-dlp[default]" | |
| # also had to add ~/.local/bin/ to path. | |
| yt-dlp https://www.youtube.com/shorts/8jM4XT-5CUA -o meow | |
| # get file size into variable | |
| fsize=$(stat --printf=%s meow.webm) | |
| # serve the video once, can see it in a web browser. http://localhost:12008 | |
| fname="meow.webm";fsize=$(stat --printf='%s' $fname);echo -e "HTTP/1.1 200 OK\nConnection: close\nContent-Length: ${fsize}\nContent-Type: video/webm\n\n";cat ${fname} | nc -l -p 12008 -q 1 | |
| # serve the same video multiple times, can see in web browser. (adding a while loop) | |
| while true; do fname="meow.webm";fsize=$(stat --printf='%s' $fname);echo -e "HTTP/1.1 200 OK\nConnection: close\nContent-Length: ${fsize}\nContent-Type: video/webm\n\n";cat ${fname} | nc -l -p 12008 -q 1; done | |
| # ncat is nice, however I didn't succeed to run anything over TLS (despite telling browser to trust everything). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment