HUGE THANKS/CREDITS TO Static HE HELPED/TAUGHT ME ABOUT A LOT OF THIS.
Thought I'd make this so people can understand how 'hooks' are found, I've done parts of this using the ASM 4.0 Lib. Basically when you compile your .java file it is compiled into bytecode which is then read by the JVM. More info can be found http://en.wikipedia....i/Java_bytecode
For example this code :
Would look like this in Bytecode :
To view the bytecode I use a program called reJ, it can be found http://sourceforge.n...rojects/rejava/, now lets use this gamepack http://up.ht/QgU83Q. Open reJ and open the gamepack I provided you. Next we'll work in the client class so open up the client class and look in the editor tab, if we scroll to the bottom you will see a a few getters. We'll focus on getCurrentAction().
As you can see it references the field client.pi so go to the top of the file and ctrl +f then type "pi". Now to iterate through the search you press f3, once you press it you should come to code like this :
Now we see two instructions which reference "pi",
putstatic String client.pi
getstatic String client.pi
the putstatic instruction is assigning a value to the field "pi" and the getstatic is getting the value of the field "pi". Just from looking at this we know the field is static due to the instruction getstatic/putstatic, if it wasn't static then in place of getstatic/putstatic would be getfield/putfield.
Now to create a pattern for this we first need to find the attributes of the method which this code is in, so scroll up until you see the method name etc....
Now from this information we take out that it is public, static, final and a void. We shouldn't use the parameters as we don't want to base it around structure in that way. Basically you'd use this as when you're iterating through each MethodNode(ASM) in the class you can check if it is public, static, final and void before searching if the pattern exists insdie it, you can use the Modifier class to do so :
We should also make sure that we don't search inside the "<clinit>" method as you shouldn't really create patterns inside their as it is too unreliable/not stable, to do so we simply do :
Now that we know how to only search the methods we want to, we can get back to the pattern(hit f3 again and you'll be back there)
ldc_w Integer constant (int) -1262470041
invokestatic String yr.ms(eu, int)
putstatic String client.pi
aconst_null
getstatic String client.pi
if_acmpne label_1670
ldc_w String Constant "Null"
putstatic String client.pi
Lets work with these instructions, your pattern shouldn't really be too long ( > 5) so lets start at the putstatic instruction. Depending on your updater base, you might have a regex searcher or you might not so I'll just give you the basic idea... What we do is search through the instructions in our methodnode(which we learnt how to filter before) until we find a series of instructions that is our pattern, so basically our pattern would be...
This is for ASM, you may have noticed the ldc_w but I only included ldc, take a look at the fields http://asm.ow2.org/a...sm/Opcodes.html there for what you would use, e.g Opcodes.LDC
Now from this we can use either the first([0]) or the third([2]) instruction to get the field name from as they both reference the same field. This may return more than one field so we can filter even more, we can use the FieldNode class(ASM) and check if it's "description"(String, int, boolean etc) is a String as we know our field is... to do this we can simply do :
This will skip the field if it's not a String basically, here's an example of how the code could look...
Now here, I've filtered through the fields, methods and then searched for the pattern, you're "updater" may not use regex to search for patterns but all you do then is get an array of the instructions in a method and search for the pattern of instructions in a series basically.
You can apply this knowledge to any game which has a client that is made in java. JaGeX made it harder for RS when they introduced different gamepacks as you have to deal with multiple levels of obfuscation(thanks pyroryan for that quote) in which the instruction patterns can be quite different.
I'd recommend reading this http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings as it educates you about each instruction, you don't have to know them but it helps.
Need an updater Famework? Check out the VFramework at https://veloxbot.org
Thought I'd make this so people can understand how 'hooks' are found, I've done parts of this using the ASM 4.0 Lib. Basically when you compile your .java file it is compiled into bytecode which is then read by the JVM. More info can be found http://en.wikipedia....i/Java_bytecode
For example this code :
Code:
public class test {
public static String name = "Name";
public String getName() {
return name;
}
}
Would look like this in Bytecode :
Code:
public class test {
public static String name = "Name";
public String getName() {
aload_0 0
getstatic String test.name
areturn
}
}
To view the bytecode I use a program called reJ, it can be found http://sourceforge.n...rojects/rejava/, now lets use this gamepack http://up.ht/QgU83Q. Open reJ and open the gamepack I provided you. Next we'll work in the client class so open up the client class and look in the editor tab, if we scroll to the bottom you will see a a few getters. We'll focus on getCurrentAction().
As you can see it references the field client.pi so go to the top of the file and ctrl +f then type "pi". Now to iterate through the search you press f3, once you press it you should come to code like this :
Now we see two instructions which reference "pi",
putstatic String client.pi
getstatic String client.pi
the putstatic instruction is assigning a value to the field "pi" and the getstatic is getting the value of the field "pi". Just from looking at this we know the field is static due to the instruction getstatic/putstatic, if it wasn't static then in place of getstatic/putstatic would be getfield/putfield.
Now to create a pattern for this we first need to find the attributes of the method which this code is in, so scroll up until you see the method name etc....
Now from this information we take out that it is public, static, final and a void. We shouldn't use the parameters as we don't want to base it around structure in that way. Basically you'd use this as when you're iterating through each MethodNode(ASM) in the class you can check if it is public, static, final and void before searching if the pattern exists insdie it, you can use the Modifier class to do so :
Code:
if(!methodnode.desc.endsWith("Z") || !Modifier.isStatic(methodnode.access) || !Modifier.isFinal(methodnode.access) || !Modifier.isPublic(methodnode.access)) {
continue;
}
We should also make sure that we don't search inside the "<clinit>" method as you shouldn't really create patterns inside their as it is too unreliable/not stable, to do so we simply do :
Code:
methodnode.name.contains("<clinit>")
Now that we know how to only search the methods we want to, we can get back to the pattern(hit f3 again and you'll be back there)
ldc_w Integer constant (int) -1262470041
invokestatic String yr.ms(eu, int)
putstatic String client.pi
aconst_null
getstatic String client.pi
if_acmpne label_1670
ldc_w String Constant "Null"
putstatic String client.pi
Lets work with these instructions, your pattern shouldn't really be too long ( > 5) so lets start at the putstatic instruction. Depending on your updater base, you might have a regex searcher or you might not so I'll just give you the basic idea... What we do is search through the instructions in our methodnode(which we learnt how to filter before) until we find a series of instructions that is our pattern, so basically our pattern would be...
Code:
putstatic aconst_null getstatic if_acmpne ldc
This is for ASM, you may have noticed the ldc_w but I only included ldc, take a look at the fields http://asm.ow2.org/a...sm/Opcodes.html there for what you would use, e.g Opcodes.LDC
Now from this we can use either the first([0]) or the third([2]) instruction to get the field name from as they both reference the same field. This may return more than one field so we can filter even more, we can use the FieldNode class(ASM) and check if it's "description"(String, int, boolean etc) is a String as we know our field is... to do this we can simply do :
Code:
if (!fieldnode.desc.equals("Ljava/lang/String;")) {
continue;
}
This will skip the field if it's not a String basically, here's an example of how the code could look...
Now here, I've filtered through the fields, methods and then searched for the pattern, you're "updater" may not use regex to search for patterns but all you do then is get an array of the instructions in a method and search for the pattern of instructions in a series basically.
You can apply this knowledge to any game which has a client that is made in java. JaGeX made it harder for RS when they introduced different gamepacks as you have to deal with multiple levels of obfuscation(thanks pyroryan for that quote) in which the instruction patterns can be quite different.
I'd recommend reading this http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings as it educates you about each instruction, you don't have to know them but it helps.
Need an updater Famework? Check out the VFramework at https://veloxbot.org




