Git Product home page Git Product logo

allbadge-tool's Introduction

Obtaining Official Badge Data

Requirements

  • boot9.bin, the FIRM9 bootrom
    • preferably not from a dev unit
  • some disk space (at most 1GB)
  • internet connection

Process

1. Dump the boot9.bin

This step must be done manually, and can be done via GodMode9. The file is in MEMORY VIRTUAL.

2. Obtain the BOSS decryption key

This key is in the bootrom, and will be used to decrypt the downloaded data.

The exact location:

  • Skip 0x8000 bytes (first half of the bootrom)
  • Skip 0x5860 bytes (reach keyarea)
  • Skip 0x170 bytes (skip AESIV data that's not necessary here)
  • Skip 0x200 bytes (skip to the BOSS decryption key, keyslot 0x38)
  • Read 0x10 bytes (the key has 128 bits)

In other words, the BOSS encryption/decryption key is at 0xDBD0, with size of 0x10 bytes.

3. Download the badge data

The files can be obtained through the following link:

https://npdl.cdn.nintendowifi.net/p01/nsa/{REGION_CODE}/data/allbadge_v{VERSION}.dat?tm=2

Changing REGION_CODE with any of the following values:

  • JPN: j0ITmVqVgfUxe0O9
  • EUR: J6la9Kj8iqTvAPOq
  • USA: OvbmGLZ9senvgV3K

And the VERSION with either 130 or 131

The files are BOSS encrypted containers.

4. Decrypting the badge data

The BOSS containers are encrypted using AES encryption in CTR mode.

The key used is the one obtained from the bootrom.

The initial value is in the header of the BOSS container, and is unique to each container.

The process is as follows:

  • Obtain the first 12 bytes of the initial value from the bytes [0x1C,0x28[ in the file.
  • The last 4 bytes are an unsigned integer with value 0x1, big endian. (0x00 0x00 0x00 0x01).
  • Run the AES-CTR algorithm on the file starting at 0x28.
  • Trim the first 0x26E bytes of the decrypted file (or 0x296 bytes if you count the BOSS header), as those are BOSS container files.

The decrypted file is then revealed to be a SARC archive.

5. Extracting the badge data

Yeah, this one I am NOT explaining, the code is in allbadge_tool.ctr.sarc.

6. Repackage the badge data

For comodity's sake, the files are organized by their badge and set names in a zip archive, as that is all that is needed.

An alternative to storage

Store every file based on their hash, and point to their data in a database, for ease of access.

Result

From a single boot9.bin to zip archives, this process obtains official .prb and .cab files, badges and collections respectively.

Building the executable (Windows)

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pyinstaller executable.py --noconsole

allbadge-tool's People

Contributors

antimach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

keyboardctrl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.