Java Tutorial How to create your own bot Runescape Private Server

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

trDna

Newbie
Aug 1, 2012
4
232
0
NOTE: I take NO responsibility over your actions that you may do from knowledge gained from this post. This post was made for educational purposes only!

This is intended to be a short summary on how people create runescape private server bot(not scripts). It may not be the best tutorial, but I hope to give people an idea of how to make them.

Thanks to crazywink for the code brackets :D !

Requirements

  • Knowledge of basic Java
  • An IDE of your choice.
  • Basic knowledge of BCEL or ASM (will provide links below).
  • Common sense
  • Knowing how to use a search engine
  • Patience
  • The ability to cope with legal issues if you plan to hack Jagex's RS client.

Tips

First off, I do not recommend hacking into the official RS client.
If you plan to create the bot quickly, then I suggest you hack into an RS private server client. They usually have most things de-obfuscated and therefore, it's easier to grab the data you will need.
Only grab the data that you will need for your scripts for your bot.
Steps
Go through all of these links. It will teach you how to start to make a bot from scratch using BCEL (can't find any detailed ASM tutorials).
Make sure that you download the external JARs for BCEL and ASM and add it as external JARs for your bot project folder.

Credits: Freddy of RSHacking

You will need to make an account there to view these links. I'm going to post his tutorial threads in order.

Alternatively, you can also go to their site, login, and go Reflection/Injection -> Tutorials & FAQ

I'll be explaining how to continue this in BCEL.
Here is a sample injector that I've found using a web search engine.
I could of just posted my own, but I'm trying to prove that a good web search engine
can be your best friend.

Credits to Echo_ at villavu:
C++:
import org.apache.*;
import org.apache.bcel.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.generic.*;
import org.apache.bcel.util.*;
import org.apache.bcel.verifier.*;
import org.apache.bcel.verifier.exc.*;
import org.apache.bcel.verifier.statics.*;
import org.apache.bcel.verifier.structurals.*;
import java.io.IOException;
/**
*
* BCEL Injector
*
* [USER=38098]Auth[/USER]or: Echo_
*
*/
public class Injector {
private ClassGen cGen;
public Injector() {
loadClass();
modify();
dumpClass();
}
private void loadClass() {
try {
cGen = new ClassGen(new ClassParser("vs.class").parse());
} catch (ClassFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void modify() {
cGen.addInterface("Animable");
for(Method m : cGen.getMethods()) {
if(m.getName().equals("p")) {
System.out.println("Method p found!");
break;
}
}
InstructionList methodIList = new InstructionList();
ConstantPoolGen theCPool = cGen.getConstantPool();
MethodGen pixelXMethod = new MethodGen(Constants.ACC_PUBLIC,Type.INT,Type.NO_AR GS,new String[]{},"pixelX",cGen.getClassName(),methodIList,theCPool);
InstructionFactory iFactory = new InstructionFactory(cGen,theCPool);
Instruction pushThis = new ALOAD(0);
Instruction pixelXField = iFactory.createFieldAccess(cGen.getClassName(),"p",Type.INT,Constants.GETSTATIC);
Instruction returnPixelX = InstructionFactory.createReturn(Type.INT);
methodIList.append(pushThis);
methodIList.append(pixelXField);
methodIList.append(returnPixelX);
pixelXMethod.setMaxStack();
pixelXMethod.setMaxLocals();
cGen.addMethod(pixelXMethod.getMethod());
}
public void dumpClass() {
try {
cGen.getJavaClass().dump("vs.class");
} catch (IOException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new Injector();
}
}
If you look at that, he explains that he uses a decompiler so that way, you can see the code of the .class file that you want to hack. I recommend using the JAD decompiler in order to see a .class file's variables and code (web search it).

The next part is pretty much the end of my mini-tutorial.

Most people usually have trouble of getting their information from their accessor methods, (which is the interfaces that you make to get your data).
Below is an example of how one may get their data, and is just an example using random Java files that I've made.

Example of getting the data from accessor methods (Done completely by myself)
Lets say that there is a program that you want to hack to get "theSecretString" 's value. I've commented each file out to help understand what's happening.
If you look below, notice how it's STATIC.

Assume that all files (including the files that you use to inject and extract the data, as well as the program's file) are all in the same package/folder (no imports will be needed).
C++:
/**
*
* [USER=38098]Auth[/USER]or A nerdy programmer
*
*/
public class TheProgram { //Using a BCEL or an ASM-based injector, you must make the class implement the interface (accessor) in order to retrieve the data.

private static String theSecretString = "Hello. My name is Bob."; //You will need to return this value.
public static void main(String[]args){ //Pretend its some sort of epic program.
System.out.println("TheProgram's string value = " + theSecretString);
}
}
As you can see above, you will need to make your injector so that it implements the interface to get what theSecretString is.

Before doing that, you will need to make the interface that you implement. Since theSecretString is a String, then you must make an accessor interface which retrieves the data of theSecretString.
C++:
public interface Accessor {
/**
*
* [USER=58433]ReT[/USER]urn Retrieves the data of theSecretString.
*/
public String nameOfString();
}
Make the injector using BCEL or ASM and implement the Accessor interface. Remember to also add the method that the interface requires through the injector. TheProgram class would look something like this (excluding the comments):
C++:
/**
*
* [USER=38098]Auth[/USER]or A nerdy programmer
*
*/
public class TheProgram implements Accessor { //Using a BCEL or an ASM-based injector, you must make the class implement the interface (accessor) in order to retrieve the data.

private static String theSecretString = "Hello. My name is Bob."; //You will need to return this value.
public static void main(String[]args){ //Pretend its some sort of epic program.
System.out.println("TheProgram's string value = " + theSecretString);
}
@Override
public String nameOfString() {
return theSecretString; //Using a BCEL or an ASM-based injector, you must make the theString as the return type.
}
}
After this, make an abstract class that would "get" the accessor's interface.
C++:
public abstract class GetAccessorClass {
/**
*
* [USER=58433]ReT[/USER]urn The Accessor interface.
*/
public abstract Accessor getAccessor();
}
After this, most people choose to make another interface which is similar to the Accessor method, for use of bot scripts.
C++:
public interface MethodInterface {
/**
*
* [USER=58433]ReT[/USER]urn The string that we want from TheProgram.
*/
public String getTheHiddenString();
}
After that, you would need to make a class that gets theHiddenString. This class would have similar methods for use in scripts.
For example, "PlayerInfoGetter.java" may contain methods that retrieve data related to player operations.

In this case, we are hacking the whole program in total, and not just one aspect of it. That's why I've named the class "Getter" because its related to getting methods of the whole program (all in one class).
I've also left a SoftReference, as I've seen RSBot's old bot code, and it seems like a great way of saving memory on a computer while running your bot.
C++:
import java.lang.ref.SoftReference;
/**
*
* [USER=38098]Auth[/USER]or trDna
*
*/
/*
* Pretty much a class that contains similar methods that are retrieved from the Accessor accessor.
* For example, "PlayerInfoGetter.java" may contain methods that retrieve data related to player operations.
*/
public class Getter extends GetAccessorClass implements MethodInterface{
private SoftReference<Accessor> sr; //optional, allows for garbage collection, which makes the Accessor accessor perform faster (less memory would be used up).


public Getter(final Accessor acx){ //Accepts any class that implements Accessor.
sr = new SoftReference<Accessor>(acx);
}

@Override
public Accessor getAccessor() {
return sr.get();
}
@Override
public String getTheHiddenString() {
return getAccessor().nameOfString();
}

}
Now you must start up your "bot" (really just a data retriever) through your program. You need to inject your code before hand, and then create an instance of TheProgram. I've invoked the main method of TheProgram in order to mimic what would happen when the RS/RSPS client loads (however, this just displays a string). After this, you would need to set up the Getter class, and use TheProgram's instance as an argument, because it implements the Accessor interface that we made.
After this, you could simply print out the String that you have retrieved.
C++:
/**
*
* [USER=38098]Auth[/USER]or trDna
*
*/
public class Setter {
public static void main(String[]args){
//Your injection code must go here, so that you can get theSecretString, for example.

TheProgram tp = new TheProgram(); //A new instance of TheProgram, which is supposed to be modified.

TheProgram.main(null); //Invoking the main method. We're just doing this to replicate how the RS client would load and display something. In this case, "Hello. My name is Bob". This line isn't needed.

Getter get = new Getter(tp); //The Accessor accessor (lol).


/*
* You could make a method context class to get the data from the Getter class so its easier to utilise the methods that you would make.
* I've simply made it shorter by getting theHiddenString straight from the Getter class to speed things up.
* This may not be perfect (or technically "correct"), but it shows an approach of how to access the accessor methods that you inject.
*
*/
System.out.println("The setter class's reference of the string: " + get.getTheHiddenString());


}

}
Your output should be:
TheProgram's string value = Hello. My name is Bob.
The setter class's reference of the string: Hello. My name is Bob.

If you got this output, congratulations! You have just retrieved the accessor data by injection!

NOTE: You will need to use the URLClassLoader#loadclass(string).newInstance() in order to load the .CLASS file that you want, then cast that Object to your interface.

Example (sorry, I don't remember the exact syntax as I'm typing on my phone; I'll re-edit it when I get home):

Code:
//Remember to try/catch the URLClassLoader
URLClassLoader ucl = new URLClassLoader("thejar.jar");

Accessor acx = (Accessor) ucl.loadClass("theprogram").newInstance();

Getter g = new Getter(acx);

....
There are better ways of doing that, but this is just a really simple way of doing it, and it may be a lot harder when hacking into the client of your choice.

Note: Accessor methods only work out when you are returning a value of a STATIC variable. This is because non-static variables' method signatures change here and there, and as a result, you will most likely get an NPE.

I hope that this tutorial helped some of you out and/or has helped you begin your journey! Feel free to leave suggestions, and I can add/edit this thread.
 

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
Very in depth! :) I'll have to read over this. Thanks for the contribution. :)
 

trDna

Newbie
Aug 1, 2012
4
232
0
Crazywink said:
Very in depth! :) I'll have to read over this. Thanks for the contribution. :)
You're welcome!

It's actually quite a bit vague, but if you have any questions, leave it here.
 

trDna

Newbie
Aug 1, 2012
4
232
0
crazywink said:
*Added code brackets. :)
Thanks :D
This makes it a lot easier to read!
I may need to make some corrections tommorow, as I'm away from home at the moment.
I also plan to add another tutorial going more in-depth soon.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods League of Legends Accounts