Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danny8376/7003e69b7f608b03444d37370b592953 to your computer and use it in GitHub Desktop.
Save danny8376/7003e69b7f608b03444d37370b592953 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BOOT9=~/.3ds/boot9.bin
if [[ ! "$1" =~ ^- ]]; then
ESSENTIAL="$1"
shift
ARGC=$#
else
ESSENTIAL="${@:$#}"
ARGC=$(($#-1))
fi
if [[ "$ESSENTIAL" =~ ^https?:// ]]; then
TMP=$(mktemp)
curl -s -o $TMP "$ESSENTIAL"
ESSENTIAL=$TMP
fi
if [[ ! -f "$ESSENTIAL" ]]; then
echo "essential.exefs doesn't exist"
exit 1
fi
if [[ $(stat -c %s "$ESSENTIAL") != "8704" ]] && [[ $(stat -c %s "$ESSENTIAL") != "3584" ]]; then
echo "essential.exefs is invalid"
exit 1
fi
if [[ $(stat -c %s "$ESSENTIAL") == "3584" ]]; then
echo "Warning: essential.exefs is only 3.5KiB, no hwcal included, outdated godmode9?"
fi
OTP=$(mktemp)
SEC=$(mktemp)
dd if="$ESSENTIAL" of=$OTP bs=1 skip=3072 count=256 status=none # 0xC00, 0x100
dd if="$ESSENTIAL" of=$SEC bs=1 skip=1024 count=273 status=none # 0x400, 0x111
SERIAL="$(dd if=$SEC bs=1 skip=258 count=11 status=none | tr -d '\0')"
echo "$SERIAL"
cleaninty ctr --boot9 $BOOT9 GenJson --otp $OTP --secureinfo $SEC "${@:1:ARGC}"
echo "$SERIAL"
if [[ -n "$TMP" ]]; then rm $TMP; fi
rm $OTP $SEC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment