PDA

View Full Version : For Brandon



lii
03-29-2014, 07:25 PM
Hey Brandon!
I need to ask you a few questions about java reflection with specifics about Puzzle Pirates. I know that you left the scene a while ago and are now really into this however if you want I can make it worth your while. I have lots of questions about your old omnis bilge bot and about ypp reflection in general. I hope you can help me because really as far as I can find your the only one who has done this successfully! Send me a pm on this site and ill reply with specifics and we can talk! thank you so much! btw if your not Brandon but your reading this let him know for me please! thanks!

NKN
03-29-2014, 07:27 PM
Uhh, I'm pretty decent with the whole reflection/java botting scene. Perhaps I can help answer some questions?

lii
03-29-2014, 07:38 PM
Well NKN I would love some help. So basically the game I would like to build a reflection client for is called Puzzle Pirates. It is 3 downloadable jars however it can be launched from the web page but it is an applet in a JFrame as far as I can tell. Now I cannot instance the main class cus it has a null constructor or something like that. I do not know how to separate the applet form the jframe at this point and so basically I am stuck. I have brandons old source code so I was going to ask him how he did it step by step. I can go ahead and give it to you if you could explain it, btw i will not use his code in my client so i wont be using his work but i would like to learn from it. If not then i just need someone to take a look at it with me and explain how one would go about starting to build a client for this game, like the best method and how to do things cus i do know java but this aspect of it is very new and kinda hard to dive into.

Brandon
03-29-2014, 09:59 PM
I don't remember if I ever got that game loaded or what code you're speaking of, but I just tried it and no matter what, it seems to create its own frame :S

This is what I have (2 files to load the client):


ClientApplet.java

package pirateloader;

import java.applet.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JPanel;

