Skip to content

Instantly share code, notes, and snippets.

@Zibri
Last active April 10, 2024 18:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zibri/3b3c34c3ce36ec6c6f57618eeda6f200 to your computer and use it in GitHub Desktop.
Save Zibri/3b3c34c3ce36ec6c6f57618eeda6f200 to your computer and use it in GitHub Desktop.
Samsung SSD Firmware decrypt
#!/bin/bash
#
# Samsung SSD Firmware decompressor & deobfuscator
# By Zibri / RamJam in 2024
#
# This version uses openssl.
#
if ! which &>/dev/null openssl
then
echo "Please install openssl."
exit 1
fi
if ! which &>/dev/null 7z
then
echo "Please install 7zip."
exit 1
fi
if ! which &>/dev/null xxd
then
echo "Please install xxd."
exit 1
fi
if [ $# -eq 0 ]
then
echo "Usage $0 <Samsung FW iso file>"
echo "Download it from: https://semiconductor.samsung.com/consumer-storage/support/tools/"
exit 1
fi
if ! [ -f $1 ]; then
echo "File does not exist."
exit 1
fi
rm &>/dev/null -rf tmp magic key DSRD
echo "Decompressing iso..."
7z &>/dev/null x -y -otmp $1
echo "Decompressing initrd..."
7z &>/dev/null x -y -otmp/ tmp/initrd
echo "Extracting fumagician..."
7z &>/dev/null x -y -otmp/ tmp/initrd~ root/fumagician
echo "Dumping Key..."
key="$(strings tmp/root/fumagician/fumagician|grep -A 2 printk|tail -1|base64 -d|xxd -p -c 100)"
echo "KEY: $key"
echo "Decrypting..."
for a in tmp/root/fumagician/*.enc
do
fn="$(basename ${a:0:-4})"
dd if="$fn" bs=32 skip=1 if="$a" status=none | openssl enc -aes-256-ecb -d -out "${fn}.bin" -nopad -K $key
dd if="$fn" bs=32 count=1 if="$a" status=none | openssl enc -aes-256-ecb -d -out "${fn}.magic" -nopad -K $key
done
rm -rf tmp
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment