From 3fc0aad7a1d0443ca421db022f406786b6c7dd39 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Tue, 27 Aug 2019 12:55:47 +0300 Subject: [PATCH] Service Access Control bugfixes --- .../NPDM/FSAccessControlController.java | 2 +- .../Controllers/NPDM/NPDMController.java | 2 +- .../NPDM/ServiceAccessControlController.java | 10 ++++------ .../java/konogonka/Tools/NPDM/ACI0Provider.java | 1 + .../Tools/NPDM/{ => ACID}/ACIDProvider.java | 7 ++++++- .../NPDM/{ => ACID}/FSAccessControlProvider.java | 2 +- .../NPDM/ACID/KernelAccessControlProvider.java | 8 ++++++++ .../{ => ACID}/ServiceAccessControlProvider.java | 16 +++++++++------- .../konogonka/Tools/NPDM/LCollectionEntry.java | 15 +++++++++++++++ .../java/konogonka/Tools/NPDM/NPDMProvider.java | 2 +- 10 files changed, 47 insertions(+), 18 deletions(-) rename src/main/java/konogonka/Tools/NPDM/{ => ACID}/ACIDProvider.java (90%) rename src/main/java/konogonka/Tools/NPDM/{ => ACID}/FSAccessControlProvider.java (95%) create mode 100644 src/main/java/konogonka/Tools/NPDM/ACID/KernelAccessControlProvider.java rename src/main/java/konogonka/Tools/NPDM/{ => ACID}/ServiceAccessControlProvider.java (52%) create mode 100644 src/main/java/konogonka/Tools/NPDM/LCollectionEntry.java diff --git a/src/main/java/konogonka/Controllers/NPDM/FSAccessControlController.java b/src/main/java/konogonka/Controllers/NPDM/FSAccessControlController.java index b94e238..0cfe26d 100644 --- a/src/main/java/konogonka/Controllers/NPDM/FSAccessControlController.java +++ b/src/main/java/konogonka/Controllers/NPDM/FSAccessControlController.java @@ -4,7 +4,7 @@ import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; import javafx.scene.control.TextField; -import konogonka.Tools.NPDM.FSAccessControlProvider; +import konogonka.Tools.NPDM.ACID.FSAccessControlProvider; import java.net.URL; import java.util.ResourceBundle; diff --git a/src/main/java/konogonka/Controllers/NPDM/NPDMController.java b/src/main/java/konogonka/Controllers/NPDM/NPDMController.java index 2d4f80b..bed2646 100644 --- a/src/main/java/konogonka/Controllers/NPDM/NPDMController.java +++ b/src/main/java/konogonka/Controllers/NPDM/NPDMController.java @@ -7,7 +7,7 @@ import javafx.scene.control.TextField; import konogonka.Controllers.ITabController; import konogonka.Tools.ISuperProvider; import konogonka.Tools.NPDM.ACI0Provider; -import konogonka.Tools.NPDM.ACIDProvider; +import konogonka.Tools.NPDM.ACID.ACIDProvider; import konogonka.Tools.NPDM.NPDMProvider; import konogonka.Workers.Analyzer; diff --git a/src/main/java/konogonka/Controllers/NPDM/ServiceAccessControlController.java b/src/main/java/konogonka/Controllers/NPDM/ServiceAccessControlController.java index 1f2c061..653d4a0 100644 --- a/src/main/java/konogonka/Controllers/NPDM/ServiceAccessControlController.java +++ b/src/main/java/konogonka/Controllers/NPDM/ServiceAccessControlController.java @@ -6,11 +6,10 @@ import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -import konogonka.LoperConverter; +import konogonka.Tools.NPDM.LCollectionEntry; import java.net.URL; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.LinkedList; import java.util.ResourceBundle; public class ServiceAccessControlController implements Initializable { @@ -26,11 +25,10 @@ public class ServiceAccessControlController implements Initializable { SACPane.getChildren().clear(); } - public void populateFields(LinkedHashMap collection){ + public void populateFields(LinkedList collection){ resetTab(); - for (Object object : collection.entrySet()) { - Map.Entry entry = (Map.Entry) object; + for (LCollectionEntry entry : collection) { Label control = new Label(String.format("0x%02x", entry.getKey())); Label serviceName = new Label(entry.getValue()); diff --git a/src/main/java/konogonka/Tools/NPDM/ACI0Provider.java b/src/main/java/konogonka/Tools/NPDM/ACI0Provider.java index 6acd59a..16973fa 100644 --- a/src/main/java/konogonka/Tools/NPDM/ACI0Provider.java +++ b/src/main/java/konogonka/Tools/NPDM/ACI0Provider.java @@ -2,6 +2,7 @@ package konogonka.Tools.NPDM; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.LinkedList; import static konogonka.LoperConverter.getLEint; diff --git a/src/main/java/konogonka/Tools/NPDM/ACIDProvider.java b/src/main/java/konogonka/Tools/NPDM/ACID/ACIDProvider.java similarity index 90% rename from src/main/java/konogonka/Tools/NPDM/ACIDProvider.java rename to src/main/java/konogonka/Tools/NPDM/ACID/ACIDProvider.java index 16a8e40..f8fe4ef 100644 --- a/src/main/java/konogonka/Tools/NPDM/ACIDProvider.java +++ b/src/main/java/konogonka/Tools/NPDM/ACID/ACIDProvider.java @@ -1,4 +1,6 @@ -package konogonka.Tools.NPDM; +package konogonka.Tools.NPDM.ACID; + +import konogonka.Tools.NPDM.ACI0Provider; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -28,6 +30,7 @@ public class ACIDProvider { private FSAccessControlProvider fsAccessControlProvider; private ServiceAccessControlProvider serviceAccessControlProvider; + private KernelAccessControlProvider kernelAccessControlProvider; public ACIDProvider(byte[] acidBytes) throws Exception{ if (acidBytes.length < 0x240) @@ -54,6 +57,7 @@ public class ACIDProvider { throw new Exception("ACIDProvider -> blocks inside the ACID are not sorted in ascending order. Only ascending order supported."); fsAccessControlProvider = new FSAccessControlProvider(Arrays.copyOfRange(acidBytes, fsAccessControlOffset, fsAccessControlOffset+fsAccessControlSize)); serviceAccessControlProvider = new ServiceAccessControlProvider(Arrays.copyOfRange(acidBytes, serviceAccessControlOffset, serviceAccessControlOffset+serviceAccessControlSize)); + kernelAccessControlProvider = new KernelAccessControlProvider(Arrays.copyOfRange(acidBytes, kernelAccessControlOffset, kernelAccessControlOffset+kernelAccessControlSize)); } public byte[] getRsa2048signature() { return rsa2048signature; } @@ -77,4 +81,5 @@ public class ACIDProvider { public FSAccessControlProvider getFsAccessControlProvider() { return fsAccessControlProvider; } public ServiceAccessControlProvider getServiceAccessControlProvider() { return serviceAccessControlProvider; } + public KernelAccessControlProvider getKernelAccessControlProvider() { return kernelAccessControlProvider; } } \ No newline at end of file diff --git a/src/main/java/konogonka/Tools/NPDM/FSAccessControlProvider.java b/src/main/java/konogonka/Tools/NPDM/ACID/FSAccessControlProvider.java similarity index 95% rename from src/main/java/konogonka/Tools/NPDM/FSAccessControlProvider.java rename to src/main/java/konogonka/Tools/NPDM/ACID/FSAccessControlProvider.java index 543e1ed..e267df1 100644 --- a/src/main/java/konogonka/Tools/NPDM/FSAccessControlProvider.java +++ b/src/main/java/konogonka/Tools/NPDM/ACID/FSAccessControlProvider.java @@ -1,4 +1,4 @@ -package konogonka.Tools.NPDM; +package konogonka.Tools.NPDM.ACID; import java.util.Arrays; diff --git a/src/main/java/konogonka/Tools/NPDM/ACID/KernelAccessControlProvider.java b/src/main/java/konogonka/Tools/NPDM/ACID/KernelAccessControlProvider.java new file mode 100644 index 0000000..23c9c9a --- /dev/null +++ b/src/main/java/konogonka/Tools/NPDM/ACID/KernelAccessControlProvider.java @@ -0,0 +1,8 @@ +package konogonka.Tools.NPDM.ACID; + +public class KernelAccessControlProvider { + + KernelAccessControlProvider(byte[] bytes){ + + } +} diff --git a/src/main/java/konogonka/Tools/NPDM/ServiceAccessControlProvider.java b/src/main/java/konogonka/Tools/NPDM/ACID/ServiceAccessControlProvider.java similarity index 52% rename from src/main/java/konogonka/Tools/NPDM/ServiceAccessControlProvider.java rename to src/main/java/konogonka/Tools/NPDM/ACID/ServiceAccessControlProvider.java index 4e1a0e2..0b40857 100644 --- a/src/main/java/konogonka/Tools/NPDM/ServiceAccessControlProvider.java +++ b/src/main/java/konogonka/Tools/NPDM/ACID/ServiceAccessControlProvider.java @@ -1,14 +1,16 @@ -package konogonka.Tools.NPDM; +package konogonka.Tools.NPDM.ACID; + +import konogonka.Tools.NPDM.LCollectionEntry; import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; +import java.util.LinkedList; public class ServiceAccessControlProvider { - private LinkedHashMap collection; + private LinkedList collection; public ServiceAccessControlProvider(byte[] bytes){ - collection = new LinkedHashMap<>(); + collection = new LinkedList<>(); byte key; String value; @@ -17,14 +19,14 @@ public class ServiceAccessControlProvider { while (i < bytes.length){ key = bytes[i]; value = new String(bytes, i+1, getSize(key), StandardCharsets.UTF_8); - collection.put(key, value); + collection.add(new LCollectionEntry(key, value)); i += getSize(key)+1; } } private int getSize(byte control) { - return ((byte) 0x7 & control) + 1; + return ((byte) 0x7 & control) + (byte) 0x01; } - public LinkedHashMap getCollection() { return collection; } + public LinkedList getCollection() { return collection; } } diff --git a/src/main/java/konogonka/Tools/NPDM/LCollectionEntry.java b/src/main/java/konogonka/Tools/NPDM/LCollectionEntry.java new file mode 100644 index 0000000..817bab2 --- /dev/null +++ b/src/main/java/konogonka/Tools/NPDM/LCollectionEntry.java @@ -0,0 +1,15 @@ +package konogonka.Tools.NPDM; + +public class LCollectionEntry { + private byte key; + private String value; + + public LCollectionEntry(byte key, String value){ + this.key = key; + this.value = value; + } + + public byte getKey() { return key; } + + public String getValue() { return value; } +} diff --git a/src/main/java/konogonka/Tools/NPDM/NPDMProvider.java b/src/main/java/konogonka/Tools/NPDM/NPDMProvider.java index 10638f1..01c0475 100644 --- a/src/main/java/konogonka/Tools/NPDM/NPDMProvider.java +++ b/src/main/java/konogonka/Tools/NPDM/NPDMProvider.java @@ -1,7 +1,7 @@ package konogonka.Tools.NPDM; -import konogonka.RainbowHexDump; import konogonka.Tools.ASuperInFileProvider; +import konogonka.Tools.NPDM.ACID.ACIDProvider; import java.io.*; import java.nio.charset.StandardCharsets;