add dependencies check and download script

This commit is contained in:
shijimasoft 2022-02-22 19:18:13 +01:00
parent 76b68379cd
commit 29a03d1190
3 changed files with 62 additions and 8 deletions

View File

@ -14,11 +14,7 @@ cia-unix/
├─ makerom ├─ makerom
└─ Encrypted Game.cia └─ Encrypted Game.cia
``` ```
**ctrtool** and **makerom** can be downloaded with `dltools.sh`
## Contributors
ctrtool and makerom are from [*3DSGuy* repository](https://github.com/3DSGuy/Project_CTR)
*[AdawareDeveloper](https://github.com/AdawareDeveloper)* contributed translating the [windows-only version](https://github.com/matiffeder/3DS-stuff/blob/master/Batch%20CIA%203DS%20Decryptor.bat)
## 📋 Roadmap ## 📋 Roadmap
- [x] Decrypt .cia - [x] Decrypt .cia
@ -33,3 +29,8 @@ Youll need the [Crystal compiler](https://crystal-lang.org/install/)
`crystal build cia-unix.cr --release` `crystal build cia-unix.cr --release`
Dependencies can be compiled with [makerom](https://github.com/3DSGuy/Project_CTR/tree/master/makerom) and [ctrtool](https://github.com/3DSGuy/Project_CTR/tree/master/ctrtool) make files Dependencies can be compiled with [makerom](https://github.com/3DSGuy/Project_CTR/tree/master/makerom) and [ctrtool](https://github.com/3DSGuy/Project_CTR/tree/master/ctrtool) make files
## Contributors
ctrtool and makerom are from [*3DSGuy* repository](https://github.com/3DSGuy/Project_CTR)
*[AdawareDeveloper](https://github.com/AdawareDeveloper)* contributed translating the [windows-only version](https://github.com/matiffeder/3DS-stuff/blob/master/Batch%20CIA%203DS%20Decryptor.bat)

View File

@ -22,12 +22,29 @@ def gen_args(name : String, part_count : Int32) : String
return args return args
end end
# dependencies check
tools = ["python2.7", "./ctrtool", "./makerom", "decrypt.py"]
tools.each do |tool|
if !File.exists? %x[which #{tool}].chomp
case tool
when "python2.7"
abort "#{"Python 2.7".colorize.mode :bold} not found. Install it before continue"
when "decrypt.py"
if !File.exists? tool
abort "#{tool.colorize.mode :bold} not found. Make sure it's located in the #{"same directory".colorize.mode :underline}"
end
else
abort "#{tool.lchop("./").colorize.mode :bold} not found. Make sure it's located in the #{"same directory".colorize.mode :underline}"
end
end
end
Dir["*.cia"].each do |cia| Dir["*.cia"].each do |cia|
if cia.includes? "decrypted" if cia.includes? "decrypted"
next next
end end
puts "Decrypting: #{cia.colorize.mode(:bold)}..." puts "Decrypting: #{cia.colorize.mode :bold}..."
cutn : String = cia.chomp ".cia" cutn : String = cia.chomp ".cia"
args : String = "" args : String = ""
content = %x[./ctrtool -tmd '#{cia}'] content = %x[./ctrtool -tmd '#{cia}']
@ -44,7 +61,7 @@ Dir["*.cia"].each do |cia|
log.puts %x[./makerom -f cia -ignoresign -target p -o '#{cutn}-decfirst.cia' #{args}] log.puts %x[./makerom -f cia -ignoresign -target p -o '#{cutn}-decfirst.cia' #{args}]
elsif content.match /T.*D.*0004000E/ elsif content.match /T.*D.*0004000E/
puts "CIA Type: #{"Patch".colorize.mode(:bold)}" puts "CIA Type: #{"Patch".colorize.mode :bold}"
log.puts %x[python2.7 decrypt.py '#{cia}'] log.puts %x[python2.7 decrypt.py '#{cia}']
patch_parts : Int32 = Dir["#{cutn}.*.ncch"].size patch_parts : Int32 = Dir["#{cutn}.*.ncch"].size
@ -54,7 +71,7 @@ Dir["*.cia"].each do |cia|
check_decrypt("#{cutn} (Patch)", "cia") check_decrypt("#{cutn} (Patch)", "cia")
elsif content.match /T.*D.*0004008C/ elsif content.match /T.*D.*0004008C/
puts "CIA Type: #{"DLC".colorize.mode(:bold)}" puts "CIA Type: #{"DLC".colorize.mode :bold}"
log.puts %x[python2.7 decrypt.py '#{cia}'] log.puts %x[python2.7 decrypt.py '#{cia}']
dlc_parts : Int32 = Dir["#{cutn}.*.ncch"].size dlc_parts : Int32 = Dir["#{cutn}.*.ncch"].size

36
dltools.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
bold=$(tput bold)
normal=$(tput sgr0)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo " * Downloading ${bold}ctrtool${normal}"
wget https://github.com/3DSGuy/Project_CTR/releases/download/ctrtool-v0.7/ctrtool-v0.7-macos_x86_64.zip -q
echo " * Extracting ${bold}ctrtool${normal}"
unzip -qq ctrtool-v0.7-macos_x86_64.zip -d ctrtool-v0.7-macos_x86_64
mv ctrtool-v0.7-macos_x86_64/ctrtool $(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/ctrtool
echo " * Downloading ${bold}makerom${normal}"
wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18/makerom-v0.18-macos_x86_64.zip -q
echo " * Extracting ${bold}makerom${normal}"
unzip -qq makerom-v0.18-macos_x86_64.zip -d makerom-v0.18-macos_x86_64
mv makerom-v0.18-macos_x86_64/makerom $(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/makerom
echo " * Cleaning up"
rm -rf ctrtool-v0.7-macos_x86_64.zip ctrtool-v0.7-macos_x86_64
rm -rf makerom-v0.18-macos_x86_64.zip makerom-v0.18-macos_x86_64
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo " * Downloading ${bold}ctrtool${normal}"
wget https://github.com/3DSGuy/Project_CTR/releases/download/ctrtool-v0.7/ctrtool-v0.7-ubuntu_x86_64.zip -q
echo " * Extracting ${bold}ctrtool${normal}"
unzip -qq ctrtool-v0.7-ubuntu_x86_64.zip -d ctrtool-v0.7-ubuntu_x86_64
mv ctrtool-v0.7-ubuntu_x86_64/ctrtool $(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/ctrtool
echo " * Downloading ${bold}makerom${normal}"
wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18/makerom-v0.18-ubuntu_x86_64.zip -q
echo " * Extracting ${bold}makerom${normal}"
unzip -qq makerom-v0.18-ubuntu_x86_64.zip -d makerom-v0.18-ubuntu_x86_64
mv makerom-v0.18-ubuntu_x86_64/makerom $(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/makerom
echo " * Cleaning up"
rm -rf ctrtool-v0.7-ubuntu_x86_64.zip ctrtool-v0.7-ubuntu_x86_64
rm -rf makerom-v0.18-ubuntu_x86_64.zip makerom-v0.18-ubuntu_x86_64
fi