Improve dev common key detection, fix splitted file support on non-windows machines
This commit is contained in:
parent
1443db9cdf
commit
6a6afff21d
4
pom.xml
4
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.mas</groupId>
|
<groupId>de.mas</groupId>
|
||||||
<artifactId>jwudtool</artifactId>
|
<artifactId>jwudtool</artifactId>
|
||||||
<version>0.4</version>
|
<version>0.5</version>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.Maschell</groupId>
|
<groupId>com.github.Maschell</groupId>
|
||||||
<artifactId>JNUSLib</artifactId>
|
<artifactId>JNUSLib</artifactId>
|
||||||
<version>90e83fe</version>
|
<version>822cf2d</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLineParser parser = new DefaultParser();
|
CommandLineParser parser = new DefaultParser();
|
||||||
CommandLine cmd = null;
|
CommandLine cmd;
|
||||||
try {
|
try {
|
||||||
cmd = parser.parse(options, args);
|
cmd = parser.parse(options, args);
|
||||||
} catch (MissingArgumentException e) {
|
} catch (MissingArgumentException e) {
|
||||||
|
@ -76,14 +76,18 @@ public class Main {
|
||||||
boolean devMode = false;
|
boolean devMode = false;
|
||||||
byte[] titlekey = null;
|
byte[] titlekey = null;
|
||||||
|
|
||||||
readKey(new File(HOMEPATH + File.separator + "common.key")).ifPresent(key -> Main.commonKey = key);
|
|
||||||
readKey(new File("common.key")).ifPresent(key -> Main.commonKey = key);
|
|
||||||
|
|
||||||
if (cmd.hasOption(OPTION_HELP)) {
|
if (cmd.hasOption(OPTION_HELP)) {
|
||||||
showHelp(options);
|
showHelp(options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd.hasOption(OPTION_DEVMODE)) {
|
||||||
|
devMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
readKey(new File(HOMEPATH + File.separator + (devMode ? "devcommon.key" : "common.key"))).ifPresent(key -> Main.commonKey = key);
|
||||||
|
readKey(new File("common.key")).ifPresent(key -> Main.commonKey = key);
|
||||||
|
|
||||||
if (cmd.hasOption(OPTION_IN)) {
|
if (cmd.hasOption(OPTION_IN)) {
|
||||||
input = cmd.getOptionValue(OPTION_IN);
|
input = cmd.getOptionValue(OPTION_IN);
|
||||||
}
|
}
|
||||||
|
@ -114,10 +118,6 @@ public class Main {
|
||||||
overwrite = true;
|
overwrite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.hasOption(OPTION_DEVMODE)) {
|
|
||||||
devMode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd.hasOption(OPTION_COMPRESS)) {
|
if (cmd.hasOption(OPTION_COMPRESS)) {
|
||||||
boolean verify = true;
|
boolean verify = true;
|
||||||
System.out.println("Compressing: " + input);
|
System.out.println("Compressing: " + input);
|
||||||
|
@ -171,6 +171,7 @@ public class Main {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void extract(String input, String output, boolean devMode, boolean overwrite, byte[] titlekey, String arg) throws Exception {
|
private static void extract(String input, String output, boolean devMode, boolean overwrite, byte[] titlekey, String arg) throws Exception {
|
||||||
|
@ -183,39 +184,35 @@ public class Main {
|
||||||
boolean extractHashes = false;
|
boolean extractHashes = false;
|
||||||
|
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "all":
|
case "all":
|
||||||
extractAll = true;
|
extractAll = true;
|
||||||
break;
|
break;
|
||||||
case "content":
|
case "content":
|
||||||
extractContent = true;
|
extractContent = true;
|
||||||
break;
|
break;
|
||||||
case "ticket":
|
case "ticket":
|
||||||
extractTicket = true;
|
extractTicket = true;
|
||||||
break;
|
break;
|
||||||
case "hashes":
|
case "hashes":
|
||||||
extractHashes = true;
|
extractHashes = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Argument not found:" + arg);
|
System.out.println("Argument not found:" + arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert input != null;
|
||||||
File inputFile = new File(input);
|
File inputFile = new File(input);
|
||||||
|
|
||||||
System.out.println("Extracting: " + inputFile.getAbsolutePath());
|
System.out.println("Extracting: " + inputFile.getAbsolutePath());
|
||||||
|
|
||||||
WiiUDisc wudInfo = null;
|
WiiUDisc wudInfo;
|
||||||
if (!devMode) {
|
if (!devMode) {
|
||||||
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
||||||
} else {
|
} else {
|
||||||
wudInfo = WUDLoader.loadDev(inputFile.getAbsolutePath());
|
wudInfo = WUDLoader.loadDev(inputFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wudInfo == null) {
|
|
||||||
System.out.println("Failed to load WUX " + inputFile.getAbsolutePath());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<NUSTitle> titles = WUDLoader.getGamePartionsAsNUSTitles(wudInfo, Main.commonKey);
|
List<NUSTitle> titles = WUDLoader.getGamePartionsAsNUSTitles(wudInfo, Main.commonKey);
|
||||||
System.out.println("Found " + titles.size() + " titles on the Disc.");
|
System.out.println("Found " + titles.size() + " titles on the Disc.");
|
||||||
for (val title : titles) {
|
for (val title : titles) {
|
||||||
|
@ -248,23 +245,19 @@ public class Main {
|
||||||
private static void decryptFile(String input, String output, String regex, boolean devMode, boolean overwrite, byte[] titlekey) throws Exception {
|
private static void decryptFile(String input, String output, String regex, boolean devMode, boolean overwrite, byte[] titlekey) throws Exception {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
System.out.println("You need to provide an input file");
|
System.out.println("You need to provide an input file");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
File inputFile = new File(input);
|
File inputFile = new File(input);
|
||||||
|
|
||||||
System.out.println("Decrypting: " + inputFile.getAbsolutePath());
|
System.out.println("Decrypting: " + inputFile.getAbsolutePath());
|
||||||
|
|
||||||
WiiUDisc wudInfo = null;
|
WiiUDisc wudInfo;
|
||||||
if (!devMode) {
|
if (!devMode) {
|
||||||
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
||||||
} else {
|
} else {
|
||||||
wudInfo = WUDLoader.loadDev(inputFile.getAbsolutePath());
|
wudInfo = WUDLoader.loadDev(inputFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wudInfo == null) {
|
|
||||||
System.out.println("Failed to load Wii U Disc Image " + inputFile.getAbsolutePath());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FSTDataProvider> partitions = WUDLoader.getPartitonsAsFSTDataProvider(wudInfo, Main.commonKey);
|
List<FSTDataProvider> partitions = WUDLoader.getPartitonsAsFSTDataProvider(wudInfo, Main.commonKey);
|
||||||
System.out.println("Found " + partitions.size() + " titles on the Disc.");
|
System.out.println("Found " + partitions.size() + " titles on the Disc.");
|
||||||
|
|
||||||
|
@ -326,7 +319,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
System.out.println("Parsing WUD image.");
|
System.out.println("Parsing WUD image.");
|
||||||
WUDImage image = new WUDImage(inputImage);
|
WUDImage image = new WUDImage(inputImage);
|
||||||
Optional<File> outputFile = Optional.empty();
|
Optional<File> outputFile;
|
||||||
if (!decompress) {
|
if (!decompress) {
|
||||||
outputFile = WUDService.compressWUDToWUX(image, output, overwrite);
|
outputFile = WUDService.compressWUDToWUX(image, output, overwrite);
|
||||||
if (outputFile.isPresent()) {
|
if (outputFile.isPresent()) {
|
||||||
|
@ -358,10 +351,10 @@ public class Main {
|
||||||
byte[] key;
|
byte[] key;
|
||||||
try {
|
try {
|
||||||
key = Files.readAllBytes(file.toPath());
|
key = Files.readAllBytes(file.toPath());
|
||||||
if (key != null && key.length == 16) {
|
if (key.length == 16) {
|
||||||
return Optional.of(key);
|
return Optional.of(key);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
Loading…
Reference in New Issue