GithubHelp home page GithubHelp logo

shijimasoft / cia-unix Goto Github PK

View Code? Open in Web Editor NEW
86.0 3.0 11.0 46 KB

Decrypt CIA/3DS roms in UNIX environments (Linux and macOS)

License: Apache License 2.0

Crystal 54.84% Shell 45.16%
roms romhacking nintendo-3ds

cia-unix's Introduction

cia-unix

Decrypt CIA and 3DS roms in UNIX environments (Linux and macOS)

cia-unix/
├─ cia-unix
├─ ctrdecrypt
├─ ctrtool
├─ makerom
└─ Encrypted Game.cia

ctrtool, makerom and ctrdecrypt can be downloaded with dltools.sh

✅ Roadmap

  • Decrypt .cia
    • Games
    • Patch and DLCs
  • Decrypt .3ds
  • Rust decrypt.py rewrite (ctrdecrypt)

Warning

Decryption with cia-unix may fail, when it happens it is suggested to decrypt roms directly on the 3DS.

The old python 3 version can be found here.

⚡️ Build from source

You’ll need the Crystal compiler

crystal build cia-unix.cr --release --no-debug

Dependencies can be compiled with makerom and ctrtool make files.

Contributors

ctrtool and makerom are from 3DSGuy repository

Adaware contributed translating the windows-only version

cia-unix's People

Contributors

shijimasoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cia-unix's Issues

#6 still occurs

Just complied today from expermential, got this error:

which: no decrypt.py in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin)
Decrypting: Metroid Prime - Federation Force (CTR-U-BCAE) (v1.2.0) (U).cia...
Unsupported CIA

'cia-unix.cr' does not exist

Hi !

When I try to build from source with the "crystal build cia-unix.cr --release --no-debug" command, I get an error saying "'cia-unix.cr' does not exist".
Did I miss something ?

Thanks,
Bye

[NCCH ERROR] CXI's ID cannot be modified without the ability to resign the AccessDesc

hey guy, I found this is a bug, because list is not sorted:

        Dir["*.ncch"].each do |ncch|
            args += "-i '#{ncch}:#{i}:#{i}' "
            i += 1
        end

this can make a error command: ./makerom -f cia -ignoresign -target p -o 'Fire_Emblem_Kakusei_CHN-decfirst.cia' -i 'Fire_Emblem_Kakusei_CHN.1.ncch:0:0' -i 'Fire_Emblem_Kakusei_CHN.0.ncch:1:1'

so I rewrite with python like this

            if re.search(r'T.*d.*00040000', content):
                print("CIA Type: Game")
                subprocess.run(f"python3 decrypt.py '{cia}'", shell=True)

                i = 0
                for ncch in sorted(os.listdir('.')):
                    if ncch.endswith('.ncch'):
                        args += f"-i '{ncch}:{i}:{i}' "
                        i += 1

                subprocess.run(f"./makerom -f cia -ignoresign -target p -o '{cutn}-decfirst.cia' {args}", shell=True)

can fix it.

how to deal with ncch?

Im not sure am i right.

I do with .cia file with decrypt.py and get output file .ncch.

While actually my citra reads cia file? How may I get cia file, from ncch?

Does the next step do with ctrtool or makerom? I try search online but didnt get useful guide.

Any plan to make this tools work for Python 3.0+

It took me some effort to make cia-unix work on Ubuntu 22.04 with Python2. It would be nice to have it work for Python3 since Python2 is too old, and maybe later we will not run Python 2 at all.

"[SETTING ERROR] Argument "-rsf" is required" --> with .3ds file

Hello,
[Mac 10.14]
I'm having some troubles launching the decryption with the Terminal Mac for an Ocarina of Time rom which has the .3ds extension (and not .cia) in order to use it in Citra.

What I've done before :

I installed the cia-unix-main.zip (and unzipped it)
I installed the 0.32.0 version of Crystal (the most newest versions are incompatible with my mac, so I decided to take an earlier version)
I executed the dltools.sh in order to get the differents dependencies
I compiled with crystal build cia-unix.cr --release --no-debug
I've carefully put the rom into the cia_unix_main folder.

Here is the output from the terminal :

popos-Mac-Pro-2:cia-unix-main popo$ ./cia-unix /Users/popo/Desktop/EMULATION/CITRA/cia-unix-main/3DS1259\ -\ Legend\ of\ Zelda\ -\ Ocarina\ of\ Time\ 3D\,\ The\ \(USA\)\ \(En\,Fr\,Es\)\ \(Rev\ 1\).3ds 
Decrypting: 3DS1259 - Legend of Zelda - Ocarina of Time 3D, The (USA) (En,Fr,Es) (Rev 1).3ds...
dyld: cannot load 'ctrdecrypt' (load command 0x80000034 is unknown)
Building decrypted 3DS1259 - Legend of Zelda - Ocarina of Time 3D, The (USA) (En,Fr,Es) (Rev 1) 3DS...
[SETTING ERROR] Argument "-rsf" is required
Decryption failed

Removing cache...
Log saved

