Skip to content

Commit

Permalink
support full boot9 dump
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaveamac committed May 19, 2017
1 parent d4870fd commit c3dcbc2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
24 changes: 21 additions & 3 deletions 3dsconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
Options:
--output=<dir> - Save converted files in specified directory
Default: {}
--boot9=<file> - Path to dump of protected ARM9 bootROM
--boot9=<file> - Path to dump of ARM9 bootROM, protected or full
--overwrite - Overwrite existing converted files
--ignore-bad-hashes - Ignore invalid hashes and CCI files and convert anyway
--verbose - Print more information'''.format(
Expand Down Expand Up @@ -188,10 +188,13 @@ def show_progress(val, maxval):
print_v('pyaes found, Searching for protected ARM9 bootROM')

def set_keys(boot9_file):
prot_offset = 0
if os.path.getsize(boot9_file) == 0x10000:
prot_offset = 0x8000
with open(boot9_file, 'rb') as f:
global keys_set, orig_ncch_key
# get Original NCCH (slot 0x2C key X)
f.seek(0x59D0)
f.seek(0x59D0 + prot_offset)
key = f.read(0x10)
key_hash = hashlib.md5(key).hexdigest()
if key_hash == 'e35bf88330f4f1b2bb6fd5b870a679ca':
Expand All @@ -208,13 +211,28 @@ def set_keys(boot9_file):
set_keys(boot9_path)
else:
print_v('File doesn\'t exist.')
# check current directory
# check current directory for boot9.bin
if not keys_set:
print_v('... boot9.bin: ', end='')
if os.path.isfile('boot9.bin'):
set_keys('boot9.bin')
else:
print_v('File doesn\'t exist.')
# check current directory for boot9_prot.bin
if not keys_set:
print_v('... boot9_prot.bin: ', end='')
if os.path.isfile('boot9_prot.bin'):
set_keys('boot9_prot.bin')
else:
print_v('File doesn\'t exist.')
# check ~/.3ds/boot9.bin
if not keys_set:
path = os.path.expanduser('~') + '/.3ds/boot9.bin'
print_v('... ' + path + ': ', end='')
if os.path.isfile(path):
set_keys(path)
else:
print_v('File doesn\'t exist.')
# check ~/.3ds/boot9_prot.bin
if not keys_set:
path = os.path.expanduser('~') + '/.3ds/boot9_prot.bin'
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ python3 3dsconv.py [options] game.3ds [game.3ds ...]
* `--verbose` - Print more information

## Encryption
3dsconv requires the Nintendo 3DS protected ARM9 bootROM to decrypt files using Original NCCH encryption (slot 0x2C). The file is checked for in the order of:
3dsconv requires the Nintendo 3DS full or protected ARM9 bootROM to decrypt files using Original NCCH encryption (slot 0x2C). The file is checked for in the order of:

* Value of option `--boot9=` or variable `boot9_path`, if set
* `boot9_prot.bin` in current working directory
* `$HOME/.3ds/boot9_prot.bin` (Linux/Unix systems) or `%USERPROFILE%\.3ds\boot9_prot.bin` (Windows)
* `boot9.bin` (full) in current working directory
* `boot9_prot.bin` (protected) in current working directory
* `~/.3ds/boot9.bin` (full)
* `~/.3ds/boot9_prot.bin` (protected)

Instructions to dump the bootROM will be put here later.

## Pack into standalone executable for Windows
Using [py2exe for Python 3](https://pypi.python.org/pypi/py2exe/), you can pack the script into a Windows executable, primarily for use on a computer without Python, or for easy use in the Windows Command Prompt. [Python 3.4](https://www.python.org/downloads/release/python-344/) is required, 3.5 or later is currently not supported.
Expand Down

0 comments on commit c3dcbc2

Please sign in to comment.