Skip to content

Commit 17a6150

Browse files
committed
Prevent private keys from being directly visible in the terminal
1 parent 6a337a7 commit 17a6150

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

upload.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ echo "[1] Github Release [gh auth login]
1515
read -p "Please enter your number: " UP
1616
read -p "Please enter file path/name: " FP
1717

18+
read_secret() {
19+
echo -n "$1"; KEY=""; while IFS= read -r -s -n1 c; do [[ $c == $'\n' || $c == $'\0' ]] && echo && break; [[ $c == $'\177' ]] && KEY="${KEY%?}" && echo -ne "\b \b" || { KEY+="$c"; echo -n "*"; }; done
20+
}
21+
1822
if [ $UP == 1 ]; then
1923
read -p "Please enter github repo link: " GH
2024
FN="$(basename $FP)" && FN="${FN%%.*}"
@@ -24,14 +28,14 @@ gh release upload --clobber $FN $FP --repo $GH
2428
fi
2529

2630
if [ $UP == 2 ]; then
27-
read -p "Please enter devupload key: " KEY
28-
echo -e "Started uploading file on DevUploads..."
29-
bash <(curl -s https://devuploads.com/upload.sh) -f $FP -k $KEY
31+
read_secret "Please enter devupload key: "
32+
echo "Started uploading file on DevUploads..."
33+
bash <(curl -s https://devuploads.com/upload.sh) -f $FP -k "$KEY"
3034
fi
3135

3236
if [ $UP == 3 ]; then
33-
read -p "Please enter Pixel Drain key: " KEY
34-
echo -e "Started uploading file on PixelDrain..."
37+
read_secret "Please enter Pixel Drain key: "
38+
echo "Started uploading file on PixelDrain..."
3539
curl -T $FP -u ":$KEY" https://pixeldrain.com/api/file/
3640
fi
3741

0 commit comments

Comments
 (0)