added decrypt script

This commit is contained in:
henne 2024-04-03 10:45:38 +02:00
parent ed3475e2a7
commit f26490e918
1 changed files with 33 additions and 0 deletions

33
decryptKey Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
KEY=$1
KEYLENGTH=${#KEY}
TOKEN=$2
if [ "$#" -ne 2 ]; then
echo "Usage: ${0} pin \"token\""
echo "With:"
echo -e " pin\t\t numeric pin with 1 to 32 numbers"
echo -e " token\t\t the token from Snipe"
exit 1
fi
if ! [[ $KEY =~ ^[0-9]+$ ]];
then
echo "Invalid key"
exit 1
fi
if [ $KEYLENGTH -gt 32 ]; then
echo "Key is too long"
exit 1
fi
while [ $KEYLENGTH -lt 32 ]
do
KEY="0${KEY}"
KEYLENGTH=${#KEY}
done
echo -n $TOKEN >/tmp/apitoken_snipe
K=$(echo -n $KEY | xxd -p -c 100)
DEC=$(openssl enc -aes-256-ecb -d -in /tmp/apitoken_snipe -K $K -base64 -A)
echo "$DEC"
rm /tmp/apitoken_snipe