use of net.runelite.cache.util.XteaKeyManager in project runelite by runelite.
the class MapDumperTest method dumpRaw.
@Test
@Ignore
public void dumpRaw() throws IOException {
File base = StoreLocation.LOCATION, outDir = folder.newFolder();
XteaKeyManager keyManager = new XteaKeyManager();
keyManager.loadKeys();
try (Store store = new Store(base)) {
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.MAPS);
for (int i = 0; i < MAX_REGIONS; i++) {
int[] keys = keyManager.getKeys(i);
int x = i >> 8;
int y = i & 0xFF;
Archive map = index.findArchiveByName("m" + x + "_" + y);
Archive land = index.findArchiveByName("l" + x + "_" + y);
assert (map == null) == (land == null);
if (map == null || land == null) {
continue;
}
byte[] data = map.decompress(storage.loadArchive(map));
Files.write(data, new File(outDir, "m" + x + "_" + y + ".dat"));
if (keys != null) {
try {
data = land.decompress(storage.loadArchive(land), keys);
} catch (IOException ex) {
logger.info("Unable to decompress and load land " + x + "," + y + " (bad keys?)", ex);
continue;
}
logger.info("Decrypted region {} coords {},{}", i, x, y);
Files.write(data, new File(outDir, "l" + x + "_" + y + ".dat"));
}
}
}
}
use of net.runelite.cache.util.XteaKeyManager in project runelite by runelite.
the class MapDumperTest method loadRegions.
private Map<MapDefinition, LocationsDefinition> loadRegions(Store store) throws IOException {
Map<MapDefinition, LocationsDefinition> mapMap = new HashMap<>();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.MAPS);
XteaKeyManager keyManager = new XteaKeyManager();
keyManager.loadKeys();
for (int i = 0; i < MAX_REGIONS; ++i) {
int x = i >> 8;
int y = i & 0xFF;
Archive map = index.findArchiveByName("m" + x + "_" + y);
Archive land = index.findArchiveByName("l" + x + "_" + y);
assert (map == null) == (land == null);
if (map == null || land == null) {
continue;
}
byte[] data = map.decompress(storage.loadArchive(map));
MapDefinition mapDef = new MapLoader().load(x, y, data);
LocationsDefinition locDef = null;
int[] keys = keyManager.getKeys(i);
if (keys != null) {
try {
data = land.decompress(storage.loadArchive(land), keys);
} catch (IOException ex) {
continue;
}
locDef = new LocationsLoader().load(x, y, data);
}
mapMap.put(mapDef, locDef);
}
return mapMap;
}
Aggregations