Created
May 6, 2022 00:51
-
-
Save nabsha/0d3c8c14f7caecf053c5e0b0dddc9649 to your computer and use it in GitHub Desktop.
A quick hack to re encrypting mule secure properties file
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 | |
if [ "$#" -ne 4 ]; then | |
echo "usage: ./reencrypt.sh <Algo> <Key Source> <source file> <Key Target>"; | |
exit -1; | |
fi | |
ALGO=$1 | |
KEY_SOURCE=$2 | |
FILE=$3 | |
KEY_TARGET=$4 | |
if [ ! -f "$FILE" ]; then | |
echo "$FILE does not exists." | |
exit -1; | |
fi | |
while IFS='=' read -r k v; do | |
if [[ $k = *[!\ ]* ]] && [[ $v = *[!\ ]* ]]; then | |
if [[ $v =~ \!\[(.*)$ ]]; then | |
ENCRYPTED=${BASH_REMATCH[1]} | |
ENC=${ENCRYPTED::-2} | |
DECRYPTED_STRING=$(docker run --rm nabsha/docker-mule-secure-tool decrypt $ALGO $KEY_SOURCE $ENC) | |
ENCRYPTED_STRING=$(docker run --rm nabsha/docker-mule-secure-tool encrypt $ALGO $KEY_TARGET $DECRYPTED_STRING) | |
echo "$k=![$ENCRYPTED_STRING]" | |
fi | |
fi | |
done < "$FILE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment