mirror of
https://github.com/Maschell/JWUDTool.git
synced 2024-11-16 21:19:19 +01:00
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>
|
||||
<groupId>de.mas</groupId>
|
||||
<artifactId>jwudtool</artifactId>
|
||||
<version>0.4</version>
|
||||
<version>0.5</version>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
@ -79,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.Maschell</groupId>
|
||||
<artifactId>JNUSLib</artifactId>
|
||||
<version>90e83fe</version>
|
||||
<version>822cf2d</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
|
@ -58,7 +58,7 @@ public class Main {
|
||||
}
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd = null;
|
||||
CommandLine cmd;
|
||||
try {
|
||||
cmd = parser.parse(options, args);
|
||||
} catch (MissingArgumentException e) {
|
||||
@ -76,14 +76,18 @@ public class Main {
|
||||
boolean devMode = false;
|
||||
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)) {
|
||||
showHelp(options);
|
||||
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)) {
|
||||
input = cmd.getOptionValue(OPTION_IN);
|
||||
}
|
||||
@ -114,10 +118,6 @@ public class Main {
|
||||
overwrite = true;
|
||||
}
|
||||
|
||||
if (cmd.hasOption(OPTION_DEVMODE)) {
|
||||
devMode = true;
|
||||
}
|
||||
|
||||
if (cmd.hasOption(OPTION_COMPRESS)) {
|
||||
boolean verify = true;
|
||||
System.out.println("Compressing: " + input);
|
||||
@ -171,6 +171,7 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("Done!");
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
switch (arg) {
|
||||
case "all":
|
||||
extractAll = true;
|
||||
break;
|
||||
case "content":
|
||||
extractContent = true;
|
||||
break;
|
||||
case "ticket":
|
||||
extractTicket = true;
|
||||
break;
|
||||
case "hashes":
|
||||
extractHashes = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("Argument not found:" + arg);
|
||||
return;
|
||||
case "all":
|
||||
extractAll = true;
|
||||
break;
|
||||
case "content":
|
||||
extractContent = true;
|
||||
break;
|
||||
case "ticket":
|
||||
extractTicket = true;
|
||||
break;
|
||||
case "hashes":
|
||||
extractHashes = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("Argument not found:" + arg);
|
||||
return;
|
||||
}
|
||||
|
||||
assert input != null;
|
||||
File inputFile = new File(input);
|
||||
|
||||
System.out.println("Extracting: " + inputFile.getAbsolutePath());
|
||||
|
||||
WiiUDisc wudInfo = null;
|
||||
WiiUDisc wudInfo;
|
||||
if (!devMode) {
|
||||
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
||||
} else {
|
||||
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);
|
||||
System.out.println("Found " + titles.size() + " titles on the Disc.");
|
||||
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 {
|
||||
if (input == null) {
|
||||
System.out.println("You need to provide an input file");
|
||||
return;
|
||||
}
|
||||
File inputFile = new File(input);
|
||||
|
||||
System.out.println("Decrypting: " + inputFile.getAbsolutePath());
|
||||
|
||||
WiiUDisc wudInfo = null;
|
||||
WiiUDisc wudInfo;
|
||||
if (!devMode) {
|
||||
wudInfo = WUDLoader.load(inputFile.getAbsolutePath(), titlekey);
|
||||
} else {
|
||||
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);
|
||||
System.out.println("Found " + partitions.size() + " titles on the Disc.");
|
||||
|
||||
@ -326,7 +319,7 @@ public class Main {
|
||||
}
|
||||
System.out.println("Parsing WUD image.");
|
||||
WUDImage image = new WUDImage(inputImage);
|
||||
Optional<File> outputFile = Optional.empty();
|
||||
Optional<File> outputFile;
|
||||
if (!decompress) {
|
||||
outputFile = WUDService.compressWUDToWUX(image, output, overwrite);
|
||||
if (outputFile.isPresent()) {
|
||||
@ -358,10 +351,10 @@ public class Main {
|
||||
byte[] key;
|
||||
try {
|
||||
key = Files.readAllBytes(file.toPath());
|
||||
if (key != null && key.length == 16) {
|
||||
if (key.length == 16) {
|
||||
return Optional.of(key);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
|
Loading…
Reference in New Issue
Block a user