Explv Posted January 9, 2016 Share Posted January 9, 2016 (edited) As some people do not know how to do this, and it is useful to prevent people stealing your code, here is how to obfuscate (https://en.wikipedia.org/wiki/Obfuscation) using ProGuard. If you don't know what Obfuscation looks like, here is an example of one of my classes, post obfuscation: import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.utility.ConditionalSleep; public final class a extends g { private final List b; private final ConditionalSleep c; public a(Combiner combiner, List list) { super(combiner); this.c = new b(this, 5000); this.b = list; } @Override public final boolean a() { for (c c2 : this.b) { if (!c2.d()) continue; return false; } return true; } @Override public final void b() { if (this.a.getBank() != null) { if (!this.a.getBank().isOpen()) { a a2 = this; try { a2.a.getBank().open(); a2.c.sleep(); } catch (InterruptedException var4_3) { a2.a.log((Object)var4_3); return; } } Object object = this.b.iterator(); while (object.hasNext()) { a a3; f[] arrf; f[] arrf2; boolean bl; block12 : { boolean bl2; block11 : { arrf2 = arrf = (f[])object.next(); a3 = this; for (f f2 : arrf2.c()) { if (a3.a.getBank().contains(new String[]{f2.a})) continue; bl2 = false; break block11; } bl2 = true; } if (!bl2) continue; arrf2 = arrf; a3 = this; arrf = arrf2; object = a3; arrf = a.a((c)arrf); Filter[] arrfilter = new Filter[1]; arrfilter[0] = arg_0 -> a.b((List)arrf, arg_0); if (object.a.getInventory().contains(arrfilter)) { arrf = arrf2; object = a3; arrf = a.a((c)arrf); Filter[] arrfilter2 = new Filter[1]; arrfilter2[0] = arg_0 -> a.a((List)arrf, arg_0); object.a.getBank().depositAllExcept(arrfilter2); return; } arrf = arrf2; object = a3; for (f f2 : arrf.c()) { if (object.a.getInventory().getAmount(new String[]{f2.a}) <= (long)f2.b) continue; bl = true; break block12; } bl = false; } if (bl) { arrf = arrf2; object = a3; for (f f2 : arrf.c()) { if (object.a.getInventory().getAmount(new String[]{f2.a}) <= (long)f2.b) continue; object.a.getBank().deposit(f2.a, (int)object.a.getInventory().getAmount(new String[]{f2.a}) - f2.b); } return; } for (f f2 : arrf2.c()) { if (a3.a.getInventory().contains(new String[]{f2.a})) continue; a3.a.getBank().withdraw(f2.a, f2.b); } return; } this.a.log("Ran out of ingredients, stopping script."); this.a.stop(true); } } private static List a(c c2) { return Arrays.stream(c2.c()).map(f2 -> f2.a).collect(Collectors.toList()); } private static /* synthetic */ boolean a(List list, Item item) { return list.contains(item.getName()); } private static /* synthetic */ boolean b(List list, Item item) { if (!list.contains(item.getName())) { return true; } return false; } } 1. Download and extract proguard http://sourceforge.net/projects/proguard/files/ 2. Create a folder anywhere called "proguard_configs", this is where you will store your configuration files to be used with ProGuard. 3. In the proguard_configs folder, create a new empty proguard config file (.pro) in notepad. 4. Define your configuration, here is the configuration I use for my scripts: -injars C:\Users\Username\OSBot\Scripts\script.jar -outjars C:\Users\Username\Obfuscated\script_obf.jar -libraryjars C:\Users\USername\Downloads\OSBot 2.4.29.jar -libraryjars C:\Program Files\Java\jre1.8.0_66\lib\rt.jar -keepattributes *Annotation* -keep public class package.Main -injars is file path to the script .jar to be obfuscated -outjars is the file path to the obfuscated script .jar -libraryjars are the OSBot.jar and the Java runtime rt.jar -keepattributes *Annotation* ensures that we keep the @ScriptManifest annotation Finally we specifiy that we want to keep the main Script class, as we need this as the entry point to our script. You should replace "package.Main" with the package that your script is in, and the name of your main script file 5. Finally run the following command in cmd / terminal, replacing path_to_proguard with the path to proguard.jar, which is found in the proguard\lib folder, and path_to_config with the path to the .pro file you previously made: java -jar path_to_proguard.jar @path_to_config.pro 6. Note if you get warnings about missing classes, that are not classes you have defined, add to you config the line, replacing javafx with the package name: -dontwarn javafx.** Edited January 9, 2016 by Explv 12 Quote Link to comment Share on other sites More sharing options...
Vilius Posted January 9, 2016 Share Posted January 9, 2016 fiirst Quote Link to comment Share on other sites More sharing options...
Chris Posted January 9, 2016 Share Posted January 9, 2016 wet Quote Link to comment Share on other sites More sharing options...
Acerd Posted January 9, 2016 Share Posted January 9, 2016 hot Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted January 9, 2016 Share Posted January 9, 2016 ? 1 Quote Link to comment Share on other sites More sharing options...
Final Calibur Posted January 9, 2016 Share Posted January 9, 2016 Very nice. This can be used as a nice little tutorial for obfuscating projects in general, not just scripts. Quote Link to comment Share on other sites More sharing options...
Explv Posted January 9, 2016 Author Share Posted January 9, 2016 ? ? Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted January 9, 2016 Share Posted January 9, 2016 ? Just didnt feel this was a necessary guide lol Quote Link to comment Share on other sites More sharing options...
Explv Posted January 9, 2016 Author Share Posted January 9, 2016 Just didnt feel this was a necessary guide lol Maybe not for you, but some people asked me to make it, and some people don't know how to do it Quote Link to comment Share on other sites More sharing options...
Tom Posted January 9, 2016 Share Posted January 9, 2016 Just didnt feel this was a necessary guide lol hey man we arent all scripter III like you!!!!!!!!!!!!!!!!!!! 2 Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 9, 2016 Share Posted January 9, 2016 Nice tut,. I tried it and got the "Processing completed successfully" message but my script wont show up in the client..Any ideas? Quote Link to comment Share on other sites More sharing options...
Explv Posted January 9, 2016 Author Share Posted January 9, 2016 Nice tut,. I tried it and got the "Processing completed successfully" message but my script wont show up in the client..Any ideas? Missed a line out: -keepattributes *Annotation* Which is essential, because you need to keep the @ScriptManifest annotation. I have edited the config. Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 9, 2016 Share Posted January 9, 2016 Missed a line out: -keepattributes *Annotation* Which is essential, because you need to keep the @ScriptManifest annotation. I have edited the config. Bingo! Thanks Explv Quote Link to comment Share on other sites More sharing options...
Soldtodie Posted January 9, 2016 Share Posted January 9, 2016 It's not necessary because everything you can add is not necessary to save. 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted January 9, 2016 Author Share Posted January 9, 2016 It's not necessary because everything you can add is not necessary to save. What? 1 Quote Link to comment Share on other sites More sharing options...