I know that someone already did a post on the "-rsf" argument. However, according to the solution, I modified the line (in the cia-unix.cr file)
log.puts %x[./makerom -ciatocci '#{decfirst}' -o '#{cutn}-decrypted.cci']
to log.puts %x[./makerom -desc -ciatocci '#{decfirst}' -o '#{cutn}-decrypted.cci'] (added -desc)
And it didn't solve the problem.

Four hypothesis :

  • I may have misunderstood the solution
  • The solution is available only for .cia files.
  • The Crystal I have isn't new enough (in the case there is new features in the decrypter code)
  • I don't have the correct version of the decrypter (should I check in the "release" tab of the github page ?)

How to reassemble decrypted .ncch partition files back into a .3ds file?

Hi! There’s no discussion tab so apologies for posting this question as an issue.

I have your experimental python3 script working in Batocera Linux in a virtualenv.

giving it an encrypted .3ds file it writes a .Main.ncch, .Manual.ncch, .N3DSUpdateData.ncch and .UpdateData.ncch files which I assume are the extracted partitions.

Do I use another command to reassemble the decrypted partitions into a .3ds file again?

I tried to download makerom but couldn’t make heads or tails of the usage.

How to run the package for someone who does not know how to use Python

Hi there, firstly, thank you for the effort you put on doing this, I know that for someone who has some knowledge in coding this can be a piece of cake. Unfortunately that is not my case haha. So, I wonder if you could help me with running this. I will be attaching some screens of how I see cia-unix-experimental in my PY3 folder.

Thank you

Captura de pantalla 2024-02-07 a las 10 41 07

ctrtool not found

im on linux and after being like 2 hours trying to search everything i needed to make this work i tried to run the program on crystal but then it says "ctrtool not found" even though it is right there, in the same file, and ive checked that it is the latest version (1.2.0) but it just wont find it. and ive checked many times to see if there are any differences on the names but its just the same exact file and it cant find it :(
and when it asks me if i want to download the missing tools it says --: 1: ./dltools.sh: not found even though it is RIGHT THERE TOO :,D
if you can give me any tips i would really appreaciate it, thank you.

Unable to decrypt Senran Kagura 2

Parsing CIA in file "Senran Kagura 2 - Deep Crimson (Europe) (DLC).cia":
  Problem parsing CIA content, skipping. Sorry about that :/

  Problem parsing CIA content, skipping. Sorry about that :/

  Problem parsing CIA content, skipping. Sorry about that :/

  Problem parsing CIA content, skipping. Sorry about that :/

  Problem parsing CIA content, skipping. Sorry about that :/


Partitions extracted

Using the python3 version.

[SETTING ERROR] Argument "-rsf" is required

When executing the program (after tinkering with missing libpcre.so files, and having to put decrypt.py in a PATH folder), it returns the following output:

Decrypting: Stella Glow (EUR).cia...
CIA Type: Game
[SETTING ERROR] Argument "-rsf" is required
Removing cache...
Log saved

Then quits to prompt. It happens independently of ./cia-unix being invoked with the argument "-rsf" (happens with and without)
I do not have access to my real, physical 3DS for a bit, so was hoping to make this work somehow

[SETTING ERROR] Argument "-rsf" is required

When I tried to run inside a directory containing a cia file, I got this error message
[SETTING ERROR] Argument "-rsf" is required
log:

2022-08-01 15:40:36 UTC

Partitions extracted

btw I patched cia-unix.cr to use python3 instead of python2.7
does that matter?

I keep getting this error

Some tools are missing, do you want to download them? (y/n): y
--: ./dltools.sh: Permission denied
ctrtool not found. Make sure it's located in the same directory

Haven't used Crystal before, so I might be doing something wrong, but shouldn't the tools be automatically downloaded?

[NCCH ERROR]

[NCCH ERROR] CXI's ID cannot be modified without the ability to resign the AccessDesc
I am attempting to decrypt Mario Kart 7 from many different sources (none work)

Issue extracting ctrtool, had to download zip manually

This happened on WSL Ubuntu. Here is the uname -a output: 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux. running dltools.sh gave the following error:

Screenshot 2024-03-11 101540

I was able to fix the issue by downloading the zip file myself using wget: wget https://github.com/3DSGuy/Project_CTR/releases/download/ctrtool-v1.2.0/ctrtool-v1.2.0-ubuntu_x86_64.zip, then re-running the shell script. Having looked at the shell script, my wget command looked identical to the one in the script, so I'm not really sure why this happened.

dependancy hell on Linux

Running Fedora linux and I keep running into dependency issues. At first it was with pycrypto, but the alternative pycryptodome fixed that. Hoever now I get "error while loading shared libraries: libpcre.so.3: cannot open shared object file: No such file or directory" when trying to run it

which: no decrypt.py in ...

Running cia-unix in experimental results in which not being able to find decrypt.py
I worked around this by adding it the directory to $PATH and making it executable.
export $PATH=$PATH:`pwd` && chmod u+x decrypt.py

How to use this tool?

Firstly, thanks for the tool!!!

But I met some problems:
I ran "python decrypt.py xxx.cia", and got two ncch files, but no cci file, and the two ncch files hadn't been deleted.

This is the screenshot of the folder
image

This is the output on terminal
image

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.