Last active
May 8, 2024 05:28
-
-
Save danny8376/7003e69b7f608b03444d37370b592953 to your computer and use it in GitHub Desktop.
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
#!/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