Created
November 5, 2020 09:17
-
-
Save JonathonReinhart/d78e56586c6fd976d3bc52ee4614a083 to your computer and use it in GitHub Desktop.
Decrypt pfSense encrypted config backups
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 | |
# Adapted from https://forum.netgate.com/topic/139561 | |
set -o pipefail | |
if [[ $# -lt 1 ]]; then | |
echo "Usage: $(basename $0) <encrypted-config>" | |
exit 1 | |
fi | |
inpath="$1" | |
tmpout="$(mktemp)" | |
cat "$inpath" \ | |
| sed -e '1d' -e '$d' \ | |
| base64 -d \ | |
| openssl enc -d -aes-256-cbc -md md5 \ | |
> $tmpout | |
exitstatus=$? | |
if [[ $exitstatus -eq 0 ]]; then | |
cat $tmpout | |
fi | |
rm $tmpout | |
exit $exitstatus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment