-
-
Save kevn-xyz/c995ad626134c2cbfb79f0414a13ad45 to your computer and use it in GitHub Desktop.
Simple netcat based one shot http file server
This file contains 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
#!/bin/bash | |
file=$1 | |
port=$2 | |
if [[ -n "$file" ]] && [[ -n "$port" ]]; then | |
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Disposition: inline; filename=\"$1\"\r\nContent-Length: $(wc -c < $file)\r\n\r\n"; cat $file; } | nc -l $port | |
else | |
echo "Usage: ncws <file> <port>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment