Search in sources :

Example 1 with XteaKeyManager

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"));
            }
        }
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) XteaKeyManager(net.runelite.cache.util.XteaKeyManager) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) IOException(java.io.IOException) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with XteaKeyManager

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;
}
Also used : Archive(net.runelite.cache.fs.Archive) HashMap(java.util.HashMap) XteaKeyManager(net.runelite.cache.util.XteaKeyManager) Index(net.runelite.cache.fs.Index) IOException(java.io.IOException) LocationsLoader(net.runelite.cache.definitions.loaders.LocationsLoader) MapDefinition(net.runelite.cache.definitions.MapDefinition) Storage(net.runelite.cache.fs.Storage) MapLoader(net.runelite.cache.definitions.loaders.MapLoader) LocationsDefinition(net.runelite.cache.definitions.LocationsDefinition)

Aggregations

IOException (java.io.IOException)2 Archive (net.runelite.cache.fs.Archive)2 Index (net.runelite.cache.fs.Index)2 Storage (net.runelite.cache.fs.Storage)2 XteaKeyManager (net.runelite.cache.util.XteaKeyManager)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LocationsDefinition (net.runelite.cache.definitions.LocationsDefinition)1 MapDefinition (net.runelite.cache.definitions.MapDefinition)1 LocationsLoader (net.runelite.cache.definitions.loaders.LocationsLoader)1 MapLoader (net.runelite.cache.definitions.loaders.MapLoader)1 Store (net.runelite.cache.fs.Store)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1