BenLand100
2010-12-14 12:10:55
If you want to do something that you can't mooch off someone else (easily), then you have to actually know what you are doing and get down and dirty with the runescape client.
There are two basic routes you can take — decompile the runescape jar (nearly impossible to do completely / correctly, i.e. it will not recompile after you decompile it, but its good pseudo code), or view the bytecode directly (provided you know bytecode well enough, you can do this and make on the fly edits if you so choose; this is the method you will eventually have to take if you plan on writing an updater/adding to an existing updater).
Firstly, you need stuff to work on — download a runescape.jar and extract it. If you find yourself wondering how to extract it, you probably need to stop here and do some learning about java. If you just need a pointer, JAR archives are the same format as ZIP archives (quick and dirty method, change extension to zip and use you favorite extractor. The stuff inside are the java binary files (.class), and the directory structure (there really isn't one in the runescape jar) would be the package structure. There are a lot of class files, you need them all.
Decompiling: Get a decompiler. JAD (which seems to have disappeared since I was active, but it is mirrored here: http://www.varaneckas.com/jad) is a nice simple decompiler that I used to use, it's at least got a windows version (might be only for windows but runs in wine just fine). There are probably other decompilers out there, so ask around in the java-based hacking forums and see what the new cool toy is. Decompile all of the class files to get something that looks like java source code. It won't be exactly java source code because Jagex takes steps called obfuscation which basically scrambles the bytecode into a form that can't be (easily) decompiled, but still runs in the JVM just fine. NOTE: the java hackers that are up to date on their shit might know exactly how jagex obfuscates (this was the case quite a while ago) and could provide you with what is called an "unobsfucated jar" which would decompile perfectly for you. In this case, it might make it easier, but you won't be looking at the same bytecode in the jar, so its useless for hooking, just good for searching with your eyes. To that end, a "renamed jar" would have meaningful names in place of the single/two character names that Jagex replaces all symbols with, which might be useful for searching, but you will need to know the "actual" obfuscated name of the fields/classes in order to make a path.
Bytecode: Learn bytecode, at least some. DON'T EVEN TRY TO DO THIS IF YOU DON'T KNOW BYTECODE WELL ENOUGH TO GUESS WHAT SOURCE CODE IT WAS DERIVED FROM. Seriously, you will just be wasting your own time and the time of anyone you ask for help. Arguably, this is the more powerful method to use, as you can find your hooks and your paths at the same time. Get a dynamic bytecode viewer (my personal preference, however the program that I used to use does not exist anymore, but this is pretty good http://www.cs.ioc.ee/~ando/jbe/), OR a program that dumps the bytecode in human readable form. Then, dive in. A word to the wise, learn to look for unique patterns in bytecode that can be used to identify your hooks — this is the basic principle that updaters work on.
Okay, so what now? Well you either decided to dig through source code or bytecode, look for the part of the client that does the thing you want to do, e.g. if you want to find the interface positions, look for the part that lays out the interfaces on the screen. Observe the code; see how the client does it, what fields it uses, what algorithm it uses. Then take what you learned, make it into pascal code using the SMART interface to read the fields, and voila, you contributed something original. I'm proud of you, you should be a reflection dev. ;) If you want to take it some steps further, observe the bytecode of the code you examined. Look for a way to uniquely identify that code from ALL the other code in the client. Learn a bytecode manipulator like BCEL (my personal preference), and write code to search for that code section in the client. Now you have an updater that can find the path automatically from client version to client version (this is important since the names change, though you could find it manually every time).
Things you should know / common pitfalls:
There are two basic routes you can take — decompile the runescape jar (nearly impossible to do completely / correctly, i.e. it will not recompile after you decompile it, but its good pseudo code), or view the bytecode directly (provided you know bytecode well enough, you can do this and make on the fly edits if you so choose; this is the method you will eventually have to take if you plan on writing an updater/adding to an existing updater).
Firstly, you need stuff to work on — download a runescape.jar and extract it. If you find yourself wondering how to extract it, you probably need to stop here and do some learning about java. If you just need a pointer, JAR archives are the same format as ZIP archives (quick and dirty method, change extension to zip and use you favorite extractor. The stuff inside are the java binary files (.class), and the directory structure (there really isn't one in the runescape jar) would be the package structure. There are a lot of class files, you need them all.
Decompiling: Get a decompiler. JAD (which seems to have disappeared since I was active, but it is mirrored here: http://www.varaneckas.com/jad) is a nice simple decompiler that I used to use, it's at least got a windows version (might be only for windows but runs in wine just fine). There are probably other decompilers out there, so ask around in the java-based hacking forums and see what the new cool toy is. Decompile all of the class files to get something that looks like java source code. It won't be exactly java source code because Jagex takes steps called obfuscation which basically scrambles the bytecode into a form that can't be (easily) decompiled, but still runs in the JVM just fine. NOTE: the java hackers that are up to date on their shit might know exactly how jagex obfuscates (this was the case quite a while ago) and could provide you with what is called an "unobsfucated jar" which would decompile perfectly for you. In this case, it might make it easier, but you won't be looking at the same bytecode in the jar, so its useless for hooking, just good for searching with your eyes. To that end, a "renamed jar" would have meaningful names in place of the single/two character names that Jagex replaces all symbols with, which might be useful for searching, but you will need to know the "actual" obfuscated name of the fields/classes in order to make a path.
Bytecode: Learn bytecode, at least some. DON'T EVEN TRY TO DO THIS IF YOU DON'T KNOW BYTECODE WELL ENOUGH TO GUESS WHAT SOURCE CODE IT WAS DERIVED FROM. Seriously, you will just be wasting your own time and the time of anyone you ask for help. Arguably, this is the more powerful method to use, as you can find your hooks and your paths at the same time. Get a dynamic bytecode viewer (my personal preference, however the program that I used to use does not exist anymore, but this is pretty good http://www.cs.ioc.ee/~ando/jbe/), OR a program that dumps the bytecode in human readable form. Then, dive in. A word to the wise, learn to look for unique patterns in bytecode that can be used to identify your hooks — this is the basic principle that updaters work on.
Okay, so what now? Well you either decided to dig through source code or bytecode, look for the part of the client that does the thing you want to do, e.g. if you want to find the interface positions, look for the part that lays out the interfaces on the screen. Observe the code; see how the client does it, what fields it uses, what algorithm it uses. Then take what you learned, make it into pascal code using the SMART interface to read the fields, and voila, you contributed something original. I'm proud of you, you should be a reflection dev. ;) If you want to take it some steps further, observe the bytecode of the code you examined. Look for a way to uniquely identify that code from ALL the other code in the client. Learn a bytecode manipulator like BCEL (my personal preference), and write code to search for that code section in the client. Now you have an updater that can find the path automatically from client version to client version (this is important since the names change, though you could find it manually every time).
Things you should know / common pitfalls:
- Bytecode is obfuscated so it is a little different every time. Jagex does this specifically to prevent things like updater from working (this was stepped up significantly after Aryan, so it might be more accurate to say it was added to prevent people from decompiling and refactoring the client)
- Last time I checked, Method (or someone) had something he called a "refactored client" which was really just a deobfuscated and renamed client, I don't think he actually did any refactoring. Anyway, it is an excellent resource for learning how the client works, I suggest you find his (or someone's) and learn.
- Static variables and methods are NEVER in the same place. They are shuffled around through the various classes in the client just to confuse you.
- Names are NEVER the same and have no significance (with the client class being the exception, you can always find it. at least, i assume that is still the case)
- This is not easy and takes a LOT of effort. When the code changes, updaters usually break and you have to manually go in and fix them.
- The client is HUGE, so don't expect to easily find anything
- You really do need background information on how the client functions and a very good understanding of java. I'm not just saying this to discourage you. If you don't know what you are doing, you will end up like Cstrike and go ask so many stupid questions, to someone that does know what they are doing, that you piss them off and they rage at you until you run away with your tail between your legs.