-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt.sh
executable file
·43 lines (37 loc) · 1.08 KB
/
decrypt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
readonly ENCRYPT_SCRIPT_RAW="https://raw.githubusercontent.com/zakattack9/encrypt-2FA-codes/master/encrypt.sh"
RECOVERY_CODES_DIR="./recovery_codes"
SETUP_CODES_DIR="./setup_codes"
MISC_DIR="./misc"
FILE=$1
# set encrypted zip to default or passed in file
if [ -z "$1" ]; then
if [ -f "./backup_codes.zip" ]; then
FILE="backup_codes.zip"
else
read -e -p "Enter zip file to decrypt: " FILE
fi
fi
# read in archive filename passed into this script
7za x $FILE
# check if unzip command ran successfully before deleting the zip file
if [ $? -eq 0 ]; then
# remove encrypted zip
rm $FILE
printf "\nDecrypted $FILE codes successfully!!!\n"
if [ ! -f "./encrypt.sh" ]; then
printf "\nGenerating encrypt script...\n"
curl $ENCRYPT_SCRIPT_RAW -o encrypt.sh
chmod +x encrypt.sh
fi
printf "\nDelete decrypt script?\n"
printf "Enter (y)es or (n)o: "
read CLEANUP
if [[ $CLEANUP == "y" ]]; then
printf "\nCleaning up...\n"
rm -- "$0"
fi
else
printf "\nFailed to decrypt the zip file :(\n"
rm -rf $SETUP_CODES_DIR $RECOVERY_CODES_DIR $MISC_DIR
fi