From aa3e91c9bcbd88c7b18f4922eb17e80a27cc68eb Mon Sep 17 00:00:00 2001 From: Lucwousin Date: Thu, 18 Jul 2019 15:57:59 +0200 Subject: [PATCH] Question marking hard at why travis is failing --- .../mapping/mappingdumper/MappedClass.java | 22 +++ .../mapping/mappingdumper/MappedField.java | 15 ++ .../mapping/mappingdumper/MappedMethod.java | 17 ++ .../mapping/mappingdumper/MappingDump.java | 35 ++++ .../src/test/java/ConfigLoader.java | 111 +++++++++++ .../src/test/java/ISAACCipherTest.java | 54 ++++++ runescape-client/src/test/java/Main.java | 35 ++++ runescape-client/src/test/java/MainTest.java | 40 ++++ .../src/test/java/RLISAACCipher.java | 173 ++++++++++++++++++ runescape-client/src/test/java/RSStub.java | 90 +++++++++ 10 files changed, 592 insertions(+) create mode 100644 deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedClass.java create mode 100644 deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedField.java create mode 100644 deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedMethod.java create mode 100644 deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappingDump.java create mode 100644 runescape-client/src/test/java/ConfigLoader.java create mode 100644 runescape-client/src/test/java/ISAACCipherTest.java create mode 100644 runescape-client/src/test/java/Main.java create mode 100644 runescape-client/src/test/java/MainTest.java create mode 100644 runescape-client/src/test/java/RLISAACCipher.java create mode 100644 runescape-client/src/test/java/RSStub.java diff --git a/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedClass.java b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedClass.java new file mode 100644 index 0000000000..329d16415f --- /dev/null +++ b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedClass.java @@ -0,0 +1,22 @@ +package net.runelite.deob.deobfuscators.mapping.mappingdumper; + +import com.google.gson.annotations.SerializedName; +import java.util.List; + +public class MappedClass +{ + @SerializedName("class") + public String implementingName; + @SerializedName("name") + public String obfuscatedName; + @SerializedName("super") + public String superClass; + public int access; + public List interfaces; + public List fields; + public List methods; + public List constructors; + // Static fields/methods belonging to this class (ClassName_name) + public List staticFields; + public List staticMethods; +} diff --git a/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedField.java b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedField.java new file mode 100644 index 0000000000..b690c0d805 --- /dev/null +++ b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedField.java @@ -0,0 +1,15 @@ +package net.runelite.deob.deobfuscators.mapping.mappingdumper; + +import com.google.gson.annotations.SerializedName; + +public class MappedField +{ + @SerializedName("field") + public String exportedName; + public String owner; + @SerializedName("name") + public String obfuscatedName; + public int access; + public String descriptor; + public Long decoder; +} diff --git a/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedMethod.java b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedMethod.java new file mode 100644 index 0000000000..b2f0c15345 --- /dev/null +++ b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappedMethod.java @@ -0,0 +1,17 @@ +package net.runelite.deob.deobfuscators.mapping.mappingdumper; + +import com.google.gson.annotations.SerializedName; +import java.util.List; + +public class MappedMethod +{ + @SerializedName("method") + public String exportedName; + public String owner; + @SerializedName("name") + public String obfuscatedName; + public int access; + public List parameters; + public String descriptor; + public Long garbageValue; +} diff --git a/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappingDump.java b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappingDump.java new file mode 100644 index 0000000000..bd3f089bd3 --- /dev/null +++ b/deobfuscator/src/test/java/net/runelite/deob/deobfuscators/mapping/mappingdumper/MappingDump.java @@ -0,0 +1,35 @@ +package net.runelite.deob.deobfuscators.mapping.mappingdumper; + +import java.util.List; + +public class MappingDump +{ + public int revision; + + public int totalClasses; + public int totalNamedClasses; + + public int totalFields; + public int totalNamedFields; + + public int totalNonStaticFields; + public int totalNamedNonStaticFields; + + public int totalStaticFields; + public int totalNamedStaticFields; + + public int totalMethods; + public int totalNamedMethods; + + public int totalNonStaticMethods; + public int totalNamedNonStaticMethods; + + public int totalStaticMethods; + public int totalNamedStaticMethods; + + public List classes; + + // Static things belonging to a certain class will be in both these lists and in the classes + public List staticFields; + public List staticMethods; +} diff --git a/runescape-client/src/test/java/ConfigLoader.java b/runescape-client/src/test/java/ConfigLoader.java new file mode 100644 index 0000000000..70bb31e8e9 --- /dev/null +++ b/runescape-client/src/test/java/ConfigLoader.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016-2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConfigLoader +{ + private static final Logger logger = LoggerFactory.getLogger(ConfigLoader.class); + + private static final String CONFIG_RESOURCE = "/jav_config.ws"; + + public static final String CODEBASE = "codebase"; + public static final String INITIAL_JAR = "initial_jar"; + public static final String INITIAL_CLASS = "initial_class"; + public static final String APP_MINWIDTH = "applet_minwidth"; + public static final String APP_MINHEIGHT = "applet_minheight"; + + private final Map properties = new HashMap<>(), + appletProperties = new HashMap<>(); + + public void fetch() throws IOException + { + try (BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(CONFIG_RESOURCE)))) + { + String str; + + while ((str = in.readLine()) != null) + { + int idx = str.indexOf('='); + + if (idx == -1) + continue; + + String s = str.substring(0, idx); + + if (s.equals("param")) + { + str = str.substring(idx + 1); + idx = str.indexOf('='); + s = str.substring(0, idx); + + String value = str.substring(idx + 1); + + appletProperties.put(s, value); + + logger.info("Param: {} -> {}", s, value); + } + else if (s.equals("msg")) + { + // ignore + } + else + { + String value = str.substring(idx + 1); + + properties.put(s, value); + + logger.info("Property: {} -> {}", s, value); + } + } + } + } + + public String getProperty(String name) + { + return properties.get(name); + } + + public Map getProperties() + { + return properties; + } + + public String getAppletProperty(String name) + { + return appletProperties.get(name); + } + + public Map getAppletProperties() + { + return appletProperties; + } +} diff --git a/runescape-client/src/test/java/ISAACCipherTest.java b/runescape-client/src/test/java/ISAACCipherTest.java new file mode 100644 index 0000000000..e930e92aa8 --- /dev/null +++ b/runescape-client/src/test/java/ISAACCipherTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.junit.Assert; +import org.junit.Test; + +/** + * + * @author Adam + */ +public class ISAACCipherTest +{ + private static final int TEST_SIZE = 100; + + @Test + public void testNextInt() + { + int[] keyInts = new int[] + { + 4, 8, 15, 16, 23, 42 + }; + + IsaacCipher is = new IsaacCipher(keyInts); + + RLISAACCipher cipher = new RLISAACCipher(keyInts); + + for (int i = 0; i < TEST_SIZE; ++i) + { + Assert.assertEquals(is.nextInt(), cipher.nextInt()); + } + } +} diff --git a/runescape-client/src/test/java/Main.java b/runescape-client/src/test/java/Main.java new file mode 100644 index 0000000000..42c09e45a6 --- /dev/null +++ b/runescape-client/src/test/java/Main.java @@ -0,0 +1,35 @@ + +import java.io.IOException; +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +public class Main extends JFrame +{ + private static final int WIDTH = 765; + private static final int HEIGHT = 503; + + public Main() throws IOException + { + this.setSize(800, 600); + Client client = new Client(); + + ConfigLoader config = new ConfigLoader(); + config.fetch(); + + client.setStub(new RSStub(config, client)); + + this.add(client); + + client.setSize(WIDTH, HEIGHT); + + client.init(); + client.start(); + this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + this.setVisible(true); + } + + public static void main(String[] args) throws IOException + { + new Main(); + } +} diff --git a/runescape-client/src/test/java/MainTest.java b/runescape-client/src/test/java/MainTest.java new file mode 100644 index 0000000000..cc4b28a87c --- /dev/null +++ b/runescape-client/src/test/java/MainTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016-2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.IOException; +import org.junit.Test; + +public class MainTest +{ + //@Test + public void test() throws IOException, InterruptedException + { + Main main = new Main(); + for (;;) + { + Thread.sleep(500L); + } + } +} diff --git a/runescape-client/src/test/java/RLISAACCipher.java b/runescape-client/src/test/java/RLISAACCipher.java new file mode 100644 index 0000000000..337f107f3b --- /dev/null +++ b/runescape-client/src/test/java/RLISAACCipher.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Arrays; + +/** + * Based off of the implementation from + * https://rosettacode.org/wiki/The_ISAAC_Cipher#Java Modified to not extend + * java.util.Random, and return results in reverse order + * + * @author Adam + */ +public class RLISAACCipher +{ + private final int[] randResult = new int[256]; // output of last generation + private int valuesLeft; // the number of values already left in randResult + + // internal generator state + private final int[] mm = new int[256]; + private int aa, bb, cc; + + public RLISAACCipher(int[] key) + { + init(key); + } + + private void generateMoreResults() + { + cc++; + bb += cc; + + for (int i = 0; i < 256; i++) + { + int x = mm[i]; + switch (i & 3) + { + case 0: + aa = aa ^ (aa << 13); + break; + case 1: + aa = aa ^ (aa >>> 6); + break; + case 2: + aa = aa ^ (aa << 2); + break; + case 3: + aa = aa ^ (aa >>> 16); + break; + } + aa = mm[i ^ 128] + aa; + int y = mm[i] = mm[(x >>> 2) & 0xFF] + aa + bb; + randResult[i] = bb = mm[(y >>> 10) & 0xFF] + x; + } + + valuesLeft = 256; + } + + private static void mix(int[] s) + { + s[0] ^= s[1] << 11; + s[3] += s[0]; + s[1] += s[2]; + s[1] ^= s[2] >>> 2; + s[4] += s[1]; + s[2] += s[3]; + s[2] ^= s[3] << 8; + s[5] += s[2]; + s[3] += s[4]; + s[3] ^= s[4] >>> 16; + s[6] += s[3]; + s[4] += s[5]; + s[4] ^= s[5] << 10; + s[7] += s[4]; + s[5] += s[6]; + s[5] ^= s[6] >>> 4; + s[0] += s[5]; + s[6] += s[7]; + s[6] ^= s[7] << 8; + s[1] += s[6]; + s[7] += s[0]; + s[7] ^= s[0] >>> 9; + s[2] += s[7]; + s[0] += s[1]; + } + + private void init(int[] seed) + { + if (seed != null && seed.length != 256) + { + seed = Arrays.copyOf(seed, 256); + } + aa = bb = cc = 0; + int[] initState = new int[8]; + Arrays.fill(initState, 0x9e3779b9); // the golden ratio + + for (int i = 0; i < 4; i++) + { + mix(initState); + } + + for (int i = 0; i < 256; i += 8) + { + if (seed != null) + { + for (int j = 0; j < 8; j++) + { + initState[j] += seed[i + j]; + } + } + + mix(initState); + for (int j = 0; j < 8; j++) + { + mm[i + j] = initState[j]; + } + } + + if (seed != null) + { + for (int i = 0; i < 256; i += 8) + { + for (int j = 0; j < 8; j++) + { + initState[j] += mm[i + j]; + } + + mix(initState); + + for (int j = 0; j < 8; j++) + { + mm[i + j] = initState[j]; + } + } + } + + valuesLeft = 0; // Make sure generateMoreResults() will be called by the next nextInt() call. + } + + public int nextInt() + { + if (valuesLeft == 0) + { + generateMoreResults(); + assert valuesLeft == 256; + } + + int value = randResult[--valuesLeft]; + + return value; + } +} diff --git a/runescape-client/src/test/java/RSStub.java b/runescape-client/src/test/java/RSStub.java new file mode 100644 index 0000000000..da2bdd545e --- /dev/null +++ b/runescape-client/src/test/java/RSStub.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016-2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.applet.Applet; +import java.applet.AppletContext; +import java.applet.AppletStub; +import java.awt.Dimension; +import java.net.MalformedURLException; +import java.net.URL; + +public class RSStub implements AppletStub +{ + private final ConfigLoader config; + private final Applet app; + + public RSStub(ConfigLoader config, Applet app) + { + this.config = config; + this.app = app; + } + + @Override + public boolean isActive() + { + return true; + } + + @Override + public URL getDocumentBase() + { + return getCodeBase(); + } + + @Override + public URL getCodeBase() + { + try + { + return new URL(config.getProperty(ConfigLoader.CODEBASE)); + } + catch (MalformedURLException ex) + { + return null; + } + } + + @Override + public String getParameter(String name) + { + return config.getAppletProperty(name); + } + + @Override + public AppletContext getAppletContext() + { + return null; + } + + @Override + public void appletResize(int width, int height) + { + Dimension d = new Dimension(width, height); + + app.setSize(d); + app.setPreferredSize(d); + } + +}