/**
*
* @author Brandon
*/
public class ClientApplet extends JPanel implements AppletStub {

private Applet applet = null;
private URLClassLoader loader = null;
private URL codeBase = null, documentBase = null;
private final HashMap<String, String> parameters = new HashMap<>();

private static final Pattern widthRegex = Pattern.compile("width=\\\"(.*?)\\\"");
private static final Pattern heightRegex = Pattern.compile("height=\\\"(.*?)\\\"");
private static final Pattern parameterRegex = Pattern.compile("<param name=\\\"([^\\s]+)\\\"\\s+value=\\\"([^>]*)\\\"/>");

public ClientApplet() {

try {
this.setLayout(new BorderLayout(0, 0));
String page = this.savePage(new URL("http://www.puzzlepirates.com/getdown.xhtml"));
Matcher parameterMatcher = parameterRegex.matcher(page);

while (parameterMatcher.find()) {
this.parameters.put(parameterMatcher.group(1), parameterMatcher.group(2));
}

if (this.parameters.size() > 0) {
Matcher heightMatcher = heightRegex.matcher(page);
Matcher widthMatcher = widthRegex.matcher(page);

String appbase = this.parameters.get("appbase").replaceFirst("/client", "/%VERSION%");
this.parameters.put("appbase", appbase);
this.codeBase = new URL(this.parameters.get("archive"));
this.documentBase = new URL(this.parameters.get("appbase"));



this.loader = new URLClassLoader(new URL[]{new URL(this.parameters.get("archive"))});
//this.applet = (Applet)loader.loadClass("com.threerings.getdown.launcher.GetdownApplet").newInstance();

this.applet = (Applet)this.loader.loadClass(this.parameters.get("code")).newInstance();
this.applet.setStub(this);

widthMatcher.find();
heightMatcher.find();
int Width = Integer.parseInt(widthMatcher.group(1));
int Height = Integer.parseInt(heightMatcher.group(1));
this.applet.setPreferredSize(new Dimension(Width, Height));
this.add(applet, BorderLayout.CENTER);
}

} catch(MalformedURLException | ClassNotFoundException | InstantiationException | IllegalAccessException | NumberFormatException e) {
e.printStackTrace();
}
}

public void start() {
this.applet.init();
this.applet.start();
}

public void stop() {
this.remove(this.applet);
this.applet.stop();
this.applet.destroy();
this.applet = null;

try {
this.loader.close();
} catch(IOException e) {

}
}

@Override
public boolean isActive() {
return true;
}

@Override
public URL getDocumentBase() {
return this.documentBase;
}

@Override
public URL getCodeBase() {
return this.codeBase;
}

@Override
public String getParameter(String name) {
return this.parameters.get(name);
}

@Override
public AppletContext getAppletContext() {
return null;
}

@Override
public void appletResize(int width, int height) {
}

public static String savePage(URL url) {
try {
URLConnection connection = url.openConnection();
connection.addRequestProperty("Protocol", "HTTP/1.1");
connection.addRequestProperty("Connection", "keep-alive");
connection.addRequestProperty("Keep-Alive", "200");
connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");

String line = "";
StringBuilder builder = new StringBuilder();
try (BufferedReader stream = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
while ((line = stream.readLine()) != null) {
builder.append(line);
builder.append("\n");
}
}
return builder.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}



Main File: PirateLoader.java

package pirateloader;

import javax.swing.JFrame;

/**
*
* @author Brandon
*/
public class PirateLoader {

public static void main(String[] args) {
JFrame frame = new JFrame("Hello");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

ClientApplet applet = new ClientApplet();
frame.add(applet);
frame.pack();
frame.setVisible(true);
applet.start();
}

}



What it prints in the console before its own frame pops up and starts loading the game.. And it saves everything here: C:\Users\Brandon\AppData\LocalLow\yoclient


2014/03/29 17:55:42:890 INFO r.a: App Base: http://download.threerings.net/yoclient/%VERSION%
2014/03/29 17:55:42:901 INFO r.a: App Name: yoclient
2014/03/29 17:55:42:986 INFO r.a: ------------------ VM Info ------------------
2014/03/29 17:55:42:987 INFO r.a: -- OS Name: Windows 8.1
2014/03/29 17:55:42:987 INFO r.a: -- OS Arch: amd64
2014/03/29 17:55:42:988 INFO r.a: -- OS Vers: 6.3
2014/03/29 17:55:42:988 INFO r.a: -- Java Vers: 1.8.0
2014/03/29 17:55:42:989 INFO r.a: -- Java Home: C:\Program Files\Java\jdk1.8.0\jre
2014/03/29 17:55:42:989 INFO r.a: -- User Name: Brandon
2014/03/29 17:55:42:990 INFO r.a: -- User Home: C:\Users\Brandon
2014/03/29 17:55:42:990 INFO r.a: -- Cur dir: C:\Users\Brandon\Documents\NetBeansProjects\Pirate Loader
2014/03/29 17:55:42:991 INFO r.a: ---------------------------------------------
2014/03/29 17:55:42:992 WARNING r.a: No resource certificate found, falling back to class signers
2014/03/29 17:55:43:065 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libkeybd.so]
2014/03/29 17:55:43:066 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libunsafe.so]
2014/03/29 17:55:43:067 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/liblwjgl64.so]
2014/03/29 17:55:43:068 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/liblwjgl.so]
2014/03/29 17:55:43:068 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libopenal.so]
2014/03/29 17:55:43:069 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libopenal64.so]
2014/03/29 17:55:43:069 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libfroth.so]
2014/03/29 17:55:43:070 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/liblwjgl.jnilib]
2014/03/29 17:55:43:070 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/openal.dylib]
2014/03/29 17:55:43:071 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/libfroth.jnilib]
2014/03/29 17:55:43:073 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=java_location, value=[linux] /yoclient/java_linux.jar]
2014/03/29 17:55:43:146 INFO r.a: Failed to find proxy settings in Windows registry [error=java.lang.UnsatisfiedLinkError: no jRegistryKey in java.library.path]
2014/03/29 17:55:43:151 INFO r.a: ---------------- Proxy Info -----------------
2014/03/29 17:55:43:151 INFO r.a: -- Proxy Host: null
2014/03/29 17:55:43:152 INFO r.a: -- Proxy Port: null
2014/03/29 17:55:43:152 INFO r.a: ---------------------------------------------
2014/03/29 17:55:43:156 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libkeybd.so]
2014/03/29 17:55:43:157 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libunsafe.so]
2014/03/29 17:55:43:157 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/liblwjgl64.so]
2014/03/29 17:55:43:158 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/liblwjgl.so]
2014/03/29 17:55:43:159 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libopenal.so]
2014/03/29 17:55:43:159 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libopenal64.so]
2014/03/29 17:55:43:161 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=resource, value=[linux] native/libfroth.so]
2014/03/29 17:55:43:162 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/liblwjgl.jnilib]
2014/03/29 17:55:43:163 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/openal.dylib]
2014/03/29 17:55:43:163 INFO r.a: Skipping [quals=mac os x, osname=windows 8.1, osarch=amd64, key=resource, value=[mac os x] native/libfroth.jnilib]
2014/03/29 17:55:43:165 INFO r.a: Skipping [quals=linux, osname=windows 8.1, osarch=amd64, key=java_location, value=[linux] /yoclient/java_linux.jar]
2014/03/29 17:55:43:190 INFO r.a: Able to lock for updates: true
.
.
.

lii
03-30-2014, 05:47 AM
Yes so i know why that is, because getdown is the updater which is checked prior to launching the game from a second jar. As far as i can tell getdown checks the frame and refreshes or relaunches it if the frame is not the right one. That being said the other jars are launched from within getdown. I have your code and here is the link to download the sources for it mpgh.net/forum/showthread.php?t=739094 dont really know how it got there but yea. Your old omnis sources are in there.