Created
April 10, 2024 17:17
-
-
Save agustik/5db8ce0807a0764bafd6882c09db0084 to your computer and use it in GitHub Desktop.
Revisions
-
agustik created this gist
Apr 10, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/bin/bash port=$(shuf -i 9000-60000 -n 1) file=$1 if [[ -z "$1" ]]; then echo "Missing file, use $0 <file>" exit 1 fi md5=$(md5sum $file | awk '{ print $1 }') name=$(basename "$file") primaryip=$(ip route get 1.1.1.1 | grep -oP 'src \K\S+') echo "Serving file on $port # To fetch the file use: # curl http://$HOSTNAME:$port -o $name # Or using ip # curl http://$primaryip:$port -o $name # # Check the content, md5sum $name it should be: # $md5 # Hint, you might need to turn of your firewall # sudo systecmtl stop iptables # " cat <(echo "HTTP/1.1 200 OK Content-Type: Content-type: application/octet-stream E-Tag: $md5 Content-Disposition: attachment; filename=\"$name\" Content-Length: $( du -b $file ) Server: Netcat " ) $file | nc -l $port > /dev/null echo "Transfer complete"