-
-
Save amadoalmex/d967504d6b1434675fdf05639e6d3ffb to your computer and use it in GitHub Desktop.
One-shot HTTP webserver to serve file contents using netcat
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
serveit(){ | |
clen=$(wc -c < "$1" | cut -f1 -d' ') | |
while true ; do | |
cat <<endheaders | |
HTTP/1.0 200 OK | |
Content-Type: application/octet-stream | |
Content-Length: $clen | |
Content-Disposition: attachment; filename="$1" | |
endheaders | |
cat "$1" | |
break; | |
done | nc -l -p 8789 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment