Skip to content

Instantly share code, notes, and snippets.

@JonathonReinhart
Created November 5, 2020 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JonathonReinhart/d78e56586c6fd976d3bc52ee4614a083 to your computer and use it in GitHub Desktop.
Save JonathonReinhart/d78e56586c6fd976d3bc52ee4614a083 to your computer and use it in GitHub Desktop.
Decrypt pfSense encrypted config backups
#!/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