Created
December 28, 2012 22:01
-
-
Save pxpc2/4402350 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.brtm.client.loader; | |
import us.brtm.client.decrypter.Decrypter; | |
import javax.swing.*; | |
import java.applet.AppletContext; | |
import java.applet.AppletStub; | |
import java.awt.*; | |
import java.io.*; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.jar.JarFile; | |
/** | |
* @author pxpc2 | |
*/ | |
public class RSLoader extends JFrame implements AppletStub { | |
private static final String URL = "http://world45.runescape.com/"; | |
public File runescapeJar = null; | |
public JarFile jarFile = null; | |
JLabel label = new JLabel(); | |
private Map<String, String> parameters = new HashMap<>(); | |
public RSLoader() { | |
try { | |
loadComponents(); | |
Decrypter decrypter = new Decrypter(this); | |
Class<?> clazz = decrypter.getClass("client"); | |
BApplet applet = new BApplet(clazz); | |
applet.setStub(this); | |
applet.init(); | |
applet.start(); | |
getContentPane().removeAll(); | |
getContentPane().add(applet, BorderLayout.CENTER); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
private void loadComponents() throws IOException { | |
setVisible(true); | |
setResizable(false); | |
setSize(775, 590); | |
setLocationRelativeTo(getOwner()); | |
setTitle("Runescape Client - pxpc2"); | |
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
getContentPane().setBackground(Color.BLACK); | |
label.setForeground(Color.WHITE); | |
label.setHorizontalAlignment(JLabel.CENTER); | |
label.setFont(new Font("Arial", Font.BOLD, 12)); | |
getContentPane().add(label); | |
label.setText("Preparing client"); | |
getParams(URL); | |
download(URL + parameters.get("archive")); | |
runescapeJar = new File("Runescape.jar"); | |
jarFile = new JarFile(runescapeJar); | |
label.setText("Loading data"); | |
System.out.println("Runescape.jar obtained"); | |
} | |
private void getParams(String url) { | |
String[] VALUES = {"document.write", "<param name=\"", "\">'", "'", "\\(", "\\)", "\"", " ", ";", "value"}; | |
try (BufferedReader in = new BufferedReader( | |
new InputStreamReader(new URL(url).openStream()))) { | |
String line; | |
for (String s : parameters.values()) { | |
System.out.println(s); | |
} | |
while ((line = in.readLine()) != null) { | |
if (line.contains("app") && line.contains("write")) { | |
parameters.put("<app", ""); | |
parameters.put("let ", ""); | |
} else if (line.contains("document.write")) { | |
for (String s : VALUES) { | |
line = line.replaceAll(s, ""); | |
} | |
String[] split = line.split("="); | |
if (split.length == 1) { | |
parameters.put(split[0], ""); | |
} else if (split.length == 2) { | |
parameters.put(split[0], split[1]); | |
} else if (split.length == 3) { | |
parameters.put(split[0], split[1] + split[2]); | |
} | |
} | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
private void download(String url) { | |
try (BufferedInputStream in = new BufferedInputStream( | |
new URL(url).openStream())) { | |
FileOutputStream fos = new FileOutputStream("Runescape.jar"); | |
BufferedOutputStream out = new BufferedOutputStream(fos, 1024); | |
byte[] data = new byte[1024]; | |
int x; | |
while ((x = in.read(data, 0, 1024)) >= 0) { | |
out.write(data, 0, x); | |
} | |
in.close(); | |
out.close(); | |
getContentPane().repaint(); | |
} catch (Exception e) { | |
System.out.println("Error downloading data!"); | |
} | |
} | |
public URL getDocumentBase() { | |
try { | |
return new URL(URL); | |
} catch (MalformedURLException e) { | |
return null; | |
} | |
} | |
public URL getCodeBase() { | |
try { | |
return new URL(URL); | |
} catch (MalformedURLException e) { | |
return null; | |
} | |
} | |
public String getParameter(String name) { | |
return parameters.get(name); | |
} | |
public AppletContext getAppletContext() { | |
return null; | |
} | |
public void appletResize(int width, int height) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment